def read_has_prefix(path):
 ParseResult = namedtuple(u'ParseResult', (u'placeholder', u'filemode', u'filepath'))
 def parse_line(line):
  parts = tuple((x.strip(u'"\'') for x in shlex.split(line, posix=False)))
  if (len(parts) == 1):
   return ParseResult(PREFIX_PLACEHOLDER, FileMode.text, parts[0])
  elif (len(parts) == 3):
   return ParseResult(parts[0], FileMode(parts[1]), parts[2])
  else:
   raise RuntimeError((u'Invalid has_prefix file at path: %s' % path))
 parsed_lines = (parse_line(line) for line in yield_lines(path))
 return {pr.filepath: (pr.placeholder, pr.filemode) for pr in parsed_lines}

def read_has_prefix ( path ) : ParseResult = namedtuple ( u'ParseResult' , ( u'placeholder' , u'filemode' , u'filepath' ) ) def parse_line ( line ) : parts = tuple ( ( x . strip ( u'"\'' ) for x in shlex . split ( line , posix = False ) ) ) if ( len ( parts ) == 1 ) : return ParseResult ( PREFIX_PLACEHOLDER , FileMode . text , parts [ 0 ] ) elif ( len ( parts ) == 3 ) : return ParseResult ( parts [ 0 ] , FileMode ( parts [ 1 ] ) , parts [ 2 ] ) else : raise RuntimeError ( ( u'Invalid has_prefix file at path: %s' % path ) ) parsed_lines = ( parse_line ( line ) for line in yield_lines ( path ) ) return { pr . filepath : ( pr . placeholder , pr . filemode ) for pr in parsed_lines }
reads has_prefix file and return dict mapping filepaths to tuples a line in has_prefix contains one of * filepath * placeholder mode filepath mode values are one of * text * binary .