def test_multiple_authors(self):
     author = [split_name('Jack Jr. Brown'), split_name('von Hammer, Hans')]
     self.bg.generate_author(author)
     result = self.bg.get_generated_reference()
     expected = ''.join(['@article{.*,', os.linesep,
                         'author = {Brown, Jr., Jack and von Hammer, Hans}',
                         self.refend])  
     self.failUnless(re.search(expected, result))
Ejemplo n.º 2
0
 def test_multiple_authors(self):
     author = [split_name('Jack Jr. Brown'), split_name('von Hammer, Hans')]
     self.bg.generate_author(author)
     result = self.bg.get_generated_reference()
     expected = ''.join([
         '@article{.*,', os.linesep,
         'author = {Brown, Jr., Jack and von Hammer, Hans}', self.refend
     ])
     self.failUnless(re.search(expected, result))
 def test_single_author(self):
     author = [split_name('Jack Jr. Brown Jovovic')]
     self.bg.generate_author(author)
     result = self.bg.get_generated_reference()
     expected = ''.join(['@article{.*,', os.linesep,
                         'author = {Jovovic, Jr. Brown, Jack}',
                         self.refend])  
     self.failUnless(re.search(expected, result))
Ejemplo n.º 4
0
 def test_single_author(self):
     author = [split_name('Jack Jr. Brown Jovovic')]
     self.bg.generate_author(author)
     result = self.bg.get_generated_reference()
     expected = ''.join([
         '@article{.*,', os.linesep, 'author = {Jovovic, Jr. Brown, Jack}',
         self.refend
     ])
     self.failUnless(re.search(expected, result))
Ejemplo n.º 5
0
 def test_split_name(self):
     name = "Last, J."
     result = split_name(name)
     self.failUnless(result['first_name'] == 'J.')
     self.failUnless(result['last_name'] == 'Last')
     self.failUnless(result['middle_name'] == '')
     
     name = "Last, Middle, First"
     result = split_name(name)
     self.failUnless(result['first_name'] == 'First')
     self.failUnless(result['last_name'] == 'Last')
     self.failUnless(result['middle_name'] == 'Middle')
     
     name = "First Middle Last"
     result = split_name(name)
     self.failUnless(result['first_name'] == 'First')
     self.failUnless(result['last_name'] == 'Last')
     self.failUnless(result['middle_name'] == 'Middle')
     
     name = "First Last"
     result = split_name(name)
     self.failUnless(result['first_name'] == 'First')
     self.failUnless(result['last_name'] == 'Last')
     self.failUnless(result['middle_name'] == '')
Ejemplo n.º 6
0
    def test_split_name(self):
        name = "Last, J."
        result = split_name(name)
        self.failUnless(result['first_name'] == 'J.')
        self.failUnless(result['last_name'] == 'Last')
        self.failUnless(result['middle_name'] == '')

        name = "Last, Middle, First"
        result = split_name(name)
        self.failUnless(result['first_name'] == 'First')
        self.failUnless(result['last_name'] == 'Last')
        self.failUnless(result['middle_name'] == 'Middle')

        name = "First Middle Last"
        result = split_name(name)
        self.failUnless(result['first_name'] == 'First')
        self.failUnless(result['last_name'] == 'Last')
        self.failUnless(result['middle_name'] == 'Middle')

        name = "First Last"
        result = split_name(name)
        self.failUnless(result['first_name'] == 'First')
        self.failUnless(result['last_name'] == 'Last')
        self.failUnless(result['middle_name'] == '')
Ejemplo n.º 7
0
 def apply(self, input):
     log.debug('Applying PersonRule') #@UndefinedVariable
     if not type(input) == list:
         return []
     
     names = []
     for person in input:
         person = re.sub('\d', '', person)
         person = person.strip()
         if not person:
             continue
         
         name = split_name(person)
         if name:
             names.append(name)
     return names
Ejemplo n.º 8
0
    def _format_names(self, result, key='author'):
        """
        Formats a list of author/editor names
        """
        name_list = []
        newn_list = []

        if result.has_key(key):
            for each in result[key]:
                each = each.replace(' AND ', ' and ')
                name_list.extend(each.split(' and '))

        if name_list:
            name_list = [x for x in name_list if x]
            for name in name_list:
                newn_list.append(split_name(name))
        return newn_list