if v != None: flags[k] = v if options.all or options.lint: # if lint, don't filter anything flags = flags.fromkeys(flags, True) try: try: filepath = args[0] except IndexError: raise OptionException() dg = master(filepath, options.projview, flags, maxdepth=options.depth) if options.quiet: pass # do nothing, avoid else clause below elif options.write: prettyprinter.pp(dg, collapse_duplicates=True) elif options.ls: ls(dg) elif options.ls_abspath: ls_abspath(dg) elif options.ls_searchpath: ls_searchpath(dg) elif options.ls_stdlibpath: ls_stdlibpath(dg) elif options.lint: sys.exit(lint(dg)) elif options.verify: sys.exit(verify(dg)) elif options.dotfile: fp = options.dotfile _, ext = os.path.splitext(fp)
def parseBdsGroup(s): node_root = xml.dom.minidom.parseString(s) dct = {} elems = ('Projects',) for elem in elems: dct[elem] = get_keypairs(node_root, 'BorlandProject/Default.Personality', elem) return dct def parseBdsProj(s): node_root = xml.dom.minidom.parseString(s) dct = {} elems = ('Source', 'FileVersion', 'Compiler', 'Linker', 'Directories', 'Parameters', 'Language', 'VersionInfo', 'VersionInfoKeys') for elem in elems: dct[elem] = get_keypairs(node_root, 'BorlandProject/Delphi.Personality', elem) return dct if __name__ == '__main__': file = sys.argv[1] s = open(file).read() dct = {} _, ext = os.path.splitext(file) if ext == '.bdsproj': dct = parseBdsProj(s) elif ext == '.bdsgroup': dct = parseBdsGroup(s) prettyprinter.pp(dct)
if __name__ == '__main__': funcs_s = util.find_module_funcs_matching(__name__, '^find_') usage = "Usage: %s --finder <func> file.pas" % sys.argv[0] optparser = OptionParser(usage=usage) optparser.add_option("-f", "--finder", dest="finder", metavar="function", help="use finder (%s)" % funcs_s) (options, args) = optparser.parse_args() try: try: source = open(args[0]).read() except IndexError: raise model.OptionException() try: finder = options.finder exec('finder = find_%s' % finder) except NameError: raise model.OptionException() st = finder(source, stripcomments=True) if isinstance(st, basestring): sys.stdout.write(st) else: prettyprinter.pp(st) except model.OptionException: optparser.print_help()
# Licensed under the GNU Public License, version 3. if __name__ == '__main__': import __path__ from delpy import util from delpy.delphisrc.scope import Scope class SymbolTable(object): def __init__(self): self.index = {} def set(self, unitid, blockid, symbol): if unitid not in self.index: self.index[unitid] = {} if blockid not in self.index[unitid]: self.index[unitid][blockid] = {} self.index[unitid][blockid][symbol.id] = symbol st = SymbolTable() sym = Symbol('price', 'integer', Scope.LocalVar) fsym = Symbol('Effe', 'integer', Scope.UnitFunc) st.set('Gui', 'TFormMain.BtnCheckPriceClick', sym) st.set('Gui', 'InterfaceSection', fsym) from delpy.lib import prettyprinter as pp pp.pp(st)