Conditions | 2 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | #!/usr/bin/python |
||
42 | @staticmethod |
||
43 | def move_to_category(filename, category, base_directory=os.getcwd()): |
||
44 | """Move file to the sub_category folder |
||
45 | |||
46 | :type base_directory: str |
||
47 | :type filename: str |
||
48 | :type category: str |
||
49 | :return: |
||
50 | """ |
||
51 | folder = re.sub(r'["/?*:<>|]', r'', html.unescape(category)) |
||
52 | folder = os.path.join(base_directory, folder) |
||
53 | folder = os.path.abspath(FileHandler.unicode_translate(folder, "\n\t\r", " ")) |
||
54 | if not os.path.exists(folder): |
||
55 | os.makedirs(folder) |
||
56 | move(os.path.join(base_directory, filename), os.path.join(folder, filename)) |
||
57 |