[Zope3-checkins] CVS: Zope3/src/zope/app/dublincore - dcterms.py:1.2

Fred L. Drake, Jr. fred at zope.com
Thu Aug 21 01:53:49 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/dublincore
In directory cvs.zope.org:/tmp/cvs-serv11687

Modified Files:
	dcterms.py 
Log Message:
flesh out the Period validator


=== Zope3/src/zope/app/dublincore/dcterms.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/dublincore/dcterms.py:1.1	Wed Aug 20 17:25:15 2003
+++ Zope3/src/zope/app/dublincore/dcterms.py	Thu Aug 21 00:53:49 2003
@@ -16,6 +16,8 @@
 $Id$
 """
 
+from zope.app.dublincore import dcsv
+
 # useful namespace URIs
 DC_NS = "http://purl.org/dc/elements/1.1/"
 DCTERMS_NS = "http://purl.org/dc/terms/"
@@ -72,8 +74,26 @@
 def check_tgn(value):
     pass
 
+_period_fields = "name start end scheme".split()
+
 def check_period(value):
-    pass
+    # checks a Period in DCSV format; see:
+    # http://dublincore.org/documents/dcmi-period/
+    items = dcsv.decode(value)
+    d = {}
+    for k, v in items:
+        if not k:
+            raise ValueError("missing field label")
+        if k not in _period_fields:
+            raise ValueError("unknown field label %r" % k)
+        if k in d:
+            raise ValueError("duplicate field label %r" % k)
+        d[k] = v
+    if d.get("scheme", "w3cdtf").lower() == "w3cdtf":
+        if "start" in d:
+            check_w3cdtf(d["start"])
+        if "end" in d:
+            check_w3cdtf(d["end"])
 
 def check_w3cdtf(value):
     pass




More information about the Zope3-Checkins mailing list