spack.util.unparse package
Submodules
spack.util.unparse.unparser module
Usage: unparse.py <path to source file>
- class spack.util.unparse.unparser.Unparser(py_ver_consistent=False, _avoid_backslashes=False)[source]
Bases:
object
Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarded.
- binop = {'Add': '+', 'BitAnd': '&', 'BitOr': '|', 'BitXor': '^', 'Div': '/', 'FloorDiv': '//', 'LShift': '<<', 'MatMult': '@', 'Mod': '%', 'Mult': '*', 'Pow': '**', 'RShift': '>>', 'Sub': '-'}
- binop_precedence = {'%': 12, '&': 9, '*': 12, '**': 14, '+': 11, '-': 11, '/': 12, '//': 12, '<<': 10, '>>': 10, '@': 12, '^': 8, '|': 7}
- binop_rassoc = frozenset({'**'})
- boolop_precedence = {'and': 4, 'or': 3}
- boolops = {'And': 'and', 'Or': 'or'}
- cmpops = {'Eq': '==', 'Gt': '>', 'GtE': '>=', 'In': 'in', 'Is': 'is', 'IsNot': 'is not', 'Lt': '<', 'LtE': '<=', 'NotEq': '!=', 'NotIn': 'not in'}
- delimit(start, end)[source]
A context manager for preparing the source for expressions. It adds start to the buffer and enters, after exit it adds end.
- items_view(traverser, items)[source]
Traverse and separate the given items with a comma and append it to the buffer. If items is a single item sequence, a trailing comma will be added.
- unop = {'Invert': '~', 'Not': 'not', 'UAdd': '+', 'USub': '-'}
- unop_precedence = {'+': 13, '-': 13, 'not': 5, '~': 13}