mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] filter_directory_content
Allows a user to extract the files having a specific extension
This commit is contained in:
parent
b558b02711
commit
6832b05230
@ -2,8 +2,8 @@ import datetime
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import re
|
||||
import shutil
|
||||
|
||||
supported_versions = ["bukkit", "paper", "spigot"]
|
||||
|
||||
@ -102,6 +102,15 @@ def get_path_from_extension(filename) -> str or None:
|
||||
return None
|
||||
|
||||
|
||||
def filter_directory_contents(desired_extension: str, directory_contents: list[str]):
|
||||
filtered_list = []
|
||||
for item in directory_contents:
|
||||
_, ext = os.path.splitext(item)
|
||||
if ext.lower() == desired_extension:
|
||||
filtered_list.append(item)
|
||||
return filtered_list
|
||||
|
||||
|
||||
def kebab_to_camel_case(s: str) -> str:
|
||||
parts = s.split('-')
|
||||
return parts[0] + ''.join(part.title() for part in parts[1:])
|
||||
|
Loading…
Reference in New Issue
Block a user