def test_normabspath(self): base = "/foo/bar" self.assertEqual("/foo/bar", normabspath('.', base)) self.assertEqual("/foo/bar", normabspath('foo/..', base)) self.assertEqual("/foo/bar", normabspath(base, base)) self.assertEqual("/foo", normabspath("/foo", base)) self.assertEqual("/foo/bar/bim", normabspath('bim', base)) self.assertEqual("/foo", normabspath('..', base))
def do_work(self): localname = "" scm = None uri = "" curr_uri = None exists = False version = "" # what is given in config file modified = "" actualversion = "" # revision number of version specversion = "" # actual revision number localname = self.element.get_local_name() path = self.element.get_path() or localname if localname is None or localname == "": raise MultiProjectException( "Missing local-name in element: %s" % self.element) if (os.path.exists(normabspath(path, self.path))): exists = True if self.element.is_vcs_element(): if not exists: path_spec = self.element.get_path_spec() version = path_spec.get_version() else: path_spec = self.element.get_versioned_path_spec() version = path_spec.get_version() curr_uri = path_spec.get_curr_uri() status = self.element.get_status(self.path, self.untracked) if (status is not None and status.strip() != ''): modified = True specversion = path_spec.get_revision() if (version is not None and version.strip() != '' and (specversion is None or specversion.strip() == '')): specversion = '"%s"' % version actualversion = path_spec.get_current_revision() scm = path_spec.get_scmtype() uri = path_spec.get_uri() return {'scm': scm, 'exists': exists, 'localname': localname, 'path': path, 'uri': uri, 'curr_uri': curr_uri, 'version': version, 'specversion': specversion, 'actualversion': actualversion, 'modified': modified, 'properties': self.element.get_properties()}
def add_path_spec(self, path_spec, merge_strategy='KillAppend'): """ add new element to this config with information provided in path spec :param merge_strategy: see insert_element :param path_specs: PathSpec objects :returns: merge action taken, see insert_element """ # compute the local_path for the config element local_path = normabspath(path_spec.get_local_name(), self.get_base_path()) if os.path.isfile(local_path): if path_spec.get_tags( ) is not None and 'setup-file' in path_spec.get_tags(): elem = SetupConfigElement(local_path, os.path.normpath( path_spec.get_local_name()), properties=path_spec.get_tags()) return self.insert_element(elem, merge_strategy) else: print("!!!!! Warning: Not adding file %s" % local_path) return None else: # scmtype == None kept for historic reasons here if (path_spec.get_scmtype() == None and self.config_filename is not None and os.path.exists( os.path.join(local_path, self.config_filename))): print( "!!!!! Warning: Not recursing into other config folder %s containing file %s" % (local_path, self.config_filename)) return None if path_spec.get_scmtype() != None: return self._insert_vcs_path_spec(path_spec, local_path, merge_strategy) else: # keep the given local name (e.g. relative path) for other # elements, but normalize local_name = os.path.normpath(path_spec.get_local_name()) elem = OtherConfigElement(local_path, local_name, path_spec.get_uri(), path_spec.get_version(), properties=path_spec.get_tags()) return self.insert_element(elem, merge_strategy)
def add_path_spec(self, path_spec, merge_strategy='KillAppend'): """ add new element to this config with information provided in path spec :param merge_strategy: see insert_element :param path_specs: PathSpec objects :returns: merge action taken, see insert_element """ # compute the local_path for the config element local_path = normabspath( path_spec.get_local_name(), self.get_base_path()) if os.path.isfile(local_path): if path_spec.get_tags() is not None and 'setup-file' in path_spec.get_tags(): elem = SetupConfigElement(local_path, os.path.normpath(path_spec.get_local_name()), properties=path_spec.get_tags()) return self.insert_element(elem, merge_strategy) else: print("!!!!! Warning: Not adding file %s" % local_path) return None else: # scmtype == None kept for historic reasons here if (path_spec.get_scmtype() == None and self.config_filename is not None and os.path.exists(os.path.join(local_path, self.config_filename))): print("!!!!! Warning: Not recursing into other config folder %s containing file %s" % (local_path, self.config_filename)) return None if path_spec.get_scmtype() != None: return self._insert_vcs_path_spec(path_spec, local_path, merge_strategy) else: # keep the given local name (e.g. relative path) for other # elements, but normalize local_name = os.path.normpath(path_spec.get_local_name()) elem = OtherConfigElement(local_path, local_name, path_spec.get_uri(), path_spec.get_version(), properties=path_spec.get_tags()) return self.insert_element(elem, merge_strategy)
def do_work(self): localname = "" scm = None uri = "" curr_uri = None exists = False version = "" # what is given in config file curr_version_label = "" # e.g. branchname remote_revision = "" # UID on remote default_remote_label = None # git default branch display_version = '' modified = "" currevision = "" # revision number of version specversion = "" # actual revision number localname = self.element.get_local_name() path = self.element.get_path() or localname if localname is None or localname == "": raise MultiProjectException( "Missing local-name in element: %s" % self.element) if (os.path.exists(normabspath(path, self.path))): exists = True if self.element.is_vcs_element(): if not exists: path_spec = self.element.get_path_spec() version = path_spec.get_version() else: path_spec = self.element.get_versioned_path_spec( fetch=fetch) version = path_spec.get_version() remote_revision = path_spec.get_remote_revision() curr_version_label = path_spec.get_curr_version() if (curr_version_label is not None and version != curr_version_label): display_version = curr_version_label else: display_version = version curr_uri = path_spec.get_curr_uri() status = self.element.get_status(self.path, self.untracked) if (status is not None and status.strip() != ''): modified = True specversion = path_spec.get_revision() if (version is not None and version.strip() != '' and (specversion is None or specversion.strip() == '')): specversion = '"%s"' % version if (self.fetch and specversion == None and path_spec.get_scmtype() == 'git'): default_remote_label = self.element.get_default_remote_label( ) currevision = path_spec.get_current_revision() scm = path_spec.get_scmtype() uri = path_spec.get_uri() return { 'scm': scm, 'exists': exists, 'localname': localname, 'path': path, 'uri': uri, 'curr_uri': curr_uri, 'version': version, 'remote_revision': remote_revision, 'default_remote_label': default_remote_label, 'curr_version_label': curr_version_label, 'specversion': specversion, 'actualversion': currevision, 'modified': modified, 'properties': self.element.get_properties() }
def do_work(self): localname = "" scm = None uri = "" curr_uri = None exists = False version = "" # what is given in config file curr_version_label = "" # e.g. branchname remote_revision = "" # UID on remote default_remote_label = None # git default branch display_version = '' modified = "" currevision = "" # revision number of version specversion = "" # actual revision number localname = self.element.get_local_name() path = self.element.get_path() or localname if localname is None or localname == "": raise MultiProjectException( "Missing local-name in element: %s" % self.element) if (os.path.exists(normabspath(path, self.path))): exists = True if self.element.is_vcs_element(): if not exists: path_spec = self.element.get_path_spec() version = path_spec.get_version() else: path_spec = self.element.get_versioned_path_spec(fetch=fetch) version = path_spec.get_version() remote_revision = path_spec.get_remote_revision() curr_version_label = path_spec.get_curr_version() if (curr_version_label is not None and version != curr_version_label): display_version = curr_version_label else: display_version = version curr_uri = path_spec.get_curr_uri() status = self.element.get_status(self.path, self.untracked) if (status is not None and status.strip() != ''): modified = True specversion = path_spec.get_revision() if (version is not None and version.strip() != '' and (specversion is None or specversion.strip() == '')): specversion = '"%s"' % version if (self.fetch and specversion == None and path_spec.get_scmtype() == 'git'): default_remote_label = self.element.get_default_remote_label() currevision = path_spec.get_current_revision() scm = path_spec.get_scmtype() uri = path_spec.get_uri() return {'scm': scm, 'exists': exists, 'localname': localname, 'path': path, 'uri': uri, 'curr_uri': curr_uri, 'version': version, 'remote_revision': remote_revision, 'default_remote_label': default_remote_label, 'curr_version_label': curr_version_label, 'specversion': specversion, 'actualversion': currevision, 'modified': modified, 'properties': self.element.get_properties()}