X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/7499a88c62e78c49d7f9e393b8e67a315acc16ba..02500a11ed4bd76a6fc32f3e8676365eb344f771:/apps/catalogue/management/edumed.py diff --git a/apps/catalogue/management/edumed.py b/apps/catalogue/management/edumed.py index c384dac2..76d39649 100644 --- 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}(.*)") - num = re.compile(r"^[\s]*[0-9a-z]{1,2}[.]\s+(.*)") + num = re.compile(r"^[\s]*[a-z]{1,2}[.]\s+(.*)") def __init__(self, *args): @@ -258,9 +258,13 @@ 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) - print "looking for %s" % title_re.pattern + ## print "looking for %s" % title_re.pattern if title_re.pattern[0:6] == 'pomoce': import pdb; pdb.set_trace() @@ -286,11 +290,11 @@ def find_block(content, title_re, begin=-1, end=-1): break if rb >= 0: return rb, i + raise NotFound() 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] = [] @@ -417,8 +421,14 @@ def toxml(content, pretty_print=False): # 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)