def main():
<EOL>import signal<EOL>signal.signal(signal.SIGPIPE, signal.SIG_DFL)<EOL>import argparse<EOL>aparser = argparse.ArgumentParser(<EOL>description='<STR_LIT>'<EOL>)<EOL>aparser.add_argument(<EOL>'<STR_LIT>',<EOL>action='<STR_LIT:store>',<EOL>type=str,<EOL>help=("<STR_LIT>")<EOL>)<EOL>aparser.add_argument(<EOL>'<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>default=False,<EOL>help=("<STR_LIT>")<EOL>)<EOL>args = aparser.parse_args()<EOL>filetoread = args.hatlcfile<EOL>if not os.path.exists(filetoread):<EOL><INDENT>LOGERROR("<STR_LIT>" % filetoread)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>filename = os.path.basename(filetoread)<EOL>if filename.endswith('<STR_LIT>') or filename.endswith('<STR_LIT>'):<EOL><INDENT>if args.describe:<EOL><INDENT>describe(read_csvlc(filename))<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>with gzip.open(filename,'<STR_LIT:rb>') as infd:<EOL><INDENT>for line in infd:<EOL><INDENT>print(line.decode(),end='<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif filename.endswith('<STR_LIT>'):<EOL><INDENT>lcdict, msg = read_and_filter_sqlitecurve(filetoread)<EOL>describe(lcdict, offsetwith='<STR_LIT:#>')<EOL>if args.describe:<EOL><INDENT>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>apertures = sorted(lcdict['<STR_LIT>'].keys())<EOL>for aper in apertures:<EOL><INDENT>COLUMNDEFS.update({'<STR_LIT>' % (x, aper): COLUMNDEFS[x] for x in<EOL>LC_MAG_COLUMNS})<EOL>COLUMNDEFS.update({'<STR_LIT>' % (x, aper): COLUMNDEFS[x] for x in<EOL>LC_ERR_COLUMNS})<EOL>COLUMNDEFS.update({'<STR_LIT>' % (x, aper): COLUMNDEFS[x] for x in<EOL>LC_FLAG_COLUMNS})<EOL><DEDENT>formstr = '<STR_LIT:U+002C>'.join([COLUMNDEFS[x][<NUM_LIT:1>] for x in lcdict['<STR_LIT>']])<EOL>ndet = lcdict['<STR_LIT>']['<STR_LIT>']<EOL>for ind in range(ndet):<EOL><INDENT>line = [lcdict[x][ind] for x in lcdict['<STR_LIT>']]<EOL>formline = formstr % tuple(line)<EOL>print(formline)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>LOGERROR('<STR_LIT>' % filetoread)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>
This is called when we're executed from the commandline.

The current usage from the command-line is described below::

    usage: hatlc [-h] [--describe] hatlcfile

    read a HAT LC of any format and output to stdout

    positional arguments:
      hatlcfile   path to the light curve you want to read and pipe to stdout

    optional arguments:
      -h, --help  show this help message and exit
      --describe  don't dump the columns, show only object info and LC metadata