Skip to content

Commit dab41fa

Browse files
committed
Added verbose support in interactive mode ^_^
1 parent 01349af commit dab41fa

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pycatfile.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@
145145
except Exception:
146146
PATH_TYPES = (basestring,)
147147

148+
def running_interactively():
149+
main = sys.modules.get("__main__")
150+
no_main_file = not hasattr(main, "__file__")
151+
interactive_flag = bool(getattr(sys.flags, "interactive", 0))
152+
return no_main_file or interactive_flag
153+
154+
if running_interactively():
155+
logging.basicConfig(format="%(message)s", stream=PY_STDOUT_TEXT, level=logging.DEBUG)
156+
148157
def _ensure_text(s, encoding="utf-8", errors="replace", allow_none=False):
149158
"""
150159
Normalize any input to text_type (unicode on Py2, str on Py3).

0 commit comments

Comments
 (0)