summaryrefslogtreecommitdiff
path: root/perc
diff options
context:
space:
mode:
Diffstat (limited to 'perc')
-rwxr-xr-xperc79
1 files changed, 47 insertions, 32 deletions
diff --git a/perc b/perc
index 354d2f6..9ec1c7f 100755
--- a/perc
+++ b/perc
@@ -37,8 +37,8 @@
# - Created Config class to more cleanly get/set config options
# - Split config files into perc.cfg and custom_perc.cfg for options that can change on commit and custom user specified options that are persistent
# 3.6:
-# - Added a 'count' output option to display a countdown of days until the finish
-# - wjoe ruined everything
+# - Added a 'count' output option to display a countdown of days until the finish
+# - wjoe ruined everything
# 3.61:
# - Fixed count output, was failing to count days before
#
@@ -48,6 +48,9 @@
# 3.63:
# - Changed the count output to say the name of the event
#
+# 3.4:
+# - Added -i --info option to display start/end dates
+
import copy
import decimal
import json
@@ -79,7 +82,7 @@ CONFIG = None
CUSTOM_CONFIG = None
EVENT_DATETIME_FORMAT = "%d-%m-%Y %H:%M"
-
+INFO_DATETIME_FORMAT = "%a %d %b %Y %H:%M"
MONDAY = 0
TUESDAY = 1
WEDNESDAY = 2
@@ -356,6 +359,14 @@ def removeEvent(name):
if "EVENTS" in CUSTOM_CONFIG and name in CUSTOM_CONFIG["EVENTS"]:
del CUSTOM_CONFIG["EVENTS"][name]
+def info(name):
+ if "EVENTS" in CUSTOM_CONFIG and name in CUSTOM_CONFIG["EVENTS"]:
+ start = CUSTOM_CONFIG["EVENTS"][name]["start"]
+ stime = datetime.strptime(start, EVENT_DATETIME_FORMAT)
+ finish = CUSTOM_CONFIG["EVENTS"][name]["finish"]
+ ftime = datetime.strptime(finish, EVENT_DATETIME_FORMAT)
+ print name+" info - Start: "+stime.strftime(INFO_DATETIME_FORMAT)+", Finish: "+ftime.strftime(INFO_DATETIME_FORMAT)
+
def parseUserArgs(args, user):
start, finish, start_formatted, finish_formatted = user.start, user.finish, user.start.strftime(user.format), user.finish.strftime(user.format)
@@ -647,7 +658,6 @@ def admin(args):
parser.add_option("-f", "--finish", action="store", dest="finish", help="Used in conjunction with -a/--add-event option. The finish date/time of the event.")
parser.add_option("-p", "--format", action="store", default="", dest="format", help="Used in conjunction with -a/--add-event option. The format of the printed event date/time, uses python strftime formatting and accepts {name} keyword to display name of event.")
parser.add_option("-o", "--output", action="store", type="choice", choices=OUTPUT_TYPES, dest="output", help="The output display type for the user. Options are %s" % ", ".join(OUTPUT_TYPES))
-
(options, args) = parser.parse_args(args)
if options.version:
@@ -706,41 +716,46 @@ def admin(args):
if options.remove_event:
removeEvent(options.remove_event)
-
+
saveConfig()
def user(args):
- global options
-
- parser = optparse.OptionParser("{0} <finish> [options] | {0} <start> <finish> [options]. Custom Events: {1}".format(PROG, ", ".join(CUSTOM_CONFIG["EVENTS"].keys() if "EVENTS" in CUSTOM_CONFIG else [])))
- parser.add_option("-v", "--version", action="store_true", dest="version", help="Display the version of %s" % PROG)
- parser.add_option("-s", "--start", action="store", dest="start", help="The start time of your particular day")
- parser.add_option("-f", "--finish", action="store", dest="finish", help="The finish time of your particular day")
- parser.add_option("-n", "--nick", action="store", dest="nick", help="Nickname of someone (e.g. fuckwad, l_bratch, bikeman or something)")
- parser.add_option("-o", "--output", action="store", type="choice", choices=OUTPUT_TYPES, dest="output", help="Output display type. Options are %s" % ", ".join(OUTPUT_TYPES))
- parser.add_option("-m", "--mobile", action="store_true", default=False, dest="mobile", help="Indicate this should be displayed appropriately for a mobile device (i.e. smaller character display width)")
-
- (options, args) = parser.parse_args(args)
-
+ global options
+
+ parser = optparse.OptionParser("{0} <finish> [options] | {0} <start> <finish> [options]. Custom Events: {1}".format(PROG, ", ".join(CUSTOM_CONFIG["EVENTS"].keys() if "EVENTS" in CUSTOM_CONFIG else [])))
+ parser.add_option("-v", "--version", action="store_true", dest="version", help="Display the version of %s" % PROG)
+ parser.add_option("-s", "--start", action="store", dest="start", help="The start time of your particular day")
+ parser.add_option("-f", "--finish", action="store", dest="finish", help="The finish time of your particular day")
+ parser.add_option("-n", "--nick", action="store", dest="nick", help="Nickname of someone (e.g. fuckwad, l_bratch, bikeman or something)")
+ parser.add_option("-o", "--output", action="store", type="choice", choices=OUTPUT_TYPES, dest="output", help="Output display type. Options are %s" % ", ".join(OUTPUT_TYPES))
+ parser.add_option("-m", "--mobile", action="store_true", default=False, dest="mobile", help="Indicate this should be displayed appropriately for a mobile device (i.e. smaller character display width)")
+ parser.add_option("-i", "--info", action="store", dest="info", help="Display info from %s" % PROG)
+
+ (options, args) = parser.parse_args(args)
+
# if isWeekend():
# print "It's the freekin' Weekend!!!!"
# sys.exit(0)
-
- if options.version:
- print "v%s" % VERSION
- sys.exit(0)
-
- # Choose which user to display percentages for
- user = USER
- if options.nick:
- nick = options.nick.lower()
- user = User(nick)
-
- start, finish, ratio, output_type, delta = parseUserArgs(args, user)
+
+ if options.version:
+ print "v%s" % VERSION
+ sys.exit(0)
+
+ if options.info:
+ info(options.info)
+ sys.exit(0)
+
+ # Choose which user to display percentages for
+ user = USER
+ if options.nick:
+ nick = options.nick.lower()
+ user = User(nick)
+
+ start, finish, ratio, output_type, delta = parseUserArgs(args, user)
- # Finally output the percentage in the specified way
- output = Output()
- output.output(output_type, ratio, start, finish, delta)
+ # Finally output the percentage in the specified way
+ output = Output()
+ output.output(output_type, ratio, start, finish, delta)
def readConfig():
global CONFIG, CUSTOM_CONFIG