当前位置: 首页>>代码示例>>Python>>正文


Python types.ListType方法代码示例

本文整理汇总了Python中types.ListType方法的典型用法代码示例。如果您正苦于以下问题:Python types.ListType方法的具体用法?Python types.ListType怎么用?Python types.ListType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在types的用法示例。


在下文中一共展示了types.ListType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_headers

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def check_headers(headers):
    assert type(headers) is ListType, (
        "Headers (%r) must be of type list: %r"
        % (headers, type(headers)))
    header_names = {}
    for item in headers:
        assert type(item) is TupleType, (
            "Individual headers (%r) must be of type tuple: %r"
            % (item, type(item)))
        assert len(item) == 2
        name, value = item
        assert name.lower() != 'status', (
            "The Status header cannot be used; it conflicts with CGI "
            "script, and HTTP status is not given through headers "
            "(value: %r)." % value)
        header_names[name.lower()] = None
        assert '\n' not in name and ':' not in name, (
            "Header names may not contain ':' or '\\n': %r" % name)
        assert header_re.search(name), "Bad header name: %r" % name
        assert not name.endswith('-') and not name.endswith('_'), (
            "Names may not end in '-' or '_': %r" % name)
        assert not bad_header_value_re.search(value), (
            "Bad header value: %r (bad char: %r)"
            % (value, bad_header_value_re.search(value).group(0))) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:26,代码来源:lint.py

示例2: check_headers

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def check_headers(headers):
    assert_(type(headers) is ListType,
        "Headers (%r) must be of type list: %r"
        % (headers, type(headers)))
    header_names = {}
    for item in headers:
        assert_(type(item) is TupleType,
            "Individual headers (%r) must be of type tuple: %r"
            % (item, type(item)))
        assert_(len(item) == 2)
        name, value = item
        assert_(name.lower() != 'status',
            "The Status header cannot be used; it conflicts with CGI "
            "script, and HTTP status is not given through headers "
            "(value: %r)." % value)
        header_names[name.lower()] = None
        assert_('\n' not in name and ':' not in name,
            "Header names may not contain ':' or '\\n': %r" % name)
        assert_(header_re.search(name), "Bad header name: %r" % name)
        assert_(not name.endswith('-') and not name.endswith('_'),
            "Names may not end in '-' or '_': %r" % name)
        if bad_header_value_re.search(value):
            assert_(0, "Bad header value: %r (bad char: %r)"
            % (value, bad_header_value_re.search(value).group(0))) 
开发者ID:glmcdona,项目名称:meddle,代码行数:26,代码来源:validate.py

示例3: process_message

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def process_message(self, topic, payload, *args):

        log.debug('Bus receive: topic={topic}, payload={payload}', topic=topic, payload=payload)

        # TODO: filter by realm/topic

        # decode message
        if type(payload) is types.DictionaryType:
            message = payload.copy()
        elif type(payload) is types.ListType:
            message = OrderedDict(payload)
        else:
            raise TypeError('Unable to handle data type "{}" from bus'.format(type(payload)))

        # compute storage location from topic and message
        storage_location = self.storage_location(message)
        log.debug('Storage location: {storage_location}', storage_location=dict(storage_location))

        # store data
        self.store_message(storage_location, message) 
开发者ID:daq-tools,项目名称:kotori,代码行数:22,代码来源:influx.py

示例4: validNatCheckReplyMsg

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def validNatCheckReplyMsg(self, ncr_data):
        if not type(ncr_data) == ListType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. It must be a list of parameters.'
            return False
        if not type(ncr_data[0]) == StringType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The first element in the list must be a string.'
            return False
        if not type(ncr_data[1]) == IntType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The second element in the list must be an integer.'
            return False
        if not type(ncr_data[2]) == IntType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The third element in the list must be an integer.'
            return False
        if not type(ncr_data[3]) == StringType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The forth element in the list must be a string.'
            return False
        if not type(ncr_data[4]) == IntType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The fifth element in the list must be an integer.'
            return False
        if not type(ncr_data[5]) == StringType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The sixth element in the list must be a string.'
            return False
        if not type(ncr_data[6]) == IntType:
            raise RuntimeError, 'NatCheckMsgHandler: received data is not valid. The seventh element in the list must be an integer.'
            return False 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:27,代码来源:NatCheckMsgHandler.py

