Exemplo n.º 1
0
 def _getDir(self, rootName, folder, template):
     if folder != None:
         folder = self._expandDir(folder)
         folder = fileutils.ensureAbsDirPath(folder)
         folder = fileutils.cleanupPath(folder)
         return virtualpath.VirtualPath(folder, rootName)
     folder = fileutils.ensureAbsDirPath(template % self.subdir)
     folder = fileutils.cleanupPath(folder)
     return virtualpath.VirtualPath(folder, rootName)
Exemplo n.º 2
0
 def virtualize(cls, path, local):
     """
     From a path and local, it creates a VirtualPath instance.
     """
     path = fileutils.cleanupPath(path)
     for name, value in local.iterVirtualRoots():
         value = fileutils.cleanupPath(value)
         if path.startswith(value):
             path = fileutils.ensureAbsPath(path[len(value):])
             return VirtualPath(path, name)
     raise errors.VirtualPathError("Cannot virtualize local path '%s', "
                                   "no compatible virtual root found" % path)
Exemplo n.º 3
0
 def __get__(self, obj, type=None):
     storeValue = getattr(obj.store, self._storePropertyName)
     if storeValue != None:
         value = obj._expandDir(storeValue)
         value = fileutils.ensureAbsDirPath(value)
         value = fileutils.cleanupPath(value)
         return virtualpath.VirtualPath(value)
     return getattr(obj.parent, self._basePropertyName)
Exemplo n.º 4
0
 def subdir(self):
     subdir = self.store.subdir
     if subdir != None:
         subdir = fileutils.str2path(subdir)
         subdir = fileutils.ensureRelDirPath(subdir)
         return fileutils.cleanupPath(subdir)
     subdir = fileutils.str2filename(self.store.name)
     return fileutils.ensureDirPath(subdir)
Exemplo n.º 5
0
 def __init__(self, profCtx, targStore):
     base.BaseStoreContext.__init__(self, profCtx, targStore)
     self._variables.addVar("targetName", self.name)
     subdir = self.store.subdir or ""
     subdir = fileutils.str2path(subdir)
     subdir = fileutils.ensureRelDirPath(subdir)
     subdir = fileutils.cleanupPath(subdir)
     self._variables.addVar("targetSubdir", subdir)
     targPath = (fileutils.joinPath(self._variables["sourceDir"], subdir)
                 + self._variables["sourceFile"])
     self._variables.addFileVars(fileutils.ensureRelPath(targPath),
                                 "target", extension=self.extension)
Exemplo n.º 6
0
 def _getDir(self, custData, profData, kind="incoming"):
     middle, attr = {"incoming": ("incoming", "inputDir"),
                     "outgoing": ("outgoing", "outputDir"),
                     "links": ("links", "linkDir"),
                     "errors": ("failed", "errorDir")}[kind]
     if getattr(profData, attr):
         return getattr(profData, attr)
     if getattr(custData, attr):
         result = getattr(custData, attr)
     elif custData.subdir:
         result = custData.subdir
     else:
         result = fileutils.str2filename(custData.name)
     result = fileutils.ensureRelDirPath(result)
     result = "%sfiles/%s/" % (result, middle)
     if profData.subdir:
         result = result + profData.subdir
     else:
         result = result + fileutils.str2filename(profData.name)
     return fileutils.cleanupPath(result)
Exemplo n.º 7
0
 def _guessOverridenDir(self, dir, custData, profData):
     for middle, new in [('incoming', 'incoming'),
                         ('outgoing', 'outgoing'),
                         ('errors', 'failed'),
                         ('links', 'links'),
                         ('thumbnails', 'thumbnails')]:
         try:
             i = dir.index(middle)
             p1 = dir[:i].strip('/')
             p2 = dir[i + len(middle):].strip('/')
             # Check to reorder profiles directories
             custSubdir = custData.subdir or fileutils.str2filename(custData.name)
             profSubdir = profData.subdir or fileutils.str2filename(profData.name)
             if p1 == (custSubdir + '/' + profSubdir):
                 result =  custSubdir + "/files/" + new + "/" + profSubdir + '/' + p2
             else:
                 result =  p1 + "/files/" + new + "/" + p2
             result = fileutils.ensureDirPath(result)
             result = fileutils.cleanupPath(result)
             return result
         except ValueError:
             pass
     return dir
Exemplo n.º 8
0
 def __get__(self, obj, type=None):
     template = getattr(obj, self._templatePropertyName)
     path = obj._variables.substitute(template)
     path = fileutils.ensureRelPath(path)
     return fileutils.cleanupPath(path)
Exemplo n.º 9
0
 def doneRepRelPath(self):
     path = self._variables.substitute(self.reportFileTemplate)
     path = fileutils.ensureRelPath(path)
     return fileutils.cleanupPath(path)
Exemplo n.º 10
0
 def configRelPath(self):
     path = self._variables.substitute(self.configFileTemplate)
     path = fileutils.ensureRelPath(path)
     return fileutils.cleanupPath(path)