Repository: scieloorg/xylose

Issue:
Pages com bug na leitura do registro JSON.
Os novos registros quando carregados a partir do XML passaram a vir com uma estrutura de dados diferente do original:

antes:
```
[
    {
        _: "",
        f: "1099",
        l: "1101",
    }
],
```

depois:
```
[
    {
        _: "",
        f: "1099"
    },
   {
        l: "1101",
        _: ""
    }
],
```

O Xylose deverá abstrair as duas formas de persistência das páginas.

Discussion:

Patch:
diff --git a/setup.py b/setup.py
index 3e2e89c..09e541f 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ except ImportError:
 
 setup(
     name="xylose",
-    version='0.6b',
+    version='0.7b',
     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 bed9cfc..a16ee47 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -788,8 +788,9 @@ class Article(object):
         This method deals with the legacy fields (14).
         """
         if 'v14' in self.data['article']:
-            if 'f' in self.data['article']['v14'][0]:
-                return self.data['article']['v14'][0]['f']
+            for item in self.data['article']['v14']:
+                if 'f' in item:
+                    return item['f']
 
     @property
     def end_page(self):
@@ -798,8 +799,9 @@ class Article(object):
         This method deals with the legacy fields (14).
         """
         if 'v14' in self.data['article']:
-            if 'l' in self.data['article']['v14'][0]:
-                return self.data['article']['v14'][0]['l']
+            for item in self.data['article']['v14']:
+                if 'l' in item:
+                    return item['l']
 
     @property
     def doi(self):


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index 5236fdd..71a7da4 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -956,6 +956,22 @@ class ArticleTests(unittest.TestCase):
         del(article.data['article']['v14'][0]['f'])
         self.assertEqual(article.start_page, None)
 
+    def test_start_page_loaded_through_xml(self):
+        article = self.article
+
+        article.data['article']['v14'] = [
+            {
+                u'_': u'',
+                u'l': u'122'
+            },
+            {
+                u'_': u'',
+                u'f': u'110'
+            }
+        ]
+
+        self.assertEqual(article.start_page, u'110')
+
     def test_last_page(self):
         article = self.article
 
@@ -967,6 +983,23 @@ class ArticleTests(unittest.TestCase):
         del(article.data['article']['v14'][0]['l'])
         self.assertEqual(article.end_page, None)
 
+    def test_end_page_loaded_through_xml(self):
+        article = self.article
+
+        article.data['article']['v14'] = [
+            {
+                u'_': u'',
+                u'f': u'110'
+            },
+            {
+                u'_': u'',
+                u'l': u'122'
+            }
+        ]
+
+        self.assertEqual(article.end_page, u'122')
+
+
     def test_without_pages(self):
         article = self.article