Commit 5e6868b3 authored by maruel@chromium.org's avatar maruel@chromium.org

Clarify the variable names and reorder assignments to be more consistent.

Enforce a reviewer, when $EMAIL_ADDRESS is not set

BUG=
TEST=


Review URL: http://codereview.chromium.org/7988012

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@102340 0039d316-1c4b-4281-b951-d872f2087c98
parent 0bccb920
...@@ -76,29 +76,29 @@ def get_previous_quarter(today): ...@@ -76,29 +76,29 @@ def get_previous_quarter(today):
If today is in the last month of a quarter, assume it's the current quarter If today is in the last month of a quarter, assume it's the current quarter
that is requested. that is requested.
""" """
year = today.year end_year = today.year
month = today.month - (today.month % 3) + 1 end_month = today.month - (today.month % 3) + 1
if month <= 0: if end_month <= 0:
month += 12 end_year -= 1
year -= 1 end_month += 12
if month > 12: if end_month > 12:
month -= 12 end_year += 1
year += 1 end_month -= 12
previous_month = month - 3 end = '%d-%02d-01' % (end_year, end_month)
previous_year = year begin_year = end_year
if previous_month <= 0: begin_month = end_month - 3
previous_month += 12 if begin_month <= 0:
previous_year -= 1 begin_year -= 1
return ( begin_month += 12
'%d-%02d-01' % (previous_year, previous_month), begin = '%d-%02d-01' % (begin_year, begin_month)
'%d-%02d-01' % (year, month)) return begin, end
def main(): def main():
# Silence upload.py. # Silence upload.py.
rietveld.upload.verbosity = 0 rietveld.upload.verbosity = 0
today = datetime.date.today() today = datetime.date.today()
created_after, created_before = get_previous_quarter(today) begin, end = get_previous_quarter(today)
parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
parser.add_option( parser.add_option(
'--count', action='store_true', '--count', action='store_true',
...@@ -108,15 +108,15 @@ def main(): ...@@ -108,15 +108,15 @@ def main():
default=os.environ.get('EMAIL_ADDRESS'), default=os.environ.get('EMAIL_ADDRESS'),
help='Filter on issue reviewer, default=%default') help='Filter on issue reviewer, default=%default')
parser.add_option( parser.add_option(
'-c', '--created_after', metavar='<date>', '-b', '--begin', metavar='<date>',
help='Filter issues created after the date') help='Filter issues created after the date')
parser.add_option( parser.add_option(
'-C', '--created_before', metavar='<date>', '-e', '--end', metavar='<date>',
help='Filter issues create before the date') help='Filter issues created before the date')
parser.add_option( parser.add_option(
'-Q', '--last_quarter', action='store_true', '-Q', '--last_quarter', action='store_true',
help='Use last quarter\'s dates, e.g. %s to %s' % ( help='Use last quarter\'s dates, e.g. %s to %s' % (
created_after, created_before)) begin, end))
parser.add_option( parser.add_option(
'-i', '--instance_url', metavar='<host>', '-i', '--instance_url', metavar='<host>',
default='http://codereview.chromium.org', default='http://codereview.chromium.org',
...@@ -126,24 +126,25 @@ def main(): ...@@ -126,24 +126,25 @@ def main():
options, args = parser.parse_args() options, args = parser.parse_args()
if args: if args:
parser.error('Args unsupported') parser.error('Args unsupported')
if not options.reviewer:
parser.error('$EMAIL_ADDRESS is not set, please use -r')
print >> sys.stderr, 'Searching for reviews by %s' % options.reviewer print >> sys.stderr, 'Searching for reviews by %s' % options.reviewer
if options.last_quarter: if options.last_quarter:
options.created_after = created_after options.begin = begin
options.created_before = created_before options.end = end
print >> sys.stderr, 'Using range %s to %s' % ( print >> sys.stderr, 'Using range %s to %s' % (
options.created_after, options.created_before) options.begin, options.end)
if options.count: if options.count:
print_count( print_count(
options.reviewer, options.reviewer,
options.created_after, options.begin,
options.created_before, options.end,
options.instance_url) options.instance_url)
else: else:
print_reviews( print_reviews(
options.reviewer, options.reviewer,
options.created_after, options.begin,
options.created_before, options.end,
options.instance_url) options.instance_url)
return 0 return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment