+def processKLLFile( filename ):
+ with open( filename ) as file:
+ data = file.read()
+ tokenSequence = tokenize( data )
+ #print ( pformat( tokenSequence ) ) # Display tokenization
+ try:
+ tree = parse( tokenSequence )
+ except NoParseError as e:
+ print("Error parsing %s. %s" % (filename, e.msg), file=sys.stderr)
+ sys.exit(1)
+
+
+### Misc Utility Functions ###
+
+def gitRevision( kllPath ):
+ import subprocess
+
+ # Change the path to where kll.py is
+ origPath = os.getcwd()
+ os.chdir( kllPath )
+
+ # Just in case git can't be found
+ try:
+ # Get hash of the latest git commit
+ revision = subprocess.check_output( ['git', 'rev-parse', 'HEAD'] ).decode()[:-1]
+
+ # Get list of files that have changed since the commit
+ changed = subprocess.check_output( ['git', 'diff-index', '--name-only', 'HEAD', '--'] ).decode().splitlines()
+ except:
+ revision = "<no git>"
+ changed = []
+
+ # Change back to the old working directory
+ os.chdir( origPath )
+
+ return revision, changed
+
+