wizlib 3.1.4__tar.gz → 3.2.0__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wizlib
3
- Version: 3.1.4
3
+ Version: 3.2.0
4
4
  Summary: Framework for flexible and powerful command-line applications
5
5
  License: MIT
6
6
  Author: Steampunk Wizard
@@ -43,4 +43,3 @@ WizLib wraps the built-in ArgumentParser with a set of functions, classes, and c
43
43
  Logo by [Freepik](https://www.freepik.com/?_gl=1*1y9rvc9*test_ga*Mjc1MTIzODYxLjE2ODA3OTczNTg.*test_ga_523JXC6VL7*MTY4MDc5NzM1OC4xLjEuMTY4MDc5NzQxNS4zLjAuMA..*fp_ga*Mjc1MTIzODYxLjE2ODA3OTczNTg.*fp_ga_1ZY8468CQB*MTY4MDc5NzM1OC4xLjEuMTY4MDc5NzQxNS4zLjAuMA..)
44
44
 
45
45
 
46
-
@@ -24,4 +24,3 @@ WizLib wraps the built-in ArgumentParser with a set of functions, classes, and c
24
24
 
25
25
  Logo by [Freepik](https://www.freepik.com/?_gl=1*1y9rvc9*test_ga*Mjc1MTIzODYxLjE2ODA3OTczNTg.*test_ga_523JXC6VL7*MTY4MDc5NzM1OC4xLjEuMTY4MDc5NzQxNS4zLjAuMA..*fp_ga*Mjc1MTIzODYxLjE2ODA3OTczNTg.*fp_ga_1ZY8468CQB*MTY4MDc5NzM1OC4xLjEuMTY4MDc5NzQxNS4zLjAuMA..)
26
26
 
27
-
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wizlib"
3
- version = "3.1.4"
3
+ version = "3.2.0"
4
4
  description = "Framework for flexible and powerful command-line applications"
5
5
  authors = ["Steampunk Wizard <wizlib@steampunkwizard.ca>"]
6
6
  license = "MIT"
@@ -0,0 +1,27 @@
1
+ # Primitive i/o functions referenced elsewhere, useful for test patching (a
2
+ # sort of dependency injection
3
+
4
+ import sys
5
+
6
+ import readchar
7
+
8
+ from wizlib.parser import WizArgumentError
9
+
10
+
11
+ ISATTY = all(s.isatty() for s in (sys.stdin, sys.stdout, sys.stderr))
12
+
13
+
14
+ def isatty():
15
+ return ISATTY
16
+
17
+
18
+ def stream():
19
+ return '' if ISATTY else sys.stdin.read()
20
+
21
+
22
+ def ttyin():
23
+ if ISATTY:
24
+ return readchar.readkey()
25
+ else:
26
+ raise WizArgumentError(
27
+ 'Command designed for interactive use')
@@ -0,0 +1,42 @@
1
+ # In a non-interactive, non-testing mode, route input from stdin to the output.
2
+ # When testing, read from the object provided (probably a StreamIO)
3
+
4
+ from pathlib import Path
5
+ import sys
6
+
7
+ from wizlib.handler import Handler
8
+ from wizlib.parser import WizParser
9
+ import wizlib.io
10
+
11
+
12
+ class StreamHandler(Handler):
13
+ """Handle non-interactive input, such as via a pipe in a shell. Only runs
14
+ when not in a tty."""
15
+
16
+ name = 'stream'
17
+ text: str = ''
18
+
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
wizlib-3.1.4/wizlib/io.py DELETED
@@ -1,21 +0,0 @@
1
- # Primitive i/o functions referenced elsewhere, useful for test patching (a
2
- # sort of dependency injection
3
-
4
- import sys
5
-
6
- import readchar
7
-
8
-
9
- ISATTY = sys.stdin.isatty()
10
-
11
-
12
- def isatty():
13
- return ISATTY
14
-
15
-
16
- def stream():
17
- return '' if ISATTY else sys.stdin.read()
18
-
19
-
20
- def ttyin():
21
- return readchar.readkey()
@@ -1,33 +0,0 @@
1
- # In a non-interactive, non-testing mode, route input from stdin to the output.
2
- # When testing, read from the object provided (probably a StreamIO)
3
-
4
- from pathlib import Path
5
- import sys
6
-
7
- from wizlib.handler import Handler
8
- from wizlib.parser import WizParser
9
- import wizlib.io
10
-
11
-
12
- class StreamHandler(Handler):
13
- """Handle non-interactive input, such as via a pipe in a shell. Only runs
14
- when not in a tty."""
15
-
16
- name = 'stream'
17
- text: str = ''
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes