aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/make_archive.py
blob: a55a4bd6e6088df5b28c314db1ea85fc13e9ae5c (plain)
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
#!/usr/bin/env python
# encoding: utf-8
import sys
import re
import os
import zipfile

ARCHIVE_FILE_EXTENSIONS = ('.html', '.css', '.js', '.ico', '.png')

def buildArchive(archiveName):
	if not os.path.isdir(archiveName):
		print ("Invalid archive name: " + archiveName)
		return

	zf = zipfile.ZipFile(archiveName + ".zip", 'w')

	print ("Building '" + archiveName + "' archive:")
	os.chdir(archiveName)

	filenames = os.listdir('.')
	filenames.sort()
	for filename in filenames:
		if os.path.isfile(filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
			zf.write(filename, './' + filename)
			print ("    Adding file: " + filename)

	os.chdir('../')

	zf.close()

def main():
	buildArchive("wwwroot")

if __name__ == "__main__":
	sys.exit(main())