Ejemplo n.º 1
0
    def __setitem__(self, key, value):
        if key == "includes":
            if isinstance(value, list):
                value = value[0]
            for path in split(value):
                path = self._parser._interpolate("DEFAULT", None, path, self)
                path = posixpath.expanduser(path)
                if not posixpath.exists(path):
                    raise Exception, "No such configuration file: %s" % path
                if posixpath.isdir(path):
                    logging.info("Parsing config filenames from directory: %s",
                        path)
                    def walk_func(arg, directory, names):
                        for name in names:
                            path = posixpath.join(directory, name)
                            if not posixpath.isdir(path):
                                arg._parser.read(path)

                    posixpath.walk(path, walk_func, self)
                else:
                    logging.info("Parsing config filename: %s", path)
                    self._parser.read(path)

        # Environment has precedence over configuration
        elif not key.startswith("CHECKBOX") or key.upper() not in os.environ:
            super(IncludeDict, self).__setitem__(key, value)
Ejemplo n.º 2
0
def path_expand_recursive(path):
    paths = []
    for path in path_expand(path):
        if posixpath.isdir(path):
            def walk_func(arg, directory, names):
                for name in names:
                    path = posixpath.join(directory, name)
                    if not posixpath.isdir(path):
                        arg.append(path)

            posixpath.walk(path, walk_func, paths)
        else:
            paths.append(path)

    return paths
Ejemplo n.º 3
0
def linkdir(sourcedir, targetdir, recursive, linkcache={}, overrides={}):
    #print 'linkdir', sourcedir, targetdir
    files = {}
    dirs = {}
    overrides_performed = []
    posixpath.walk(sourcedir, linkdir_compile, (files, dirs, recursive))
    #print
    #makedirandpath(targetdir)
    directorys = dirs.keys()
    directorys.sort()
    for directory in directorys:
        directoryimage = directory[len(sourcedir):]
        dirs[directory] = directoryimage
        maybemakedir(targetdir + directoryimage, verbose=0)
    for file in files.keys():
        if file[-1] == '~' or file[-4:] == '.pyc':
            #print 'Skipping file ',file
            pass
        else:
            pathend = string.rfind(file, '/')
            path = file[:pathend]
            subpath = path[len(sourcedir):]

            filename = file[pathend + 1:]
            doit = 1
            abstargetname = targetdir + subpath + '/' + filename
            target = targetdir + subpath + '/' + filename
            reformedfile = filename
            if len(subpath) > 1: reformedfile = subpath[1:] + '/' + filename
            if overrides.has_key(reformedfile):
                file = overrides[reformedfile]
                overrides_performed.append([reformedfile])
            try:
                os.unlink(target)
            except posix.error:
                pass
            if file:
                getholdof(file, targetdir + subpath + '/' + filename,
                          linkcache)
            else:
                # user has specified None as an override; do not create the file
                pass
    return overrides_performed
Ejemplo n.º 4
0
def linkdir(sourcedir, targetdir, recursive, linkcache = {}, overrides = {}):
    #print 'linkdir', sourcedir, targetdir
    files = {}
    dirs = {}
    overrides_performed = []
    posixpath.walk(sourcedir, linkdir_compile, (files,dirs,recursive))
    #print
    #makedirandpath(targetdir)
    directorys = dirs.keys()
    directorys.sort()
    for directory in directorys:
	directoryimage = directory[len(sourcedir):]
	dirs[directory] = directoryimage
	maybemakedir(targetdir + directoryimage, verbose=0)
    for file in files.keys():
        if file[-1] == '~' or file[-4:] == '.pyc':
            #print 'Skipping file ',file
            pass
        else:
            pathend = string.rfind(file, '/')
            path = file[:pathend]
            subpath = path[len(sourcedir):]

            filename = file[pathend+1:]
            doit = 1
            abstargetname = targetdir+subpath+'/' + filename
            target = targetdir+subpath+'/' + filename
            reformedfile = filename
            if len(subpath)>1: reformedfile = subpath[1:]+'/'+filename
            if overrides.has_key(reformedfile): 
                file = overrides[reformedfile]
                overrides_performed.append([reformedfile])
            try:
                os.unlink(target)
            except posix.error:
                pass
            if file:
                getholdof(file,targetdir+subpath+'/' + filename, linkcache) 
            else:
                # user has specified None as an override; do not create the file
                pass
    return overrides_performed