本文整理汇总了Python中twisted.python.util.InsensitiveDict.get方法的典型用法代码示例。如果您正苦于以下问题:Python InsensitiveDict.get方法的具体用法?Python InsensitiveDict.get怎么用?Python InsensitiveDict.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.python.util.InsensitiveDict
的用法示例。
在下文中一共展示了InsensitiveDict.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
def __init__(self, headers):
self.expires = None
self.mtime = None
self.length = 0
self.start = 0
self.size = 0
self.mimeType = None
headers = InsensitiveDict(headers)
encoding = headers.get("Transfer-Encoding", None)
if encoding == 'chunked':
raise errors.FlumotionError("Chunked transfer not supported")
expires = headers.get("Expires", None)
if expires is not None:
try:
self.expires = http.stringToDatetime(expires)
except:
self.expires = 0
lastmod = headers.get("Last-Modified", None)
if lastmod is not None:
self.mtime = http.stringToDatetime(lastmod)
range = headers.get("Content-Range", None)
length = headers.get("Content-Length", None)
if range is not None:
start, end, total = http.parseContentRange(range)
self.start = start
self.length = total
if length is not None:
self.size = int(length)
else:
self.size = end - start
elif length is not None:
self.length = int(length)
self.size = int(length)
else:
raise errors.FlumotionError("Can't get length/size from headers",
headers)
ctype = headers.get("Content-Type", None)
if ctype is not None:
self.mimeType, _pdict = cgi.parse_header(ctype)
示例2: Element
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class Element(Node):
preserveCase = 0
caseInsensitive = 1
nsprefixes = None
namespace = ''
def __init__(self, tagName, attributes=None, parentNode=None,
filename=None, markpos=None,
caseInsensitive=1, preserveCase=0,
namespace=''):
Node.__init__(self, parentNode)
self.preserveCase = preserveCase or not caseInsensitive
self.caseInsensitive = caseInsensitive
if not preserveCase:
tagName = tagName.lower()
if attributes is None:
self.attributes = {}
else:
self.attributes = attributes
for k, v in self.attributes.items():
self.attributes[k] = unescape(v)
if caseInsensitive:
self.attributes = InsensitiveDict(self.attributes,
preserve=preserveCase)
self.endTagName = self.nodeName = self.tagName = tagName
self._filename = filename
self._markpos = markpos
self.namespace = namespace
def addPrefixes(self, pfxs):
if self.nsprefixes is None:
self.nsprefixes = pfxs
else:
self.nsprefixes.update(pfxs)
def endTag(self, endTagName):
if not self.preserveCase:
endTagName = endTagName.lower()
self.endTagName = endTagName
def isEqualToElement(self, n):
if self.caseInsensitive:
return (self.attributes == n.attributes) and (self.nodeName.lower() == n.nodeName.lower())
return (self.attributes == n.attributes) and (self.nodeName == n.nodeName)
def cloneNode(self, deep=0, parent=None):
clone = Element(
self.tagName, parentNode=parent, namespace=self.namespace,
preserveCase=self.preserveCase, caseInsensitive=self.caseInsensitive)
clone.attributes.update(self.attributes)
if deep:
clone.childNodes = [child.cloneNode(1, clone) for child in self.childNodes]
else:
clone.childNodes = []
return clone
def getElementsByTagName(self, name):
if self.caseInsensitive:
return getElementsByTagNameNoCase(self, name)
return getElementsByTagName(self, name)
def hasAttributes(self):
return 1
def getAttribute(self, name, default=None):
return self.attributes.get(name, default)
def getAttributeNS(self, ns, name, default=None):
nsk = (ns, name)
if self.attributes.has_key(nsk):
return self.attributes[nsk]
if ns == self.namespace:
return self.attributes.get(name, default)
return default
def getAttributeNode(self, name):
return _Attr(self.getAttribute(name), self)
def setAttribute(self, name, attr):
self.attributes[name] = attr
def removeAttribute(self, name):
if name in self.attributes:
del self.attributes[name]
def removeAttribute_has_key(self, name):
if self.attributes.has_key(name):
del self.attributes[name]
def hasAttribute(self, name):
return name in self.attributes
def hasAttribute_has_key(self, name):
return self.attributes.has_key(name)
if dictsAreNotSequences:
hasAttribute = hasAttribute_has_key
#.........这里部分代码省略.........
示例3: Element
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class Element(Node):
preserveCase = 0
caseInsensitive = 1
nsprefixes = None
def __init__(self, tagName, attributes=None, parentNode=None,
filename=None, markpos=None,
caseInsensitive=1, preserveCase=0,
namespace=None):
Node.__init__(self, parentNode)
self.preserveCase = preserveCase or not caseInsensitive
self.caseInsensitive = caseInsensitive
if not preserveCase:
tagName = tagName.lower()
if attributes is None:
self.attributes = {}
else:
self.attributes = attributes
for k, v in self.attributes.items():
self.attributes[k] = unescape(v)
if caseInsensitive:
self.attributes = InsensitiveDict(self.attributes,
preserve=preserveCase)
self.endTagName = self.nodeName = self.tagName = tagName
self._filename = filename
self._markpos = markpos
self.namespace = namespace
def addPrefixes(self, pfxs):
if self.nsprefixes is None:
self.nsprefixes = pfxs
else:
self.nsprefixes.update(pfxs)
def endTag(self, endTagName):
if not self.preserveCase:
endTagName = endTagName.lower()
self.endTagName = endTagName
def isEqualToElement(self, n):
if self.caseInsensitive:
return ((self.attributes == n.attributes)
and (self.nodeName.lower() == n.nodeName.lower()))
return (self.attributes == n.attributes) and (self.nodeName == n.nodeName)
def isEqualToNode(self, other):
"""
Compare this element to C{other}. If the C{nodeName}, C{namespace},
C{attributes}, and C{childNodes} are all the same, return C{True},
otherwise return C{False}.
"""
return (
self.nodeName.lower() == other.nodeName.lower() and
self.namespace == other.namespace and
self.attributes == other.attributes and
Node.isEqualToNode(self, other))
def cloneNode(self, deep=0, parent=None):
clone = Element(
self.tagName, parentNode=parent, namespace=self.namespace,
preserveCase=self.preserveCase, caseInsensitive=self.caseInsensitive)
clone.attributes.update(self.attributes)
if deep:
clone.childNodes = [child.cloneNode(1, clone) for child in self.childNodes]
else:
clone.childNodes = []
return clone
def getElementsByTagName(self, name):
if self.caseInsensitive:
return getElementsByTagNameNoCase(self, name)
return getElementsByTagName(self, name)
def hasAttributes(self):
return 1
def getAttribute(self, name, default=None):
return self.attributes.get(name, default)
def getAttributeNS(self, ns, name, default=None):
nsk = (ns, name)
if self.attributes.has_key(nsk):
return self.attributes[nsk]
if ns == self.namespace:
return self.attributes.get(name, default)
return default
def getAttributeNode(self, name):
return _Attr(self.getAttribute(name), self)
def setAttribute(self, name, attr):
self.attributes[name] = attr
def removeAttribute(self, name):
if name in self.attributes:
#.........这里部分代码省略.........
示例4: IRCBot
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class IRCBot(irc.IRCClient):
sasl_buffer = ""
sasl_result = None
sasl_login = None
def __init__(self, factory, plugin):
self.factory = factory
self.nickname = plugin.nickname.encode('ascii')
self.realname = plugin.realname.encode('ascii')
self.username = plugin.ident.encode('ascii')
self.ns_username = plugin.username
self.ns_password = plugin.password
self.password = plugin.server_password.encode('ascii')
self.channel = plugin.channel.encode('ascii')
self.console = plugin.console
self.irc_message = plugin.irc_message
self.users = InsensitiveDict()
self.cap_requests = set()
def register(self, nickname, hostname="foo", servername="bar"):
self.sendLine("CAP LS")
return irc.IRCClient.register(self, nickname, hostname, servername)
def _parse_cap(self, cap):
mod = ''
while cap[0] in "-~=":
mod, cap = mod + cap[0], cap[1:]
if '/' in cap:
vendor, cap = cap.split('/', 1)
else:
vendor = None
return (cap, mod, vendor)
def request_cap(self, *caps):
self.cap_requests |= set(caps)
self.sendLine("CAP REQ :{0}".format(' '.join(caps)))
@defer.inlineCallbacks
def end_cap(self):
if self.sasl_result:
yield self.sasl_result
self.sendLine("CAP END")
def irc_CAP(self, prefix, params):
self.supports_cap = True
identifier, subcommand, args = params
args = args.split(' ')
if subcommand == "LS":
self.sasl_start(args)
if not self.cap_requests:
self.sendLine("CAP END")
elif subcommand == "ACK":
ack = []
for cap in args:
if not cap:
continue
cap, mod, vendor = self._parse_cap(cap)
if '-' in mod:
if cap in self.capabilities:
del self.capabilities[cap]
continue
self.cap_requests.remove(cap)
if cap == 'sasl':
self.sasl_next()
if ack:
self.sendLine("CAP ACK :{0}".format(' '.join(ack)))
if not self.cap_requests:
self.end_cap()
elif subcommand == "NAK":
# this implementation is probably not compliant but it will have to do for now
for cap in args:
self.cap_requests.remove(cap)
if not self.cap_requests:
self.end_cap()
def signedOn(self):
if ISSLTransport.providedBy(self.transport):
cert = self.transport.getPeerCertificate()
fp = cert.digest("sha1")
verified = "verified" if self.factory.parent.server_fingerprint else "unverified"
self.console("irc: connected securely. server fingerprint: {0} ({1})".format(fp, verified))
else:
self.console("irc: connected")
if self.ns_username and self.ns_password and not self.sasl_login:
self.msg('NickServ', 'IDENTIFY {0} {1}'.format(self.ns_username, self.ns_password))
self.join(self.channel)
def irc_JOIN(self, prefix, params):
nick = prefix.split('!')[0]
channel = params[-1]
if nick == self.nickname:
self.joined(channel)
else:
self.userJoined(prefix, channel)
def joined(self, channel):
self.console('irc: joined channel')
#.........这里部分代码省略.........
示例5: Element
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class Element(Node):
nsprefixes = None
create_attr = lambda k, v: (' ', k, '="', escape(v), '"')
SINGLETONS = (
'img', 'br', 'hr', 'base', 'meta', 'link', 'param',
'area', 'input', 'col', 'basefont', 'isindex', 'frame')
BLOCKELEMENTS = (
'html', 'head', 'body', 'noscript', 'ins', 'del',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'script',
'ul', 'ol', 'dl', 'pre', 'hr', 'blockquote',
'address', 'p', 'div', 'fieldset', 'table', 'tr',
'form', 'object', 'fieldset', 'applet', 'map')
NICEFORMATS = ('tr', 'ul', 'ol', 'head')
def __init__(
self, tagName, attributes=None, parentNode=None, filename=None,
markpos=None, case_insensitive=1, namespace=None
):
Node.__init__(self, parentNode)
preserve_case = not case_insensitive
tagName = tagName if preserve_case else tagName.lower()
unescaped = unescape_dict(attributes or {})
if case_insensitive:
self.attributes = InsensitiveDict(unescaped, preserve=preserve_case)
else:
self.attributes = unescaped
self.preserve_case = not case_insensitive
self.case_insensitive = case_insensitive
self.endTagName = self.nodeName = self.tagName = tagName
self._filename = filename
self._markpos = markpos
self.namespace = namespace
self.tag_is_blockelement = tagName in self.BLOCKELEMENTS
self.tag_is_nice_format = tagName in self.NICEFORMATS
self.tag_is_singleton = tagName.lower() in self.SINGLETONS
def addPrefixes(self, pfxs):
if self.nsprefixes is None:
self.nsprefixes = pfxs
else:
self.nsprefixes.update(pfxs)
def endTag(self, endTagName):
if self.case_insensitive:
endTagName = endTagName.lower()
self.endTagName = endTagName
def isEqualToElement(self, n):
same_attrs = self.attributes == n.attributes
if self.case_insensitive:
eq = same_attrs and (self.nodeName.lower() == n.nodeName.lower())
else:
eq = same_attrs and (self.nodeName == n.nodeName)
return eq
def isEqualToNode(self, other):
"""
Compare this element to C{other}. If the C{nodeName}, C{namespace},
C{attributes}, and C{childNodes} are all the same, return C{True},
otherwise return C{False}.
"""
return (
self.nodeName.lower() == other.nodeName.lower() and
self.namespace == other.namespace and
self.attributes == other.attributes and
Node.isEqualToNode(self, other))
def cloneNode(self, deep=0, parent=None):
clone = Element(
self.tagName, parentNode=parent, namespace=self.namespace,
case_insensitive=self.case_insensitive)
clone.attributes.update(self.attributes)
if deep:
clone.childNodes = [
child.cloneNode(1, clone) for child in self.childNodes]
else:
clone.childNodes = []
return clone
def getElementsByTagName(self, name):
icase = self.case_insensitive
return getElementsByTagName(self.childNodes, name, icase)
def hasAttributes(self):
return 1
def getAttribute(self, name, default=None):
return self.attributes.get(name, default)
#.........这里部分代码省略.........
示例6: BaseLDAPEntry
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class BaseLDAPEntry(object):
implements(interfaces.ILDAPEntry)
dn = None
def __init__(self, dn, attributes={}):
"""
Initialize the object.
@param dn: Distinguished Name of the object, as a string.
@param attributes: Attributes of the object. A dictionary of
attribute types to list of attribute values.
"""
self._attributes=InsensitiveDict()
self.dn = distinguishedname.DistinguishedName(dn)
for k,vs in attributes.items():
if k not in self._attributes:
self._attributes[k] = []
self._attributes[k].extend(vs)
for k,vs in self._attributes.items():
self._attributes[k] = self.buildAttributeSet(k, vs)
def buildAttributeSet(self, key, values):
return attributeset.LDAPAttributeSet(key, values)
def __getitem__(self, key):
return self._attributes[key]
def get(self, key, default=None):
return self._attributes.get(key, default)
def has_key(self, key):
return key in self._attributes
def __contains__(self, key):
return self.has_key(key)
def keys(self):
a = []
if self.get('objectClass'):
a.append('objectClass')
l=list(self._attributes.keys())
l.sort()
for key in l:
if key.lower() != 'objectclass':
a.append(key)
return a
def items(self):
a=[]
objectClasses = list(self.get('objectClass', []))
objectClasses.sort()
if objectClasses:
a.append(('objectClass', objectClasses))
l=list(self._attributes.items())
l.sort()
for key, values in l:
if key.lower() != 'objectclass':
vs = list(values)
vs.sort()
a.append((key, vs))
return a
def __str__(self):
a=[]
objectClasses = list(self.get('objectClass', []))
objectClasses.sort()
a.append(('objectClass', objectClasses))
l=list(self.items())
l.sort()
for key, values in l:
if key.lower() != 'objectclass':
vs = list(values)
vs.sort()
a.append((key, vs))
return ldif.asLDIF(self.dn, a)
def __eq__(self, other):
if not isinstance(other, BaseLDAPEntry):
return 0
if self.dn != other.dn:
return 0
my=self.keys()
my.sort()
its=other.keys()
its.sort()
if my!=its:
return 0
for key in my:
myAttr=self[key]
itsAttr=other[key]
#.........这里部分代码省略.........
示例7: IRCBot
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class IRCBot(irc.IRCClient):
sasl_buffer = ""
sasl_result = None
sasl_login = None
cancel_hilight_re = re.compile(ur"(?:(?<=\u00a7[0-9a-flmnor])|(?<!\u00a7)\b).+?\b")
def __init__(self, factory, parent):
self.factory = factory
self.nickname = parent.nickname.encode('ascii')
self.realname = parent.realname.encode('ascii')
self.username = parent.ident.encode('ascii')
self.ns_username = parent.username
self.ns_password = parent.password
self.password = parent.server_password.encode('ascii')
self.join_channels = parent.channel_map.keys()
self.users = InsensitiveDict()
self.channels = InsensitiveDict()
self.cap_requests = set()
self.parent = parent
def register(self, nickname, hostname="foo", servername="bar"):
self.sendLine("CAP LS")
return irc.IRCClient.register(self, nickname, hostname, servername)
def sendLine(self, line):
if isinstance(line, unicode):
line = line.encode('utf8', 'replace')
irc.IRCClient.sendLine(self, line)
def _parse_cap(self, cap):
mod = ''
while cap[0] in "-~=":
mod, cap = mod + cap[0], cap[1:]
if '/' in cap:
vendor, cap = cap.split('/', 1)
else:
vendor = None
return (cap, mod, vendor)
def request_cap(self, *caps):
self.cap_requests |= set(caps)
self.sendLine("CAP REQ :{0}".format(' '.join(caps)))
@defer.inlineCallbacks
def end_cap(self):
if self.sasl_result:
yield self.sasl_result
self.sendLine("CAP END")
def irc_CAP(self, prefix, params):
self.supports_cap = True
identifier, subcommand, args = params
args = args.split(' ')
if subcommand == "LS":
self.sasl_start(args)
if not self.cap_requests:
self.sendLine("CAP END")
elif subcommand == "ACK":
ack = []
for cap in args:
if not cap:
continue
cap, mod, vendor = self._parse_cap(cap)
if '-' in mod:
if cap in self.capabilities:
del self.capabilities[cap]
continue
self.cap_requests.remove(cap)
if cap == 'sasl':
self.sasl_next()
if ack:
self.sendLine("CAP ACK :{0}".format(' '.join(ack)))
if not self.cap_requests:
self.end_cap()
elif subcommand == "NAK":
# this implementation is probably not compliant but it will have to do for now
for cap in args:
self.cap_requests.remove(cap)
if not self.cap_requests:
self.end_cap()
def signedOn(self):
if ISSLTransport.providedBy(self.transport):
cert = self.transport.getPeerCertificate()
fp = cert.digest("sha1")
verified = "verified" if self.factory.parent.server_fingerprint else "unverified"
print("irc: connected securely. server fingerprint: {0} ({1})".format(fp, verified))
else:
print("irc: connected")
if self.ns_username and self.ns_password and not self.sasl_login:
self.msg('NickServ', 'IDENTIFY {0} {1}'.format(self.ns_username, self.ns_password))
for channel in self.join_channels:
self.join(channel)
def irc_JOIN(self, prefix, params):
#.........这里部分代码省略.........
示例8: IRCBot
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class IRCBot(irc.IRCClient):
def __init__(self, factory, plugin):
self.factory = factory
self.nickname = plugin.nickname.encode('ascii')
self.realname = plugin.realname.encode('ascii')
self.username = plugin.username.encode('ascii')
self.ns_password = plugin.password
self.password = plugin.server_password.encode('ascii')
self.channel = plugin.channel.encode('ascii')
self.console = plugin.console
self.irc_message = plugin.irc_message
self.users = InsensitiveDict()
def signedOn(self):
if have_ssl and isinstance(self.transport, TLSMemoryBIOProtocol):
cert = self.transport.getPeerCertificate()
fp = cert.digest("sha1")
verified = "verified" if self.factory.parent.server_fingerprint else "unverified"
self.console("irc: connected securely. server fingerprint: {} ({})".format(fp, verified))
else:
self.console("irc: connected")
if self.ns_password:
self.msg('NickServ', 'IDENTIFY %s' % self.ns_password)
self.join(self.channel)
def irc_JOIN(self, prefix, params):
nick = prefix.split('!')[0]
channel = params[-1]
if nick == self.nickname:
self.joined(channel)
else:
self.userJoined(prefix, channel)
def joined(self, channel):
self.console('irc: joined channel')
self.factory.client = self
def who(a):
self.sendLine("WHO " + channel)
self.factory.parent.repeating_task(who, 30, now=True)
def isupport(self, args):
self.compute_prefix_names()
def compute_prefix_names(self):
KNOWN_NAMES = {"o": "op", "h": "halfop", "v": "voice"}
prefixdata = self.supported.getFeature("PREFIX", {"o": ("@", 0), "v": ("+", 1)}).items()
op_priority = ([priority for mode, (prefix, priority) in prefixdata if mode == "o"] + [None])[0]
self.prefixes, self.statuses, self.priority = {}, {}, {}
for mode, (prefix, priority) in prefixdata:
name = "?"
if mode in KNOWN_NAMES:
name = KNOWN_NAMES[mode]
elif priority == 0:
if op_priority == 2:
name = "owner"
else:
name = "admin"
else:
name = "+" + mode
self.prefixes[mode] = prefix
self.statuses[prefix] = name
self.priority[name] = priority
self.priority[mode] = priority
self.priority[prefix] = priority
def parse_prefixes(self, user, nick, prefixes=''):
status = []
prefixdata = self.supported.getFeature("PREFIX", {"o": ("@", 0), "v": ("+", 1)}).items()
for mode, (prefix, priority) in prefixdata:
if prefix in prefixes + nick:
nick = nick.replace(prefix, '')
status.append((prefix, priority))
if nick == self.nickname:
return
user.status = ''.join(t[0] for t in sorted(status, key=lambda t: t[1]))
def irc_RPL_WHOREPLY(self, prefix, params):
_, channel, username, host, server, nick, status, hg = params
if nick == self.nickname:
return
hops, gecos = hg.split(' ', 1)
user = IRCUser(self, nick)
user.username = username
user.hostname = host
user.oper = '*' in status
user.away = status[0] == 'G'
self.users[nick] = user
self.parse_prefixes(user, nick, status[1:].replace('*', ''))
def modeChanged(self, user, channel, _set, modes, args):
args = list(args)
if channel.lower() != self.channel.lower():
return
for m, arg in zip(modes, args):
if m in self.prefixes and arg != self.nickname:
u = self.users.get(arg, None)
if u:
#.........这里部分代码省略.........
示例9: BaseLDAPEntry
# 需要导入模块: from twisted.python.util import InsensitiveDict [as 别名]
# 或者: from twisted.python.util.InsensitiveDict import get [as 别名]
class BaseLDAPEntry(WireStrAlias):
dn = None
_object_class_keys = set(get_strings('objectClass'))
_object_class_lower_keys = set(get_strings('objectclass'))
_user_password_keys = set(get_strings('userPassword'))
def __init__(self, dn, attributes={}):
"""
Initialize the object.
@param dn: Distinguished Name of the object, as a string.
@param attributes: Attributes of the object. A dictionary of
attribute types to list of attribute values.
"""
self._attributes = InsensitiveDict()
self.dn = distinguishedname.DistinguishedName(dn)
for k, vs in attributes.items():
if k not in self._attributes:
self._attributes[k] = []
self._attributes[k].extend(vs)
for k, vs in self._attributes.items():
self._attributes[k] = self.buildAttributeSet(k, vs)
def buildAttributeSet(self, key, values):
return attributeset.LDAPAttributeSet(key, values)
def __getitem__(self, key):
for k in get_strings(key):
if k in self._attributes:
return self._attributes[k]
raise KeyError(key)
def get(self, key, default=None):
for k in get_strings(key):
if k in self._attributes:
return self._attributes[k]
return default
def has_key(self, key):
for k in get_strings(key):
if k in self._attributes:
return True
return False
def __contains__(self, key):
return self.has_key(key)
def __iter__(self):
for key in self._attributes.iterkeys():
yield key
def keys(self):
a = []
for key in self._object_class_keys:
if key in self._attributes:
a.append(key)
l = list(self._attributes.keys())
l.sort(key=to_bytes)
for key in l:
if key.lower() not in self._object_class_lower_keys:
a.append(key)
return a
def items(self):
a = []
for key in self._object_class_keys:
objectClasses = list(self._attributes.get(key, []))
objectClasses.sort(key=to_bytes)
if objectClasses:
a.append((key, objectClasses))
l = list(self._attributes.items())
l.sort(key=lambda x: to_bytes(x[0]))
for key, values in l:
if key.lower() not in self._object_class_lower_keys:
vs = list(values)
vs.sort()
a.append((key, vs))
return a
def toWire(self):
a = []
for key in self._object_class_keys:
objectClasses = list(self._attributes.get(key, []))
objectClasses.sort(key=to_bytes)
a.append((key, objectClasses))
items_gen = ((key, self[key]) for key in self)
items = sorted(items_gen, key=lambda x: to_bytes(x[0]))
for key, values in items:
if key.lower() not in self._object_class_lower_keys:
vs = list(values)
#.........这里部分代码省略.........