def ConvertVersionToDecimal(StringIn): if IsValidHexVersion(StringIn): Value = int(StringIn, 16) Major = Value >> 16 Minor = Value & 0xFFFF MinorStr = str(Minor) if len(MinorStr) == 1: MinorStr = '0' + MinorStr return str(Major) + '.' + MinorStr else: if StringIn.find(TAB_SPLIT) != -1: return StringIn elif StringIn: return StringIn + '.0' else: # # when StringIn is '', return it directly # return StringIn
def SetPiSpecificationVersion(self, PiSpecificationVersion, Comments): # # Value has been set before. # if self.PiSpecificationVersion != None: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ %(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION), LineInfo=self.CurrentLine) return False # # The EdkReleaseVersion should be 4 bytes hex string. # if IsValidHexVersion(PiSpecificationVersion) or \ IsValidDecVersionVal(PiSpecificationVersion): self.PiSpecificationVersion = InfDefMember() self.PiSpecificationVersion.SetValue(PiSpecificationVersion) self.PiSpecificationVersion.Comments = Comments return True else: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ %(PiSpecificationVersion), LineInfo=self.CurrentLine) return False
def SetEdkReleaseVersion(self, EdkReleaseVersion, Comments): # # Value has been set before. # if self.EdkReleaseVersion is not None: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\ %(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION), LineInfo=self.CurrentLine) return False # # The EdkReleaseVersion should be 4 bytes hex string. # if IsValidHexVersion(EdkReleaseVersion) or \ IsValidDecVersionVal(EdkReleaseVersion): self.EdkReleaseVersion = InfDefMember() self.EdkReleaseVersion.SetValue(EdkReleaseVersion) self.EdkReleaseVersion.Comments = Comments return True else: ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\ %(EdkReleaseVersion), LineInfo=self.CurrentLine) return False