return first_non_none(_option_layers()) ############################################################################### # Traceback Trimming (tbtrim) # root path ROOT = pathlib.Path(__file__).resolve().parent def predicate(filename: str) -> bool: return pathlib.Path(filename).parent == ROOT tbtrim.set_trim_rule(predicate, strict=True, target=BPCSyntaxError) ############################################################################### # Main convertion implementation class Context(BaseContext): """General conversion context. Args: node (parso.tree.NodeOrLeaf): parso AST config (Config): conversion configurations Keyword Args: raw (bool): raw processing flag
from pcapkit.utilities.exceptions import DEVMODE, BaseError from pcapkit.utilities.warnings import DevModeWarning # set up sys.excepthook if DEVMODE: warnings.showwarning( 'development mode enabled', DevModeWarning, filename=__file__, lineno=0, line=f"PCAPKIT_DEVMODE={os.environ['PCAPKIT_DEVMODE']}") else: ROOT = os.path.dirname(os.path.realpath(__file__)) tbtrim.set_trim_rule(lambda filename: ROOT in os.path.realpath(filename), exception=BaseError, strict=False) # All Reference import pcapkit.all # Interface from pcapkit.interface import * # ToolKit from pcapkit.toolkit import * # Protocols from pcapkit.protocols.null import NoPayload from pcapkit.protocols.raw import Raw from pcapkit.protocols.link.arp import ARP
from macdaily.util.const.macro import DEVMODE from macdaily.util.const.term import red, reset from macdaily.util.exceptions import Error, UnsupportedOS from macdaily.util.tools.misc import predicate # set up sys.excepthook if DEVMODE: warnings.showwarning( f'development mode enabled', RuntimeWarning, filename=__file__, lineno=0, line=f"MACDAILY_DEVMODE={os.environ['MACDAILY_DEVMODE']}") else: tbtrim.set_trim_rule(predicate, strict=False, target=(Error, KeyboardInterrupt)) # check platform if platform.system() != 'Darwin': raise UnsupportedOS('macdaily: error: script runs only on macOS') # check dependencies if sys.version_info[:2] <= (3, 4): def test_import(module): try: importlib.import_module(module) except ImportError: print(f'macdaily: {red}error{reset}: broken dependency', file=sys.stderr)