cengal.code_flow_control.smart_values.versions.v_0.result_types
Module Docstring Docstrings: http://www.python.org/dev/peps/pep-0257/
1#!/usr/bin/env python 2# coding=utf-8 3 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space> 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18""" 19Module Docstring 20Docstrings: http://www.python.org/dev/peps/pep-0257/ 21""" 22 23__author__ = "ButenkoMS <gtalk@butenkoms.space>" 24__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>" 25__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ] 26__license__ = "Apache License, Version 2.0" 27__version__ = "4.4.1" 28__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>" 29__email__ = "gtalk@butenkoms.space" 30# __status__ = "Prototype" 31__status__ = "Development" 32# __status__ = "Production" 33 34 35class ResultExistence: 36 __slots__ = ('existence', 'result') 37 38 def __init__(self, existence, result): 39 self.existence = existence 40 self.result = result 41 42 def __bool__(self): 43 return self.existence 44 45 def __nonzero__(self): 46 return self.__bool__() 47 48 def __str__(self): 49 return '{}: {}'.format(self.existence, self.result) 50 51 def __getstate__(self): 52 return self.existence, self.result 53 54 def __setstate__(self, state): 55 existence, value = state 56 self.value = value 57 self.existence = existence 58 59 def __eq__(self, __value: object) -> bool: 60 if isinstance(__value, ResultExistence): 61 return (self.existence == __value.existence) and (self.value == __value.value) 62 else: 63 if self.existence: 64 return self.value == __value 65 else: 66 return False 67 68 def __ne__(self, __value: object) -> bool: 69 return not self.__eq__(__value) 70 71 72class ResultCache(ResultExistence): 73 __slots__ = tuple() 74 75 def __init__(self): 76 super(ResultCache, self).__init__(False, None) 77 78 def __call__(self, *args, **kwargs): 79 self.existence = False 80 81 def get(self): 82 return self.result 83 84 def set(self, new_result): 85 self.existence = True 86 self.result = new_result 87 88 def __getstate__(self): 89 return self.existence, self.result 90 91 def __setstate__(self, state): 92 existence, value = state 93 self.value = value 94 self.existence = existence 95 96 def __eq__(self, __value: object) -> bool: 97 if isinstance(__value, ResultExistence): 98 return (self.existence == __value.existence) and (self.value == __value.value) 99 else: 100 if self.existence: 101 return self.value == __value 102 else: 103 return False 104 105 def __ne__(self, __value: object) -> bool: 106 return not self.__eq__(__value) 107 108 109class ResultType: 110 __slots__ = ('type_id', 'result') 111 112 def __init__(self, type_id, result): 113 self.type_id = type_id 114 self.result = result 115 116 def __eq__(self, other): 117 # "__ne__() delegates to __eq__() and inverts the result" 118 # if type(other) == ResultType: 119 if isinstance(other, ResultType): 120 return self.type_id == other.type_id 121 else: 122 return self.type_id == other 123 124 def __getstate__(self): 125 return self.type_id, self.result 126 127 def __setstate__(self, state): 128 self.type_id, self.result = state
class
ResultExistence:
36class ResultExistence: 37 __slots__ = ('existence', 'result') 38 39 def __init__(self, existence, result): 40 self.existence = existence 41 self.result = result 42 43 def __bool__(self): 44 return self.existence 45 46 def __nonzero__(self): 47 return self.__bool__() 48 49 def __str__(self): 50 return '{}: {}'.format(self.existence, self.result) 51 52 def __getstate__(self): 53 return self.existence, self.result 54 55 def __setstate__(self, state): 56 existence, value = state 57 self.value = value 58 self.existence = existence 59 60 def __eq__(self, __value: object) -> bool: 61 if isinstance(__value, ResultExistence): 62 return (self.existence == __value.existence) and (self.value == __value.value) 63 else: 64 if self.existence: 65 return self.value == __value 66 else: 67 return False 68 69 def __ne__(self, __value: object) -> bool: 70 return not self.__eq__(__value)
73class ResultCache(ResultExistence): 74 __slots__ = tuple() 75 76 def __init__(self): 77 super(ResultCache, self).__init__(False, None) 78 79 def __call__(self, *args, **kwargs): 80 self.existence = False 81 82 def get(self): 83 return self.result 84 85 def set(self, new_result): 86 self.existence = True 87 self.result = new_result 88 89 def __getstate__(self): 90 return self.existence, self.result 91 92 def __setstate__(self, state): 93 existence, value = state 94 self.value = value 95 self.existence = existence 96 97 def __eq__(self, __value: object) -> bool: 98 if isinstance(__value, ResultExistence): 99 return (self.existence == __value.existence) and (self.value == __value.value) 100 else: 101 if self.existence: 102 return self.value == __value 103 else: 104 return False 105 106 def __ne__(self, __value: object) -> bool: 107 return not self.__eq__(__value)
Inherited Members
class
ResultType:
110class ResultType: 111 __slots__ = ('type_id', 'result') 112 113 def __init__(self, type_id, result): 114 self.type_id = type_id 115 self.result = result 116 117 def __eq__(self, other): 118 # "__ne__() delegates to __eq__() and inverts the result" 119 # if type(other) == ResultType: 120 if isinstance(other, ResultType): 121 return self.type_id == other.type_id 122 else: 123 return self.type_id == other 124 125 def __getstate__(self): 126 return self.type_id, self.result 127 128 def __setstate__(self, state): 129 self.type_id, self.result = state