예제 #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
예제 #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
예제 #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
예제 #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
예제 #5
0
 def setUp(self):
     self.eg = ReferenceGateway()
예제 #6
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
예제 #7
0
 def __init__(self, format=ReferenceFormat.BIBTEX):
     self.reference_gw = ReferenceGateway()
     self.format = format
     self.util_factory = UtilFactory()
예제 #8
0
 def setUp(self):
     self.eg = ReferenceGateway()