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
|
from PyQt4.uic.Compiler.misc import Literal, moduleMember
class ProxyType(type):
def __init__(*args):
type.__init__(*args)
for cls in args[0].__dict__.values():
if type(cls) is ProxyType:
cls.module = args[0].__name__
if not hasattr(args[0], "module"):
args[0].module = ""
def __getattribute__(cls, name):
try:
return type.__getattribute__(cls, name)
except AttributeError:
# Avoid a circular import.
from PyQt4.uic.Compiler.qtproxies import LiteralProxyClass
return type(name, (LiteralProxyClass, ),
{"module": moduleMember(type.__getattribute__(cls, "module"),
type.__getattribute__(cls, "__name__"))})
def __str__(cls):
return moduleMember(type.__getattribute__(cls, "module"),
type.__getattribute__(cls, "__name__"))
def __or__(self, r_op):
return Literal("%s|%s" % (self, r_op))
def __eq__(self, other):
return str(self) == str(other)
|