Little features
git-svn-id: http://photonzero.com/dotfiles/trunk@89 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
ed0869cb88
commit
77acad2040
1 changed files with 10 additions and 4 deletions
14
bin/ptw
14
bin/ptw
|
|
@ -17,8 +17,11 @@ def convertToTimedelta(toks):
|
||||||
'week' : timedelta(7),
|
'week' : timedelta(7),
|
||||||
'day' : timedelta(1),
|
'day' : timedelta(1),
|
||||||
'hour' : timedelta(0,0,0,0,0,1),
|
'hour' : timedelta(0,0,0,0,0,1),
|
||||||
|
'hr' : timedelta(0,0,0,0,0,1),
|
||||||
'minute' : timedelta(0,0,0,0,1),
|
'minute' : timedelta(0,0,0,0,1),
|
||||||
|
'min' : timedelta(0,0,0,0,1),
|
||||||
'second' : timedelta(0,1),
|
'second' : timedelta(0,1),
|
||||||
|
'sec' : timedelta(0,1),
|
||||||
}[unit]
|
}[unit]
|
||||||
if toks.qty:
|
if toks.qty:
|
||||||
td *= int(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 = map( CL,
|
||||||
"today tomorrow yesterday noon midnight now".split())
|
"today tomorrow yesterday noon midnight now".split())
|
||||||
plural = lambda s : Combine(CL(s) + Optional(CL("s")))
|
plural = lambda s : Combine(CL(s) + Optional(CL("s")))
|
||||||
week, day, hour, minute, second = map( plural,
|
week, day, hour, hr, minute, min, second, sec = map( plural,
|
||||||
"week day hour minute second".split())
|
"week day hour hr minute min second sec".split())
|
||||||
am = CL("am")
|
am = CL("am")
|
||||||
pm = CL("pm")
|
pm = CL("pm")
|
||||||
COLON = Suppress(':')
|
COLON = Suppress(':')
|
||||||
|
|
@ -131,7 +134,7 @@ todayRef = (dayOffset + dayFwdBack).setParseAction(convertToTimedelta) | \
|
||||||
dayTimeSpec = dayRef | todayRef
|
dayTimeSpec = dayRef | todayRef
|
||||||
dayTimeSpec.setParseAction(calculateTime)
|
dayTimeSpec.setParseAction(calculateTime)
|
||||||
|
|
||||||
hourMinuteOrSecond = (hour | minute | second)
|
hourMinuteOrSecond = (hour | hr | minute | min | second | sec)
|
||||||
|
|
||||||
timespec = Group(int4("miltime") |
|
timespec = Group(int4("miltime") |
|
||||||
integer("HH") +
|
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",
|
parser.add_option("-v", "--verbose", dest="verbose", help="Debug output",
|
||||||
default=False, action="store_true")
|
default=False, action="store_true")
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if len(args) < 2:
|
if len(args) < 1:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
exit()
|
exit()
|
||||||
command = args[0]
|
command = args[0]
|
||||||
text = " ".join(args[1:])
|
text = " ".join(args[1:])
|
||||||
if command == "post":
|
if command == "post":
|
||||||
|
if len(text) < 1:
|
||||||
|
parser.print_help()
|
||||||
|
exit()
|
||||||
data = {"timestamp" : time.time(), "text" : text, "client" : options.client,
|
data = {"timestamp" : time.time(), "text" : text, "client" : options.client,
|
||||||
"hostname" : options.hostname }
|
"hostname" : options.hostname }
|
||||||
if not os.path.exists(os.path.expanduser("~/.ptwdb")):
|
if not os.path.exists(os.path.expanduser("~/.ptwdb")):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue