Skip to content

Commit

Permalink
Fix hosed gzip_assets. (How did this happen?
Browse files Browse the repository at this point in the history
  • Loading branch information
cgroskopf committed Jun 10, 2011
1 parent 5eba9de commit f1f0c6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions censusweb/.gitignore
@@ -1 +1,2 @@
manage manage
gzip_media
13 changes: 6 additions & 7 deletions censusweb/gzip_assets.py
Expand Up @@ -13,20 +13,19 @@ def time(self):
gzip.time = FakeTime() gzip.time = FakeTime()


shutil.rmtree('gzip_media', ignore_errors=True) shutil.rmtree('gzip_media', ignore_errors=True)
shutil.copytree('media', 'gzip_media')


for path, dirs, files in os.walk('media'): for path, dirs, files in os.walk('gzip_media'):
for filename in files: for filename in files:
if filename[-3:] not in ['js', 'css', 'txt', 'html']: if filename[-3:] not in ['js', 'css', 'txt', 'html']:
continue continue


src_path = os.path.join(path, filename) file_path = os.path.join(path, filename)
dest_path = 'gzip_'+src_path
if not os.path.exists(os.path.dirname(dest_path)):
os.makedirs(os.path.dirname(dest_path))


f_in = open(src_path, 'rb') f_in = open(file_path, 'rb')
contents = f_in.read() contents = f_in.read()
f_in.close() f_in.close()
f_out = gzip.open(dest_path, 'wb') f_out = gzip.open(file_path, 'wb')
f_out.write(contents) f_out.write(contents)
f_out.close(); f_out.close();

0 comments on commit f1f0c6e

Please sign in to comment.