diff options
author | pab <devnull@localhost> | 2009-07-02 12:21:35 +0000 |
---|---|---|
committer | pab <devnull@localhost> | 2009-07-02 12:21:35 +0000 |
commit | 5eacb77c8998fd31b68477e0ec37388e9983b97b (patch) | |
tree | 1bd29c6e84c031c9155bc5257d9184ca629fe967 /scripts | |
parent | 09ace7cc97e9eebd9b36d2724da9f14ee5a7278a (diff) |
Hold class-unique values in template map. Rework module prefix/path management
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/pyxbgen | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/scripts/pyxbgen b/scripts/pyxbgen index 396f81d..eb11fcd 100755 --- a/scripts/pyxbgen +++ b/scripts/pyxbgen @@ -80,27 +80,32 @@ if module_path is None: sys.exit(1) if 0 <= module_path.find('.'): - (module_path_prefix, schema_prefix) = module_path.rsplit('.', 1) + (module_prefix, schema_prefix) = module_path.rsplit('.', 1) else: - module_path_prefix = '' + module_prefix = '' schema_prefix = module_path if not schema_prefix: print 'Require --schema-prefix' sys.exit(1) -module_path_elts = module_path_prefix.split('.') -if not module_path_elts: - module_path_elts.append('.') +print 'Input MPP %s' % (module_prefix,) +module_prefix_elts = [] +if module_prefix: + module_prefix_elts.extend(module_prefix.split('.')) if generate_raw_binding: - module_path_elts.append('raw') -binding_path = os.path.join(*module_path_elts) + module_prefix_elts.append('raw') +binding_path_elts = module_prefix_elts[:] +if not binding_path_elts: + binding_path_elts.append('.') +binding_path = os.path.join(*binding_path_elts) if save_component_model: component_model_file = os.path.join(binding_path, '%s.wxs' % (schema_prefix,)) binding_file = os.path.join(binding_path,'%s.py' % (schema_prefix,)) -if module_path_prefix: - module_path_prefix += '.' +module_path = '.'.join(module_prefix_elts + [schema_prefix]) + +print 'Output BP %s, MPP %s, MP %s, SP %s' % (binding_path, module_prefix, module_path, schema_prefix) import sys import traceback @@ -149,7 +154,7 @@ tns = wxs.targetNamespace() # parsed schema file try: tns.setModulePath(module_path) - modules = GenerateAllPython(namespace=tns, module_path_prefix=module_path_prefix) + modules = GenerateAllPython(namespace=tns, module_prefix_elts=module_prefix_elts) print 'Python for %s requires %d modules' % (tns, len(modules)) for m in modules: @@ -157,7 +162,14 @@ try: if sns != tns: continue print 'Module path %s' % (tns.modulePath(),) - use_binding_file = os.path.join(*tns.modulePath().split('.')) + '.py' + mod_elts = tns.modulePath().split('.') + leaf = mod_elts.pop() + mod_path = os.path.join(*mod_elts) + try: + os.makedirs(os.path.join(mod_path)) + except Exception, e: + print 'Exception creating directory %s: %s' % (mod_path, e) + use_binding_file = os.path.join(mod_path, '%s.py' % (leaf,)) file(use_binding_file, 'w').write(m.moduleContents()) print 'Saved binding source to %s' % (use_binding_file,) except Exception, e: |