-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_files.py
30 lines (25 loc) · 1008 Bytes
/
upload_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import zipfile
# Specify the directory containing your project files
project_dir = 'C:\\Users\\marco\\my_project'
zip_filename = 'project_files.zip'
# Specify the file extensions and names to include
include_extensions = ['.py', '.ipynb', '.csv', '.json', '.md', '.txt']
include_files = ['README.md', 'requirements.txt', 'setup.py']
# Function to determine if a file should be included
def should_include(file_name):
for ext in include_extensions:
if file_name.endswith(ext):
return True
if file_name in include_files:
return True
return False
# Create a ZIP file
with zipfile.ZipFile(zip_filename, 'w') as zipf:
for root, dirs, files in os.walk(project_dir):
for file in files:
if should_include(file):
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, project_dir)
zipf.write(file_path, arcname)
print(f'Created {zip_filename} containing project files.')