/usr/lib/python2.7/dist-packages/swap/mixin.py is in python-swap 1.2.1-7.
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 | """mixin.py
$ID: $
We want to be able to mixin query functions
These include:
substitution(self, bindings, why=None):
substituteEquals(self, bindings, newRedirections):
occurringIn(self, vars):
unify(self, other, vars, existentials, bindings):
we want the interface to be convenient.
Here is how to use it:
Let us say, in one file, you have a class foo
class foo(object):
def something(self):
...
and you want to add a other() method to it. Create another file,
and do as follows
------
from mixin import Mixin
class betterFoo(Mixin, foo):
def other(self):
....
----
and import that file where you need to use betterFoo, even AFTER the
objects are created!
"""
##try:
## Set = set
##except NameError:
## from sets import Set
##
##operations = {}
class mixinClass(object):
"""
"""
def __new__(metacls, name, bases, dict):
for base in bases:
#print base
if base.__class__ is not mixinClass:
for func in dict:
#print func
if func[0:1] != '_':
## if func not in operations:
## operations[func] = {}
## operations[func][base] = dict[func]
if func in base.__dict__:
raise ValueError('''I can't let you override an existing method.
Use real inheritance: %s.%s''' % (`base`, func))
setattr(base, func, dict[func])
return object.__new__(metacls)
class Mixin:
__metaclass__ = mixinClass
|