Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import zipfile
- import datetime
- def pack():
- # Remove old archive
- for item in os.listdir('.'):
- if item.endswith(".zip"):
- os.remove(item)
- dt = datetime.datetime.now().strftime('%H-%M_%d.%m.%y')
- with zipfile.ZipFile(f'submission-{dt}.zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
- for root, dirs, files in os.walk(os.getcwd()):
- # Skip the .venv directory
- if '.venv' in root.split(os.sep):
- continue
- for file in files:
- file_path = os.path.join(root, file)
- archive_path = os.path.relpath(file_path, '.')
- current_dir = root.split(os.sep)[-1]
- if file in ['requirements.txt', 'manage.py', 'caller.py']\
- or current_dir in ['main_app', 'orm_skeleton', 'migrations']:
- zipf.write(file_path, archive_path)
- print('Submission created!')
- if __name__ == '__main__':
- pack()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement