edk2toollib/uefi/edk2/parsers/base_parser.py
def ParseGuid(self, line):
        """
        parse a guid into a different format
        Will throw exception if missing any of the 11 parts of isn't long enough
        Args:
          l: the guid to parse ex: { 0xD3B36F2C, 0xD551, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}

        Returns: a string of the guid. ex: D3B36F2C-D551-11D4-9A46-0090273FC14D

        """
        entries = line.lstrip(' {').rstrip(' }').split(',')
        if len(entries) != 11:
            raise RuntimeError(
                f"Invalid GUID found {line}. We are missing some parts since we only found: {len(entries)}")
        gu = entries[0].lstrip(' 0').lstrip('x').strip()
        # pad front until 8 chars
        while(len(gu) < 8):
            gu = "0" + gu

        gut = entries[1].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 4):
            gut = "0" + gut
        gu = gu + "-" + gut

        gut = entries[2].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 4):
            gut = "0" + gut
        gu = gu + "-" + gut

        # strip off extra {
        gut = entries[3].lstrip(' { 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + "-" + gut

        gut = entries[4].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        gut = entries[5].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + "-" + gut

        gut = entries[6].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        gut = entries[7].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        gut = entries[8].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        gut = entries[9].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        gut = entries[10].split()[0].lstrip(' 0').lstrip('x').rstrip(' } ').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut

        proper_guid_length = 36
        if len(gu) > proper_guid_length:
            raise RuntimeError(f"The guid we parsed was too long: {gu}")
        if len(gu) < proper_guid_length:
            raise RuntimeError(f"The guid we parsed was too short: {gu}")

        return gu.upper()

        parse a guid into a different format
        Will throw exception if missing any of the 11 parts of isn't long enough
        Args:
          l: the guid to parse ex: { 0xD3B36F2C, 0xD551, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}

        Returns: a string of the guid. ex: D3B36F2C-D551-11D4-9A46-0090273FC14D

        
parse a guid into a different format
Will throw exception if missing any of the 11 parts of isn't long enough
parse a guid into a different format Will throw exception if missing any of the 11 parts of isn ' t long enough
def ParseGuid(self, line):
        entries = line.lstrip(' {').rstrip(' }').split(',')
        if len(entries) != 11:
            raise RuntimeError(
                f"Invalid GUID found {line}. We are missing some parts since we only found: {len(entries)}")
        gu = entries[0].lstrip(' 0').lstrip('x').strip()
        while(len(gu) < 8):
            gu = "0" + gu
        gut = entries[1].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 4):
            gut = "0" + gut
        gu = gu + "-" + gut
        gut = entries[2].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 4):
            gut = "0" + gut
        gu = gu + "-" + gut
        gut = entries[3].lstrip(' { 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + "-" + gut
        gut = entries[4].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        gut = entries[5].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + "-" + gut
        gut = entries[6].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        gut = entries[7].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        gut = entries[8].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        gut = entries[9].lstrip(' 0').lstrip('x').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        gut = entries[10].split()[0].lstrip(' 0').lstrip('x').rstrip(' } ').strip()
        while(len(gut) < 2):
            gut = "0" + gut
        gu = gu + gut
        proper_guid_length = 36
        if len(gu) > proper_guid_length:
            raise RuntimeError(f"The guid we parsed was too long: {gu}")
        if len(gu) < proper_guid_length:
            raise RuntimeError(f"The guid we parsed was too short: {gu}")
        return gu.upper()
def ParseGuid ( self , line ) : entries = line . lstrip ( ' {' ) . rstrip ( ' }' ) . split ( ',' ) if len ( entries ) != 11 : raise RuntimeError ( f"Invalid GUID found {line}. We are missing some parts since we only found: {len(entries)}" ) gu = entries [ 0 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gu ) < 8 ) : gu = "0" + gu gut = entries [ 1 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 4 ) : gut = "0" + gut gu = gu + "-" + gut gut = entries [ 2 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 4 ) : gut = "0" + gut gu = gu + "-" + gut gut = entries [ 3 ] . lstrip ( ' { 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + "-" + gut gut = entries [ 4 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut gut = entries [ 5 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + "-" + gut gut = entries [ 6 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut gut = entries [ 7 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut gut = entries [ 8 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut gut = entries [ 9 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut gut = entries [ 10 ] . split ( ) [ 0 ] . lstrip ( ' 0' ) . lstrip ( 'x' ) . rstrip ( ' } ' ) . strip ( ) while ( len ( gut ) < 2 ) : gut = "0" + gut gu = gu + gut proper_guid_length = 36 if len ( gu ) > proper_guid_length : raise RuntimeError ( f"The guid we parsed was too long: {gu}" ) if len ( gu ) < proper_guid_length : raise RuntimeError ( f"The guid we parsed was too short: {gu}" ) return gu . upper ( )
parse a guid into a different format
Will throw exception if missing any of the 11 parts of isn't long enough
parse a guid into a different format Will throw exception if missing any of the 11 parts of isn ' t long enough
"""
        parse a guid into a different format
        Will throw exception if missing any of the 11 parts of isn't long enough
        Args:
          l: the guid to parse ex: { 0xD3B36F2C, 0xD551, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}

        Returns: a string of the guid. ex: D3B36F2C-D551-11D4-9A46-0090273FC14D

        """ # pad front until 8 chars # strip off extra {
self
line
l
None