File mappet.py
has 528 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
u"""Module for dynamic mapping of XML trees to Python objects.
.. :module: mappet
Mappet
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class Mappet(Node):
u"""A node that may have children."""
_aliases = None
u"""Dictionary with node aliases.
Function sget
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def sget(self, path, default=NONE_NODE):
u"""Enables access to nodes if one or more of them don't exist.
Example:
>>> m = Mappet('<root><tag attr1="attr text">text value</tag></root>')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function xpath
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def xpath(
self,
path,
namespaces=None,
regexp=False,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function xpath
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def xpath(
Function update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update(self, **kwargs):
u"""Updating or creation of new simple nodes.
Each dict key is used as a tagname and value as text.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function iter_children
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def iter_children(self, key=None):
u"""Iterates over children.
:param key: A key for filtering children by tagname.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, xml):
u"""Creates the mappet object from either lxml object, a string or a dict.
If you pass a dict without root element, one will be created for you with
'root' as tag name.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _get_aliases
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_aliases(self):
u"""Creates a dict with aliases.
The key is a normalized tagname, value the original tagname.
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"