crunk
6 months ago
1 changed files with 21 additions and 0 deletions
@ -1 +1,22 @@ |
|||||
|
import os |
||||
|
|
||||
|
import magic |
||||
|
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES |
||||
|
|
||||
from models.distribusi_file_model import DistribusiFiles |
from models.distribusi_file_model import DistribusiFiles |
||||
|
|
||||
|
MIME_TYPE = magic.Magic(mime=True) |
||||
|
|
||||
|
|
||||
|
def distribusi_file_with_type(full_path): |
||||
|
mime = MIME_TYPE.from_file(full_path) |
||||
|
type_, subtype = mime.split("/") |
||||
|
if type_ in FILE_TYPES: |
||||
|
print(f"distribusi file:{full_path} type:{type_}") |
||||
|
|
||||
|
|
||||
|
for root, dirs, files in os.walk("stash", topdown=True): |
||||
|
files = list(filter(lambda f: not f.startswith("."), files)) |
||||
|
for file in files: |
||||
|
full_path = os.path.join(root, file) |
||||
|
distribusi_file_with_type(full_path) |
||||
|
Loading…
Reference in new issue