-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_zip.py
More file actions
55 lines (47 loc) · 1.79 KB
/
create_zip.py
File metadata and controls
55 lines (47 loc) · 1.79 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""
Chrome Extension ZIP Creator
Creates a ZIP archive with required files for the GitHub Clone with VS Code extension.
"""
import os
import zipfile
import sys
import platform
def create_extension_zip():
"""Create a ZIP file containing all required extension files"""
# ZIP file name
zip_name = "github-clone-addon.zip"
# Delete if already exists
if os.path.exists(zip_name):
os.remove(zip_name)
print(f"Deleted existing {zip_name}")
# Files and folders to include
files_to_zip = ["content.js", "manifest.json", "README.md"]
folders_to_zip = ["assets", "icons"]
# Create new ZIP file
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
# Add individual files
for file in files_to_zip:
if os.path.exists(file):
zipf.write(file)
print(f"Added {file}")
else:
print(f"WARNING: {file} not found")
# Add folders recursively
for folder in folders_to_zip:
if os.path.exists(folder) and os.path.isdir(folder):
for root, dirs, files in os.walk(folder):
for file in files:
file_path = os.path.join(root, file)
# Preserve folder structure in ZIP
zipf.write(file_path)
print(f"Added {file_path}")
else:
print(f"WARNING: {folder} directory not found")
# Verification
if os.path.exists(zip_name):
print(f"\nZIP creation complete: {zip_name}")
print(f"Size: {os.path.getsize(zip_name) / 1024:.2f} KB")
print(f"System: {platform.system()} {platform.release()}")
if __name__ == "__main__":
create_extension_zip()