forked from cirlabs/rainmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgzip_assets.py
29 lines (22 loc) · 826 Bytes
/
gzip_assets.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
#!/bin/env python
import os
import gzip
import shutil
class FakeTime:
def time(self):
return 1261130520.0
# Hack to override gzip's time implementation
# See: http://stackoverflow.com/questions/264224/setting-the-gzip-timestamp-from-python
gzip.time = FakeTime()
project_dir = 'rainmaker'
shutil.rmtree(os.path.join(project_dir, 'gzip'), ignore_errors=True)
shutil.copytree(os.path.join(project_dir, 'static'), os.path.join(project_dir, 'gzip/static'))
for path, dirs, files in os.walk(os.path.join(project_dir, 'gzip/static')):
for filename in files:
file_path = os.path.join(path, filename)
f_in = open(file_path, 'rb')
contents = f_in.readlines()
f_in.close()
f_out = gzip.open(file_path, 'wb')
f_out.writelines(contents)
f_out.close();