Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
crunk | bb1bd62250 | 2 days ago |
crunk | d7ef42dddb | 2 weeks ago |
5 changed files with 71 additions and 13 deletions
@ -0,0 +1,22 @@ |
|||
import os |
|||
|
|||
import magic |
|||
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES |
|||
|
|||
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) |
@ -0,0 +1,36 @@ |
|||
"""empty message |
|||
|
|||
Revision ID: 8ede45e978d9 |
|||
Revises: |
|||
Create Date: 2024-04-30 22:15:48.023060 |
|||
|
|||
""" |
|||
from alembic import op |
|||
import sqlalchemy as sa |
|||
|
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = '8ede45e978d9' |
|||
down_revision = None |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
with op.batch_alter_table('distribusi_files', schema=None) as batch_op: |
|||
batch_op.alter_column('type', |
|||
existing_type=sa.VARCHAR(length=300), |
|||
nullable=True) |
|||
|
|||
# ### end Alembic commands ### |
|||
|
|||
|
|||
def downgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
with op.batch_alter_table('distribusi_files', schema=None) as batch_op: |
|||
batch_op.alter_column('type', |
|||
existing_type=sa.VARCHAR(length=300), |
|||
nullable=False) |
|||
|
|||
# ### end Alembic commands ### |
Loading…
Reference in new issue