當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。