pyflyby 1.10.1__cp311-cp311-manylinux_2_24_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyflyby might be problematic. Click here for more details.

Files changed (55) hide show
  1. pyflyby/__init__.py +61 -0
  2. pyflyby/__main__.py +9 -0
  3. pyflyby/_autoimp.py +2229 -0
  4. pyflyby/_cmdline.py +548 -0
  5. pyflyby/_comms.py +221 -0
  6. pyflyby/_dbg.py +1367 -0
  7. pyflyby/_docxref.py +379 -0
  8. pyflyby/_dynimp.py +154 -0
  9. pyflyby/_fast_iter_modules.cpython-311-x86_64-linux-gnu.so +0 -0
  10. pyflyby/_file.py +771 -0
  11. pyflyby/_flags.py +230 -0
  12. pyflyby/_format.py +186 -0
  13. pyflyby/_idents.py +227 -0
  14. pyflyby/_import_sorting.py +165 -0
  15. pyflyby/_importclns.py +658 -0
  16. pyflyby/_importdb.py +680 -0
  17. pyflyby/_imports2s.py +643 -0
  18. pyflyby/_importstmt.py +723 -0
  19. pyflyby/_interactive.py +2113 -0
  20. pyflyby/_livepatch.py +793 -0
  21. pyflyby/_log.py +104 -0
  22. pyflyby/_modules.py +641 -0
  23. pyflyby/_parse.py +1381 -0
  24. pyflyby/_py.py +2166 -0
  25. pyflyby/_saveframe.py +1145 -0
  26. pyflyby/_saveframe_reader.py +471 -0
  27. pyflyby/_util.py +458 -0
  28. pyflyby/_version.py +7 -0
  29. pyflyby/autoimport.py +20 -0
  30. pyflyby/etc/pyflyby/canonical.py +10 -0
  31. pyflyby/etc/pyflyby/common.py +27 -0
  32. pyflyby/etc/pyflyby/forget.py +10 -0
  33. pyflyby/etc/pyflyby/mandatory.py +10 -0
  34. pyflyby/etc/pyflyby/numpy.py +156 -0
  35. pyflyby/etc/pyflyby/std.py +335 -0
  36. pyflyby/importdb.py +19 -0
  37. pyflyby/libexec/pyflyby/colordiff +34 -0
  38. pyflyby/libexec/pyflyby/diff-colorize +148 -0
  39. pyflyby/share/emacs/site-lisp/pyflyby.el +108 -0
  40. pyflyby-1.10.1.data/scripts/collect-exports +76 -0
  41. pyflyby-1.10.1.data/scripts/collect-imports +58 -0
  42. pyflyby-1.10.1.data/scripts/find-import +38 -0
  43. pyflyby-1.10.1.data/scripts/list-bad-xrefs +34 -0
  44. pyflyby-1.10.1.data/scripts/prune-broken-imports +34 -0
  45. pyflyby-1.10.1.data/scripts/pyflyby-diff +34 -0
  46. pyflyby-1.10.1.data/scripts/reformat-imports +27 -0
  47. pyflyby-1.10.1.data/scripts/replace-star-imports +37 -0
  48. pyflyby-1.10.1.data/scripts/saveframe +299 -0
  49. pyflyby-1.10.1.data/scripts/tidy-imports +163 -0
  50. pyflyby-1.10.1.data/scripts/transform-imports +47 -0
  51. pyflyby-1.10.1.dist-info/METADATA +591 -0
  52. pyflyby-1.10.1.dist-info/RECORD +55 -0
  53. pyflyby-1.10.1.dist-info/WHEEL +5 -0
  54. pyflyby-1.10.1.dist-info/entry_points.txt +4 -0
  55. pyflyby-1.10.1.dist-info/licenses/LICENSE.txt +23 -0
pyflyby/_log.py ADDED
@@ -0,0 +1,104 @@
1
+ # pyflyby/_log.py.
2
+ # Copyright (C) 2011, 2012, 2013, 2014, 2015, 2018 Karl Chen.
3
+ # License: MIT http://opensource.org/licenses/MIT
4
+
5
+
6
+
7
+ import builtins
8
+ import logging
9
+ from logging import Handler, Logger
10
+ import os
11
+ import sys
12
+ from prompt_toolkit import patch_stdout
13
+
14
+
15
+ class _PyflybyHandler(Handler):
16
+
17
+ _pre_log_function = None
18
+ _logged_anything_during_context = False
19
+
20
+ _interactive_prefix = "\033[0m\033[33m[PYFLYBY]\033[0m "
21
+ _noninteractive_prefix = "[PYFLYBY] "
22
+
23
+ def emit(self, record):
24
+ try:
25
+ if _is_ipython() or _is_interactive(sys.stderr):
26
+ prefix = self._interactive_prefix
27
+ else:
28
+ prefix = self._noninteractive_prefix
29
+
30
+ msg = self.format(record)
31
+ msg = ''.join(["%s%s\n" % (prefix, line) for line in msg.splitlines()])
32
+ with patch_stdout.patch_stdout(raw=True):
33
+ sys.stderr.write(msg)
34
+ sys.stderr.flush()
35
+ except (KeyboardInterrupt, SystemExit):
36
+ raise
37
+ except Exception:
38
+ self.handleError(record)
39
+
40
+ def _is_interactive(file):
41
+ filemod = type(file).__module__
42
+ if filemod.startswith("IPython.") or filemod.startswith("prompt_toolkit."):
43
+ # Inside IPython notebook/kernel
44
+ return True
45
+ try:
46
+ fileno = file.fileno()
47
+ except Exception:
48
+ return False # dunno
49
+ return os.isatty(fileno)
50
+
51
+
52
+ def _is_ipython():
53
+ """
54
+ Returns true if we're currently running inside IPython.
55
+ """
56
+ # This currently only works for versions of IPython that are modern enough
57
+ # to install 'builtins.get_ipython()'.
58
+ if 'IPython' not in sys.modules:
59
+ return False
60
+ if not hasattr(builtins, "get_ipython"):
61
+ return False
62
+ ip = builtins.get_ipython()
63
+ if ip is None:
64
+ return False
65
+ return True
66
+
67
+
68
+ class PyflybyLogger(Logger):
69
+
70
+ _LEVELS = dict( (k, getattr(logging, k))
71
+ for k in ['DEBUG', 'INFO', 'WARNING', 'ERROR'] )
72
+
73
+ def __init__(self, name, level):
74
+ Logger.__init__(self, name)
75
+ handler = _PyflybyHandler()
76
+ self.addHandler(handler)
77
+ self.set_level(level)
78
+
79
+ def set_level(self, level):
80
+ """
81
+ Set the pyflyby logger's level to ``level``.
82
+
83
+ :type level:
84
+ ``str``
85
+ """
86
+ if isinstance(level, int):
87
+ level_num = level
88
+ else:
89
+ try:
90
+ level_num = self._LEVELS[level.upper()]
91
+ except KeyError:
92
+ raise ValueError("Bad log level %r" % (level,))
93
+ Logger.setLevel(self, level_num)
94
+
95
+ @property
96
+ def debug_enabled(self):
97
+ return self.level <= logging.DEBUG
98
+
99
+ @property
100
+ def info_enabled(self):
101
+ return self.level <= logging.INFO
102
+
103
+
104
+ logger = PyflybyLogger('pyflyby', os.getenv("PYFLYBY_LOG_LEVEL") or "INFO")