Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
# TODO: theoretically version shouldn't differ if we don't preload previous results
if not citation.version:
version = kwargs.get('version', None)
if not version and citation.path:
modname = citation.path.split('.', 1)[0]
if '.' in modname:
package = modname.split('.', 1)[0]
else:
package = modname
@borrowdoc(Citation, "__init__", replace="PLUGDOCSTRING")
def dcite(self, *args, **kwargs):
"""Decorator for references. PLUGDOCSTRING
Parameters
----------
conditions: dict, optional
If reference should be cited whenever parameters to the function call
satisfy given values (all of the specified).
Each key in the dictionary is a 2 element tuple with first element, integer,
pointing to a position of the argument in the original function call signature,
while second provides the name, thus if used as a keyword argument.
Use "DC_DEFAULT" keyword as a value to depict default value (e.g. if no
explicit value was provided for that positional or keyword argument).
If "keyword argument" is of the form "obj.attr1.attr2", then actual value
for comparison would be taken by extracting attr1 (and then attr2) attributes
from the provided value. So, if desired to condition of the state of the object,