Mercurial > LightClone
changeset 45:50def8c971d9
Move build functionality into map.py
author | koryspansel |
---|---|
date | Thu, 22 Sep 2011 13:41:29 -0700 |
parents | 6790cf9e8bd8 |
children | a379bce1aeb1 |
files | LightTools/Build.py LightTools/Map.py |
diffstat | 2 files changed, 37 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/LightTools/Build.py Thu Sep 22 12:34:42 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# -# Build -# - -import Map -import os -import sys - -if __name__ == '__main__': - path_root = os.path.dirname(sys.argv[0]) - path_assets = os.path.abspath(os.path.join(path_root, '..', 'Assets', 'Maps')) - path_build = os.path.abspath(os.path.join(path_root, '..', 'Data', 'Maps')) - - if os.path.isdir(path_assets): - for filename in os.listdir(path_assets): - if not filename.endswith('.def'): - continue - - definition = Map.ReadDefinition(os.path.join(path_assets, filename)) - if not definition: - continue - - output = os.path.join(path_build, os.path.splitext(filename)[0] + '.map') - folder = os.path.dirname(output) - - if not os.path.isdir(folder): - os.makedirs(folder) - - print 'Building %s from %s' % (os.path.basename(output), os.path.basename(filename)) - definition.Write(output)
--- a/LightTools/Map.py Thu Sep 22 12:34:42 2011 -0700 +++ b/LightTools/Map.py Thu Sep 22 13:41:29 2011 -0700 @@ -65,20 +65,43 @@ return MapDefinition(size, position, direction, fcount, functions, grid) +#if __name__ == '__main__': +# if len(sys.argv) < 2: +# print 'Usage: Map <map> [output]' +# sys.exit() +# +# path_input = os.path.abspath(sys.argv[1]) +# path_output = os.path.splitext(path_input)[0] + '.map' +# +# if len(sys.argv) > 2: +# path_output = os.path.abspath(sys.argv[2]) +# if os.path.isdir(path_output): +# path_output += os.path.splitext(os.path.basename(path_input))[0] + '.map' +# +# definition = ReadDefinition(path_input) +# if definition: +# print 'Building %s from %s' % (os.path.basename(path_output), os.path.basename(path_input)) +# definition.Write(path_output) + if __name__ == '__main__': - if len(sys.argv) < 2: - print 'Usage: Map <map> [output]' - sys.exit() - - path_input = os.path.abspath(sys.argv[1]) - path_output = os.path.splitext(path_input)[0] + '.map' + path_root = os.path.dirname(sys.argv[0]) + path_assets = os.path.abspath(os.path.join(path_root, '..', 'Assets', 'Maps')) + path_build = os.path.abspath(os.path.join(path_root, '..', 'Data', 'Maps')) - if len(sys.argv) > 2: - path_output = os.path.abspath(sys.argv[2]) - if os.path.isdir(path_output): - path_output += os.path.splitext(os.path.basename(path_input))[0] + '.map' + if os.path.isdir(path_assets): + for filename in os.listdir(path_assets): + if not filename.endswith('.def'): + continue + + definition = ReadDefinition(os.path.join(path_assets, filename)) + if not definition: + continue - definition = ReadDefinition(path_input) - if definition: - print 'Building %s from %s' % (os.path.basename(path_output), os.path.basename(path_input)) - definition.Write(path_output) \ No newline at end of file + output = os.path.join(path_build, os.path.splitext(filename)[0] + '.map') + folder = os.path.dirname(output) + + if not os.path.isdir(folder): + os.makedirs(folder) + + print 'Building %s from %s' % (os.path.basename(output), os.path.basename(filename)) + definition.Write(output)