示例5: set_tracker_hierarchy

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def set_tracker_hierarchy(self, hier):
        if self.readonly:
            raise OperationNotPossibleAtRuntimeException()
        newhier = []
        if type(hier) != ListType:
            raise ValueError('hierarchy is not a list')
        for tier in hier:
            if type(tier) != ListType:
                raise ValueError('tier is not a list')
            newtier = []
            for url in tier:
                if not isValidURL(url):
                    raise ValueError('Invalid URL: ' + `url`)
                if url.endswith('/'):
                    url = url[:-1]
                newtier.append(url)

            newhier.append(newtier)

        self.input['announce-list'] = newhier
        self.metainfo_valid = False 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:23,代码来源:TorrentDef.py

示例6: set_dht_nodes

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def set_dht_nodes(self, nodes):
        if self.readonly:
            raise OperationNotPossibleAtRuntimeException()
        if type(nodes) != ListType:
            raise ValueError('nodes not a list')
        else:
            for node in nodes:
                if type(node) != ListType and len(node) != 2:
                    raise ValueError('node in nodes not a 2-item list: ' + `node`)
                if type(node[0]) != StringType:
                    raise ValueError('host in node is not string:' + `node`)
                if type(node[1]) != IntType:
                    raise ValueError('port in node is not int:' + `node`)

        self.input['nodes'] = nodes
        self.metainfo_valid = False 
开发者ID:alesnav,项目名称:p2ptv-pi,代码行数:18,代码来源:TorrentDef.py

示例7: bytes2int

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def bytes2int(bytes):
    """Converts a list of bytes or a string to an integer

    >>> (128*256 + 64)*256 + + 15
    8405007
    >>> l = [128, 64, 15]
    >>> bytes2int(l)
    8405007
    """

    if not (type(bytes) is types.ListType or type(bytes) is types.StringType):
        raise TypeError("You must pass a string or a list")

    # Convert byte stream to integer
    integer = 0
    for byte in bytes:
        integer *= 256
        if type(byte) is types.StringType: byte = ord(byte)
        integer += byte

    return integer 
开发者ID:deadblue,项目名称:baidupan_shell,代码行数:23,代码来源:_version133.py

示例8: bytes2int

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def bytes2int(bytes):
    """Converts a list of bytes or a string to an integer

    >>> (((128 * 256) + 64) * 256) + 15
    8405007
    >>> l = [128, 64, 15]
    >>> bytes2int(l)              #same as bytes2int('\x80@\x0f')
    8405007
    """

    if not (type(bytes) is types.ListType or type(bytes) is types.StringType):
        raise TypeError("You must pass a string or a list")

    # Convert byte stream to integer
    integer = 0
    for byte in bytes:
        integer *= 256
        if type(byte) is types.StringType: byte = ord(byte)
        integer += byte

    return integer 
开发者ID:deadblue,项目名称:baidupan_shell,代码行数:23,代码来源:_version200.py

示例9: str642int

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def str642int(string):
    """Converts a base64 encoded string into an integer.
    The chars of this string in in the range '0'-'9','A'-'Z','a'-'z','-','_'
    
    >>> str642int('7MyqL')
    123456789
    """

    if not (type(string) is types.ListType or type(string) is types.StringType):
        raise TypeError("You must pass a string or a list")

    integer = 0
    for byte in string:
        integer *= 64
        if type(byte) is types.StringType: byte = ord(byte)
        integer += from64(byte)

    return integer 
开发者ID:deadblue,项目名称:baidupan_shell,代码行数:20,代码来源:_version200.py

示例10: argparse

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def argparse(self,name,args):
        if not name and self.defaults.has_key('name'):
            args['name'] = self.defaults['name']
        if type(name) is types.StringType:
            args['name']=name
        else:
            if len(name) == 1:
                if name[0]:
                    args['name']=name[0]
        if defaults['server_rotate'] and \
                type(defaults['server']) == types.ListType:
            defaults['server'] = defaults['server'][1:]+defaults['server'][:1]
        for i in defaults.keys():
            if not args.has_key(i):
                if self.defaults.has_key(i):
                    args[i]=self.defaults[i]
                else:
                    args[i]=defaults[i]
        if type(args['server']) == types.StringType:
            args['server'] = [args['server']]
        self.args=args 
