chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
WIP chat tracking
[ypp-sc-tools.main.git]
/
yoweb-scrape
diff --git
a/yoweb-scrape
b/yoweb-scrape
index ca174e27647efdba100a326e8559e9f6fd62d5c4..462bd01c0366a42e877d8b47b8c4dade0a9c34ec 100755
(executable)
--- a/
yoweb-scrape
+++ b/
yoweb-scrape
@@
-433,25
+433,28
@@
class ShipCrewTracker:
del self._pl[p]
self._v = {'#lastaboard': timestamp}
del self._pl[p]
self._v = {'#lastaboard': timestamp}
- def _
warn(self,
m):
- pass
+ def _
debug_line_disposition(self,timestamp,l,
m):
+ debug('SCT %-13s %-30s %s' % (timestamp,m,l))
def chatline(self,l):
rm = lambda re: regexp.match(re,l)
def chatline(self,l):
rm = lambda re: regexp.match(re,l)
+ d = lambda m: self._debug_line_disposition(timestamp,l,m)
+ timestamp = None
+
m = rm('=+ (\\d+)/(\\d+)/(\\d+) =+$')
if m:
self._date = m.groups()
m = rm('=+ (\\d+)/(\\d+)/(\\d+) =+$')
if m:
self._date = m.groups()
- return
+ return d('date '+`self._date`)
+
if self._date is None:
if self._date is None:
- return
+ return d('date unset')
+
m = rm('\\[(\d\d):(\d\d):(\d\d)\\] ')
if not m:
m = rm('\\[(\d\d):(\d\d):(\d\d)\\] ')
if not m:
- self._warn('undated? '+l)
- return
+ return d('no timestamp')
time_tuple = [int(x) for x in self._date + m.groups()]
time_tuple += (-1,-1,-1)
time_tuple = [int(x) for x in self._date + m.groups()]
time_tuple += (-1,-1,-1)
- print `time_tuple`
timestamp = time.mktime(time_tuple)
l = l[l.find(' ')+1:]
timestamp = time.mktime(time_tuple)
l = l[l.find(' ')+1:]
@@
-463,28
+466,33
@@
class ShipCrewTracker:
m = rm('Going aboard the (\\S.*\\S)\\.\\.\\.$')
if m:
self._vessel = m.group(1)
m = rm('Going aboard the (\\S.*\\S)\\.\\.\\.$')
if m:
self._vessel = m.group(1)
+ dm = 'boarding'
try: self._v = self._vl[self._vessel]
try: self._v = self._vl[self._vessel]
- except KeyError: self._v = None
+ except KeyError: self._v = None
; dm += ' new'
if self._v is not None: la = self._v['#lastaboard']
if self._v is not None: la = self._v['#lastaboard']
- else: la = 0
+ else: la = 0
; dm += ' ?la'
if timestamp - la > 3600:
self.clear_vessel(timestamp)
if timestamp - la > 3600:
self.clear_vessel(timestamp)
+ dm += ' stale'
+ self._vl[self._vessel] = self._v
ob(self._myself.name, 'we boarded')
ob(self._myself.name, 'we boarded')
+ return d(dm)
- if self._v is None: return
+ if self._v is None:
+ return d('no vessel')
m = rm('You have ordered (\\w+) to do some (\\S.*\\S)\\.$')
if m:
pa = oba(m, 'ordered')
if m.group(2) == 'Gunning':
pa.gunner = True
m = rm('You have ordered (\\w+) to do some (\\S.*\\S)\\.$')
if m:
pa = oba(m, 'ordered')
if m.group(2) == 'Gunning':
pa.gunner = True
- return
+ return
d('duty order')
m = rm('(\\w+) abandoned a (\\S.*\\S) station\\.$')
m = rm('(\\w+) abandoned a (\\S.*\\S) station\\.$')
- if m: oba(m,'abandoned'); return
+ if m: oba(m,'abandoned'); return
d('abandoned')
m = rm('(\\w+) says, "')
m = rm('(\\w+) says, "')
- if m: ob(m.group(1), 'talked'); return
+ if m: ob(m.group(1), 'talked'); return
d('talked')
m = rm('(\\w+) has left the vessel\.')
if m:
m = rm('(\\w+) has left the vessel\.')
if m:
@@
-492,9
+500,9
@@
class ShipCrewTracker:
ob(who, 'disembarked')
del self._v[who]
del self._pl[who]
ob(who, 'disembarked')
del self._v[who]
del self._pl[who]
- return
+ return
d('disembarked')
- return
+ return
d('not matched')
def do_ship_aid(args, bu):
if len(args) != 1: bu('ship-aid takes only chat log filename')
def do_ship_aid(args, bu):
if len(args) != 1: bu('ship-aid takes only chat log filename')
@@
-508,18
+516,14
@@
def do_ship_aid(args, bu):
f = file(logfn)
l = ''
while True:
f = file(logfn)
l = ''
while True:
- print "1>"+l+"<"
l += f.readline()
if l.endswith('\n'):
l += f.readline()
if l.endswith('\n'):
- l.rstrip()
- print "2>"+l+"<"
- track.chatline(l)
+ track.chatline(l.rstrip())
# print `track.__dict__`
l = ''
continue
if l:
continue
# print `track.__dict__`
l = ''
continue
if l:
continue
- print "3>EOF<"
print `track.__dict__`
os.sleep(1)
print `track.__dict__`
os.sleep(1)