From 0e8c7af70671c53e26fa3de0825d2c5402b7e83d Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 05:14:41 +0100 Subject: [svn] parsing of 2007 logbook. still problems Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8039 by julian @ 10/27/2008 2:03 AM --- parsers/logbooks.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'parsers/logbooks.py') diff --git a/parsers/logbooks.py b/parsers/logbooks.py index cc3a746..95e410f 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -98,7 +98,7 @@ def GetTripPersons(trippeople, expedition): tripperson = tripperson.strip() mul = re.match("(.*?)$", tripperson) if mul: - tripperson = mul.group(1) + tripperson = mul.group(1).strip() if tripperson and tripperson[0] != '*': #assert tripperson in personyearmap, "'%s' << %s\n\n %s" % (tripperson, trippeople, personyearmap) personyear = expedition.GetPersonExpedition(tripperson) @@ -110,7 +110,7 @@ def GetTripPersons(trippeople, expedition): author = res[-1] return res, author -def Parselogwikitxt(year, personyearmap, txt): +def Parselogwikitxt(year, expedition, txt): trippara = re.findall("===(.*?)===([\s\S]*?)(?====)", txt) for triphead, triptext in trippara: tripheadp = triphead.split("|") @@ -130,13 +130,18 @@ def Parselogwikitxt(year, personyearmap, txt): assert re.match("\d\d\d\d-\d\d-\d\d", tripdate), tripdate ldate = datetime.date(int(tripdate[:4]), int(tripdate[5:7]), int(tripdate[8:10])) - lbo = models.LogbookEntry(date = ldate, cave = tripcave, title = tripsplace[-1], text = triptext, tu = triptime) + print "ppp", trippeople, len(triptext) + trippersons, author = GetTripPersons(trippeople, expedition) + triptext = triptext[:10] # seems to have aproblem with this + print "ttt", triptext + lbo = models.LogbookEntry(date = ldate, place = tripcave, title = tripsplace[-1], text = triptext, author=author) lbo.save() - trippersons, author = GetTripPersons(trippeople, personyearmap) + print "ppp", trippersons for tripperson in trippersons: - lbo.cavers.add(tripperson) - # add the author + pto = models.PersonTrip(personexpedition = tripperson, place=tripcave, date=ldate, timeunderground=triptime, + logbookentry=lbo, is_logbookentryauthor=(tripperson == author)) + pto.save() def Parseloghtmltxt(year, expedition, txt): tripparas = re.findall("([\s\S]*?)(?== "2007": - Parselogwikitxt(year, personyearmap, txt) + Parselogwikitxt(year, expedition, txt) else: Parseloghtmltxt(year, expedition, txt) -- cgit v1.2.3