def noinject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=0, via=None): """ Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged """ if PRINT_INJECT_ORDER: from utool._internal import meta_util_dbg callername = meta_util_dbg.get_caller_name(N=N + 1, strict=False) lineno = meta_util_dbg.get_caller_lineno(N=N + 1, strict=False) suff = ' via %s' % (via, ) if via else '' fmtdict = dict(N=N, lineno=lineno, callername=callername, modname=module_name, suff=suff) msg = '[util_inject] N={N} {modname} is imported by {callername} at lineno={lineno}{suff}'.format( **fmtdict) builtins.print(msg) if EXIT_ON_INJECT_MODNAME == module_name: builtins.print('...exiting') assert False, 'exit in inject requested'
def noinject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=0): """ Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged """ if PRINT_INJECT_ORDER: from utool._internal import meta_util_dbg callername = meta_util_dbg.get_caller_name(N=2 + N, strict=False) lineno = meta_util_dbg.get_caller_lineno(N=2 + N, strict=False) fmtdict = dict(N=N, lineno=lineno, callername=callername, modname=module_name) msg = '[util_inject] N={N} {modname} is imported by {callername} at lineno={lineno}'.format(**fmtdict) builtins.print(msg)
def noinject(module_name=None, module_prefix='[???]', DEBUG=False, module=None, N=0, via=None): """ Use in modules that do not have inject in them Does not inject anything into the module. Just lets utool know that a module is being imported so the import order can be debuged """ if PRINT_INJECT_ORDER: from utool._internal import meta_util_dbg callername = meta_util_dbg.get_caller_name(N=N + 1, strict=False) lineno = meta_util_dbg.get_caller_lineno(N=N + 1, strict=False) suff = ' via %s' % (via,) if via else '' fmtdict = dict(N=N, lineno=lineno, callername=callername, modname=module_name, suff=suff) msg = '[util_inject] N={N} {modname} is imported by {callername} at lineno={lineno}{suff}'.format(**fmtdict) builtins.print(msg) if EXIT_ON_INJECT_MODNAME == module_name: builtins.print('...exiting') assert False, 'exit in inject requested'
or '--verbinject' in sys.argv or '--print-imports' in sys.argv or '--verb-inject' in sys.argv or '--verbimport' in sys.argv or '--verbimp' in sys.argv or '--verb-import' in sys.argv or '--verb-import' in sys.argv or '--verbose-import' in sys.argv) LOGGING_VERBOSE = VERYVERBOSE or '--verb-logging' in sys.argv if PRINT_INJECT_ORDER: # HACK from utool._internal import meta_util_dbg from six.moves import builtins N = 0 callername = meta_util_dbg.get_caller_name(N=2 + N, strict=False) lineno = meta_util_dbg.get_caller_lineno(N=2 + N, strict=False) fmtdict = dict(N=N, lineno=lineno, callername=callername, modname=__name__) msg = '[util_inject] N={N} {modname} is imported by {callername} at lineno={lineno}'.format( **fmtdict) builtins.print(msg) def _try_cast(val, type_): if type_ in [types.BooleanType] and isinstance(val, six.string_types): if val.lower() == 'true': newval = True elif val.lower() == 'false': newval = True else: newval = type_(val) return newval
VERBOSE = '--verbose' in sys.argv or '--verb' in sys.argv VERYVERBOSE = '--very-verbose' in sys.argv or '--veryverbose' in sys.argv NO_INDENT = '--noindent' in sys.argv or '--no-indent' in sys.argv or SILENT PRINT_ALL_CALLERS = '--print-all-callers' in sys.argv USE_ASSERT = not NO_ASSERTS NOT_QUIET = not QUIET PRINT_INJECT_ORDER = VERYVERBOSE or '--print-inject-order' in sys.argv LOGGING_VERBOSE = VERYVERBOSE or '--verb-logging' in sys.argv if PRINT_INJECT_ORDER: # HACK from utool._internal import meta_util_dbg from six.moves import builtins N = 0 callername = meta_util_dbg.get_caller_name(N=2 + N, strict=False) lineno = meta_util_dbg.get_caller_lineno(N=2 + N, strict=False) fmtdict = dict(N=N, lineno=lineno, callername=callername, modname=__name__) msg = '[util_inject] N={N} {modname} is imported by {callername} at lineno={lineno}'.format(**fmtdict) builtins.print(msg) #def get_argval(arg, type_=None, default=None): # arg_after = default # if type_ is bool: # arg_after = False if default is None else default # try: # argx = sys.argv.index(arg) # if argx < len(sys.argv): # if type_ is bool: # arg_after = True # else: # try: