movoid-debug 1.0.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.
@@ -0,0 +1 @@
1
+ prune test
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.1
2
+ Name: movoid_debug
3
+ Version: 1.0.0
4
+ Home-page:
5
+ Author: movoid
6
+ Author-email: bobrobotsun@163.com
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: movoid_function
9
+
10
+ This is a simple program for developer to
@@ -0,0 +1 @@
1
+ This is a simple program for developer to
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ # File : __init__.py
5
+ # Author : Sun YiFan-Movoid
6
+ # Time : 2024/4/14 16:15
7
+ # Description :
8
+ """
9
+ from simple_debug import DEBUG, SimpleDebug
@@ -0,0 +1,51 @@
1
+ #! /usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ # File : flow
5
+ # Author : Sun YiFan-Movoid
6
+ # Time : 2024/4/14 16:15
7
+ # Description :
8
+ """
9
+
10
+ from movoid_function import Function
11
+
12
+
13
+ class FlowFunction:
14
+ def __init__(self, func, args, kwargs, flow, ignore_exception):
15
+ self._func = Function(func, args, kwargs)
16
+ self._flow = flow
17
+ self._ignore_exception = ignore_exception
18
+ self._init = True
19
+ self._exception = None
20
+
21
+ def __call__(self):
22
+ while True:
23
+ try:
24
+ self.ask_call()
25
+ break
26
+ except:
27
+ break
28
+
29
+ def ask_call(self):
30
+ if self._init:
31
+ self._init = False
32
+ return self._func()
33
+ else:
34
+ ask_str = input('请输入操作方案(1)重新执行(2)返回None跳过执行(3)输入返回值后跳过执行(4)重新输入参数后执行(其他)认可失败,退出:')
35
+ if ask_str == '1':
36
+ return self._func()
37
+ elif ask_str == '2':
38
+ return None
39
+ elif ask_str == '3':
40
+ ask_return = input('请输入返回值:')
41
+ return eval(ask_return)
42
+ elif ask_str == '4':
43
+ ask_args = input('请输入参数值:')
44
+ return eval(f'self._func({ask_args})')
45
+ else:
46
+ raise self._exception
47
+
48
+
49
+ class Flow:
50
+ def __init__(self):
51
+ self._function_list = []
@@ -0,0 +1,65 @@
1
+ #! /usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ # File : simple_debug
5
+ # Author : Sun YiFan-Movoid
6
+ # Time : 2024/5/20 1:52
7
+ # Description :
8
+ """
9
+ import traceback
10
+ from movoid_function import wraps, Function
11
+
12
+
13
+ class ErrorFunction:
14
+ def __init__(self, func, args, kwargs, error):
15
+ self.func = func
16
+ self.args = args
17
+ self.kwargs = kwargs
18
+ self.error = error
19
+ self.traceback = traceback.format_exc()
20
+
21
+
22
+ class SimpleDebug:
23
+ def __init__(self):
24
+ self._error_list = []
25
+
26
+ def when_error(self, _continue=True, error_teardown=None, error_teardown_args=None, error_teardown_kwargs=None):
27
+ if isinstance(_continue, bool):
28
+ error_teardown_function = Function(error_teardown, error_teardown_args, error_teardown_kwargs)
29
+
30
+ def dec(func):
31
+ @wraps(func)
32
+ def wrapping(*args, **kwargs):
33
+ try:
34
+ re_value = func(*args, **kwargs)
35
+ except Exception as err:
36
+ if _continue:
37
+ self._error_list.append(ErrorFunction(func, args, kwargs, err))
38
+ try:
39
+ error_teardown_function()
40
+ except:
41
+ print(f'fail to teardown:\n{traceback.format_exc()}')
42
+ else:
43
+ raise err
44
+ else:
45
+ return re_value
46
+
47
+ return wrapping
48
+
49
+ return dec
50
+ else:
51
+ return self.when_error()(_continue)
52
+
53
+ def raise_all(self):
54
+ raise DebugError(self._error_list)
55
+
56
+
57
+ class DebugError(Exception):
58
+ def __init__(self, error_list, *args):
59
+ all_info = ''
60
+ for error in error_list:
61
+ all_info += f'{error.func.__name__}{error.args}{error.kwargs}:{error.error}\n{error.traceback}\n'
62
+ super().__init__(all_info, *args)
63
+
64
+
65
+ DEBUG = SimpleDebug()
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.1
2
+ Name: movoid_debug
3
+ Version: 1.0.0
4
+ Home-page:
5
+ Author: movoid
6
+ Author-email: bobrobotsun@163.com
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: movoid_function
9
+
10
+ This is a simple program for developer to
@@ -0,0 +1,11 @@
1
+ MANIFEST.in
2
+ README.md
3
+ setup.py
4
+ movoid_debug/__init__.py
5
+ movoid_debug/flow.py
6
+ movoid_debug/simple_debug.py
7
+ movoid_debug.egg-info/PKG-INFO
8
+ movoid_debug.egg-info/SOURCES.txt
9
+ movoid_debug.egg-info/dependency_links.txt
10
+ movoid_debug.egg-info/requires.txt
11
+ movoid_debug.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ movoid_function
@@ -0,0 +1,2 @@
1
+ movoid_debug
2
+ test
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding='utf-8') as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name='movoid_debug',
8
+ version='1.0.0',
9
+ packages=find_packages(),
10
+ url='',
11
+ license='',
12
+ author='movoid',
13
+ author_email='bobrobotsun@163.com',
14
+ description='',
15
+ long_description=long_description,
16
+ long_description_content_type="text/markdown",
17
+ install_requires=[
18
+ 'movoid_function'
19
+ ],
20
+ )