예제 #1
0
 def find_reference_by_id(self, id):
     if not id:
         raise ValueError
     
     log.debug('Querying the database. Reference with id %s' % str(id)) #@UndefinedVariable
     m_reference = (self.session.query(mappers.Reference).
                    filter(mappers.Reference.id == id).one())
     
     if not m_reference:
         return None
     
     log.debug('Creating new reference') #@UndefinedVariable
     reference = Reference()
     reference.id = m_reference.id
     reference.validity = m_reference.validity
     
     log.debug('Adding fields') #@UndefinedVariable
     for m_field in m_reference.fields:
         reference.set_field(m_field.name, m_field.value, m_field.valid)
     
     log.debug('Adding authors') #@UndefinedVariable
     authors = []
     for m_author in m_reference.authors:
         authors.append(m_author.to_name_dict())
     if authors:
         reference.set_field(u'author', authors, True)
     
     log.debug('Adding editors') #@UndefinedVariable
     editors = []
     for m_editor in m_reference.editors:
         editors.append(m_editor.to_name_dict())
     if editors:
         reference.set_field(u'editor', editors, True)
     
     return reference
예제 #2
0
        if not content:
            log.info('Empty entries file')  #@UndefinedVariable
            return references

        if not self.parser.check_format(content):
            log.error('Given entry is not in %s' % format)  #@UndefinedVariable
            return references

        # There may be more than one entry for the same file.
        log.debug('Parsing entries')  #@UndefinedVariable

        entries = self.parser.split_source(content)
        for entry in entries:
            fields = self.parser.parse_entry(entry)
            reference = Reference(fields, format, entry)
            reference.validity = 1.0
            references.append(reference)
        return references

    def persist_file_references(self, file_path):
        """
        Parses references from a file and stores them to the database
        """
        extraction_gw = ExtractionGateway()
        references = self._parse_entries_file(file_path)
        extractions = []

        for reference, index in zip(references, range(len(references))):

            extraction = Extraction()
예제 #3
0
         log.info('Empty entries file') #@UndefinedVariable
         return references
     
     
     if not self.parser.check_format(content):
         log.error('Given entry is not in %s' % format) #@UndefinedVariable
         return references
     
     # There may be more than one entry for the same file.
     log.debug('Parsing entries') #@UndefinedVariable
     
     entries = self.parser.split_source(content)
     for entry in entries:
         fields = self.parser.parse_entry(entry)
         reference = Reference(fields, format, entry)
         reference.validity = 1.0
         references.append(reference)
     return references
     
 def persist_file_references(self, file_path):
     """
     Parses references from a file and stores them to the database
     """
     extraction_gw = ExtractionGateway()
     references = self._parse_entries_file(file_path)
     extractions = []
     
     for reference, index in zip(references, range(len(references))):
         
         extraction = Extraction()