Skip to content

Commit

Permalink
Merge pull request #2 from koeart/master
Browse files Browse the repository at this point in the history
Fix arguments for ddata command and correct parsing in abfahrt command
  • Loading branch information
blotter committed Jun 4, 2013
2 parents 116667c + 00db911 commit 2158a18
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pentabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def ddate(self, mess, args):
ddate = ''
if len(args) <= 1 :
ddate += os.popen('/usr/bin/ddate').read()
elif len(args) == 3:
ddate += os.popen('/usr/bin/ddate '+args[0]+' '+ args[1]+' '+ args[2]).read()
elif len(args) == 3 and all(arg.isdigit() for arg in args):
ddate += os.popen('/usr/bin/ddate ' + args[0] + ' ' + args[1] + ' ' + args[2]).read()
else:
ddate = 'You are not using correctly!\n Just enter ddate or append day month year'
return ddate
Expand Down Expand Up @@ -300,15 +300,12 @@ def abfahrt( self, mess, args):

data = urllib2.urlopen(full_url)
dare = data.read()
dare = dare.replace("[[", "")
dare = dare.replace("]]", "")

abfahrt += "\n"
abfahrt += "%6s %-19s %7s\n" % ("Linie", "Richtung", "Abfahrt")

for line in dare.split("],["):
outp = line.replace("\"", "").split(",")
abfahrt += "%6s %-19s %7s\n" % (outp[0], outp[1], outp[2])
for line in json.loads(dare):
abfahrt += "%6s %-19s %7s\n" % (line[0], line[1], line[2])

return abfahrt

Expand Down

0 comments on commit 2158a18

Please sign in to comment.