예제 #1
0
파일: base.py 프로젝트: Byron/bit
 def package_search_paths(self):
     """@return list of absolute package search paths, under which we will check for packages and changes thereof"""
     out = list()
     for search_path in self.settings().package.search_paths:
         search_path = Path(search_path)
         if not search_path.isabs():
             assert self._config_file_path is not None, "Require a configuration file path for relative search paths"
             search_path = self._config_file_path.dirname() / search_path
         # end make absolute path
         out.append(search_path)
     # end for each possibly relative search path
     return out
예제 #2
0
파일: fsops.py 프로젝트: Byron/bit
    def _normalized_destination(cls, package, config):
        """@return an absolute path with all strp based items replaced if applicable"""
        stat = package.root().stat()
        assert config.date_field in cls.valid_times, "Invalid date field, must be one of %s" % (', '.join(cls.valid_times))
        assert config.destination, "'destination' field must be set"

        time_tuple = gmtime(getattr(stat, 'st_%s' % config.date_field) - timezone)

        destination_path = Path(strftime(config.destination, time_tuple))
        if not destination_path.isabs():
            destination_path = package.root() / destination_path
        # end make absolute

        return destination_path
예제 #3
0
파일: utility.py 프로젝트: mottosso/bcore
 def to_abs_path(self, path):
     """Convert the given possibly relative path to an absolute path, if necessary
     @note it is not checked for existence
     @param path string or butility.Path
     @return absolute version of the path, as butility.Path
     @throws ValueError if the path is relative and there is no valid root path
     @note assumes the best when an environment variable is found, which never be made absolute.
     Will only appliy to paths like '$FOO/bar', not to 'foo/$BAR'"""
     path = Path(path)
     if path.isabs():
         return path
     if path.containsvars():
         return path
     if self.root_path() is None:
         raise EnvironmentError("Cannot convert '%s' to absolute path in package '%s' without a single valid tree, tried: [%s]" % (path, self.name(), ', '.join(self._data.trees)))
     # end handle root path
     return self.root_path() / path