Skip to content

Commit

Permalink
Fix excludes of template and vanilla files in packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
slicedlime committed Mar 8, 2023
1 parent 46209b5 commit 0dc381a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import os.path
from zipfile import ZipFile

def in_excluded_folder(file, excludes):
excluded_folders = [x for x in excludes if x[-1] == '/']
file = file.replace('\\', '/')
for folder in excluded_folders:
if file[:len(folder)] == folder:
return True
return False

def zip(zip_filename, folder, excludes = []):
with ZipFile(zip_filename, 'w') as zip:
# Iterate over all the files in directory
Expand All @@ -13,7 +21,7 @@ def zip(zip_filename, folder, excludes = []):
continue

relative = os.path.relpath(file_path, folder)
if relative[0] == '.':
if relative[0] == '.' or in_excluded_folder(relative, excludes):
continue
# Add file to zip
print(f'{relative}')
Expand All @@ -23,4 +31,4 @@ def zip(zip_filename, folder, excludes = []):
os.remove('seasons.zip')
except OSError:
pass
zip('seasons.zip', '.', ['templates', 'vanilla', 'build.py', 'CONTRIBUTING.md', 'Notes.txt', 'package.py', 'seasons.zip', 'square.jpg', 'square_400.jpg'])
zip('seasons.zip', '.', ['templates/', 'vanilla/', 'build.py', 'CONTRIBUTING.md', 'Notes.txt', 'package.py', 'seasons.zip', 'credentials.json', 'metadata.json'])

0 comments on commit 0dc381a

Please sign in to comment.