2 isafe = set("abcdefghijklmnopqrstuvwxyz" +
3 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
5 qsafe = isafe | set("0123456789-+")
8 if not isinstance(o, symbol):
10 return (s.name == o.name) and (s.ns == o.ns)
13 return (hash(self.ns) * 31) + hash(self.name)
16 ns, nm = ("", o) if isinstance(o, str) else (s.ns, s.name)
17 return s.ns < ns or s.name < nm
19 ns, nm = ("", o) if isinstance(o, str) else (s.ns, s.name)
20 return s.ns > ns or s.name > nm
42 return nssymbol(ns, name)
46 return self.quote(self.name)
47 return "%s:%s" % (self.quote(self.ns), self.quote(self.name))
49 class usymbol(symbol):
51 def __init__(self, name):
55 return hash(self.name)
57 if isinstance(o, str):
59 return super().__eq__(o)
61 class nssymbol(symbol):
62 def __init__(self, ns, name, *args, **kw):
63 super().__init__(*args, **kw)
68 def __getitem__(self, key):
69 return self.__dict__[key]
70 def __setitem__(self, key, val):
71 self.__dict__[key] = val
72 def __delitem__(self, key):
73 del self.__dict__[key]