parameters: (infile)
return_statement: return results
docstring: Parse a separate options file to list:
          [(namemask, options), ...]
docstring_summary: Parse a separate options file to list:
          [(namemask, options), ...]
docstring_tokens: Parse a separate options file to list : [ ( namemask options ) ... ]
function: def read_options_file(infile):
      '''Parse a separate options file to list:
          [(namemask, options), ...]
      '''
      results = []
      data = infile.read()
      data = re.sub('/\*.*?\*/', '', data, flags = re.MULTILINE)
      data = re.sub('//.*?$', '', data, flags = re.MULTILINE)
      data = re.sub('#.*?$', '', data, flags = re.MULTILINE)
      for i, line in enumerate(data.split('\n')):
          line = line.strip()
          if not line:
              continue
  
          parts = line.split(None, 1)
  
          if len(parts) < 2:
              sys.stderr.write("%s:%d: " % (infile.name, i + 1) +
                               "Option lines should have space between field name and options. " +
                               "Skipping line: '%s'\n" % line)
              continue
  
          opts = nanopb_pb2.NanoPBOptions()
  
          try:
              text_format.Merge(parts[1], opts)
          except Exception as e:
              sys.stderr.write("%s:%d: " % (infile.name, i + 1) +
                               "Unparseable option line: '%s'. " % line +
                               "Error: %s\n" % str(e))
              continue
          results.append((parts[0], opts))
  
      return results
function_tokens: def read_options_file ( infile ) : results = [ ] data = infile . read ( ) data = re . sub ( '/\*.*?\*/' , '' , data , flags = re . MULTILINE ) data = re . sub ( '//.*?$' , '' , data , flags = re . MULTILINE ) data = re . sub ( '#.*?$' , '' , data , flags = re . MULTILINE ) for i , line in enumerate ( data . split ( '\n' ) ) : line = line . strip ( ) if not line : continue parts = line . split ( None , 1 ) if len ( parts ) < 2 : sys . stderr . write ( "%s:%d: " % ( infile . name , i + 1 ) + "Option lines should have space between field name and options. " + "Skipping line: '%s'\n" % line ) continue opts = nanopb_pb2 . NanoPBOptions ( ) try : text_format . Merge ( parts [ 1 ] , opts ) except Exception as e : sys . stderr . write ( "%s:%d: " % ( infile . name , i + 1 ) + "Unparseable option line: '%s'. " % line + "Error: %s\n" % str ( e ) ) continue results . append ( ( parts [ 0 ] , opts ) ) return results