Repository: scieloorg/xylose

Issue:
Ajustar identificação de licença
A identificação de licença coleta atualmente apenas o tipo da licença, ex:
by, by-nc.....

É importante também considerar a versão ex:
by/3.0
by/4.0
by-nc/3.0

Discussion:

Patch:
diff --git a/setup.py b/setup.py
index 0193a00..bb78b72 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ except ImportError:
 
 setup(
     name="xylose",
-    version='0.10b',
+    version='0.11b',
     description="A SciELO library to abstract a JSON data structure that is a product of the ISIS2JSON conversion using the ISIS2JSON type 3 data model.",
     author="SciELO",
     author_email="scielo-dev@googlegroups.com",
diff --git a/xylose/scielodocument.py b/xylose/scielodocument.py
index 5e7c073..59a6a86 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -25,8 +25,8 @@ else:
     html_parser = unescape
 # --------------
 
-LICENSE_REGEX = re.compile(r'a.+href="(.+)"')
-LICENSE_CREATIVE_COMMONS = re.compile(r'licenses/(.*?)/.') # Extracts the creative commons id from the url.
+LICENSE_REGEX = re.compile(r'a.+?href="(.+?)"')
+LICENSE_CREATIVE_COMMONS = re.compile(r'licenses/(.*?/\d\.\d)') # Extracts the creative commons id from the url.
 DOI_REGEX = re.compile(r'\d{2}\.\d+/.*$')
 
 def html_decode(string):
@@ -90,6 +90,7 @@ class Journal(object):
             for dlicense in self.data['v540']:
                 if not 't' in dlicense:
                     continue
+
                 license_url = LICENSE_REGEX.findall(dlicense['t'])
                 if len(license_url) == 0:
                     continue
@@ -400,6 +401,7 @@ class Article(object):
             for dlicense in self.data['v540']:
                 if not 't' in dlicense:
                     continue
+
                 license_url = LICENSE_REGEX.findall(dlicense['t'])
                 if len(license_url) == 0:
                     continue


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index 745859f..db84c57 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -351,13 +351,13 @@ class JournalTests(unittest.TestCase):
 
         journal = Journal(self.fulldoc['title'])
 
-        self.assertEqual(journal.permissions['id'], 'by')
+        self.assertEqual(journal.permissions['id'], 'by/3.0')
 
     def test_permission_id(self):
 
         journal = Journal(self.fulldoc['title'])
 
-        self.assertEqual(journal.permissions['id'], 'by-nc')
+        self.assertEqual(journal.permissions['id'], 'by-nc/3.0')
 
 
     def test_permission_url(self):