diff options
author | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:38:18 +0100 |
---|---|---|
committer | substantialnoninfringinguser <substantialnoninfringinguser@gmail.com> | 2009-05-13 05:38:18 +0100 |
commit | 0f5109cb0988d76c5b7d3037acca0ad8ac07f0dd (patch) | |
tree | c272078cde2262740c74fcfdf40dea9073c87f27 /parsers | |
parent | da154a736b2bd9c690f0e7bcbb9c06c7cb1859e2 (diff) | |
download | troggle-0f5109cb0988d76c5b7d3037acca0ad8ac07f0dd.tar.gz troggle-0f5109cb0988d76c5b7d3037acca0ad8ac07f0dd.tar.bz2 troggle-0f5109cb0988d76c5b7d3037acca0ad8ac07f0dd.zip |
[svn] new person expedition
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8189 by julian @ 1/18/2009 7:50 PM
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/logbooks.py | 37 | ||||
-rw-r--r-- | parsers/people.py | 5 | ||||
-rw-r--r-- | parsers/survex.py | 3 |
3 files changed, 41 insertions, 4 deletions
diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 53726c6..a2cf58a 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -169,10 +169,20 @@ def Parseloghtml01(year, expedition, txt): triptitles = triptitle.split(" - ")
tripcave = triptitles[0].strip()
- ltriptext = re.sub("</p>", "", triptext)
+ ltriptext = triptext
+
+ mtail = re.search('(?:<a href="[^"]*">[^<]*</a>|\s|/|-|&|</?p>|\((?:same day|\d+)\))*$', ltriptext)
+ if mtail:
+ #print mtail.group(0)
+ ltriptext = ltriptext[:mtail.start(0)]
+ ltriptext = re.sub("</p>", "", ltriptext)
ltriptext = re.sub("\s*?\n\s*", " ", ltriptext)
- ltriptext = re.sub("<p>", "\n\n", ltriptext).strip()
+ ltriptext = re.sub("<p>|<br>", "\n\n", ltriptext).strip()
#ltriptext = re.sub("[^\s0-9a-zA-Z\-.,:;'!]", "NONASCII", ltriptext)
+ ltriptext = re.sub("</?u>", "_", ltriptext)
+ ltriptext = re.sub("</?i>", "''", ltriptext)
+ ltriptext = re.sub("</?b>", "'''", ltriptext)
+
#print ldate, trippeople.strip()
# could includ the tripid (url link for cross referencing)
@@ -246,6 +256,28 @@ def SetDatesFromLogbookEntries(expedition): expedition.date_to = max([personexpedition.date_to for personexpedition in expedition.personexpedition_set.all() if personexpedition.date_to] or [None])
expedition.save()
+ # order by appearance in the logbook (done by id)
+ lprevlogbookentry = None
+ for logbookentry in expedition.logbookentry_set.order_by('id'):
+ logbookentry.logbookentry_prev = lprevlogbookentry
+ if lprevlogbookentry:
+ lprevlogbookentry.logbookentry_next = logbookentry
+ lprevlogbookentry.save()
+ logbookentry.logbookentry_next = None
+ logbookentry.save()
+ lprevlogbookentry = logbookentry
+
+ # order by date for setting the references
+ lprevlogbookentry = None
+ for logbookentry in expedition.logbookentry_set.order_by('date'):
+ if lprevlogbookentry and lprevlogbookentry.date == logbookentry.date:
+ mcount = re.search("_(\d+)$", lprevlogbookentry.href)
+ mc = mcount and (int(mcount.group(1)) + 1) or 1
+ logbookentry.href = "%s_%d" % (logbookentry.date, mc)
+ else:
+ logbookentry.href = "%s" % logbookentry.date
+ logbookentry.save()
+ lprevlogbookentry = logbookentry
def LoadLogbookForExpedition(expedition):
@@ -268,6 +300,7 @@ def LoadLogbooks(): models.LogbookEntry.objects.all().delete()
expowebbase = os.path.join(settings.EXPOWEB, "years")
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
+ #yearlinks = [ ("1997", "1997/log.htm", Parseloghtml01),] # overwrite
for year, lloc, parsefunc in yearlinks:
expedition = models.Expedition.objects.filter(year = year)[0]
diff --git a/parsers/people.py b/parsers/people.py index d85d772..c59d3d8 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -81,8 +81,11 @@ def LoadPersonsExpos(): print firstname, lastname, "NNN", nickname #assert lastname == person[header[""]], person + href = firstname.lower() + if lastname: + href += "_" + lastname.lower() pObject = models.Person(first_name = firstname, - last_name = lastname, + last_name = lastname, href=href, is_vfho = person[header["VfHO member"]], ) diff --git a/parsers/survex.py b/parsers/survex.py index 00b6254..1f688c3 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -70,7 +70,8 @@ def make_model(name, parent, iter_lines, sf, c, l): and names.strip("\t").strip(" ") != "Both"]) for name in re.split("&|/|\+|,|;", names): try: - models.PersonRole(person = exp.GetPersonExpedition(name.strip(" ")).person, + models.PersonRole(personexpedition = exp.GetPersonExpedition(name.strip(" ")), + person = exp.GetPersonExpedition(name.strip(" ")).person, survex_block = m, role = models.Role.objects.get(name = roles[role])).save() except AttributeError: |