def __init__(self, template, variables={}): if hasattr(template, 'readlines'): self.template_string = uc_str(''.join(template.readlines()), 'utf-8') self.filename = template.name else: self.template_string = template self.filename = 'string' self.variables = variables.copy() self.node_variables = {} parser = Parser(self.template_string) self.nodes = parser.parse()
def _repositoriesOnDisk(): """Returns all repositories that are found on disk""" import glob, os.path reposdir = options.env_path('svn_dir') repositories = [] if not os.path.exists(reposdir): return [] for rep in os.listdir(reposdir): if os.path.isdir((reposdir + rep).encode('utf-8')): repositories.append(uc_str(rep)) return repositories
def get_entries(self, path): # lots of conversions from and to utf-8 disk_url = directory(self.name).encode('utf-8') root_path_utf8 = repos.svn_repos_find_root_path(disk_url) if root_path_utf8 is None or not os.path.exists(root_path_utf8): if os.path.exists(disk_url): raise EncodingError(disk_url) raise DoesNotExistError(disk_url) try: repository = repos.svn_repos_open(root_path_utf8) except SubversionException as e: # check for messages like the following: # "Expected FS Format 'x'; found format 'y'" # there are different errorcodes for each version, so do a string # match instead of errorcode match errstr = str(e) if "Expected" in errstr and "format" in errstr and "found" in errstr: raise VersionError raise PermissionError fs_ptr = repos.svn_repos_fs(repository) path_utf8 = uc_to_svn(uc_str(path)) youngest_revision_number = fs.youngest_rev(fs_ptr) try: root = fs.revision_root(fs_ptr, youngest_revision_number) except SubversionException as e: raise PermissionError entries = fs.dir_entries(root, path_utf8) dirs = [] for entry in entries.keys(): d = {} node_type = fs.check_path(root, os.path.join(path_utf8, entry)) if (node_type == core.svn_node_dir): d['kind'] = 'dir' elif (node_type == core.svn_node_file): d['kind'] = 'file' else: d['kind'] = 'unknown' d['name'] = uc_from_svn(entry) dirs.append(d) return dirs
def get_entries(self, path): # lots of conversions from and to utf-8 disk_url = directory(self.name) root_path_utf8 = repos.svn_repos_find_root_path(disk_url) if root_path_utf8 is None or not os.path.exists(root_path_utf8): raise DoesNotExistError(disk_url) try: repository = repos.svn_repos_open(root_path_utf8) except SubversionException as e: # check for messages like the following: # "Expected FS Format 'x'; found format 'y'" # there are different errorcodes for each version, so do a string # match instead of errorcode match errstr = str(e) if "Expected" in errstr and "format" in errstr and "found" in errstr: raise VersionError raise PermissionError fs_ptr = repos.svn_repos_fs(repository) path_utf8 = uc_to_svn(uc_str(path)) youngest_revision_number = fs.youngest_rev(fs_ptr) try: root = fs.revision_root(fs_ptr, youngest_revision_number) except SubversionException as e: raise PermissionError entries = fs.dir_entries(root, path_utf8) dirs = [] for entry in entries.keys(): d = {} node_type = fs.check_path(root, os.path.join(path_utf8, entry)) if (node_type == core.svn_node_dir): d['kind'] = 'dir' elif (node_type == core.svn_node_file): d['kind'] = 'file' else: d['kind'] = 'unknown' d['name'] = uc_from_svn(entry) dirs.append(d) return dirs