os.path.join(os.path.dirname(sys.argv[1]), 'tech_origin_list.csv'), 'w') as w: with open( os.path.join(os.path.dirname(sys.argv[1]), 'max_tech_origins.txt'), 'w') as mto: tech_columns = [] mto.write( 'Calculated Max Tech Levels:\n These tech levels have been determined by parsing ALL origin_tech variables in code included by {0}.\n' .format(sys.argv[1])) for tech in sorted(CMTLs.keys()): tech_columns.append(tech) mto.write('{:>15}: {}\n'.format(tech, CMTLs[tech])) w.write(','.join(['Atom', 'Name'] + tech_columns) + "\n") for path in sorted(AtomTechOrigins.keys()): row = [] row.append(path) atom = tree.GetAtom(path) name = atom.properties.get('name', None) if name is None: name = '' else: name = name.value row.append('"' + name.replace('"', '""') + '"') for tech in tech_columns: if tech in AtomTechOrigins[path]: row.append(str(AtomTechOrigins[path][tech])) else: row.append('') w.write(','.join(row) + "\n") # prettify(tree.Tree.children)
''' Created on Apr 29, 2014 @author: Rob ''' import argparse, os from byond.objtree import ObjectTree from byond.basetypes import Proc def dumpSubTypes(atom): print('{}:{}: {}'.format(atom.filename, atom.line, atom.path)) for rpath, catom in atom.children.items(): if not isinstance(catom, Proc): dumpSubTypes(catom) if __name__ == '__main__': opt = argparse.ArgumentParser() opt.add_argument('project', metavar="project.dme") opt.add_argument('--subtypes', type=str, help="List all subtypes of the given type") args = opt.parse_args() if os.path.isfile(args.project): tree = ObjectTree() tree.ProcessFilesFromDME(args.project) if args.subtypes: atom = tree.GetAtom(args.subtypes) dumpSubTypes(atom)
if line.strip() == '': continue # PROPERTY: step_x > pixel_x # TYPE: /obj/item/key > /obj/item/weapon/key/janicart subject, action = line.split(':') subject = subject.lower() if subject == 'property': old, new = action.split('>') actions += [ mapfixes.base.RenameProperty(old.strip(), new.strip()) ] if subject == 'type' or subject == 'type!': force = subject == 'type!' old, new = action.split('>') newtype = new.strip() if tree.GetAtom(newtype) is None: print('{0}:{1}: {2}'.format(sys.argv[2], ln, line.strip('\r\n'))) print(' ERROR: Unable to find replacement type "{0}".'. format(newtype)) errors += 1 actions += [ mapfixes.base.ChangeType(old.strip(), newtype, force) ] if errors > 0: print('!!! {0} errors, please fix them.'.format(errors)) sys.exit(1) print('Changes to make:') for action in actions: print(' * ' + str(action)) dmm = Map(tree, forgiving_atom_lookups=1)
regex=re.compile(r'\bspawn(\(([0-9]*)\))?\b'), in_procnames=('process')), RegexScanner( id='del-in-ex_act', warning= 'del() should not be used in ex_act(). Consider replacing with qdel.', regex=re.compile(r'\bdel(\(.*\))?\b'), in_procnames=('ex_act')), ] otr = ObjectTree() otr.ProcessFilesFromDME(sys.argv[1], '.dm') procs = 0 alerts = 0 for path in otr.Atoms: atom = otr.GetAtom(path) if isinstance(atom, Proc): continue proceed = False skipping = [] for rule in rules: if rule.MatchAtom(atom): proceed = True else: skipping += [rule] if not proceed: continue for childName in atom.children: warnings = {} child = atom.children[childName] if isinstance(child, Proc): proceed = False for rule in rules: