criação da função categorizar_por_tipo()
This commit is contained in:
14
organizer.py
14
organizer.py
@ -1,12 +1,22 @@
|
||||
# organizer.py
|
||||
# Funções para categorizar ficheiros e criar estrutura de destino
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def categorizar_por_tipo(ficheiro):
|
||||
def categorizar_por_tipo(ficheiro: str) -> str:
|
||||
"""
|
||||
Devolve o tipo de ficheiro (imagem, documento, vídeo, etc) com base na extensão.
|
||||
"""
|
||||
pass
|
||||
# TODO: extensões configuraveis externamente pelo utilizador
|
||||
extensao = Path(ficheiro).suffix.lower().lstrip('.')
|
||||
if extensao in ['jpeg', 'jpg', 'bmp', 'cr2', 'raw']:
|
||||
return 'imagem'
|
||||
elif extensao in ['pdf', 'doc', 'docx', 'xls', 'xlsx']:
|
||||
return 'documento'
|
||||
elif extensao in ['mp4', 'mpeg', 'mov']:
|
||||
return 'video'
|
||||
else:
|
||||
return 'outros'
|
||||
|
||||
|
||||
def categorizar_por_data(ficheiro):
|
||||
|
||||
Reference in New Issue
Block a user