MCPcopy Index your code
hub / github.com/geekcomputers/Python / get_category

Function get_category

smart_file_organizer.py:48–61  ·  view source on GitHub ↗

Determine the category of a file based on its extension. Args: file_ext: File extension (e.g., ".txt"). Returns: Category name (e.g., "Documents") or "Others" if not matched.

(file_ext: str)

Source from the content-addressed store, hash-verified

46
47
48def get_category(file_ext: str) -> str:
49 """
50 Determine the category of a file based on its extension.
51
52 Args:
53 file_ext: File extension (e.g., ".txt").
54
55 Returns:
56 Category name (e.g., "Documents") or "Others" if not matched.
57 """
58 for category, extensions in FILE_CATEGORIES.items():
59 if file_ext.lower() in extensions:
60 return category
61 return "Others"
62
63
64def organize_files(base_path: str) -> None:

Callers 1

organize_filesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected