def _par_read(dirname, compressed=True):
templates = []<EOL>if compressed:<EOL><INDENT>arc = tarfile.open(dirname, "<STR_LIT>")<EOL>members = arc.getmembers()<EOL>_parfile = [member for member in members<EOL>if member.name.split(os.sep)[-<NUM_LIT:1>] ==<EOL>'<STR_LIT>']<EOL>if len(_parfile) == <NUM_LIT:0>:<EOL><INDENT>arc.close()<EOL>raise MatchFilterError(<EOL>'<STR_LIT>')<EOL><DEDENT>parfile = arc.extractfile(_parfile[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>parfile = open(dirname + '<STR_LIT:/>' + '<STR_LIT>', '<STR_LIT:r>')<EOL><DEDENT>for line in parfile:<EOL><INDENT>t_in = Template()<EOL>for key_pair in line.rstrip().split('<STR_LIT:U+002C>'):<EOL><INDENT>if key_pair.split('<STR_LIT::>')[<NUM_LIT:0>].strip() == '<STR_LIT:name>':<EOL><INDENT>t_in.__dict__[key_pair.split('<STR_LIT::>')[<NUM_LIT:0>].strip()] =key_pair.split('<STR_LIT::>')[-<NUM_LIT:1>].strip()<EOL><DEDENT>elif key_pair.split('<STR_LIT::>')[<NUM_LIT:0>].strip() == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>t_in.__dict__[key_pair.split('<STR_LIT::>')[<NUM_LIT:0>].strip()] =int(key_pair.split('<STR_LIT::>')[-<NUM_LIT:1>])<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>t_in.__dict__[key_pair.split('<STR_LIT::>')[<NUM_LIT:0>].strip()] =float(key_pair.split('<STR_LIT::>')[-<NUM_LIT:1>])<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>templates.append(t_in)<EOL><DEDENT>parfile.close()<EOL>if compressed:<EOL><INDENT>arc.close()<EOL><DEDENT>return templates<EOL>
Internal write function to read a formatted parameter file.

:type dirname: str
:param dirname: Directory to read the parameter file from.
:type compressed: bool
:param compressed: Whether the directory is compressed or not.