Пример #1
0
 def user_macros(self):
     #
     # Return something even if it does not exist.
     #
     if self.opts['macros'] is None:
         return None
     um = []
     configs = self.defaults.expand('%{_configdir}').split(':')
     for m in self.opts['macros'].split(','):
         if path.exists(m):
             um += [m]
         else:
             # Get the expanded config macros then check them.
             cm = path.expand(m, configs)
             ccm = path.exists(cm)
             if True in ccm:
                 # Pick the first found
                 um += [cm[ccm.index(True)]]
             else:
                 um += [m]
     return um if len(um) else None
Пример #2
0
 def user_macros(self):
     #
     # Return something even if it does not exist.
     #
     if self.opts['macros'] is None:
         return None
     um = []
     configs = self.defaults.expand('%{_configdir}').split(':')
     for m in self.opts['macros'].split(','):
         if path.exists(m):
             um += [m]
         else:
             # Get the expanded config macros then check them.
             cm = path.expand(m, configs)
             ccm = path.exists(cm)
             if True in ccm:
                 # Pick the first found
                 um += [cm[ccm.index(True)]]
             else:
                 um += [m]
     return um if len(um) else None
Пример #3
0
def create(name, area = None, link = None):
    """Create a profile named <name>.

    The profile is created under <area>.

    If <link> is not None the profile is made as a link to <link>.

    If successful,  profile object is returned.  Else none.
    """
    p = Profile(name, area)

    if os.path.exists(p.path):
        OSError("Profile exists '%s'" % p.path)

    if not os.path.exists(p.area):
        os.makedirs(p.area)

    if link:
        link = pmod.expand(link)
        os.symlink(link, p.path)
        return
    if not os.path.exists(p.path):
        os.makedirs(p.path)
    return p
Пример #4
0
def Profile(name, area = None):
    area = pmod.expand(area or default_profile_area)
    path = os.path.join(area, name)
    return namedtuple('Profile','name area path')(name, area, path)