/usr/lib/python2.7/dist-packages/pyqtgraph/flowchart/library/Operators.py is in python-pyqtgraph 0.9.10-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # -*- coding: utf-8 -*-
from ..Node import Node
class UniOpNode(Node):
"""Generic node for performing any operation like Out = In.fn()"""
def __init__(self, name, fn):
self.fn = fn
Node.__init__(self, name, terminals={
'In': {'io': 'in'},
'Out': {'io': 'out', 'bypass': 'In'}
})
def process(self, **args):
return {'Out': getattr(args['In'], self.fn)()}
class BinOpNode(Node):
"""Generic node for performing any operation like A.fn(B)"""
def __init__(self, name, fn):
self.fn = fn
Node.__init__(self, name, terminals={
'A': {'io': 'in'},
'B': {'io': 'in'},
'Out': {'io': 'out', 'bypass': 'A'}
})
def process(self, **args):
if isinstance(self.fn, tuple):
for name in self.fn:
try:
fn = getattr(args['A'], name)
break
except AttributeError:
pass
else:
fn = getattr(args['A'], self.fn)
out = fn(args['B'])
if out is NotImplemented:
raise Exception("Operation %s not implemented between %s and %s" % (fn, str(type(args['A'])), str(type(args['B']))))
#print " ", fn, out
return {'Out': out}
class AbsNode(UniOpNode):
"""Returns abs(Inp). Does not check input types."""
nodeName = 'Abs'
def __init__(self, name):
UniOpNode.__init__(self, name, '__abs__')
class AddNode(BinOpNode):
"""Returns A + B. Does not check input types."""
nodeName = 'Add'
def __init__(self, name):
BinOpNode.__init__(self, name, '__add__')
class SubtractNode(BinOpNode):
"""Returns A - B. Does not check input types."""
nodeName = 'Subtract'
def __init__(self, name):
BinOpNode.__init__(self, name, '__sub__')
class MultiplyNode(BinOpNode):
"""Returns A * B. Does not check input types."""
nodeName = 'Multiply'
def __init__(self, name):
BinOpNode.__init__(self, name, '__mul__')
class DivideNode(BinOpNode):
"""Returns A / B. Does not check input types."""
nodeName = 'Divide'
def __init__(self, name):
# try truediv first, followed by div
BinOpNode.__init__(self, name, ('__truediv__', '__div__'))
|