This repository was archived by the owner on Apr 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·76 lines (72 loc) · 3.82 KB
/
main.py
File metadata and controls
executable file
·76 lines (72 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import argparse
from future import standard_library
from hpdr import api
standard_library.install_aliases()
def main(args):
keywords = {}
if args.step: keywords['step'] = args.step
if args.dzone: keywords['dzone'] = args.dzone
if args.qzone: keywords['qzone'] = args.qzone
if args.slop: keywords['slop'] = args.slop
if args.lslop: keywords['lslop'] = args.lslop
if args.rslop: keywords['rslop'] = args.rslop
if args.years: keywords['years'] = args.years
if args.months: keywords['months'] = args.months
if args.days: keywords['days'] = args.days
if args.hours: keywords['hours'] = args.hours
if args.minutes: keywords['minutes'] = args.minutes
specs = api.build_with_steps(args.begin,
args.end,
**keywords)
for spec in specs:
if args.file:
query = open(args.file, 'r').read()
print(spec.substitute(query, args.verbose, args.pretty))
else:
print(spec.partition_range.build_display(pretty=args.pretty))
if __name__ == '__main__':
PARSER = argparse.ArgumentParser(description='hpdr -- Hive Partition Date Range')
PARSER.add_argument('-b', '--begin', required=True,
help='beginning time, inclusive, in YYYY[[MM][[DD][HH][NN]]] format.')
PARSER.add_argument('-e', '--end', required=True,
help='end time, exclusive, in YYYY[[MM][[DD][HH][NN]]] format.')
PARSER.add_argument('-t', '--step', required=False,
help=('return multiple Spec objects broken down into duration in '
'\\d+(days|hours|minutes) format.'))
PARSER.add_argument('-s', '--slop', required=False,
help=('extra duration to add to both ends of range in '
'\\d+(days|hours|minutes) format.'))
PARSER.add_argument('-l', '--lslop', required=False,
help=('extra duration to add to beginning of range in '
'\\d+(days|hours|minutes) format.'))
PARSER.add_argument('-r', '--rslop', required=False,
help=('extra duration to add to end of range in '
'\\d+(days|hours|minutes) format.'))
PARSER.add_argument('-d', '--dzone', required=False,
help=('timezone data is stored in, in tzdata format, '
'e.g. Asia/Katmandu. Defaults to UTC.'))
PARSER.add_argument('-q', '--qzone', required=False,
help=('timezone query dates and times are specified in, in tzdata format, '
'e.g. Asia/Katmandu. Defaults to UTC.'))
PARSER.add_argument('-p', '--pretty', action='store_true',
help='pretty print output. Not relevant if --file option specified.')
PARSER.add_argument('-v', '--verbose', action='store_true')
PARSER.add_argument('-f', '--file',
help="File to perform substitution on.")
PARSER.add_argument('--years', required=False, default='YYYY',
help='display symbols for years.')
PARSER.add_argument('--months', required=False, default='MM',
help='display symbols for months.')
PARSER.add_argument('--days', required=False, default='DD',
help='display symbols for days.')
PARSER.add_argument('--hours', required=False, default='HH',
help='display symbols for hours.')
PARSER.add_argument('--minutes', required=False, default='MIN',
help='display symbols for minutes.')
ARGS = PARSER.parse_args()
main(ARGS)