fname
stringlengths
63
176
rel_fname
stringclasses
706 values
line
int64
-1
4.5k
name
stringlengths
1
81
kind
stringclasses
2 values
category
stringclasses
2 values
info
stringlengths
0
77.9k
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
171
get_callbacks
def
function
def get_callbacks(self, node): """Get callbacks from handler for the visited node.""" klass = node.__class__ methods = self._cache.get(klass) if methods is None: handler = self.handler kid = klass.__name__.lower() e_method = getattr( handler, f"visit_{kid}", getattr(handler, "visit_default", None) ) l_method = getattr( handler, f"leave_{kid}", getattr(handler, "leave_default", None) ) self._cache[klass] = (e_method, l_method) else: e_method, l_method = methods return e_method, l_method def visit(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[0] if method is not None: method(node) def leave(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[1] if method is not None: method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
189
visit
def
function
def visit(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[0] if method is not None: method(node) def leave(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[1] if method is not None: method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
191
get_callbacks
ref
function
method = self.get_callbacks(node)[0]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
193
method
ref
function
method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
195
leave
def
function
def leave(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[1] if method is not None: method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
197
get_callbacks
ref
function
method = self.get_callbacks(node)[1]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
199
method
ref
function
method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
202
LocalsVisitor
def
class
__init__ visit
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
209
visit
def
function
def visit(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[0] if method is not None: method(node) def leave(self, node): """Walk on the tree from <node>, getting callbacks from handler.""" method = self.get_callbacks(node)[1] if method is not None: method(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
215
get_callbacks
ref
function
methods = self.get_callbacks(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
220
visit
ref
function
self.visit(local_node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
226
get_annotation_label
def
function
def get_annotation_label(ann: Union[nodes.Name, nodes.Subscript]) -> str: label = "" if isinstance(ann, nodes.Subscript): label = ann.as_string() elif isinstance(ann, nodes.Name): label = ann.name return label
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
229
as_string
ref
function
label = ann.as_string()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
235
get_annotation
def
function
def get_annotation( node: Union[nodes.AssignAttr, nodes.AssignName]
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
253
infer
ref
function
default, *_ = node.infer()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
257
get_annotation_label
ref
function
label = get_annotation_label(ann)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
270
infer_node
def
function
def infer_node(node: Union[nodes.AssignAttr, nodes.AssignName]) -> set: """Return a set containing the node annotation if it exists otherwise return a set of the inferred types using the NodeNG.infer method """ ann = get_annotation(node) try: if ann: if isinstance(ann, nodes.Subscript): return {ann} return set(ann.infer()) return set(node.infer()) except astroid.InferenceError: return {ann} if ann else set()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
275
get_annotation
ref
function
ann = get_annotation(node)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
280
infer
ref
function
return set(ann.infer())
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
281
infer
ref
function
return set(node.infer())
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/utils.py
pylint/pyreverse/utils.py
286
check_graphviz_availability
def
function
def check_graphviz_availability(): """Check if the ``dot`` command is available on the machine. This is needed if image output is desired and ``dot`` is used to convert from *.dot or *.gv into the final output format. """ if shutil.which("dot") is None: print( "The requested output format is currently not available.\n" "Please install 'Graphviz' to have other output formats " "than 'dot' or 'vcg'." ) sys.exit(32)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
187
VCGPrinter
def
class
_open_graph _close_graph emit_node _build_label_for_node emit_edge _write_attributes
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
188
_open_graph
def
function
def _open_graph(self) -> None: """Emit the header lines.""" self.emit("graph:{\n") self._inc_indent() self._write_attributes( GRAPH_ATTRS, title=self.title, layoutalgorithm="dfs", late_edge_labels="yes", port_sharing="no", manhattan_edges="yes", ) if self.layout: self._write_attributes(GRAPH_ATTRS, orientation=ORIENTATION[self.layout]) def _close_graph(self) -> None: """Emit the lines needed to properly close the graph.""" self._dec_indent() self.emit("}") def emit_node( self, name: str, type_: NodeType, properties: Optional[NodeProperties] = None, ) -> None: """Create a new node. Nodes can be classes, packages, participants etc.""" if properties is None: properties = NodeProperties(label=name) elif properties.label is None: properties.label = name self.emit(f'node: {{title:"{name}"', force_newline=_False) self._write_attributes( NODE_ATTRS, label=self._build_label_for_node(properties), shape=SHAPES[type_], ) self.emit("}") @staticmethod def _build_label_for_node(properties: NodeProperties) -> str: fontcolor = "\f09" if properties.fontcolor == "red" else "" label = rf"\fb{fontcolor}{properties.label}\fn" if properties.attrs is None and properties.methods is None: # return a compact form which only displays the classname in a box return label attrs = properties.attrs or [] methods = properties.methods or [] method_names = [func.name for func in methods] # box width for UML like diagram maxlen = max(len(name) for name in [properties.label] + method_names + attrs) line = "_" * (maxlen + 2) label = rf"{label}\n\f{line}" for attr in attrs: label = rf"{label}\n\f08{attr}" if attrs: label = rf"{label}\n\f{line}" for func in method_names: label = rf"{label}\n\f10{func}()" return label def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: Optional[str] = None, ) -> None: """Create an edge from one node to another to display relationships.""" self.emit( f'edge: {{sourcename:"{from_node}" targetname:"{to_node}"', force_newline=_False, ) attributes = ARROWS[type_] if label: attributes["label"] = label self._write_attributes( EDGE_ATTRS, **attributes, ) self.emit("}") def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
190
emit
ref
function
self.emit("graph:{\n")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
191
_inc_indent
ref
function
self._inc_indent()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
192
_write_attributes
ref
function
self._write_attributes(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
201
_write_attributes
ref
function
self._write_attributes(GRAPH_ATTRS, orientation=ORIENTATION[self.layout])
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
203
_close_graph
def
function
def _close_graph(self) -> None: """Emit the lines needed to properly close the graph.""" self._dec_indent() self.emit("}") def emit_node( self, name: str, type_: NodeType, properties: Optional[NodeProperties] = None, ) -> None: """Create a new node. Nodes can be classes, packages, participants etc.""" if properties is None: properties = NodeProperties(label=name) elif properties.label is None: properties.label = name self.emit(f'node: {{title:"{name}"', force_newline=_False) self._write_attributes( NODE_ATTRS, label=self._build_label_for_node(properties), shape=SHAPES[type_], ) self.emit("}") @staticmethod def _build_label_for_node(properties: NodeProperties) -> str: fontcolor = "\f09" if properties.fontcolor == "red" else "" label = rf"\fb{fontcolor}{properties.label}\fn" if properties.attrs is None and properties.methods is None: # return a compact form which only displays the classname in a box return label attrs = properties.attrs or [] methods = properties.methods or [] method_names = [func.name for func in methods] # box width for UML like diagram maxlen = max(len(name) for name in [properties.label] + method_names + attrs) line = "_" * (maxlen + 2) label = rf"{label}\n\f{line}" for attr in attrs: label = rf"{label}\n\f08{attr}" if attrs: label = rf"{label}\n\f{line}" for func in method_names: label = rf"{label}\n\f10{func}()" return label def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: Optional[str] = None, ) -> None: """Create an edge from one node to another to display relationships.""" self.emit( f'edge: {{sourcename:"{from_node}" targetname:"{to_node}"', force_newline=_False, ) attributes = ARROWS[type_] if label: attributes["label"] = label self._write_attributes( EDGE_ATTRS, **attributes, ) self.emit("}") def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
205
_dec_indent
ref
function
self._dec_indent()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
206
emit
ref
function
self.emit("}")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
208
emit_node
def
function
def emit_node( self, name: str, type_: NodeType, properties: Optional[NodeProperties] = None, ) -> None: """Create a new node. Nodes can be classes, packages, participants etc.""" if properties is None: properties = NodeProperties(label=name) elif properties.label is None: properties.label = name self.emit(f'node: {{title:"{name}"', force_newline=_False) self._write_attributes( NODE_ATTRS, label=self._build_label_for_node(properties), shape=SHAPES[type_], ) self.emit("}") @staticmethod def _build_label_for_node(properties: NodeProperties) -> str: fontcolor = "\f09" if properties.fontcolor == "red" else "" label = rf"\fb{fontcolor}{properties.label}\fn" if properties.attrs is None and properties.methods is None: # return a compact form which only displays the classname in a box return label attrs = properties.attrs or [] methods = properties.methods or [] method_names = [func.name for func in methods] # box width for UML like diagram maxlen = max(len(name) for name in [properties.label] + method_names + attrs) line = "_" * (maxlen + 2) label = rf"{label}\n\f{line}" for attr in attrs: label = rf"{label}\n\f08{attr}" if attrs: label = rf"{label}\n\f{line}" for func in method_names: label = rf"{label}\n\f10{func}()" return label def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: Optional[str] = None, ) -> None: """Create an edge from one node to another to display relationships.""" self.emit( f'edge: {{sourcename:"{from_node}" targetname:"{to_node}"', force_newline=_False, ) attributes = ARROWS[type_] if label: attributes["label"] = label self._write_attributes( EDGE_ATTRS, **attributes, ) self.emit("}") def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
216
NodeProperties
ref
function
properties = NodeProperties(label=name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
219
emit
ref
function
self.emit(f'node: {{title:"{name}"', force_newline=False)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
220
_write_attributes
ref
function
self._write_attributes(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
222
_build_label_for_node
ref
function
label=self._build_label_for_node(properties),
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
225
emit
ref
function
self.emit("}")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
228
_build_label_for_node
def
function
def _build_label_for_node(properties: NodeProperties) -> str: fontcolor = "\f09" if properties.fontcolor == "red" else "" label = rf"\fb{fontcolor}{properties.label}\fn" if properties.attrs is None and properties.methods is None: # return a compact form which only displays the classname in a box return label attrs = properties.attrs or [] methods = properties.methods or [] method_names = [func.name for func in methods] # box width for UML like diagram maxlen = max(len(name) for name in [properties.label] + method_names + attrs) line = "_" * (maxlen + 2) label = rf"{label}\n\f{line}" for attr in attrs: label = rf"{label}\n\f08{attr}" if attrs: label = rf"{label}\n\f{line}" for func in method_names: label = rf"{label}\n\f10{func}()" return label def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: Optional[str] = None, ) -> None: """Create an edge from one node to another to display relationships.""" self.emit( f'edge: {{sourcename:"{from_node}" targetname:"{to_node}"', force_newline=_False, ) attributes = ARROWS[type_] if label: attributes["label"] = label self._write_attributes( EDGE_ATTRS, **attributes, ) self.emit("}") def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
249
emit_edge
def
function
def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: Optional[str] = None, ) -> None: """Create an edge from one node to another to display relationships.""" self.emit( f'edge: {{sourcename:"{from_node}" targetname:"{to_node}"', force_newline=_False, ) attributes = ARROWS[type_] if label: attributes["label"] = label self._write_attributes( EDGE_ATTRS, **attributes, ) self.emit("}") def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
257
emit
ref
function
self.emit(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
264
_write_attributes
ref
function
self._write_attributes(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
268
emit
ref
function
self.emit("}")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
270
_write_attributes
def
function
def _write_attributes(self, attributes_dict: Mapping[str, Any], **args) -> None: """Write graph, node or edge attributes.""" for key, value in args.items(): try: _type = attributes_dict[key] except KeyError as e: raise Exception( f"no such attribute {key}\npossible attributes are {attributes_dict.keys()}" ) from e if not _type: self.emit(f'{key}:"{value}"\n') elif _type == 1: self.emit(f"{key}:{int(value)}\n") elif value in _type: self.emit(f"{key}:{value}\n") else: raise Exception( f"value {value} isn't correct for attribute {key} correct values are {type}" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
281
emit
ref
function
self.emit(f'{key}:"{value}"\n')
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
283
emit
ref
function
self.emit(f"{key}:{int(value)}\n")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/vcg_printer.py
pylint/pyreverse/vcg_printer.py
285
emit
ref
function
self.emit(f"{key}:{value}\n")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
37
DiagramWriter
def
class
__init__ write write_packages write_classes set_printer get_package_properties get_class_properties get_shape_color save
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
42
get_printer_for_filetype
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
74
exists
ref
function
if os.path.exists(self.config.output_directory):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
76
set_printer
ref
function
self.set_printer(file_name, basename)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
78
write_classes
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
80
write_packages
ref
function
self.write_packages(diagram)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
81
save
ref
function
self.save()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
83
write_packages
def
function
def write_packages(self, diagram: PackageDiagram) -> None: """Write a package diagram.""" # sorted to get predictable (hence testable) results for module in sorted(diagram.modules(), key=lambda x: x.title): module.fig_id = module.node.qname() self.printer.emit_node( module.fig_id, type_=NodeType.PACKAGE, properties=self.get_package_properties(module), ) # package dependencies for rel in diagram.get_relationships("depends"): self.printer.emit_edge( rel.from_object.fig_id, rel.to_object.fig_id, type_=EdgeType.USES, ) def write_classes(self, diagram: ClassDiagram) -> None: """Write a class diagram.""" # sorted to get predictable (hence testable) results for obj in sorted(diagram.objects, key=lambda x: x.title): obj.fig_id = obj.node.qname() type_ = NodeType.INTERFACE if obj.shape == "interface" else NodeType.CLASS self.printer.emit_node( obj.fig_id, type_=type_, properties=self.get_class_properties(obj) ) # inheritance links for rel in diagram.get_relationships("specialization"): self.printer.emit_edge( rel.from_object.fig_id, rel.to_object.fig_id, type_=EdgeType.INHERITS, ) # implementation links for rel in diagram.get_relationships("implements"): self.printer.emit_edge( rel.from_object.fig_id, rel.to_object.fig_id, type_=EdgeType.IMPLEMENTS, ) # generate associations for rel in diagram.get_relationships("association"): self.printer.emit_edge( rel.from_object.fig_id, rel.to_object.fig_id, label=rel.name, type_=EdgeType.ASSOCIATION, ) def set_printer(self, file_name: str, basename: str) -> None: """Set printer.""" self.printer = self.printer_class(basename) self.file_name = file_name def get_package_properties(self, obj: PackageEntity) -> NodeProperties: """Get label and shape for packages.""" return NodeProperties( label=obj.title, color=self.get_shape_color(obj) if self.config.colorized else "black", ) def get_class_properties(self, obj: ClassEntity) -> NodeProperties: """Get label and shape for classes.""" properties = NodeProperties( label=obj.title, attrs=obj.attrs if not self.config.only_classnames else None, methods=obj.methods if not self.config.only_classnames else None, fontcolor="red" if is_exception(obj.node) else "black", color=self.get_shape_color(obj) if self.config.colorized else "black", ) return properties def get_shape_color(self, obj: DiagramEntity) -> str: """Get shape color.""" qualified_name = obj.node.qname() if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]): return "grey" if isinstance(obj.node, nodes.ClassDef): package = qualified_name.rsplit(".", maxsplit=2)[0] elif obj.node.package: package = qualified_name else: package = qualified_name.rsplit(".", maxsplit=1)[0] base_name = ".".join(package.split(".", self.depth)[: self.depth]) if base_name not in self.used_colors: self.used_colors[base_name] = next(self.available_colors) return self.used_colors[base_name] def save(self) -> None: """Write to disk.""" self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
86
modules
ref
function
for module in sorted(diagram.modules(), key=lambda x: x.title):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
87
qname
ref
function
module.fig_id = module.node.qname()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
88
emit_node
ref
function
self.printer.emit_node(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
91
get_package_properties
ref
function
properties=self.get_package_properties(module),
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
94
get_relationships
ref
function
for rel in diagram.get_relationships("depends"):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
95
emit_edge
ref
function
self.printer.emit_edge(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
101
write_classes
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
105
qname
ref
function
obj.fig_id = obj.node.qname()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
107
emit_node
ref
function
self.printer.emit_node(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
108
get_class_properties
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
111
get_relationships
ref
function
for rel in diagram.get_relationships("specialization"):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
112
emit_edge
ref
function
self.printer.emit_edge(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
118
get_relationships
ref
function
for rel in diagram.get_relationships("implements"):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
119
emit_edge
ref
function
self.printer.emit_edge(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
125
get_relationships
ref
function
for rel in diagram.get_relationships("association"):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
126
emit_edge
ref
function
self.printer.emit_edge(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
133
set_printer
def
function
def set_printer(self, file_name: str, basename: str) -> None: """Set printer.""" self.printer = self.printer_class(basename) self.file_name = file_name def get_package_properties(self, obj: PackageEntity) -> NodeProperties: """Get label and shape for packages.""" return NodeProperties( label=obj.title, color=self.get_shape_color(obj) if self.config.colorized else "black", ) def get_class_properties(self, obj: ClassEntity) -> NodeProperties: """Get label and shape for classes.""" properties = NodeProperties( label=obj.title, attrs=obj.attrs if not self.config.only_classnames else None, methods=obj.methods if not self.config.only_classnames else None, fontcolor="red" if is_exception(obj.node) else "black", color=self.get_shape_color(obj) if self.config.colorized else "black", ) return properties def get_shape_color(self, obj: DiagramEntity) -> str: """Get shape color.""" qualified_name = obj.node.qname() if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]): return "grey" if isinstance(obj.node, nodes.ClassDef): package = qualified_name.rsplit(".", maxsplit=2)[0] elif obj.node.package: package = qualified_name else: package = qualified_name.rsplit(".", maxsplit=1)[0] base_name = ".".join(package.split(".", self.depth)[: self.depth]) if base_name not in self.used_colors: self.used_colors[base_name] = next(self.available_colors) return self.used_colors[base_name] def save(self) -> None: """Write to disk.""" self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
135
printer_class
ref
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
138
get_package_properties
def
function
def get_package_properties(self, obj: PackageEntity) -> NodeProperties: """Get label and shape for packages.""" return NodeProperties( label=obj.title, color=self.get_shape_color(obj) if self.config.colorized else "black", ) def get_class_properties(self, obj: ClassEntity) -> NodeProperties: """Get label and shape for classes.""" properties = NodeProperties( label=obj.title, attrs=obj.attrs if not self.config.only_classnames else None, methods=obj.methods if not self.config.only_classnames else None, fontcolor="red" if is_exception(obj.node) else "black", color=self.get_shape_color(obj) if self.config.colorized else "black", ) return properties def get_shape_color(self, obj: DiagramEntity) -> str: """Get shape color.""" qualified_name = obj.node.qname() if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]): return "grey" if isinstance(obj.node, nodes.ClassDef): package = qualified_name.rsplit(".", maxsplit=2)[0] elif obj.node.package: package = qualified_name else: package = qualified_name.rsplit(".", maxsplit=1)[0] base_name = ".".join(package.split(".", self.depth)[: self.depth]) if base_name not in self.used_colors: self.used_colors[base_name] = next(self.available_colors) return self.used_colors[base_name] def save(self) -> None: """Write to disk.""" self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
140
NodeProperties
ref
function
return NodeProperties(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
142
get_shape_color
ref
function
color=self.get_shape_color(obj) if self.config.colorized else "black",
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
145
get_class_properties
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
147
NodeProperties
ref
function
properties = NodeProperties(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
151
is_exception
ref
function
fontcolor="red" if is_exception(obj.node) else "black",
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
152
get_shape_color
ref
function
color=self.get_shape_color(obj) if self.config.colorized else "black",
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
156
get_shape_color
def
function
def get_shape_color(self, obj: DiagramEntity) -> str: """Get shape color.""" qualified_name = obj.node.qname() if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]): return "grey" if isinstance(obj.node, nodes.ClassDef): package = qualified_name.rsplit(".", maxsplit=2)[0] elif obj.node.package: package = qualified_name else: package = qualified_name.rsplit(".", maxsplit=1)[0] base_name = ".".join(package.split(".", self.depth)[: self.depth]) if base_name not in self.used_colors: self.used_colors[base_name] = next(self.available_colors) return self.used_colors[base_name] def save(self) -> None: """Write to disk.""" self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
158
qname
ref
function
qualified_name = obj.node.qname()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
159
is_standard_module
ref
function
if modutils.is_standard_module(qualified_name.split(".", maxsplit=1)[0]):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
172
save
def
function
def save(self) -> None: """Write to disk.""" self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/pyreverse/writer.py
pylint/pyreverse/writer.py
174
generate
ref
function
self.printer.generate(self.file_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/__init__.py
pylint/reporters/__init__.py
37
initialize
def
function
def initialize(linter: "PyLinter") -> None: """Initialize linter with reporters in this package.""" utils.register_plugins(linter, __path__[0])
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/__init__.py
pylint/reporters/__init__.py
39
register_plugins
ref
function
utils.register_plugins(linter, __path__[0])
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
17
BaseReporter
def
class
__init__ handle_message set_output writeln display_reports _display display_messages on_set_current_module on_close
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
36
handle_message
def
function
def handle_message(self, msg: Message) -> None: """Handle a new message triggered on the current file.""" self.messages.append(msg) def set_output(self, output: Optional[TextIO] = None) -> None: """Set output stream.""" # pylint: disable-next=fixme # TODO: Remove this method after depreciation warn( "'set_output' will be removed in 3.0, please use 'reporter.out = stream' instead", DeprecationWarning, ) self.out = output or sys.stdout def writeln(self, string: str = "") -> None: """Write a line in the output buffer.""" print(string, file=self.out) def display_reports(self, layout: "Section") -> None: """Display results encapsulated in the layout tree.""" self.section = 0 if layout.report_id: if isinstance(layout.children[0].children[0], Text): layout.children[0].children[0].data += f" ({layout.report_id})" else: raise ValueError(f"Incorrect child for {layout.children[0].children}") self._display(layout) def _display(self, layout: "Section") -> None: """Display the layout.""" raise NotImplementedError() def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
40
set_output
def
function
def set_output(self, output: Optional[TextIO] = None) -> None: """Set output stream.""" # pylint: disable-next=fixme # TODO: Remove this method after depreciation warn( "'set_output' will be removed in 3.0, please use 'reporter.out = stream' instead", DeprecationWarning, ) self.out = output or sys.stdout def writeln(self, string: str = "") -> None: """Write a line in the output buffer.""" print(string, file=self.out) def display_reports(self, layout: "Section") -> None: """Display results encapsulated in the layout tree.""" self.section = 0 if layout.report_id: if isinstance(layout.children[0].children[0], Text): layout.children[0].children[0].data += f" ({layout.report_id})" else: raise ValueError(f"Incorrect child for {layout.children[0].children}") self._display(layout) def _display(self, layout: "Section") -> None: """Display the layout.""" raise NotImplementedError() def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
50
writeln
def
function
def writeln(self, string: str = "") -> None: """Write a line in the output buffer.""" print(string, file=self.out) def display_reports(self, layout: "Section") -> None: """Display results encapsulated in the layout tree.""" self.section = 0 if layout.report_id: if isinstance(layout.children[0].children[0], Text): layout.children[0].children[0].data += f" ({layout.report_id})" else: raise ValueError(f"Incorrect child for {layout.children[0].children}") self._display(layout) def _display(self, layout: "Section") -> None: """Display the layout.""" raise NotImplementedError() def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
54
display_reports
def
function
def display_reports(self, layout: "Section") -> None: """Display results encapsulated in the layout tree.""" self.section = 0 if layout.report_id: if isinstance(layout.children[0].children[0], Text): layout.children[0].children[0].data += f" ({layout.report_id})" else: raise ValueError(f"Incorrect child for {layout.children[0].children}") self._display(layout) def _display(self, layout: "Section") -> None: """Display the layout.""" raise NotImplementedError() def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
62
_display
ref
function
self._display(layout)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
64
_display
def
function
def _display(self, layout: "Section") -> None: """Display the layout.""" raise NotImplementedError() def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
68
display_messages
def
function
def display_messages(self, layout: Optional["Section"]) -> None: """Hook for displaying the messages of the reporter. This will be called whenever the underlying messages needs to be displayed. For some reporters, it probably doesn't make sense to display messages as soon as they are available, so some mechanism of storing them could be used. This method can be implemented to display them after they've been aggregated. """ # Event callbacks def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
81
on_set_current_module
def
function
def on_set_current_module(self, module: str, filepath: Optional[str]) -> None: """Hook called when a module starts to be analysed.""" def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/base_reporter.py
pylint/reporters/base_reporter.py
84
on_close
def
function
def on_close( self, stats: LinterStats, previous_stats: LinterStats, ) -> None: """Hook called when a module finished analyzing."""
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/collecting_reporter.py
pylint/reporters/collecting_reporter.py
10
CollectingReporter
def
class
__init__ reset _display
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/collecting_reporter.py
pylint/reporters/collecting_reporter.py
19
reset
def
function
def reset(self) -> None: self.messages = [] def _display(self, layout: "Section") -> None: pass
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/collecting_reporter.py
pylint/reporters/collecting_reporter.py
22
_display
def
function
def _display(self, layout: "Section") -> None: pass
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/json_reporter.py
pylint/reporters/json_reporter.py
26
JSONReporter
def
class
display_messages display_reports _display
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/reporters/json_reporter.py
pylint/reporters/json_reporter.py
33
display_messages
def
function
def display_messages(self, layout: Optional["Section"]) -> None: """Launch layouts display.""" json_dumpable = [ { "type": msg.category, "module": msg.module, "obj": msg.obj, "line": msg.line, "column": msg.column, "endLine": msg.end_line, "endColumn": msg.end_column, "path": msg.path, "symbol": msg.symbol, "message": msg.msg or "", "message-id": msg.msg_id, } for msg in self.messages ] print(json.dumps(json_dumpable, indent=4), file=self.out) def display_reports(self, layout: "Section") -> None: """Don't do anything in this reporter.""" def _display(self, layout: "Section") -> None: """Do nothing."""