# HG changeset patch # User David Barts # Date 1559316217 25200 # Node ID 3a6180c1feea88ccfcd82eba723ce4c57c69a091 # Parent 243603aaab7e0bd97439420270828d1190f35571 Remove some needless repetition. diff -r 243603aaab7e -r 3a6180c1feea tincan.py --- a/tincan.py Thu May 30 22:19:41 2019 -0700 +++ b/tincan.py Fri May 31 08:23:37 2019 -0700 @@ -801,6 +801,8 @@ _BANNED = set([_WINF]) _EBANNED = set([_IEXTEN, _TEXTEN, _PEXTEN, _PEXTEN+"c"]) ENCODING = "utf-8" +_BITBUCKET = logging.getLogger(__name__) +_BITBUCKET.addHandler(logging.NullHandler) class _Launcher(object): """ @@ -818,7 +820,7 @@ self.encoding = ENCODING self.static = False self.multithread = multithread - self.logger = None + self.logger = _BITBUCKET def launch(self): """ @@ -882,11 +884,7 @@ elif S_ISDIR(etype): self._launch(subdir + [entry]) -_BITBUCKET = logging.getLogger(__name__) -_BITBUCKET.addHandler(logging.NullHandler) - -def launch(fsroot=None, urlroot='/', logger=_BITBUCKET, encoding=ENCODING, - static=False, multithread=True): +def launch(fsroot=None, urlroot='/', multithread=True, **kwargs): """ Launch and return a TinCan webapp. Does not run the app; it is the caller's responsibility to call app.run() @@ -894,9 +892,9 @@ if fsroot is None: fsroot = os.getcwd() launcher = _Launcher(fsroot, urlroot, multithread) - launcher.logger = logger - launcher.encoding = encoding - launcher.static = static + for i in [ "logger", "encoding", "static" ]: + if i in kwargs: + setattr(launcher, i, kwargs[i]) launcher.launch() return launcher.app, launcher.errors