示例#1
0
文件: ChainFile.py 项目: mjuric/eups
    def setVersion(self, version, flavors=None):
        """
        assign this tag to a version.

        @param version : the version to assign this tag to
        @param flavors : the flavors to update tags for as a list or a single
                           string (for a single flavor).  If None, tag all 
                           previously tagged flavors will be retagged.
        """
        if flavors is None:
            return self.setVersion(self.getFlavors())
        if not isinstance(flavors, list):
            flavors = [flavors]

        for flavor in flavors:
            if flavor in self.info:
                info = self.info[flavor].copy()
                info["modifier"] = who
                info["modified"] = ctimeTZ()
            else:
                info = { "declarer": who, "declared": ctimeTZ() } 

            info["version"] = version
            self.info[flavor] = info
示例#2
0
    def setVersion(self, version, flavors=None):
        """
        assign this tag to a version.

        @param version : the version to assign this tag to
        @param flavors : the flavors to update tags for as a list or a single
                           string (for a single flavor).  If None, tag all 
                           previously tagged flavors will be retagged.
        """
        if flavors is None:
            return self.setVersion(self.getFlavors())
        if not isinstance(flavors, list):
            flavors = [flavors]

        for flavor in flavors:
            if self.info.has_key(flavor):
                info = self.info[flavor].copy()
                info["modifier"] = who
                info["modified"] = ctimeTZ()
            else:
                info = {"declarer": who, "declared": ctimeTZ()}

            info["version"] = version
            self.info[flavor] = info
示例#3
0
    def addFlavor(self, flavor, installdir = None, tablefile = None, 
                  upsdir = None):
        """
        add a flavored version to this file.  If an entry for this flavor
        already exists, it will be modified.

        @param flavor :     the name of the platform flavor to be adding.
        @param installdir : the installation directory for the new version 
                              being added.  If None, this package as no 
                              install directory.
        @param tablefile :  the path to the table file for this version.  If 
                              this is relative, then it is assumed to be 
                              relative to the upsdir; if upsdir is None,
                              it is assumed to be relative to installdir
                              If None, the product has no tablefile.
        @param upsdir :     the path to the ups directory for this product.  
                              If None, a value of  "ups" will be assumed.  
        """
        if flavor in self.info:
            # if this flavor already exists, use it to set defaults.
            info = self.info[flavor]
            if not installdir and "productDir" in info:
                installdir = info["productDir"]
            if not upsdir and "ups_dir" in info:
                upsdir = info["ups_dir"]
            if not tablefile and "table_file" in info:
                tablefile = info["table_file"]
          
        info = {}
        if installdir:
            installdir = installdir.rstrip('/')
            info["productDir"] = installdir

        if tablefile:
            # regularize upsdir: strip off leading installdir, upsdir
            if installdir and isRealFilename(installdir) and \
               os.path.isabs(tablefile) and \
               tablefile.startswith(installdir+'/'):

                # stripping off installdir
                tablefile = tablefile[len(installdir)+1:]

                # look for a ups directory
                if upsdir != "none":
                    upsdir = os.path.dirname(tablefile)
                    if upsdir:
                        tablefile = os.path.basename(tablefile)
                    else:
                        upsdir = "none"

            info["table_file"] = tablefile 

        if upsdir:
            # regularize upsdir: strip off leading installdir
            upsdir = upsdir.rstrip('/')
            if installdir and isRealFilename(upsdir) and \
               os.path.isabs(upsdir) and upsdir.startswith(installdir+'/'):
                upsdir = upsdir[len(installdir)+1:]
        if upsdir is None:
            upsdir = "none"
        info["ups_dir"] = upsdir

        if flavor in self.info:
            if "declarer" in self.info[flavor]:
                info["declarer"] = self.info[flavor]["declarer"]
            if "declared" in self.info[flavor]:
                info["declared"] = self.info[flavor]["declared"]

        if "declarer" in info or "declared" in info:
            # we're modifying
            info["modifier"] = who
            info["modified"] = ctimeTZ()
        else:
            # we're declaring
            info["declarer"] = who
            info["declared"] = ctimeTZ()

        # now save the info
        self.info[flavor] = info
示例#4
0
    def addFlavor(self, flavor, installdir = None, tablefile = None,
                  upsdir = None):
        """
        add a flavored version to this file.  If an entry for this flavor
        already exists, it will be modified.

        @param flavor :     the name of the platform flavor to be adding.
        @param installdir : the installation directory for the new version
                              being added.  If None, this package as no
                              install directory.
        @param tablefile :  the path to the table file for this version.  If
                              this is relative, then it is assumed to be
                              relative to the upsdir; if upsdir is None,
                              it is assumed to be relative to installdir
                              If None, the product has no tablefile.
        @param upsdir :     the path to the ups directory for this product.
                              If None, a value of  "ups" will be assumed.
        """
        if flavor in self.info:
            # if this flavor already exists, use it to set defaults.
            info = self.info[flavor]
            if not installdir and "productDir" in info:
                installdir = info["productDir"]
            if not upsdir and "ups_dir" in info:
                upsdir = info["ups_dir"]
            if not tablefile and "table_file" in info:
                tablefile = info["table_file"]

        info = {}
        if installdir:
            installdir = installdir.rstrip('/')
            info["productDir"] = installdir

        if tablefile:
            # regularize upsdir: strip off leading installdir, upsdir
            if installdir and isRealFilename(installdir) and \
               os.path.isabs(tablefile) and \
               tablefile.startswith(installdir+'/'):

                # stripping off installdir
                tablefile = tablefile[len(installdir)+1:]

                # look for a ups directory
                if upsdir != "none":
                    upsdir = os.path.dirname(tablefile)
                    if upsdir:
                        tablefile = os.path.basename(tablefile)
                    else:
                        upsdir = "none"

            info["table_file"] = tablefile

        if upsdir:
            # regularize upsdir: strip off leading installdir
            upsdir = upsdir.rstrip('/')
            if installdir and isRealFilename(upsdir) and \
               os.path.isabs(upsdir) and upsdir.startswith(installdir+'/'):
                upsdir = upsdir[len(installdir)+1:]
        if upsdir is None:
            upsdir = "none"
        info["ups_dir"] = upsdir

        if flavor in self.info:
            if "declarer" in self.info[flavor]:
                info["declarer"] = self.info[flavor]["declarer"]
            if "declared" in self.info[flavor]:
                info["declared"] = self.info[flavor]["declared"]

        if "declarer" in info or "declared" in info:
            # we're modifying
            info["modifier"] = who
            info["modified"] = ctimeTZ()
        else:
            # we're declaring
            info["declarer"] = who
            info["declared"] = ctimeTZ()

        # now save the info
        self.info[flavor] = info