示例#1
0
def compute_prune_list(executable, guidlistfile):
    guidlist = open(guidlistfile).read()

    rx_guid = '[0-9a-z]{8}[-][0-9a-z]{4}[-][0-9a-z]{4}[-][0-9a-z]{4}[-][0-9a-z]{12}'
    rx = '(?m)^(%s)\s+(.*)\n  (.*)\n' % rx_guid
    guiddct = {}
    filelist = []
    for (guid, filepath, funcname) in re.findall(rx, guidlist):
        filelist.append(filepath)
        guiddct[guid] = (filepath, funcname)

    data = open(executable).read()
    exeguids = re.findall(rx_guid, data)
    if not exeguids:
        io.write_result("No guids found in executable", error=True)
        sys.exit()
    for exeguid in exeguids:
        try:
            del(guiddct[exeguid])
        except KeyError: pass

    dct = {}
    for (fp, funcname) in guiddct.values():
        if fp not in dct:
            dct[fp] = []
        dct[fp].append(funcname)

    filelist = util.uniq(filelist)
    return filelist, dct
示例#2
0
def process_filepaths(curpath, unitaliases, fps):
    # resolve unit aliases
    nfps = []
    for fp in fps:
        stem, ext = os.path.splitext(fp)
        stem = stem.lower()
        if ext in ('.pas', '.dcu') and stem in unitaliases:
            nfps.append(unitaliases[stem] + ext)
        else:
            nfps.append(fp)
    fps = util.uniq(nfps)

    fps = [io.convert_path(fp) for fp in fps]
    fps = map(lambda f: os.path.join(curpath, f), fps)
    fps = map(lambda f: os.path.normpath(f), fps)
    fps = io.iglobs(fps)
    fps = util.uniq(fps)
    return fps
示例#3
0
def findAbstractImports(s, parser, stripcomments=False):
    if stripcomments:
        s = parse_source.transStripComments(s)

    units = []
    for item in parser.scanString(s):
        toks, _, _ = item
        for unititem in toks:
            name, filename = None, None
            try:
                name = unititem[0]
                filename = unititem[1]
            except IndexError:
                pass
            unit = filename or name + '.pas'
            units.append(unit)
    units = util.uniq(units)
    return units
示例#4
0
文件: ast.py 项目: numerodix/delpy
    def make_class(cls, name, childnames, literals=None):
        def register_class(name):
            try:
                cl = nodes.get_class(name)
            except AttributeError:
                name_cc = cls.toCamelCase(name)
                cl = type.__new__(type, name_cc, (Node,), {})
                cl.valid_children = []
                setattr(nodes, name_cc, cl)
            return cl

        cl = register_class(name)
        children = []
        for name in childnames:
            children.append( register_class(name) )
        if literals:
            children.append(basestring)

        cl.valid_children.extend(children)
        cl.valid_children = util.uniq(cl.valid_children)
示例#5
0
文件: mixins.py 项目: numerodix/delpy
    def diff(self, other):
        fmt = lambda x: x.diffname() if hasattr(x, 'diffname') else x

        atts = util.uniq(self.__dict__.keys() + other.__dict__.keys())
        dct = {}
        for att in atts:
            my_attobj = fmt(getattr(self, att, None))
            other_attobj = fmt(getattr(other, att, None))
            if my_attobj != other_attobj:
                # if is iterable try to use diffname()
                if hasattr(my_attobj, '__iter__'):
                    my_attobj = map(fmt, my_attobj)
                if hasattr(other_attobj, '__iter__'):
                    other_attobj = map(fmt, other_attobj)

                dct[att] = (my_attobj, other_attobj)
        if dct:
            diffobj = Diff(self.diffname())
            for (k, v) in dct.items():
                diffobj.add_att(k, v)
            return diffobj