开发者ID:Flolagale,项目名称:mailin,代码行数:23,代码来源:Base.py

示例11: getPartsNameList

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def getPartsNameList(self, sectionName):
        outList = []
        if sectionName is None or set(sectionName) == set(self.sectionNames):
            return
        else:
            if isinstance(sectionName, types.StringType):
                sectionNames = [
                 sectionName]
            elif isinstance(sectionName, types.ListType):
                sectionNames = sectionName
            else:
                sectionNames = []
            for section in sectionNames:
                partList = self.partNameLists.get(section)
                if partList:
                    outList.extend(partList)

        return outList 
开发者ID:PiratesOnlineRewritten,项目名称:Pirates-Online-Rewritten,代码行数:20,代码来源:AnimationMixer.py

示例12: getGoalIds

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def getGoalIds(self, uidMgr=None, all=True):
        if all:
            results = [
             (0, '')]
        else:
            results = ''
        if self.__goalType == types.ListType:
            if all:
                uidData = self.__goalData
            else:
                uidData = self.__goalData[:1]
            if uidMgr:
                results = zip(map(lambda x: uidMgr.getDoId(x, None), uidData), uidData)
            elif len(uidData) == 0:
                results = ''
            else:
                results = uidData[0]
        return results 
开发者ID:PiratesOnlineRewritten,项目名称:Pirates-Online-Rewritten,代码行数:20,代码来源:QuestPath.py

示例13: _asString

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def _asString(self):
        if self.__goalDataStr != None:
            return self.__goalDataStr
        if self.__goalData == None:
            resultStr = ''
        if self.__goalType == types.ListType:
            resultStr = str(self.__goalData)
        else:
            strRep = ''
            for currField in range(self.MAX_IDX):
                strRep += str(self.__goalData.get(currField, None))
                strRep += '-'

            resultStr = strRep
        self.__goalDataStr = resultStr
        return resultStr 
开发者ID:PiratesOnlineRewritten,项目名称:Pirates-Online-Rewritten,代码行数:18,代码来源:QuestPath.py

示例14: new_looper

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def new_looper(a, arg=None):
    """Helper function for nest()
    determines what sort of looper to make given a's type"""
    if isinstance(a,types.TupleType):
        if len(a) == 2:
            return RangeLooper(a[0],a[1])
        elif len(a) == 3:
            return RangeLooper(a[0],a[1],a[2])
    elif isinstance(a, types.BooleanType):
        return BooleanLooper(a)
    elif isinstance(a,types.IntType) or isinstance(a, types.LongType):
        return RangeLooper(a)
    elif isinstance(a, types.StringType) or isinstance(a, types.ListType):
        return ListLooper(a)
    elif isinstance(a, Looper):
        return a
    elif isinstance(a, types.LambdaType):
        return CalcField(a, arg) 
开发者ID:ActiveState,项目名称:code,代码行数:20,代码来源:recipe-473818.py

示例15: __init__

# 需要导入模块: import types [as 别名]
# 或者: from types import ListType [as 别名]
def __init__(self,rowset,description):
    # save the description as is
    self.description = fRow(description)
    self.description.__Field2Index__ = self.__fieldToIndex
    
    # Create the list and dict of fields
    self.fields = []
    self.__fieldDict = {}
    for f in range(len(description)):
      if type(description[f]) == types.TupleType or type(description[f]) == types.ListType:
        self.__fieldDict[description[f][0].lower()] = f
        self.fields.append( description[f][0].lower())
      else:
        self.__fieldDict[description[f].lower()] = f
        self.fields.append( description[f].lower())
    # Add all the rows
    for r in rowset:
      self.append(r) 
开发者ID:ActiveState,项目名称:code,代码行数:20,代码来源:recipe-223610.py


注:本文中的types.ListType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。