def build_parser(parser): # required inputs parser.add_argument( 'n', type=float, help='number of rows to sample. Can be a decimal fraction.') parser.add_argument( '--seed-in', type=utils.opener('r'), help=('file containing integer to generate random seed')) parser.add_argument( '--seed-out', type=utils.opener('w'), help=('file containing integer used to generate seed')) parser.add_argument( '--rest', help='file to output rows not included in sample.') parser.add_argument( '--replace', action='store_true', help=('Sample with or without replacement.'))
def parse_args(parser): parser.add_argument( '-l', '--log', metavar='FILE', default=sys.stdout, type=utils.opener('a'), # append help='Send logging to a file') parser.add_argument( '-v', '--verbose', action='count', dest='verbosity', default=1, help='Increase verbosity of screen output ' '(eg, -v is verbose, -vv more so)') parser.add_argument( '-q', '--quiet', action='store_const', dest='verbosity', const=0, help='Suppress output') return parser
def write_pickle(self, pth, data): with opener(pth, 'wb') as f: cPickle.dump(data, f, protocol=cPickle.HIGHEST_PROTOCOL)