diff options
| author | nyamatongwe <unknown> | 2003-08-02 04:27:42 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2003-08-02 04:27:42 +0000 | 
| commit | 570cd2be3a6af05842049f658888a8edfc7e8071 (patch) | |
| tree | 66572691024b3d762c57381fb8b9a6f6bed0ee80 | |
| parent | 59d2d0e4322886eb607c5516dfa5f779f09b6dcd (diff) | |
| download | scintilla-mirror-570cd2be3a6af05842049f658888a8edfc7e8071.tar.gz | |
Now handles creating a file when no current one exists.
| -rw-r--r-- | src/LexGen.py | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/src/LexGen.py b/src/LexGen.py index 1969d085d..da2c11531 100644 --- a/src/LexGen.py +++ b/src/LexGen.py @@ -1,19 +1,19 @@  # LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org  # Released to the public domain. -# Regenerate the Scintilla and SciTE source files that list  -# all the lexers and all the properties files.  +# Regenerate the Scintilla and SciTE source files that list +# all the lexers and all the properties files.  # Should be run whenever a new lexer is added or removed.  # Requires Python 2.1 or later  # Most files are regenerated in place with templates stored in comments. -# The VS .NET project file is generated into a different file as the  +# The VS .NET project file is generated into a different file as the  # VS .NET environment will not retain comments when modifying the file. -# The files are copied to a string apart from sections between a  -# ++Autogenerated comment and a --Autogenerated comment which is  +# The files are copied to a string apart from sections between a +# ++Autogenerated comment and a --Autogenerated comment which is  # generated by the CopyWithInsertion function. After the whole  # string is instantiated, it is compared with the target file and  # if different the file is rewritten. -# Does not regenerate the Visual C++ 6 project files but does the VS .NET  +# Does not regenerate the Visual C++ 6 project files but does the VS .NET  # project file.  import string @@ -21,7 +21,7 @@ import sys  import os  import glob -# Automatically generated sections contain start and end comments,  +# Automatically generated sections contain start and end comments,  # a definition line and the results.  # The results are replaced by regenerating based on the definition line.  # The definition line is a comment prefix followed by "**". @@ -90,7 +90,14 @@ def UpdateFile(filename, updated):  	""" If the file is different to updated then copy updated  	into the file else leave alone so CVS and make don't treat  	it as modified. """ -	infile = open(filename, "rb") +	try: +		infile = open(filename, "rb") +	except IOError:	# File is not there yet +		out = open(filename, "wb") +		out.write(updated) +		out.close() +		print "New", filename +		return  	original = infile.read()  	infile.close()  	if updated != original: @@ -99,7 +106,7 @@ def UpdateFile(filename, updated):  		out.write(updated)  		out.close()  		print "Changed", filename -	 +  def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists):  	try:  		infile = open(inpath, "rb") @@ -109,7 +116,7 @@ def RegenerateOverLists(inpath, outpath, commentPrefix, crlf, *lists):  	original = infile.read()  	infile.close()  	contents = original.replace("\r\n", "\n") -	updated = CopyWithInsertion(contents, commentPrefix,  +	updated = CopyWithInsertion(contents, commentPrefix,  		inpath == outpath, *lists)  	if crlf:  		updated = updated.replace("\n", "\r\n") | 
