From: Marcin Koziej Date: Fri, 16 Nov 2012 09:25:11 +0000 (+0100) Subject: Merge branch 'edumed' of github.com:fnp/redakcja into edumed X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/dd0db2db471a6bb8e08ca74c683fbde6b35144a9?hp=7e954ab5ac6399b7f348b972613748bb9c484670 Merge branch 'edumed' of github.com:fnp/redakcja into edumed --- diff --git a/apps/catalogue/management/edumed.py b/apps/catalogue/management/edumed.py index 9e90ba7d..c319132a 100644 --- a/apps/catalogue/management/edumed.py +++ b/apps/catalogue/management/edumed.py @@ -258,6 +258,10 @@ 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) @@ -283,11 +287,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] = [] @@ -416,8 +420,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)