Beispiel #1
0
def targets(originalFiles, aliasedFiles):
    # ALLOW these helper file extensions to be available unchanged
    # from the working directory - they will never be measured
    a = frozenset(filters['allow'])
    allowed = []
    _files = originalFiles
    files = []

    for f in _files:
        if f.imp in a:
            allowed.append(f)
        else:
            files.append(f)
        # giving a list of ALLOWed filenames and a list without ALLOWed filenames

    # reverse alias dictionary so we can look up the target for each alias
    revAlias = {}
    for k, vs in alias.iteritems():
        for v in vs:
            revAlias[v] = k

    links = []

    # ONLY measure files with these extensions
    o = filters['only']
    if o:
        _files = files
        files = []

        for imp in o:
            reva = revAlias.get(imp, None)
            for f in _files:
                if reva:
                    if f.imp == reva:
                        links.append(LinkNameParts(f.filename, imp))
                else:
                    if f.imp == imp:
                        files.append(f)
        # giving a list of ONLY links and a list of ONLY files

    # measure files with ANY extension, except ...
    else:
        # create alias filenames
        links = aliasedFiles

        # IGNORE files or links with these extensions
        ignore = frozenset(filters['ignore'])
        if ignore:
            links = [f for f in links if not f.imp in ignore]
            files = [f for f in files if not f.imp in ignore]

    # assume dat file is only written once, when all data is available

    def notUpToDate(s, d):
        try:
            return getmtime(join(srcdir, s)) > getmtime(join(datdir, d))
        except OSError, (e, _):
            return e == ENOENT  # No such file or directory
Beispiel #2
0
def worklist():
    global srcdir

    w = []
    subdirs = [
        each for each in os.listdir(dirs['src']) if each in filters['onlydirs']
    ]

    subdirs.sort()
    for d in subdirs:
        makeSubDirectoriesFor(d)

        # take all likely names in src directory
        # create simpleNames for each name and each possible alias
        srcdir = join(dirs['src'], d)

        # include undeleted filenames that might have a file extension
        files = fnmatch.filter(os.listdir(srcdir), '*.*[!~]')

        # exclude bogus files created by touch
        files = [FileNameParts(f) for f in files if not f.startswith('*')]

        original = [fp for fp in files]

        src = set(original)
        aliased = []
        for o in original:
            for imp in alias.get(o.imp, []):
                aliased.append(LinkNameParts(o.filename, imp))
        src.update(aliased)

        clean(d, src)

        allowed, sources, links = targets(original, aliased)

        programs = set(sources)
        programs.update(links)

        # symlink these programs from codedir so they are available
        # for conversion to highlight-ed xml files
        codedir = join(dirs['tmp'], d, 'code')
        for f in programs:
            linkToSource(directory=srcdir,
                         srcFilename=f.filename,
                         dstDir=codedir,
                         filename=f.programName)

            linkToSource(directory=srcdir,
                         srcFilename=f.filename,
                         dstDir=codedir,
                         filename=f.codeName)

        w.append((d, programs, allowed))

    return w