Coverage for sources/accretive/namespaces.py: 100%
22 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 23:02 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 23:02 +0000
1# vim: set filetype=python fileencoding=utf-8:
2# -*- coding: utf-8 -*-
4#============================================================================#
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#============================================================================#
21''' Accretive namespaces. '''
24from . import __
25from . import objects as _objects
28class Namespace( _objects.Object ): # pylint: disable=eq-without-hash
29 ''' Accretive namespaces. '''
31 def __init__(
32 self,
33 *iterables: __.DictionaryPositionalArgument,
34 **attributes: __.DictionaryNominativeArgument
35 ) -> None:
36 super( ).__init__( )
37 super( ).__getattribute__( '__dict__' ).update(
38 *iterables, **attributes )
40 def __repr__( self ) -> str:
41 attributes = ', '.join( tuple(
42 f"{key} = {value!r}" for key, value
43 in super( ).__getattribute__( '__dict__' ).items( ) ) )
44 fqname = __.calculate_fqname( self )
45 if not attributes: return f"{fqname}( )"
46 return f"{fqname}( {attributes} )"
48 def __eq__( self, other: __.a.Any ) -> __.ComparisonResult:
49 mydict = super( ).__getattribute__( '__dict__' )
50 if isinstance( other, ( Namespace, __.SimpleNamespace ) ):
51 return mydict == other.__dict__
52 return NotImplemented
54 def __ne__( self, other: __.a.Any ) -> __.ComparisonResult:
55 mydict = super( ).__getattribute__( '__dict__' )
56 if isinstance( other, ( Namespace, __.SimpleNamespace ) ):
57 return mydict != other.__dict__
58 return NotImplemented
60Namespace.__doc__ = __.generate_docstring(
61 Namespace, 'description of namespace', 'instance attributes accretion' )