parameters: (infile, reverse)
docstring: Parses gperf file and extract strings and return code
docstring_summary: Parses gperf file and extract strings and return code
docstring_tokens: Parses gperf file and extract strings and return code
function: def parse_gperf(infile, reverse):
    """Parses gperf file and extract strings and return code"""
    lines = [line.strip() for line in infile]
    # Extract strings after the first '%%' and before the second '%%'.
    begin = lines.index('%%') + 1
    end = lines.index('%%', begin)
    lines = lines[begin:end]
    for line in lines:
      if line[-3:-1] != ', ':
        raise InputError('Expected "domainname, <digit>", found "%s"' % line)
      # Technically the DAFSA format can support return values in the range
      # [0-31], but only the first three bits have any defined meaning.
      if not line.endswith(('0', '1', '2', '3', '4', '5', '6', '7')):
        raise InputError('Expected value to be in the range of 0-7, found "%s"' %
                         line[-1])
    if reverse:
      return [line[-4::-1] + line[-1] for line in lines]
    else:
      return [line[:-3] + line[-1] for line in lines]
function_tokens: def parse_gperf ( infile , reverse ) : lines = [ line . strip ( ) for line in infile ] # Extract strings after the first '%%' and before the second '%%'. begin = lines . index ( '%%' ) + 1 end = lines . index ( '%%' , begin ) lines = lines [ begin : end ] for line in lines : if line [ - 3 : - 1 ] != ', ' : raise InputError ( 'Expected "domainname, <digit>", found "%s"' % line ) # Technically the DAFSA format can support return values in the range # [0-31], but only the first three bits have any defined meaning. if not line . endswith ( ( '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' ) ) : raise InputError ( 'Expected value to be in the range of 0-7, found "%s"' % line [ - 1 ] ) if reverse : return [ line [ - 4 : : - 1 ] + line [ - 1 ] for line in lines ] else : return [ line [ : - 3 ] + line [ - 1 ] for line in lines ]