Beispiel #1
0
    def fromFullName(self, fullname):

        author = Author()

        if fullname == "":
            return author

        first_names = []
        last_names = []

        # Split full name by space
        for word in fullname.split(" "):
            # If name is uppercased, it's a lastname
            if (word.isupper()):
                last_names.append(word)
            else:
                first_names.append(word)

        author.first_name = " ".join(first_names)
        author.last_name = " ".join(last_names)

        return author
Beispiel #2
0
 def test_articles_to_xml(self):
     articles = []
     per = Periodique()
     per.id = 1
     per.name = "Le Seigneur des anneaux"
     bull = Bulletin()
     bull.title = "La communaute de l anneau"
     bull.number = "1"
     bull.period = "1960"
     bull.periodique = per
     article = Article()
     article.title = "Concerning hobbit"
     article.pagination = "p. 1-100"
     article.language = 'fre'
     author = Author()
     author.last_name = 'TOLKIEN'
     author.first_name = 'J.R.R'
     article.authors.append(author)
     article.bulletin = bull
     article.periodique = per
     articles.append(article)
     article = Article()
     article.title = "La comte"
     article.pagination = "p. 101-200"
     article.language = 'fre'
     article.authors.append(author)
     article.bulletin = bull
     article.periodique = per
     articles.append(article)
     conv = XmlConverter()
     flow = conv._toXml(articles)
     xml = len(etree.tostring(flow))
     xml_proof = len(
         '<unimarc><notice><rs>n</rs><dt>a</dt><bl>a</bl><hl>2</hl><el>1</el><rs>i</rs><f c="200"><s c="a">Concerning hobbit</s></f><f c="101"><s c="a">fre</s></f><f c="215"><s c="a">p. 1-100</s></f><f c="700"><s c="a">TOLKIEN</s><s c="b">J.R.R</s><s c="4">070</s></f><f c="461"><s c="t">Le Seigneur des anneaux</s><s c="9">id:1</s><s c="9">lnk:perio</s></f><f c="463"><s c="t">La communaute de l anneau</s><s c="e">1960</s><s c="v">1</s><s c="9">lnk:bull</s></f></notice><notice><rs>n</rs><dt>a</dt><bl>a</bl><hl>2</hl><el>1</el><rs>i</rs><f c="200"><s c="a">La comte</s></f><f c="101"><s c="a">fre</s></f><f c="215"><s c="a">p. 101-200</s></f><f c="700"><s c="a">TOLKIEN</s><s c="b">J.R.R</s><s c="4">070</s></f><f c="461"><s c="t">Le Seigneur des anneaux</s><s c="9">id:1</s><s c="9">lnk:perio</s></f><f c="463"><s c="t">La communaute de l anneau</s><s c="e">1960</s><s c="v">1</s><s c="9">lnk:bull</s></f></notice></unimarc>'
     )
     self.assertEqual(xml, xml_proof)