Created
December 19, 2012 08:05
-
-
Save cyroxx/4335183 to your computer and use it in GitHub Desktop.
Generator for WinShell project files (.wsp) Copy this into your LaTeX project and run _python gen_wsp.py main_document.tex_. This will create a project file named main_document.wsp that contains the main_document.tex and all other tex files in the same or any subdirectory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import string | |
PREFIX = '.tex' | |
def main(args): | |
try: | |
main_document = args[1] # [1] might be machine-specific | |
print main_document, '\n' | |
output_file = string.split(main_document, '.')[0] + '.wsp' | |
with open(output_file, 'w') as f: | |
f.write('[main]\n') | |
f.write('.\\%s\n' % main_document) | |
f.write('\n') | |
f.write('[texfiles]\n') | |
# TODO: use walk instead of listdir | |
for item in os.listdir('.'): | |
if item.endswith(PREFIX) and not (item == main_document): | |
print item | |
f.write('.\\%s\n' % item) | |
f.close() | |
except: | |
# error handling code here | |
return 1 # exit on error | |
else: | |
return 0 # exit errorlessly | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment