fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DOM tree modification functions
[redakcja.git]
/
apps
/
catalogue
/
management
/
edumed.py
diff --git
a/apps/catalogue/management/edumed.py
b/apps/catalogue/management/edumed.py
index
c384dac
..
c319132
100644
(file)
--- a/
apps/catalogue/management/edumed.py
+++ b/
apps/catalogue/management/edumed.py
@@
-96,7
+96,7
@@
class Informacje(Tagger):
class List(Tagger):
point = re.compile(r"^[\s]*[-*·]{1,2}(.*)")
class List(Tagger):
point = re.compile(r"^[\s]*[-*·]{1,2}(.*)")
- num = re.compile(r"^[\s]*[
0-9a-z]{1,2}
[.]\s+(.*)")
+ num = re.compile(r"^[\s]*[
a-z]
[.]\s+(.*)")
def __init__(self, *args):
def __init__(self, *args):
@@
-258,11
+258,12
@@
dc_fixed = {
}
}
+class NotFound(Exception):
+ pass
+
+
def find_block(content, title_re, begin=-1, end=-1):
title_re = re.compile(title_re, re.I | re.UNICODE)
def find_block(content, title_re, begin=-1, end=-1):
title_re = re.compile(title_re, re.I | re.UNICODE)
- print "looking for %s" % title_re.pattern
- if title_re.pattern[0:6] == 'pomoce':
- import pdb; pdb.set_trace()
rb = -1
if begin < 0: begin = 0
rb = -1
if begin < 0: begin = 0
@@
-286,11
+287,11
@@
def find_block(content, title_re, begin=-1, end=-1):
break
if rb >= 0:
return rb, i
break
if rb >= 0:
return rb, i
+ raise NotFound()
def remove_block(content, title_re, removed=None):
rb, re = find_block(content, title_re)
def remove_block(content, title_re, removed=None):
rb, re = find_block(content, title_re)
-
if removed is not None and isinstance(removed, list):
removed += content[rb:re][:]
content[rb:re] = []
if removed is not None and isinstance(removed, list):
removed += content[rb:re][:]
content[rb:re] = []
@@
-303,7
+304,7
@@
def mark_activities(content):
is_przebieg = re.compile(r"[\s]*przebieg zaj..[\s]*", re.I)
is_next_section = re.compile(r"^[IVX]+[.]? ")
is_przebieg = re.compile(r"[\s]*przebieg zaj..[\s]*", re.I)
is_next_section = re.compile(r"^[IVX]+[.]? ")
- is_activity = re.compile(r"^[0-9]+[.]
?
(.+)")
+ is_activity = re.compile(r"^[0-9]+[.] (.+)")
is_activity_tools = re.compile(r"^pomoce:[\s]*(.+)")
is_activity_work = re.compile(r"^forma pracy:[\s]*(.+)")
is_activity_tools = re.compile(r"^pomoce:[\s]*(.+)")
is_activity_work = re.compile(r"^forma pracy:[\s]*(.+)")
@@
-320,14
+321,16
@@
def mark_activities(content):
ae = -1
while True:
e = content[i]
ae = -1
while True:
e = content[i]
+ if isinstance(e, Section):
+ if in_activities and \
+ is_next_section.match(e.title):
+ in_activities = False
+
if isinstance(e, Paragraph):
if not in_activities and \
is_przebieg.match(e.line):
in_activities = True
if isinstance(e, Paragraph):
if not in_activities and \
is_przebieg.match(e.line):
in_activities = True
- if in_activities and \
- is_next_section.match(e.line):
- in_activities = False
if in_activities:
m = is_activity.match(e.line)
if m:
if in_activities:
m = is_activity.match(e.line)
if m:
@@
-417,8
+420,14
@@
def toxml(content, pretty_print=False):
# some transformations
content = mark_activities(content)
content = mark_dictionary(content)
# some transformations
content = mark_activities(content)
content = mark_dictionary(content)
- content = remove_block(content, r"wykorzyst(yw)?ane metody[+ PA\[\].]*")
- content = remove_block(content, r"(pomoce|potrzebne materia.y)[+ PA\[\]]*")
+ try:
+ content = remove_block(content, r"wykorzyst(yw)?ane metody[+ PA\[\].]*")
+ except NotFound:
+ pass
+ try:
+ content = remove_block(content, r"(pomoce|potrzebne materia.y)[+ PA\[\]]*")
+ except NotFound:
+ pass
content = move_evaluation(content)
info = content.pop(0)
content = move_evaluation(content)
info = content.pop(0)