parameters: (output)
return_statement: return processed
docstring: Parses the output from a system ``blkid`` call, requires output to be
      produced using the ``-p`` flag which bypasses the cache, mangling the
      names. These names are corrected to what it would look like without the
      ``-p`` flag.
  
      Normal output::
  
          /dev/sdb1: UUID="62416664-cbaf-40bd-9689-10bd337379c3" TYPE="xfs" [...]
docstring_summary: Parses the output from a system ``blkid`` call, requires output to be
      produced using the ``-p`` flag which bypasses the cache, mangling the
      names. These names are corrected to what it would look like without the
      ``-p`` flag.
docstring_tokens: Parses the output from a system blkid call requires output to be produced using the - p flag which bypasses the cache mangling the names . These names are corrected to what it would look like without the - p flag .
function: def _blkid_parser(output):
      """
      Parses the output from a system ``blkid`` call, requires output to be
      produced using the ``-p`` flag which bypasses the cache, mangling the
      names. These names are corrected to what it would look like without the
      ``-p`` flag.
  
      Normal output::
  
          /dev/sdb1: UUID="62416664-cbaf-40bd-9689-10bd337379c3" TYPE="xfs" [...]
      """
      # first spaced separated item is garbage, gets tossed:
      output = ' '.join(output.split()[1:])
      # split again, respecting possible whitespace in quoted values
      pairs = output.split('" ')
      raw = {}
      processed = {}
      mapping = {
          'UUID': 'UUID',
          'TYPE': 'TYPE',
          'PART_ENTRY_NAME': 'PARTLABEL',
          'PART_ENTRY_UUID': 'PARTUUID',
          'PART_ENTRY_TYPE': 'PARTTYPE',
          'PTTYPE': 'PTTYPE',
      }
  
      for pair in pairs:
          try:
              column, value = pair.split('=')
          except ValueError:
              continue
          raw[column] = value.strip().strip().strip('"')
  
      for key, value in raw.items():
          new_key = mapping.get(key)
          if not new_key:
              continue
          processed[new_key] = value
  
      return processed
function_tokens: def _blkid_parser ( output ) : # first spaced separated item is garbage, gets tossed: output = ' ' . join ( output . split ( ) [ 1 : ] ) # split again, respecting possible whitespace in quoted values pairs = output . split ( '" ' ) raw = { } processed = { } mapping = { 'UUID' : 'UUID' , 'TYPE' : 'TYPE' , 'PART_ENTRY_NAME' : 'PARTLABEL' , 'PART_ENTRY_UUID' : 'PARTUUID' , 'PART_ENTRY_TYPE' : 'PARTTYPE' , 'PTTYPE' : 'PTTYPE' , } for pair in pairs : try : column , value = pair . split ( '=' ) except ValueError : continue raw [ column ] = value . strip ( ) . strip ( ) . strip ( '"' ) for key , value in raw . items ( ) : new_key = mapping . get ( key ) if not new_key : continue processed [ new_key ] = value return processed