Skip to content

Commit

Permalink
Strip indentation from text files when building packages
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Jan 31, 2016
1 parent 0258b75 commit 322fd1d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compile_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def clean_vmf(vmf_path):
del inst.spawn['maxblobcount'],
del inst.spawn['detailvbsp'], inst.spawn['detailmaterial']

return inst.export(inc_version=False, minimal=True)
lines = inst.export(inc_version=False, minimal=True).splitlines()
for line in lines:
yield line.lstrip()


# Text files we should clean up.
Expand All @@ -81,7 +83,7 @@ def clean_text(file_path):
if '//' in line and line.rfind('"') < line.index('//'):
yield line.split('//')[0] + '\n'
else:
yield line
yield line.lstrip()


# Delete these files, if they exist in the source folders.
Expand Down Expand Up @@ -133,7 +135,7 @@ def build_package(data):

if OPTIMISE and file.endswith('.vmf'):
print(rel_path)
zip_file.writestr(rel_path, clean_vmf(full_path))
zip_file.writestr(rel_path, '\r\n'.join(clean_vmf(full_path)))
elif OPTIMISE and file.endswith(PROP_EXT):
print(rel_path)
zip_file.writestr(rel_path, ''.join(clean_text(full_path)))
Expand Down

0 comments on commit 322fd1d

Please sign in to comment.