Exemplo n.º 1
0

def prettify(tree, indent=0):
    prefix = ' ' * indent
    for key in tree.keys():
        atom = tree[key]
        print('{}{}/'.format(prefix, key))
        prettify(atom.children, indent + len(key))
        for propkey, value in atom.properties.items():
            print('{}var/{} = {}'.format(' ' * (indent + len(key)), propkey,
                                         repr(value)))


if os.path.isfile(sys.argv[1]):
    tree = ObjectTree()
    tree.ProcessFilesFromDME(sys.argv[1])
    ProcessTechLevels(tree.Tree)
    with open(
            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")
Exemplo n.º 2
0
                 nargs='?',
                 default='baystation12.dme',
                 type=str,
                 help='Project file.',
                 metavar='environment.dme')
opt.add_argument('map', type=str, help='Map to fix.', metavar='map.dmm')

args = opt.parse_args()

actions = []

mapfixes.Load()
actions += mapfixes.GetFixesForNS(args.namespaces, not args.no_dependencies)

tree = ObjectTree()
tree.ProcessFilesFromDME(args.dme)

for fixscript in args.fixscripts:
    with open(fixscript, 'r') as repl:
        ln = 0
        errors = 0
        for line in repl:
            ln += 1
            if line.startswith('#'):
                continue
            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()
Exemplo n.º 3
0
opt.add_argument(
    '-O',
    '--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.Load(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
Exemplo n.º 4
0
                 regex=re.compile(r'\bsleep\(([0-9]+)\)\b'),
                 in_procnames=('process')),
    RegexScanner(id='spawn-in-process',
                 warning='spawn() should not be used in process().',
                 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 = {}