summaryrefslogtreecommitdiffstats
path: root/parsers/subcaves.py
diff options
context:
space:
mode:
authorWookey <wookey@wookware.org>2011-07-11 02:10:22 +0100
committerWookey <wookey@wookware.org>2011-07-11 02:10:22 +0100
commit78cedb2070c7e9d4e4eb418ecde7b60ba428273f (patch)
treeee8029e7df8aa2eca5ed9354b2c6e592fc11c96a /parsers/subcaves.py
parentcc27334193c9ddbef15855863934dab3f73ccdd4 (diff)
downloadtroggle-78cedb2070c7e9d4e4eb418ecde7b60ba428273f.tar.gz
troggle-78cedb2070c7e9d4e4eb418ecde7b60ba428273f.tar.bz2
troggle-78cedb2070c7e9d4e4eb418ecde7b60ba428273f.zip
remove all the DOS linefeeds
Diffstat (limited to 'parsers/subcaves.py')
-rw-r--r--parsers/subcaves.py112
1 files changed, 56 insertions, 56 deletions
diff --git a/parsers/subcaves.py b/parsers/subcaves.py
index bdd64a1..6905d0a 100644
--- a/parsers/subcaves.py
+++ b/parsers/subcaves.py
@@ -1,56 +1,56 @@
-'''
-This module is the part of troggle that parses descriptions of cave parts (subcaves) from the legacy html files and saves them in the troggle database as instances of the model Subcave. Unfortunately, this parser can not be very flexible because the legacy format is poorly structured.
-'''
-
-import sys, os
-
-import os, re, logging
-from django.conf import settings
-from core.models import Subcave, Cave
-from utils import save_carefully
-
-def getLinksInCaveDescription(cave):
- '''
- Returns all HTML <a href> tags from a given cave as a list of tuples
- in the format ('filename.html','Description')
- '''
- pattern='<a href=\"(.*?)\">(.*?)</a>'
- if cave.underground_description:
- return re.findall(pattern,cave.underground_description)
- else:
- return []
-
-def importSubcaves(cave):
- for link in getLinksInCaveDescription(cave):
- try:
- subcaveFilePath=os.path.join(
- settings.EXPOWEB,
- os.path.dirname(cave.description_file),
- link[0])
- subcaveFile=open(subcaveFilePath,'r')
- description=subcaveFile.read().decode('iso-8859-1').encode('utf-8')
-
- lookupAttribs={'title':link[1], 'cave':cave}
- nonLookupAttribs={'description':description}
- newSubcave=save_carefully(Subcave,lookupAttribs=lookupAttribs,nonLookupAttribs=nonLookupAttribs)
-
- logging.info("Added " + unicode(newSubcave) + " to " + unicode(cave))
- except IOError:
- logging.info("Subcave import couldn't open "+subcaveFilePath)
-
-def getLinksInSubcaveDescription(subcave):
- pattern='<a href=\"(.*?)\">(.*?)</a>'
- if subcave.description:
- return re.findall(pattern,subcave.description)
- else:
- return []
-
-def getLinksInAllSubcaves():
- bigList=[]
- for subcave in Subcave.objects.all():
- bigList+=getLinksInSubcaveDescription(subcave)
- return bigList
-
-def importAllSubcaves():
- for cave in Cave.objects.all():
- importSubcaves(cave)
+'''
+This module is the part of troggle that parses descriptions of cave parts (subcaves) from the legacy html files and saves them in the troggle database as instances of the model Subcave. Unfortunately, this parser can not be very flexible because the legacy format is poorly structured.
+'''
+
+import sys, os
+
+import os, re, logging
+from django.conf import settings
+from core.models import Subcave, Cave
+from utils import save_carefully
+
+def getLinksInCaveDescription(cave):
+ '''
+ Returns all HTML <a href> tags from a given cave as a list of tuples
+ in the format ('filename.html','Description')
+ '''
+ pattern='<a href=\"(.*?)\">(.*?)</a>'
+ if cave.underground_description:
+ return re.findall(pattern,cave.underground_description)
+ else:
+ return []
+
+def importSubcaves(cave):
+ for link in getLinksInCaveDescription(cave):
+ try:
+ subcaveFilePath=os.path.join(
+ settings.EXPOWEB,
+ os.path.dirname(cave.description_file),
+ link[0])
+ subcaveFile=open(subcaveFilePath,'r')
+ description=subcaveFile.read().decode('iso-8859-1').encode('utf-8')
+
+ lookupAttribs={'title':link[1], 'cave':cave}
+ nonLookupAttribs={'description':description}
+ newSubcave=save_carefully(Subcave,lookupAttribs=lookupAttribs,nonLookupAttribs=nonLookupAttribs)
+
+ logging.info("Added " + unicode(newSubcave) + " to " + unicode(cave))
+ except IOError:
+ logging.info("Subcave import couldn't open "+subcaveFilePath)
+
+def getLinksInSubcaveDescription(subcave):
+ pattern='<a href=\"(.*?)\">(.*?)</a>'
+ if subcave.description:
+ return re.findall(pattern,subcave.description)
+ else:
+ return []
+
+def getLinksInAllSubcaves():
+ bigList=[]
+ for subcave in Subcave.objects.all():
+ bigList+=getLinksInSubcaveDescription(subcave)
+ return bigList
+
+def importAllSubcaves():
+ for cave in Cave.objects.all():
+ importSubcaves(cave)