mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-23 11:36:30 +00:00
NetworkXGraphEdgeDescriptor: Use __set_name__.
Still need the __init__ use to handle a single case of overriding the name. Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
This commit is contained in:
parent
2d1de939ba
commit
967e862ab1
@ -189,8 +189,8 @@ class NetworkXGraphEdgeDescriptor(ABC):
|
||||
"""
|
||||
Descriptor abstract base class for NetworkX graph edge attributes.
|
||||
|
||||
Parameter:
|
||||
name The edge property name
|
||||
Keyword Parameter:
|
||||
name Override the graph edge property name.
|
||||
|
||||
Instance class attribute use (obj parameter):
|
||||
G The NetworkX graph
|
||||
@ -198,8 +198,11 @@ class NetworkXGraphEdgeDescriptor(ABC):
|
||||
target The edge's target node
|
||||
"""
|
||||
|
||||
def __init__(self, propname: str) -> None:
|
||||
self.name = propname
|
||||
def __init__(self, propname: Optional[str] = None) -> None:
|
||||
self.override_name = propname
|
||||
|
||||
def __set_name__(self, owner, name):
|
||||
self.name = self.override_name if self.override_name else name
|
||||
|
||||
def __get__(self, obj, objtype=None):
|
||||
if obj is None:
|
||||
|
@ -595,13 +595,13 @@ class Edge:
|
||||
The default is False.
|
||||
"""
|
||||
|
||||
transition = EdgeAttrList('transition')
|
||||
setexec = EdgeAttrList('setexec')
|
||||
dyntransition = EdgeAttrList('dyntransition')
|
||||
setcurrent = EdgeAttrList('setcurrent')
|
||||
entrypoint = EdgeAttrDict('entrypoint')
|
||||
execute = EdgeAttrDict('execute')
|
||||
type_transition = EdgeAttrDict('type_transition')
|
||||
transition = EdgeAttrList()
|
||||
setexec = EdgeAttrList()
|
||||
dyntransition = EdgeAttrList()
|
||||
setcurrent = EdgeAttrList()
|
||||
entrypoint = EdgeAttrDict()
|
||||
execute = EdgeAttrDict()
|
||||
type_transition = EdgeAttrDict()
|
||||
|
||||
def __init__(self, graph, source: Type, target: Type, create: bool = False) -> None:
|
||||
self.G = graph
|
||||
|
@ -405,7 +405,7 @@ class InfoFlowStep:
|
||||
The default is False.
|
||||
"""
|
||||
|
||||
rules = EdgeAttrList('rules')
|
||||
rules = EdgeAttrList()
|
||||
|
||||
# use capacity to store the info flow weight so
|
||||
# we can use network flow algorithms naturally.
|
||||
|
Loading…
Reference in New Issue
Block a user