Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit c429395

Browse files
committed
Adjust color conversions to assume networkx 2.0+
1 parent 3c5552c commit c429395

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

colormath/color_conversions.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,17 @@ def get_conversion_path(self, start_type, target_type):
114114
# Look up edges between nodes and retrieve the conversion function for each edge.
115115
return [self.conversion_graph.get_edge_data(node_a, node_b)['conversion_function'] for node_a, node_b in
116116
zip(path[:-1], path[1:])]
117-
except networkx.NetworkXNoPath:
117+
except (networkx.NetworkXNoPath, networkx.NodeNotFound):
118118
raise UndefinedConversionError(
119119
start_type,
120120
target_type,
121121
)
122122

123123
def add_type_conversion(self, start_type, target_type, conversion_function):
124-
super(GraphConversionManager, self).add_type_conversion(start_type, target_type, conversion_function)
125-
if networkx.__version__.startswith('2'):
126-
self.conversion_graph.add_edge(start_type, target_type, conversion_function=conversion_function)
127-
else:
128-
self.conversion_graph.add_edge(start_type, target_type, {'conversion_function': conversion_function})
124+
super(GraphConversionManager, self).add_type_conversion(
125+
start_type, target_type, conversion_function)
126+
self.conversion_graph.add_edge(
127+
start_type, target_type, conversion_function=conversion_function)
129128

130129

131130
class DummyConversionManager(ConversionManager):

0 commit comments

Comments
 (0)