fixdc: only change wluri if it's fixable
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 14 Aug 2012 12:33:52 +0000 (14:33 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 14 Aug 2012 12:33:52 +0000 (14:33 +0200)
apps/catalogue/management/commands/fixdc.py

index a80352d..3f997d0 100644 (file)
@@ -20,6 +20,11 @@ class FixDC(XmlUpdater):
         except ValidationError:
             correct_field = unicode(WLURI.from_slug(
                                 WLURI(elem.text.strip()).slug))
+            try:
+                WLURI.strict(correct_field)
+            except ValidationError:
+                # Can't make a valid WLURI out of it, leave as is.
+                return False
             if verbose:
                 print "Changing %s from %s to %s" % (
                         elem.tag, elem.text, correct_field