How to use the duecredit.due 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 / __main__.py View on Github external
sys.argv = prog_argv
    progname = prog_argv[0]
    sys.path[0] = os.path.split(progname)[0]

    try:
        with open(progname) as fp:
            code = compile(fp.read(), progname, 'exec')
        # try to emulate __main__ namespace as much as possible
        globs = {
            '__file__': progname,
            '__name__': '__main__',
            '__package__': None,
            '__cached__': None,
        }
        # Since used explicitly -- activate the beast
        due.activate(True)
        runctx(code, globs, globs)
        # TODO: see if we could hide our presence from the final tracebacks if execution fails
    except IOError as err:
        lgr.error("Cannot run file %r because: %s" % (sys.argv[0], err))
        sys.exit(1)
    except SystemExit:
        pass
github duecredit / duecredit / duecredit / injections / injector.py View on Github external
def __init__(self, collector=None):
        if collector is None:
            from duecredit import due
            collector = due
        self._collector = collector
        self._delayed_injections = {}
        self._entry_records = {}  # dict:  modulename: {object: [('entry', cite kwargs)]}
        self._processed_modules = set()
        # We need to process modules only after we are done with all nested imports, otherwise we
        # might be trying to process them too early -- whenever they are not yet linked to their
        # parent's namespace. So we will keep track of import level and set of modules which
        # would need to be processed whenever we are back at __import_level == 1
        self.__import_level = 0
        self.__queue_to_process = set()
        self.__processing_queue = False
        self._active = False
        lgr.debug("Created injector %r", self)
github duecredit / duecredit / duecredit / injections / injector.py View on Github external
def __init__(self, collector=None):
        if collector is None:
            from duecredit import due
            collector = due
        self._collector = collector
        self._entry_records = {}  # dict:  modulename: {object: [('entry', cite kwargs)]}