Little features

git-svn-id: http://photonzero.com/dotfiles/trunk@89 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
michener 2011-04-01 23:41:14 +00:00
parent ed0869cb88
commit 77acad2040

14
bin/ptw
View file

@ -17,8 +17,11 @@ def convertToTimedelta(toks):
'week' : timedelta(7),
'day' : timedelta(1),
'hour' : timedelta(0,0,0,0,0,1),
'hr' : timedelta(0,0,0,0,0,1),
'minute' : timedelta(0,0,0,0,1),
'min' : timedelta(0,0,0,0,1),
'second' : timedelta(0,1),
'sec' : timedelta(0,1),
}[unit]
if toks.qty:
td *= int(toks.qty)
@ -97,8 +100,8 @@ CL = CaselessLiteral
today, tomorrow, yesterday, noon, midnight, now = map( CL,
"today tomorrow yesterday noon midnight now".split())
plural = lambda s : Combine(CL(s) + Optional(CL("s")))
week, day, hour, minute, second = map( plural,
"week day hour minute second".split())
week, day, hour, hr, minute, min, second, sec = map( plural,
"week day hour hr minute min second sec".split())
am = CL("am")
pm = CL("pm")
COLON = Suppress(':')
@ -131,7 +134,7 @@ todayRef = (dayOffset + dayFwdBack).setParseAction(convertToTimedelta) | \
dayTimeSpec = dayRef | todayRef
dayTimeSpec.setParseAction(calculateTime)
hourMinuteOrSecond = (hour | minute | second)
hourMinuteOrSecond = (hour | hr | minute | min | second | sec)
timespec = Group(int4("miltime") |
integer("HH") +
@ -212,12 +215,15 @@ parser.add_option("-s", "--since", dest="since", help="Number of posts to show",
parser.add_option("-v", "--verbose", dest="verbose", help="Debug output",
default=False, action="store_true")
(options, args) = parser.parse_args()
if len(args) < 2:
if len(args) < 1:
parser.print_help()
exit()
command = args[0]
text = " ".join(args[1:])
if command == "post":
if len(text) < 1:
parser.print_help()
exit()
data = {"timestamp" : time.time(), "text" : text, "client" : options.client,
"hostname" : options.hostname }
if not os.path.exists(os.path.expanduser("~/.ptwdb")):