Remove one useless line. Remove many lines that were too long.

Use triple-quotes when it's clearer.
This commit is contained in:
Thibault Févry 2011-03-05 17:32:20 +00:00
parent 5349412ca5
commit 1c5c0d602a

View file

@ -19,16 +19,18 @@
# Meta-Macro syntax:
# #meta-macro BASENAME [{NORMAL_PARAM, OPTIONAL_PARAM} [...]]
#
# NORMAL_PARAM: Macro parameter that will be passed unmodified to the base macro
# OPTIONAL_PARAM: Macro parameter that will sometimes be passed to the base macro
# and sometimes be replaced with a default value
# The script will create one macro for each possible combination of
# optional parameters
# NORMAL_PARAM: Macro parameter that will be passed unmodified to the base
# macro
# OPTIONAL_PARAM: Macro parameter that will sometimes be passed to the base
# macro and sometimes be replaced with a default value. The script will
# create one macro for each possible combination of optional parameters
#
# Syntax: ABBREV=NAME=DEFAULT
# ABBREV: One letter that is appended to macros taking that argument
# NAME: Name of the parameter that is used when it's passed to the base macro
# ABBREV: Default value that is used when the parameter is not passed to the base macro
# NAME: Name of the parameter that is used when it's passed to the
# base macro
# ABBREV: Default value that is used when the parameter is not passed
# to the base macro
#
#
# !!! ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING !!!
@ -37,18 +39,17 @@ import sys
import getopt
def printUsage():
print "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
print "Usage: expand-terrain-macros.py [OPTIONS] filename1 [filename2 [...]]"
print ""
print "Options:"
print " -i Insert the expanded sections into the input file(s) immediately after"
print " their macro definitions."
print " -a Append the expanded sections to the input file(s)"
print " -r Replace the input file(s) with the resulting output. Previously generated"
print " expansions will be removed. Implies -i if nothing else is specified."
print ""
print "If no options are specified, only the expanded sections will be printed to"
print "stdout"
print "Usage: expand-terrain-macros.py [OPTIONS] filename1\
[filename2 [...]]\n"
print """Options:
-i Insert the expanded sections into the input file(s) immediately after
their macro definitions.
-a Append the expanded sections to the input file(s)
-r Replace the input file(s) with the resulting output. Previously generated
expansions will be removed. Implies -i if nothing else is specified.
If no options are specified, only the expanded sections will be printed to
stdout"""
insert = False
append = False
@ -87,12 +88,13 @@ for filename in args:
f.close()
changed = False
output=[]
appended=[]
output = []
appended = []
autogenerated = False
for line in content:
if line.strip() == "#The following code is autogenerated by expand-terrain-macros.py":
if line.strip() == "#The following code is autogenerated\
by expand-terrain-macros.py":
autogenerated = True
if (insert or append) and not autogenerated:
@ -104,8 +106,8 @@ for filename in args:
if line.startswith('#meta-macro'):
elems = line[12:].strip().split()
basename = elems[0]
params= []
optional_params=[]
params = []
optional_params = []
for param in elems[1:]:
split_param = param.split('=')
@ -119,16 +121,17 @@ for filename in args:
base_macro_suffix = "_" + "".join(optional_params)
result=[]
result.append("#The following code is autogenerated by expand-terrain-macros.py")
result = []
result.append("#The following code is autogenerated\
by expand-terrain-macros.py")
if append:
result.append("#generated from: " + line.strip())
result.append("#Please do not modify")
for i in range(2**len(optional_params) - 2, -1, -1):
enabled_map = dict([(param, i & (1<<index) != 0) for index, param in enumerate(optional_params)])
enabled_map = dict([(param, i & (1<<index) != 0) for index, param in enumerate(optional_params)])
suffix =""
suffix = ""
params_external = []
params_internal = []