def readstoredmetadata(fname, skiprows=<NUM_LIT:0>, linenumber=None, comments='<STR_LIT:#>', <EOL>metametadata=None, verbosity=DEFAULT_VERBOSITY):
if is_string_like(fname):<EOL><INDENT>fh = file(fname, '<STR_LIT>')<EOL><DEDENT>elif hasattr(fname, '<STR_LIT>'):<EOL><INDENT>fh = fname<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if not metametadata:<EOL><INDENT>for _ind in range(skiprows):<EOL><INDENT>fh.readline()<EOL><DEDENT>phlines = []<EOL>if linenumber is None:<EOL><INDENT>if comments:<EOL><INDENT>for line in fh:<EOL><INDENT>if not line.startswith(comments):<EOL><INDENT>if len(phlines) == <NUM_LIT:0>:<EOL><INDENT>phlines = [line]<EOL><DEDENT>break<EOL><DEDENT>else:<EOL><INDENT>phlines.append(line)<EOL><DEDENT><DEDENT>if len(phlines) == <NUM_LIT:1>:<EOL><INDENT>if verbosity >= <NUM_LIT:10>:<EOL><INDENT>print('''<STR_LIT>''')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if verbosity >= <NUM_LIT:9>:<EOL><INDENT>print('''<STR_LIT>''' % (len(phlines) - <NUM_LIT:1>))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>phlines = [fh.readline()]<EOL>if verbosity >=<NUM_LIT:9>:<EOL><INDENT>print('''<STR_LIT>''')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for _ind in range(linenumber):<EOL><INDENT>fh.readline()<EOL><DEDENT>phlines = [fh.readline()]<EOL><DEDENT>metametadata = None<EOL>for (ln, metametaline) in enumerate(phlines):<EOL><INDENT>s = re.compile(r'<STR_LIT>').search(metametaline)<EOL>if s:<EOL><INDENT>l = s.start()<EOL>if len(uniqify(metametaline[:l])) <= <NUM_LIT:1>:<EOL><INDENT>metametaline = metametaline[l:].rstrip()<EOL>try:<EOL><INDENT>X = compiler.parse(metametaline)<EOL><DEDENT>except SyntaxError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if IsMetaMetaDict(X):<EOL><INDENT>exec(metametaline)<EOL>if verbosity > <NUM_LIT:6>:<EOL><INDENT>print('<STR_LIT>', ln, '<STR_LIT>', metametadata)<EOL><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if metametadata:<EOL><INDENT>metadata = {}<EOL>metadata['<STR_LIT>'] = metametadata<EOL>Tval = max([v if isinstance(v,int) else max(v) <EOL>for v in list(metametadata.values())])<EOL>fh = file(fname, '<STR_LIT>')<EOL>data = [fh.readline() for _ind in range(Tval + <NUM_LIT:1> + skiprows)][skiprows:]<EOL>if (max([v if isinstance(v,int) else max(v) <EOL>for v in  list(metametadata.values())]) < len(data)):<EOL><INDENT>for n in list(metametadata.keys()):<EOL><INDENT>[s, e] = [metametadata[n], metametadata[n]+<NUM_LIT:1>]if isinstance(metametadata[n],int)else [metametadata[n][<NUM_LIT:0>],metametadata[n][<NUM_LIT:1>]]<EOL>metadata[n] = '<STR_LIT>'.join(data[s:e]).strip('<STR_LIT:\n>')<EOL><DEDENT>processmetadata(metadata, comments=comments, verbosity=verbosity)<EOL>return metadata<EOL><DEDENT><DEDENT>
Read metadata from a delimited text file.