wizlib 3.1.5__py3-none-any.whl → 3.2.1__py3-none-any.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 wizlib might be problematic. Click here for more details.

wizlib/io.py CHANGED
@@ -5,8 +5,10 @@ import sys
5
5
 
6
6
  import readchar
7
7
 
8
+ from wizlib.parser import WizArgumentError
8
9
 
9
- ISATTY = sys.stdin.isatty()
10
+
11
+ ISATTY = all(s.isatty() for s in (sys.stdin, sys.stdout, sys.stderr))
10
12
 
11
13
 
12
14
  def isatty():
@@ -18,4 +20,8 @@ def stream():
18
20
 
19
21
 
20
22
  def ttyin():
21
- return readchar.readkey()
23
+ if ISATTY:
24
+ return readchar.readkey()
25
+ else:
26
+ raise WizArgumentError(
27
+ 'Command designed for interactive use')
wizlib/stream_handler.py CHANGED
@@ -16,18 +16,27 @@ class StreamHandler(Handler):
16
16
  name = 'stream'
17
17
  text: str = ''
18
18
 
19
- def __init__(self, file=None, stdin=True):
20
- if file:
21
- self.text = Path(file).read_text()
22
- elif not wizlib.io.isatty():
23
- self.text = wizlib.io.stream()
24
-
25
- def __str__(self):
26
- return self.text
27
-
28
- @classmethod
29
- def fake(cls, value):
30
- """Return a fake StreamHandler with forced values, for testing"""
31
- handler = cls(stdin=False)
32
- handler.text = value
33
- return handler
19
+ def __init__(self, file=None):
20
+ self.file = file
21
+
22
+ def read(self):
23
+ """Play like a file, sorta"""
24
+ if self.file:
25
+ return Path(self.file).read_text()
26
+ else:
27
+ return wizlib.io.stream()
28
+
29
+ @property
30
+ def text(self):
31
+ """Legacy approach - deprecated"""
32
+ return self.read()
33
+
34
+ # def __str__(self):
35
+ # return self.text
36
+
37
+ # @classmethod
38
+ # def fake(cls, value):
39
+ # """Return a fake StreamHandler with forced values, for testing"""
40
+ # handler = cls(stdin=False)
41
+ # handler.text = value
42
+ # return handler
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizlib
3
- Version: 3.1.5
3
+ Version: 3.2.1
4
4
  Summary: Framework for flexible and powerful command-line applications
5
5
  License: MIT
6
6
  Author: Steampunk Wizard
@@ -5,9 +5,9 @@ wizlib/command.py,sha256=NO1558EYuXxfkpSmX6ljjzae8n8g4w6yytZKTJtigvo,1708
5
5
  wizlib/config_handler.py,sha256=hoDavSMiGM_7PAHI8XIwC8nxPWOZDk302ryyjluoLGg,2588
6
6
  wizlib/error.py,sha256=ypwdMOYhtgKWd48ccfOX8idmCXmm-Skwx3gkPwqJB3c,46
7
7
  wizlib/handler.py,sha256=Oz80aPhDyeY9tdppZ1dvtN-19JU5ydEDVW6jtppVoD4,446
8
- wizlib/io.py,sha256=KAMYTyHyKO2zY2kbymO5c8QpIWfHoTipWsDWzBJzDSw,307
8
+ wizlib/io.py,sha256=vZ1pIMtPFUZxbOv10HFDezEmlPgwPlUVP6RPwtfM9ec,506
9
9
  wizlib/parser.py,sha256=yLHV0fENeApFomCRWa3I6sB1x4lk1ag4vKejWVsic64,1550
10
- wizlib/stream_handler.py,sha256=UUPDpvXmfYOwG0Mmz2YMA8SKxeqau14_bK1z9vZHHp0,896
10
+ wizlib/stream_handler.py,sha256=7y1ckUoqTXxaCFI-XEixdBFZQZDxOv2jEEwtjWHZsUA,1066
11
11
  wizlib/super_wrapper.py,sha256=msitlfFfEwnrskzTtQBEY975sh9TQPicdLVo67imuqU,315
12
12
  wizlib/test_case.py,sha256=T5cX7yWy94hf8JuherDeBCH9Gve5tx2x_PZOte4udC0,1017
13
13
  wizlib/ui/__init__.py,sha256=ve_p_g4aBujh4jIJMgKkJ6cE5PT0aeY5AgRlneDswGg,4241
@@ -15,6 +15,6 @@ wizlib/ui/shell/__init__.py,sha256=sPrYe4bG_Xf7Nwssx_dqXVk9jeyYBFUjh4oLdlSOeRY,9
15
15
  wizlib/ui/shell/line_editor.py,sha256=vXXsCS_i4ZCjP0su2X9W_yD1CS6MiazPAtxpiaXQ6Jc,7413
16
16
  wizlib/ui/shell_ui.py,sha256=jre7E_5vP_SceNH7GYenfXZpFf4h9Sbh9cWZZycTYk8,1911
17
17
  wizlib/ui_handler.py,sha256=JoZadtw9DKAtGvHKP3_BJF2NaYqmcQYNdsY4PeRnOjg,634
18
- wizlib-3.1.5.dist-info/METADATA,sha256=tWbblo5H7QHat5xPGvdulE0YLl4Zf3XAyZXFMkyq4i8,1779
19
- wizlib-3.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
20
- wizlib-3.1.5.dist-info/RECORD,,
18
+ wizlib-3.2.1.dist-info/METADATA,sha256=DLHbTCsrwmLNoNr2dPVNi414ZjvfsCZJgrszM5Dn9Dk,1779
19
+ wizlib-3.2.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
20
+ wizlib-3.2.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any