xlwings-utils 0.0.7.post2__py3-none-any.whl → 0.0.7.post3__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 xlwings-utils might be problematic. Click here for more details.
- xlwings_utils/xlwings_utils.py +31 -43
- {xlwings_utils-0.0.7.post2.dist-info → xlwings_utils-0.0.7.post3.dist-info}/METADATA +1 -1
- xlwings_utils-0.0.7.post3.dist-info/RECORD +6 -0
- xlwings_utils-0.0.7.post2.dist-info/RECORD +0 -6
- {xlwings_utils-0.0.7.post2.dist-info → xlwings_utils-0.0.7.post3.dist-info}/WHEEL +0 -0
- {xlwings_utils-0.0.7.post2.dist-info → xlwings_utils-0.0.7.post3.dist-info}/top_level.txt +0 -0
xlwings_utils/xlwings_utils.py
CHANGED
|
@@ -13,7 +13,7 @@ from pathlib import Path
|
|
|
13
13
|
import os
|
|
14
14
|
import sys
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
_buffer=[]
|
|
17
17
|
|
|
18
18
|
dbx = None
|
|
19
19
|
Pythonista = sys.platform == "ios"
|
|
@@ -420,60 +420,48 @@ def captured_stdout_as_value(clear=True):
|
|
|
420
420
|
return [[line] for line in captured_stdout_as_str(clear).splitlines()]
|
|
421
421
|
|
|
422
422
|
|
|
423
|
-
class handle_capture_stdout:
|
|
424
|
-
def __init__(self):
|
|
425
|
-
pass
|
|
426
423
|
|
|
427
|
-
def isatty(self):
|
|
428
|
-
return False
|
|
429
424
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
_org_stdout.write(data)
|
|
434
|
-
|
|
435
|
-
def flush(self):
|
|
436
|
-
if _do_print:
|
|
437
|
-
_org_stdout.flush()
|
|
438
|
-
_buffer.append("\n")
|
|
425
|
+
class capture_stdout:
|
|
426
|
+
"""
|
|
427
|
+
specifies how to capture stdout
|
|
439
428
|
|
|
429
|
+
Parameters
|
|
430
|
+
----------
|
|
431
|
+
include_print : bool
|
|
432
|
+
if True (default), the output is also printed out as normal
|
|
440
433
|
|
|
441
|
-
|
|
442
|
-
global _buffer
|
|
443
|
-
sys.stdout=_org_stdout
|
|
444
|
-
_buffer=[]
|
|
434
|
+
if False, no output is printed
|
|
445
435
|
|
|
446
|
-
|
|
436
|
+
Note
|
|
437
|
+
----
|
|
438
|
+
Use this function as a context manager, like ::
|
|
447
439
|
|
|
448
|
-
|
|
449
|
-
|
|
440
|
+
with capture_stdout():
|
|
441
|
+
...
|
|
450
442
|
"""
|
|
451
|
-
start capture stdout
|
|
452
443
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if
|
|
444
|
+
def __init__(self, include_print: bool = True, clear=True):
|
|
445
|
+
self.stdout = sys.stdout
|
|
446
|
+
self.include_print = include_print
|
|
447
|
+
if clear:
|
|
448
|
+
_buffer.clear()
|
|
457
449
|
|
|
458
|
-
|
|
450
|
+
def __enter__(self):
|
|
451
|
+
sys.stdout = self
|
|
459
452
|
|
|
460
|
-
|
|
461
|
-
|
|
453
|
+
def __exit__(self, exc_type, exc_value, tb):
|
|
454
|
+
sys.stdout = self.stdout
|
|
462
455
|
|
|
463
|
-
|
|
456
|
+
def write(self, data):
|
|
457
|
+
_buffer.append(data)
|
|
458
|
+
if self.include_print:
|
|
459
|
+
self.stdout.write(data)
|
|
464
460
|
|
|
465
|
-
|
|
466
|
-
if
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
raise ValueError("at least one of do_print and do_capture should be True")
|
|
470
|
-
|
|
471
|
-
if do_capture:
|
|
472
|
-
if sys.stdout is _org_stdout:
|
|
473
|
-
sys.stdout = handle_capture_stdout()
|
|
474
|
-
_do_print=do_print
|
|
475
|
-
else:
|
|
476
|
-
sys.stdout=_org_stdout
|
|
461
|
+
def flush(self):
|
|
462
|
+
if self.include_print:
|
|
463
|
+
self.stdout.flush()
|
|
464
|
+
_buffer.append("\n")
|
|
477
465
|
|
|
478
466
|
if __name__ == "__main__":
|
|
479
467
|
...
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
|
|
2
|
+
xlwings_utils/xlwings_utils.py,sha256=8eVnPAY7ZzRt_beOq8uyBG2mY7Hu7uiyriYRLOK9DoU,12839
|
|
3
|
+
xlwings_utils-0.0.7.post3.dist-info/METADATA,sha256=GDhsqh9Vu0ZCfe9_FGERX07Xxvrb874BWel3x55-1V4,5695
|
|
4
|
+
xlwings_utils-0.0.7.post3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
5
|
+
xlwings_utils-0.0.7.post3.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
|
|
6
|
+
xlwings_utils-0.0.7.post3.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
|
|
2
|
-
xlwings_utils/xlwings_utils.py,sha256=kbfgeEj3IXA6-5ZTqtp2IJcJbKhJ-bqZZa7UgerqLVA,13140
|
|
3
|
-
xlwings_utils-0.0.7.post2.dist-info/METADATA,sha256=rLzJ1x21CLpZLgZvnIlKq3kJ_4ieRRBxfv5ieAlDsao,5695
|
|
4
|
-
xlwings_utils-0.0.7.post2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
5
|
-
xlwings_utils-0.0.7.post2.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
|
|
6
|
-
xlwings_utils-0.0.7.post2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|