error-values 0.1.5__tar.gz → 0.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: error_values
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Description-Content-Type: text/markdown
5
5
  Dynamic: description
6
6
  Dynamic: description-content-type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: error_values
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Description-Content-Type: text/markdown
5
5
  Dynamic: description
6
6
  Dynamic: description-content-type
@@ -0,0 +1,4 @@
1
+ error_values.egg-info/PKG-INFO
2
+ error_values.egg-info/SOURCES.txt
3
+ error_values.egg-info/dependency_links.txt
4
+ error_values.egg-info/top_level.txt
File without changes
@@ -1,103 +0,0 @@
1
- from enum import Enum, auto
2
- from typing import Generic, TypeVar, Optional, Any
3
- from inspect import isclass
4
-
5
-
6
- class Result(Enum):
7
- FAIL = auto()
8
- PASS = auto()
9
-
10
-
11
- T = TypeVar("T", bound=Exception)
12
- U = TypeVar("U")
13
-
14
-
15
- class No_Error(Exception):
16
- """
17
- this is no errors and this is created to
18
- put in the scond type in Potential_Error if there is no error
19
- """
20
- pass
21
-
22
-
23
- class Did_Not_Handeled_Exception(Exception):
24
- pass
25
-
26
-
27
- class Attmped_To_Dewrap_While_Have_Error(Exception):
28
- pass
29
-
30
-
31
- class Potential_Error(Generic[U, T]):
32
-
33
- def __init__(self, value: U, error: Optional[T] = None):
34
- self.__val = value
35
- self.error = error
36
- self.handled = False
37
-
38
- def stat(self) -> Result:
39
- self.Handled = True
40
- return self.raw_stat()
41
-
42
- def dewrap(self) -> U:
43
- """this return the value, only if
44
- you handle the cas that it is an error."""
45
- if self.Handled:
46
- return self.__val
47
- if self.error != No_Error:
48
- raise Attmped_To_Dewrap_While_Have_Error(
49
- "you mustn't have errors "
50
- "inorder to dewrapp")
51
- raise Did_Not_Handeled_Exception(
52
- "you forgot to handle the "
53
- "speciel case. That case "
54
- "being if an error "
55
- "occured. Inordr to fix "
56
- "this you must call the "
57
- "stat method, then do this")
58
-
59
- def raw_stat(self):
60
- """
61
- this makes it so that it deosn't remember that
62
- it handle the variable.
63
- """
64
- if self.error is None or isinstance(self.error, No_Error):
65
- return Result.PASS
66
- else:
67
- return Result.FAIL
68
-
69
- def raise_error(self) -> None:
70
- raise self.error # type: ignore
71
-
72
-
73
- def potential_error_wrap(val: Any):
74
- if isclass(val) and issubclass(val, Exception):
75
- return Potential_Error(None, val())
76
- if issubclass(type(val), Exception):
77
- return Potential_Error(None, val) # type:ignore
78
- else:
79
- return Potential_Error(val, No_Error())
80
-
81
-
82
- def func_result_to_potential_error(func):
83
- """
84
- this is a wrappr for functions, the reason for this is so
85
- that you don't have to write potential_error_wrap all the time
86
- """
87
- def auto_wrap(*args, **kwargs):
88
- result = func(args, kwargs)
89
- return potential_error_wrap(result)
90
- return auto_wrap
91
-
92
-
93
- def dangerous_func_to_potntial_error(func):
94
- """
95
- this is for functions with raise
96
- """
97
- def auto_wrap(*args, **kwargs):
98
- try:
99
- result = func(args, kwargs)
100
- return potential_error_wrap(result)
101
- except Exception as e:
102
- return potential_error_wrap(e)
103
- return auto_wrap
@@ -1,12 +0,0 @@
1
- from setuptools import setup, find_packages
2
-
3
- from pathlib import Path
4
- this_directory = Path(__file__).parent
5
- long_description = (this_directory / "README.md").read_text()
6
-
7
- setup(
8
- name="error_values",
9
- version="0.1.5",
10
- packages=find_packages(),
11
- long_description=long_description,
12
- long_description_content_type='text/markdown')
@@ -1,7 +0,0 @@
1
- error_values/setup.py
2
- error_values.egg-info/PKG-INFO
3
- error_values.egg-info/SOURCES.txt
4
- error_values.egg-info/dependency_links.txt
5
- error_values.egg-info/top_level.txt
6
- error_values/error_values/__init__.py
7
- error_values/error_values/errors.py
File without changes