summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2014-10-16 09:55:40 +0200
committeremkael <emkael@tlen.pl>2014-10-16 09:55:40 +0200
commit99c990f5d04b63ad595a7133874c0071aa2f6b14 (patch)
treea3ac29d3644cdfc342918b80d24186c4e2fa1da5
parent4882862ead982dc885187c0cbf9ab3128f2b67bb (diff)
* command line arguments description formatting
* print list limit
-rwxr-xr-xelo.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/elo.py b/elo.py
index 4034dfa..43e11a5 100755
--- a/elo.py
+++ b/elo.py
@@ -2,13 +2,21 @@
import argparse
import dateutil.parser
-from f1elo.interface import Interface
-
-parser = argparse.ArgumentParser(description='Ranks Formula One drivers using Elo rating')
+parser = argparse.ArgumentParser(description='Ranks Formula One drivers using Elo rating',
+ formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('command', metavar='COMMAND', nargs='?',
- help='Action to execute against the database: print, reset or rate, print - prints the rankings for all drivers ranked in 12 months, reset - resets the rankings, rate - calculates the rankings',
+ help="Action to execute against the database:\n"
+ "print - prints the rankings for all drivers ranked in 12 months,\n"
+ "reset - resets the rankings,\n"
+ "rate - calculates the rankings\n"
+ "Default value is 'print'.",
default='print', choices=['print', 'rate', 'reset'])
-parser.add_argument('--date', help='Date for which the action should be executed. Print ratings for DATE, reset ratings all the way down to DATE or rank the races all the way up to DATE.')
+parser.add_argument('--date',
+ help='Date for which the action should be executed.\n'
+ 'Print ratings for DATE,\n'
+ 'reset ratings all the way down to DATE\n'
+ 'or rank the races all the way up to DATE.')
+parser.add_argument('--limit', help='Ranking list (display) cut-off point.', type=int)
parser.add_argument('-v', help='Display verbose info on rating progress.', action='store_true')
arguments = parser.parse_args()
@@ -17,6 +25,8 @@ date = arguments.date
if date:
date = dateutil.parser.parse(date).date()
+from f1elo.interface import Interface
+
interface = Interface(date)
if command == 'reset':
@@ -28,6 +38,8 @@ rankings = interface.fetch()
if len(rankings):
print 'Rankings for %s' % interface.date
+ if arguments.limit:
+ rankings = rankings[0:arguments.limit]
for rank in rankings:
print rank
else: