Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit bc128e0

Browse files
committed
updates
1 parent ace81f1 commit bc128e0

File tree

10 files changed

+188
-135
lines changed

10 files changed

+188
-135
lines changed

‎.idea/runConfigurations/examples.xml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎CONTRIBUTING.md‎

Whitespace-only changes.

‎README.md‎

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,52 @@
11
# PythonDebugTools
22

3-
debug helper functions
3+
*Pull requests and sugestions are welcome.*
44

55
## Getting Started
66

7-
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
7+
Helper tools to ease development.
88

9-
### Prerequisites
9+
### Tkinter
10+
All named colors in tkinter can be found in [colors.png](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/colors.png)
1011

11-
What things you need to install the software and how to install them
12+
All custom colors in tkinter can be found in [colors.py](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/colors.py)
1213

13-
```
14-
Give examples
15-
```
14+
All themes in tkinter can be found in [TkinterThemes.jpg](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/TkinterThemes.jpg)
1615

17-
### Installing
1816

19-
A step by step series of examples that tell you how to get a development env running
17+
### Debug
2018

21-
Say what the step will be
19+
[console.py](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/console.py) has functions to format an object to the console, allowing for easier debug.
2220

23-
```
24-
Give the example
25-
```
21+
[converters.py](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/converters.py) has functions to convert any object to a dict.
2622

27-
And repeat
23+
[decorators.py](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/decorators.py) has functions to be used as decorators to make debug more efficent.
2824

29-
```
30-
until finished
31-
```
25+
[chains.py](https://github.com/Jakar510/PythonDebugTools/tree/master/src/PythonDebugTools/chains.py) has functions to be used as decorators, in certain cases, to make debug more efficent.
3226

33-
End with an example of getting some data out of the system or using it for a little demo
27+
3428

35-
## Running the tests
3629

37-
Explain how to run the automated tests for this system
30+
## Installing
3831

39-
### Break down into end to end tests
32+
using pip3 or pip,
4033

41-
Explain what these tests test and why
42-
43-
```
44-
Give an example
45-
```
46-
47-
### And coding style tests
48-
49-
Explain what these tests test and why
50-
51-
```
52-
Give an example
53-
```
54-
55-
## Deployment
56-
57-
Add additional notes about how to deploy this on a live system
58-
59-
## Built With
60-
61-
*
62-
63-
## Object Structure
64-
65-
Please read [object_structure.json](https://github.com/Jakar510/PythonTkinterBindings/blob/master/src/object_struture.json) for details on the structure.
34+
pip3 install PythonDebugTools
6635

6736
## Contributing
6837

69-
Please read [CONTRIBUTING.md]() for details on our code of conduct, and the process for submitting pull requests to us.
38+
Please read [CONTRIBUTING.md](https://github.com/Jakar510/PythonDebugTools/tree/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
7039

7140
## Authors
7241

7342
* **Tyler Stegmaier** - *Initial work* - [Jakar510](https://github.com/Jakar510)
7443

75-
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
44+
See also the list of [contributors](https://github.com/Jakar510/PythonDebugTools/blob/master/contributors.md) who participated in this project.
7645

7746
## License
7847

79-
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
48+
This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the [LICENSE.md](https://github.com/Jakar510/PythonDebugTools/blob/master/LICENSE) file for details
8049

8150
## Acknowledgments
8251

83-
* Hat tip to anyone whose code was used
84-
* Inspiration
85-
* etc
52+
* [StackOverFlow Answer](https://stackoverflow.com/a/31485450/9530917)

‎contributors.md‎

Whitespace-only changes.

‎requirements.txt‎

Whitespace-only changes.

‎setup.py‎

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,39 @@
22

33
from setuptools import setup
44

5-
from src.PythonDebugTools import version
5+
from src.PythonDebugTools import __author__, __classifiers__, __email__, __license__, __maintainer__, __maintainer_email__, __name__, __short_description__, __url__, __version__
66

77

88

99

10+
with open(os.path.abspath("requirements.txt"), "r") as f:
11+
install_requires = f.readlines()
12+
1013
with open(os.path.abspath("README.md"), "r") as f:
1114
long_description = f.read()
1215

1316
data_files = [
14-
'PythonDebugTools/*.py'
17+
f'{__name__}/*.py'
1518
]
1619

17-
setup(name='PythonDebugTools',
18-
version=version,
19-
packages=['PythonDebugTools'],
20-
url='https://github.com/Jakar510/PythonDebugTools',
20+
setup(name=__name__,
21+
version=__version__,
22+
packages=[__name__],
23+
url=__url__,
2124
# download_url=f'https://github.com/Jakar510/PythonDebugTools/releases/tag/{version}',
22-
license='GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007',
23-
author='Tyler Stegmaier',
24-
author_email='tyler.stegmaier.510@gmail.com',
25-
description='A set of helpers for debugging Python 3.x.',
25+
license=__license__ or 'GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007',
26+
author=__author__,
27+
author_email=__email__,
28+
maintainer=__maintainer__,
29+
maintainer_email=__maintainer_email__,
30+
description=__short_description__,
2631
long_description=long_description,
2732
long_description_content_type="text/markdown",
28-
install_requires=[],
29-
classifiers=[
30-
# How mature is this project? Common values are
31-
# 3 - Alpha
32-
# 4 - Beta
33-
# 5 - Production/Stable
34-
'Development Status :: 4 - Beta',
35-
36-
# Indicate who your project is intended for
37-
'Intended Audience :: Developers',
38-
'Topic :: Software Development :: Build Tools',
39-
40-
# Pick your license as you wish
41-
'License :: Free To Use But Restricted',
42-
43-
# Support platforms
44-
'Operating System :: MacOS',
45-
'Operating System :: Microsoft :: Windows',
46-
'Operating System :: POSIX',
47-
48-
'Programming Language :: Python :: 3',
49-
],
33+
install_requires=install_requires,
34+
classifiers=__classifiers__,
5035
keywords='switch switch-case case',
51-
package_dir={ 'PythonDebugTools': 'src/PythonDebugTools' },
36+
package_dir={ __name__: f'src/{__name__}' },
5237
package_data={
53-
'PythonDebugTools': data_files,
38+
__name__: data_files,
5439
},
5540
)

‎src/PythonDebugTools/__init__.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,45 @@ def get_size(obj, seen: set = set()):
2828
elif hasattr(obj, '__iter__') and not isinstance(obj, (str, bytes, bytearray)):
2929
size += sum([get_size(i, seen) for i in obj])
3030
return size
31+
32+
33+
34+
__name__ = 'PythonDebugTools'
35+
__author__ = "Tyler Stegmaier"
36+
__email__ = "tyler.stegmaier.510@gmail.com"
37+
__copyright__ = "Copyright 2020"
38+
__credits__ = [
39+
"Copyright (c) 2020 Tyler Stegmaier",
40+
]
41+
__license__ = "GPL 3.0"
42+
__version__ = version
43+
__maintainer__ = __author__
44+
__maintainer_email__ = __email__
45+
46+
# How mature is this project? Common values are
47+
# 3 - Alpha
48+
# 4 - Beta
49+
# 5 - Production/Stable
50+
__status__ = 'Development Status :: 4 - Beta'
51+
52+
__url__ = fr'https://github.com/Jakar510/{__name__}'
53+
# download_url=f'https://github.com/Jakar510/PyDebug/TkinterExtensions/releases/tag/{version}'
54+
__classifiers__ = [
55+
__status__,
56+
57+
# Indicate who your project is intended for
58+
'Intended Audience :: Developers',
59+
'Topic :: Software Development :: Build Tools',
60+
61+
# Pick your license as you wish
62+
'License :: Free To Use But Restricted',
63+
64+
# Support platforms
65+
'Operating System :: MacOS',
66+
'Operating System :: Microsoft :: Windows',
67+
'Operating System :: POSIX',
68+
69+
'Programming Language :: Python :: 3',
70+
]
71+
72+
__short_description__ = 'A set of helpers for debugging Python 3.x.'

‎src/PythonDebugTools/__version__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# ------------------------------------------------------------------------------
66

77
# major.minor[.maintenance]
8-
VERSION = (1, 7, 5)
8+
VERSION = (1, 8, 1)
99

10-
__version__=version = '.'.join(map(str, VERSION))
10+
version = '.'.join(map(str, VERSION))
1111

1212

‎src/PythonDebugTools/console.py‎

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,68 @@
1-
import pprint
1+
import sys
22
import traceback
3+
from pprint import PrettyPrinter
34

45

56

67

78
__all__ = ['PRINT', 'getPPrintStr', 'print_exception']
89
debug = __debug__
910

10-
pp = pprint.PrettyPrinter(indent=4)
11-
def PRINT(title: str, *args, **kwargs):
11+
class NoStringWrappingPrettyPrinter(PrettyPrinter):
12+
"""
13+
https://stackoverflow.com/questions/31485402/can-i-make-pprint-in-python3-not-split-strings-like-in-python2
14+
https://stackoverflow.com/a/31485450/9530917
15+
"""
16+
@classmethod
17+
def Create(cls): return cls(indent=4, sort_dicts=False)
18+
19+
# noinspection PyProtectedMember, PyUnresolvedReferences
20+
def _format(self, o, *args):
21+
if isinstance(o, (str, bytes, bytearray)):
22+
width = self._width
23+
self._width = sys.maxsize
24+
try:
25+
super()._format(o, *args)
26+
finally:
27+
self._width = width
28+
else:
29+
super()._format(o, *args)
30+
31+
pp = NoStringWrappingPrettyPrinter.Create()
32+
33+
def PRINT(title: str, *args, _pp: PrettyPrinter = None, use_double_quotes: bool = True, **kwargs):
34+
"""
35+
:param title: message to start the print, to make it easier to find it.
36+
:type title: str
37+
:param o: object to be serialized
38+
:type o: any
39+
:param _pp: any PrettyPrinter inpmentation. provide your own to customize the output.
40+
:type _pp: PrettyPrinter
41+
:param use_double_quotes: use double quotes (") instead of the default single quotes (')
42+
:type use_double_quotes:
43+
:return: formatted string of the passed object
44+
:rtype: str
45+
"""
1246
if not debug: return
1347
print(f"\n ---------------- {title} ---------------- \n\r")
14-
pp.pprint(dict(args=args, kwargs=kwargs))
48+
print(getPPrintStr(dict(args=args, kwargs=kwargs), _pp=_pp, use_double_quotes=use_double_quotes))
1549

1650

1751

18-
def getPPrintStr(Object: any) -> str: return f'{pp.pformat(Object)}'
52+
def getPPrintStr(o: any, *, _pp: PrettyPrinter = None, use_double_quotes: bool = True) -> str:
53+
"""
54+
:param o: object to be serialized
55+
:type o: any
56+
:param _pp: any PrettyPrinter inpmentation. provide your own to customize the output.
57+
:type _pp: PrettyPrinter
58+
:param use_double_quotes: use double quotes (") instead of the default single quotes (')
59+
:type use_double_quotes:
60+
:return: formatted string of the passed object
61+
:rtype: str
62+
"""
63+
s = (_pp or pp).pformat(o)
64+
if use_double_quotes: s = s.replace("'", '"')
65+
return s
1966

2067

2168

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /