def getDirectoryInfo(self, filepath): # This is called when we need to get hold of the information # for a minimal path. # minimalpath is called on the supplied path on the hope # that if it is incorrect, something can be done to fix it. # Can return None. return self._directories.get(minimalpath(filepath), None)
def registerDirectoryByPath(self, filepath, subdirs=1): fp = minimalpath(filepath) self._directories[fp] = di = DirectoryInformation(filepath, fp) if subdirs: for entry in di.getSubdirs(): e_filepath = path.join(filepath, entry) self.registerDirectoryByPath(e_filepath, subdirs)
def registerDirectoryByPath(self, filepath, subdirs=1): # This is indirectly called during registration of # a directory. As you can see, minimalpath is called # on the supplied path at this point. # The idea is that the registry will only contain # small paths that are likely to work across platforms # and SOFTWARE_HOME, INSTANCE_HOME and PRODUCTS_PATH setups minimal_fp = minimalpath(filepath) info = DirectoryInformation(filepath, minimal_fp) self._directories[minimal_fp] = info if subdirs: for entry in info.getSubdirs(): entry_filepath = path.join(filepath, entry) self.registerDirectoryByPath(entry_filepath, subdirs)
def registerDirectoryByPath(self, filepath, subdirs=1): # This is indirectly called during registration of # a directory. As you can see, minimalpath is called # on the supplied path at this point. # The idea is that the registry will only contain # small paths that are likely to work across platforms # and SOFTWARE_HOME, INSTANCE_HOME and PRODUCTS_PATH setups fp = minimalpath(filepath) normfilepath = path.normpath(filepath) self._directories[fp] = di = DirectoryInformation(normfilepath, fp) if subdirs: for entry in di.getSubdirs(): e_filepath = path.join(normfilepath, entry) self.registerDirectoryByPath(e_filepath, subdirs)
def addDirectoryViews(ob, name, _prefix): """ Add a directory view for every subdirectory of the given directory. Meant to be called by filesystem-based code. Note that registerDirectory() still needs to be called by product initialization code to satisfy persistence demands. """ if not isinstance(_prefix, basestring): _prefix = package_home(_prefix) filepath = path.join(_prefix, name) minimal_fp = minimalpath(filepath) info = _dirreg.getDirectoryInfo(minimal_fp) if info is None: raise ValueError('Not a registered directory: %s' % minimal_fp) for entry in info.getSubdirs(): entry_minimal_fp = '/'.join((minimal_fp, entry)) createDirectoryView(ob, entry_minimal_fp, entry)
def addDirectoryViews(ob, name, _prefix): """ Add a directory view for every subdirectory of the given directory. Meant to be called by filesystem-based code. Note that registerDirectory() still needs to be called by product initialization code to satisfy persistence demands. """ if not isinstance(_prefix, basestring): _prefix = package_home(_prefix) filepath = path.join(_prefix, name) minimal_fp = minimalpath(filepath) info = _dirreg.getDirectoryInfo(minimal_fp) if info is None: raise ValueError('Not a registered directory: %s' % minimal_fp) for entry in info.getSubdirs(): entry_minimal_fp = '/'.join( (minimal_fp, entry) ) createDirectoryView(ob, entry_minimal_fp, entry)
def addDirectoryViews(ob, name, parent_globals): ''' Adds a directory view for every subdirectory of the given directory. ''' # Meant to be called by filesystem-based code. # Note that registerDirectory() still needs to be called # by product initialization code to satisfy # persistence demands. fp = path.join(package_home(parent_globals), name) filepath = minimalpath(fp) info = _dirreg.getDirectoryInfo(filepath) if info is None: raise ValueError('Not a registered directory: %s' % filepath) for entry in info.getSubdirs(): filepath2 = path.join(filepath, entry) createDirectoryView(ob, filepath2, entry)