opt = argparse.ArgumentParser() opt.add_argument('project', metavar="project.dme") opt.add_argument('map', metavar="map.dmm") opt.add_argument('--render-stars', dest='render_stars', default=False, action='store_true', help="Render space. Normally off to prevent ballooning the image size.") opt.add_argument('--render-areas', dest='render_areas', default=False, action='store_true', help="Render area overlays.") opt.add_argument('--render-only', dest='render_types', action='append', help="Render ONLY these types. Can be used multiple times to specify more types.") opt.add_argument('--area', dest='area', type=list, nargs='*', default=None, help="Specify an area to restrict rendering to.") opt.add_argument('--out', dest='outfile', type=str, default=None, help="What to name the file ({z} will be replaced with z-level)") opt.add_argument('--area-list', dest='areas', type=str, default=None, help="A file with area_file.png = /area/path on each line") args = opt.parse_args() if os.path.isfile(args.project): tree = ObjectTree() tree.ProcessFilesFromDME(args.project) dmm = Map(tree) dmm.readMap(args.map) renderflags = 0 if args.render_stars: renderflags |= MapRenderFlags.RENDER_STARS if args.render_areas: renderflags |= MapRenderFlags.RENDER_AREAS kwargs = {} if args.areas: with open(args.areas) as f: for line in f: if line.startswith("#"): continue if '=' not in line: continue outfile, area = line.split('=') args.area = area.strip().split(',')
subject = type.lower() if subject == 'property': old, new = action.split('>') actions += [RenameProperty(old.strip(), new.strip())] if subject == 'type': old, new = action.split('>') actions += [ChangeType(old.strip(), new.strip())] print('Changes to make:') for action in actions: print(' * ' + str(action)) tree = ObjectTree() tree.ProcessFilesFromDME('baystation12.dme') dmm = Map(tree) dmm.readMap(sys.argv[1]) dmm.writeMap2(sys.argv[1].replace('.dmm', '.dmm2')) for iid in xrange(len(dmm.instances)): atom = dmm.getInstance(iid) changes = [] for action in actions: action.SetTree(tree) if action.Matches(atom): atom=action.Fix(atom) changes += [str(action)] atom.id=iid dmm.setInstance(iid,atom) if len(changes) > 0: print('{0} (#{1}):'.format(atom.path,atom.id)) for change in changes: print(' * ' + change)
def MakePage(**kwargs): rewt = '.' depth = kwargs.get('depth', 0) if depth > 0: rewt = '/'.join(['..'] * depth) title = kwargs.get('title', 'LOL NO TITLE') body = kwargs.get('body', '') return (tmpl_head + body + tmpl_footer).replace('{TITLE}', title).replace('{ROOT}', rewt) if os.path.isfile(sys.argv[1]): selectedDMEs = [] tree = ObjectTree() tree.ProcessFilesFromDME(sys.argv[1]) dmm = Map(tree) dmm.readMap(sys.argv[2]) basedir = os.path.join(os.path.dirname(sys.argv[1]), 'analysis', os.path.basename(sys.argv[2])) if not os.path.isdir(basedir): os.makedirs(os.path.join(basedir,'instances')) os.makedirs(os.path.join(basedir,'tiles')) # Dump instances instance_info = {} for atom in dmm.instances: if atom.path not in instance_info: instance_info[atom.path] = [] instance_info[atom.path] += [atom.id] with open(os.path.join(basedir, 'instances', str(atom.id) + '.html'), 'w') as f: