[cc-commits] [git]cc.license (branch master) updated. 8195f958f9df252c7c6a51801480f3ed1c926cc5

git version control webmaster at creativecommons.org
Wed Jul 14 20:08:11 EDT 2010


The branch, master has been updated
       via  8195f958f9df252c7c6a51801480f3ed1c926cc5 (commit)
      from  d1e0c11678a2a35e8c8e0539eb965e932115976d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8195f958f9df252c7c6a51801480f3ed1c926cc5
Author: JED3 <jed at jedpad.(none)>
Date:   Wed Jul 14 17:07:43 2010 -0700

    Needed a way to get the latest unported list of license uris

-----------------------------------------------------------------------

Summary of changes (followed by patch):
 cc/license/_lib/rdf_helper.py        |   20 ++++++++++++++++++--
 cc/license/jurisdictions/__init__.py |    8 +++-----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/cc/license/_lib/rdf_helper.py b/cc/license/_lib/rdf_helper.py
index 2ac07a1..3aafaa0 100644
--- a/cc/license/_lib/rdf_helper.py
+++ b/cc/license/_lib/rdf_helper.py
@@ -203,7 +203,23 @@ def get_jurisdiction(model, uri):
     else:
         return cc.license.Jurisdiction(str(solns[0]['jurisdiction'].uri))
 
-def get_jurisdiction_licenses(uri):
+def get_unported_license_uris(model):
+    qstring = """
+              PREFIX cc: <http://creativecommons.org/ns#>
+              PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+              SELECT ?luri 
+              WHERE {
+                     ?luri rdf:type cc:License .
+                     OPTIONAL { ?luri cc:jurisdiction ?juri .} .
+                     FILTER (!BOUND(?juri))
+              }
+              """
+    query = RDF.Query(qstring, query_language='sparql')
+    solns = list(query.execute(model))
+    return tuple( str(s['luri'].uri) for s in solns )
+
+def get_jurisdiction_licenses(model, uri):
     qstring = """
               PREFIX cc: <http://creativecommons.org/ns#>
 
@@ -213,7 +229,7 @@ def get_jurisdiction_licenses(uri):
               }
               """
     query = RDF.Query(qstring % uri, query_language='sparql')
-    solns = list(query.execute(ALL_MODEL))
+    solns = list(query.execute(model))
     if len(solns) == 0:
         return [ ] # empty string makes 'Unported'
     else:
diff --git a/cc/license/jurisdictions/__init__.py b/cc/license/jurisdictions/__init__.py
index fe2fd78..51e3e3a 100644
--- a/cc/license/jurisdictions/__init__.py
+++ b/cc/license/jurisdictions/__init__.py
@@ -69,11 +69,9 @@ def uri2code(uri):
     return uri[blen:-1]
 
 def get_licenses_by_code(code):
-    if code == '':
-        return cc.license.Jurisdiction('')
     if code not in list_codes():
         raise cc.license.CCLicenseError, 'Invalid jurisdiction'
+    if code == '':
+        return rdf_helper.get_unported_license_uris(rdf_helper.ALL_MODEL)
     uri = 'http://creativecommons.org/international/%s/' % code
-    return rdf_helper.get_jurisdiction_licenses(uri)
-
-    
+    return rdf_helper.get_jurisdiction_licenses(rdf_helper.ALL_MODEL, uri)


hooks/post-receive
-- 
cc.license



More information about the cc-commits mailing list