Ejemplo n.º 1
0
class ReferenceEntryFormatter(object):
    def __init__(self, format=ReferenceFormat.BIBTEX):
        self.reference_gw = ReferenceGateway()
        self.format = format
        self.util_factory = UtilFactory()
        
    def format_reference(self, reference_id):
        log.debug('Retrieving reference from the database') #@UndefinedVariable
        reference = self.reference_gw.find_reference_by_id(reference_id)
        if not reference:
            log.error('Reference with id %d could not be retrieved'  #@UndefinedVariable
                      % reference_id)
            return None
        
        formatter = ReferenceFormatter()
        try:
            generator = self.util_factory.create_generator(self.format)
        except UtilCreationError as e:
            log.error('Could not create a formatter for %s: %s' % #@UndefinedVariable
                      (self.format, e.args))
            return None
        
        log.debug('Starting to format') #@UndefinedVariable
        formatter.format_reference(reference, generator)
        
        return reference.entry
Ejemplo n.º 2
0
class TestReferenceGateway(unittest.TestCase):
    def setUp(self):
        self.eg = ReferenceGateway()

    def xtest_find_by_id(self):
        reference = self.eg.find_reference_by_id(2) #@UnusedVariable
        pass
Ejemplo n.º 3
0
class ReferenceEntryFormatter(object):
    def __init__(self, format=ReferenceFormat.BIBTEX):
        self.reference_gw = ReferenceGateway()
        self.format = format
        self.util_factory = UtilFactory()

    def format_reference(self, reference_id):
        log.debug(
            'Retrieving reference from the database')  #@UndefinedVariable
        reference = self.reference_gw.find_reference_by_id(reference_id)
        if not reference:
            log.error(
                'Reference with id %d could not be retrieved'  #@UndefinedVariable
                % reference_id)
            return None

        formatter = ReferenceFormatter()
        try:
            generator = self.util_factory.create_generator(self.format)
        except UtilCreationError as e:
            log.error('Could not create a formatter for %s: %s'
                      %  #@UndefinedVariable
                      (self.format, e.args))
            return None

        log.debug('Starting to format')  #@UndefinedVariable
        formatter.format_reference(reference, generator)

        return reference.entry
Ejemplo n.º 4
0
class TestReferenceGateway(unittest.TestCase):
    def setUp(self):
        self.eg = ReferenceGateway()

    def xtest_find_by_id(self):
        reference = self.eg.find_reference_by_id(2)  #@UnusedVariable
        pass
Ejemplo n.º 5
0
 def setUp(self):
     self.eg = ReferenceGateway()
Ejemplo n.º 6
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
Ejemplo n.º 7
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
Ejemplo n.º 8
0
 def setUp(self):
     self.eg = ReferenceGateway()