How to use the duecredit.entries.DueCreditEntry function in duecredit

To help you get started, we’ve selected a few duecredit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duecredit / duecredit / duecredit / entries.py View on Github external
def _process_rawentry(self):
        pass

    def __repr__(self):
        args = [repr(self._rawentry),
                "key={0}".format(repr(self._key))]
        args = ", ".join(args)
        return self.__class__.__name__ + '({0})'.format(args)

    def format(self):
        # TODO: return nice formatting of the entry
        return str(self._rawentry)


class BibTeX(DueCreditEntry):
    def __init__(self, bibtex, key=None):
        super(BibTeX, self).__init__(bibtex.strip())
        self._key = None
        self._reference = None
        self._process_rawentry()
        if key is not None:
            # use the one provided, not the parsed one
            lgr.debug("Replacing parsed key %s for BibTeX with the provided %s",
                      self._key, key)
            self._key = key

    def _process_rawentry(self):
        reg = re.match("\s*@(?P\S*)\s*\{\s*(?P\S*)\s*,.*",
                       self._rawentry, flags=re.MULTILINE)
        assert(reg)
        matches = reg.groupdict()
github duecredit / duecredit / duecredit / collector.py View on Github external
def cite(self, entry, **kwargs):
        # TODO: if cite is invoked but no path is provided -- we must figure it out
        # I guess from traceback, otherwise how would we know later to associate it
        # with modules???
        path = kwargs.get('path', None)
        if path is None:
            raise ValueError('path must be provided')

        if isinstance(entry, DueCreditEntry):
            # new one -- add it
            self.add(entry)
            entry_ = self._entries[entry.get_key()]
        else:
            entry_ = self._entries[entry]

        entry_key = entry_.get_key()
        citation_key = Citation.get_key(path=path, entry_key=entry_key)
        try:
            citation = self.citations[citation_key]
        except KeyError:
            self.citations[citation_key] = citation = Citation(entry_, **kwargs)
        assert(citation.key == citation_key)
        # update citation count
        citation.count += 1
github duecredit / duecredit / duecredit / entries.py View on Github external
class Text(DueCreditEntry):
    """Just a free text entry without any special super powers in rendering etc
    """
    pass  # nothing special I guess


class Doi(DueCreditEntry):

    @property
    def doi(self):
        return self._rawentry


class Url(DueCreditEntry):

    @property
    def url(self):
        return self._rawentry
github duecredit / duecredit / duecredit / entries.py View on Github external
self._process_rawentry()
        if key is not None:
            # use the one provided, not the parsed one
            lgr.debug("Replacing parsed key %s for BibTeX with the provided %s",
                      self._key, key)
            self._key = key

    def _process_rawentry(self):
        reg = re.match("\s*@(?P\S*)\s*\{\s*(?P\S*)\s*,.*",
                       self._rawentry, flags=re.MULTILINE)
        assert(reg)
        matches = reg.groupdict()
        self._key = matches['key']


class Text(DueCreditEntry):
    """Just a free text entry without any special super powers in rendering etc
    """
    pass  # nothing special I guess


class Doi(DueCreditEntry):

    @property
    def doi(self):
        return self._rawentry


class Url(DueCreditEntry):

    @property
    def url(self):
github duecredit / duecredit / duecredit / entries.py View on Github external
def _process_rawentry(self):
        reg = re.match("\s*@(?P\S*)\s*\{\s*(?P\S*)\s*,.*",
                       self._rawentry, flags=re.MULTILINE)
        assert(reg)
        matches = reg.groupdict()
        self._key = matches['key']


class Text(DueCreditEntry):
    """Just a free text entry without any special super powers in rendering etc
    """
    pass  # nothing special I guess


class Doi(DueCreditEntry):

    @property
    def doi(self):
        return self._rawentry


class Url(DueCreditEntry):

    @property
    def url(self):
        return self._rawentry