當前位置: 首頁>>代碼示例>>Python>>正文


Python types.BooleanType方法代碼示例

本文整理匯總了Python中types.BooleanType方法的典型用法代碼示例。如果您正苦於以下問題:Python types.BooleanType方法的具體用法?Python types.BooleanType怎麽用?Python types.BooleanType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在types的用法示例。


在下文中一共展示了types.BooleanType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: into_signalfx

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def into_signalfx(sfx_key, cluster_health, node_stats):
    import signalfx
    sfx = signalfx.SignalFx()
    ingest = sfx.ingest(sfx_key)
    for node in node_stats:
        source_node = node['source_node']
        for s in node_stats_to_collect:
            flattened = flatten_json(node['node_stats'][s])
            for k,v in flattened.items():
                if isinstance(v, (int, float)) and not isinstance(v, types.BooleanType):
                    ingest.send(gauges=[{"metric": 'elasticsearch.node.' + s + '.' + k, "value": v,
                                         "dimensions": {
                                             'cluster_uuid': node.get('cluster_uuid'),
                                             'cluster_name': node.get('cluster_name'),
                                             'node_name': source_node.get('name'),
                                             'node_host': source_node.get('host'),
                                             'node_host': source_node.get('ip'),
                                             'node_uuid': source_node.get('uuid'),
                                             'cluster_name': source_node.get('uuid'),
                                             }
                                         }])
    ingest.stop() 
開發者ID:BigDataBoutique,項目名稱:elasticsearch-monitoring,代碼行數:24,代碼來源:fetch_stats.py

示例2: new_looper

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [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

示例3: _matches

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _matches(self, markup, matchAgainst):
        #print "Matching %s against %s" % (markup, matchAgainst)
        result = False
        if matchAgainst == True and type(matchAgainst) == types.BooleanType:
            result = markup != None
        elif callable(matchAgainst):
            result = matchAgainst(markup)
        else:
            #Custom match methods take the tag as an argument, but all
            #other ways of matching match the tag name as a string.
            if isinstance(markup, Tag):
                markup = markup.name
            if markup and not isString(markup):
                markup = unicode(markup)
            #Now we know that chunk is either a string, or None.
            if hasattr(matchAgainst, 'match'):
                # It's a regexp object.
                result = markup and matchAgainst.search(markup)
            elif isList(matchAgainst):
                result = markup in matchAgainst
            elif hasattr(matchAgainst, 'items'):
                result = markup.has_key(matchAgainst)
            elif matchAgainst and isString(markup):
                if isinstance(markup, unicode):
                    matchAgainst = unicode(matchAgainst)
                else:
                    matchAgainst = str(matchAgainst)

            if not result:
                result = matchAgainst == markup
        return result 
開發者ID:skarlekar,項目名稱:faces,代碼行數:33,代碼來源:_bsoup.py

示例4: __setattr__

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def __setattr__(self, name, value):
        # Ensure the `value` attribute is always a bool.
        if name == '_value' and not isinstance(value, types.BooleanType):
            raise TypeError('_value must be of type bool')

        super(AtomicBoolean, self).__setattr__(name, value) 
開發者ID:maxcountryman,項目名稱:atomos,代碼行數:8,代碼來源:atomic.py

示例5: _matches

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _matches(self, markup, matchAgainst):
        #print "Matching %s against %s" % (markup, matchAgainst)
        result = False
        if matchAgainst == True and type(matchAgainst) == types.BooleanType:
            result = markup != None
        elif callable(matchAgainst):
            result = matchAgainst(markup)
        else:
            #Custom match methods take the tag as an argument, but all
            #other ways of matching match the tag name as a string.
            if isinstance(markup, Tag):
                markup = markup.name
            if markup is not None and not isString(markup):
                markup = unicode(markup)
            #Now we know that chunk is either a string, or None.
            if hasattr(matchAgainst, 'match'):
                # It's a regexp object.
                result = markup and matchAgainst.search(markup)
            elif (isList(matchAgainst)
                  and (markup is not None or not isString(matchAgainst))):
                result = markup in matchAgainst
            elif hasattr(matchAgainst, 'items'):
                result = markup.has_key(matchAgainst)
            elif matchAgainst and isString(markup):
                if isinstance(markup, unicode):
                    matchAgainst = unicode(matchAgainst)
                else:
                    matchAgainst = str(matchAgainst)

            if not result:
                result = matchAgainst == markup
        return result 
開發者ID:pythonanywhere,項目名稱:dirigible-spreadsheet,代碼行數:34,代碼來源:BeautifulSoup.py

示例6: __init__

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def __init__(self, module):
        self.module = module
        self.changed = False
        self.action = module.params['action']
        self.fail_on_change = module.params['fail_on_change']
        self.patch = None
        self.patch_type = module.params['patch_type']
        self.resource = module.params['resource']

        if not 'kind' in self.resource:
            raise Exception('resource must define kind')
        if not 'metadata' in self.resource:
            raise Exception('resource must include metadata')
        if not 'name' in self.resource['metadata']:
            raise Exception('resource metadata must include name')

        if 'namespace' in self.resource['metadata']:
            self.namespace = self.resource['metadata']['namespace']
        elif 'namespace' in module.params:
            self.namespace = module.params['namespace']
            self.resource['metadata']['namespace'] = self.namespace

        connection = module.params['connection']
        if 'oc_cmd' in connection:
            self.oc_cmd = connection['oc_cmd'].split()
        else:
            self.oc_cmd = ['oc']
        for opt in ['server','certificate_authority','token']:
            if opt in connection:
                self.oc_cmd += ['--' + opt.replace('_', '-') + '=' + connection[opt]]
        if 'insecure_skip_tls_verify' in connection:
            if type(connection['insecure_skip_tls_verify']) == types.BooleanType:
                self.oc_cmd += ['--insecure-skip-tls-verify']
            elif connection['insecure_skip_tls_verify']:
                self.oc_cmd += ['--insecure-skip-tls-verify='+connection['insecure_skip_tls_verify']] 
開發者ID:rh-openshift-ansible-better-together,項目名稱:dev-track,代碼行數:37,代碼來源:openshift_provision.py

示例7: _unjelly_boolean

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _unjelly_boolean(self, exp):
        if BooleanType:
            assert exp[0] in ('true', 'false')
            return exp[0] == 'true'
        else:
            return Unpersistable("Could not unpersist boolean: %s" % (exp[0],)) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:8,代碼來源:jelly.py

示例8: _matches

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _matches(self, markup, matchAgainst):    
        #print "Matching %s against %s" % (markup, matchAgainst)
        result = False
        if matchAgainst == True and type(matchAgainst) == types.BooleanType:
            result = markup != None
        elif callable(matchAgainst):
            result = matchAgainst(markup)
        else:
            #Custom match methods take the tag as an argument, but all
            #other ways of matching match the tag name as a string.
            if isinstance(markup, Tag):
                markup = markup.name
            if markup and not isString(markup):
                markup = unicode(markup)
            #Now we know that chunk is either a string, or None.
            if hasattr(matchAgainst, 'match'):
                # It's a regexp object.
                result = markup and matchAgainst.search(markup)
            elif isList(matchAgainst):
                result = markup in matchAgainst
            elif hasattr(matchAgainst, 'items'):
                result = markup.has_key(matchAgainst)
            elif matchAgainst and isString(markup):
                if isinstance(markup, unicode):
                    matchAgainst = unicode(matchAgainst)
                else:
                    matchAgainst = str(matchAgainst)

            if not result:
                result = matchAgainst == markup
        return result 
開發者ID:tuwid,項目名稱:darkc0de-old-stuff,代碼行數:33,代碼來源:BeautifulSoup.py

示例9: _unjelly_boolean

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _unjelly_boolean(self, exp):
        if BooleanType:
            assert exp[0] in ('true', 'false')
            return exp[0] == 'true'
        else:
            return Unpersistable(exp[0]) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:8,代碼來源:jelly.py

示例10: _unjelly_boolean

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _unjelly_boolean(self, exp):
        if BooleanType:
            assert exp[0] in ('true', 'false')
            return self.resolveReference(exp[0] == 'true')
        else:
            return self.resolveReference(Unpersistable(exp[0])) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:8,代碼來源:newjelly.py

示例11: __pretreat

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def __pretreat(self):
        self.__input_vector_check()
        for __target in self.targets:
            __trigger = __target.get('trigger')
            if type(__trigger) is types.BooleanType or type(__trigger) is types.StringType:
                if __trigger:
                    self.verified.append(__target)
            else:
                msg = '[Trigger Type Error] Expected:boolean,found:' + str(type(__trigger))
                raise RegisterValueException(msg)
        self.__mutex_check() 
開發者ID:S4kur4,項目名稱:Sepia,代碼行數:13,代碼來源:register.py

示例12: __input_vector_check

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def __input_vector_check(self):
        if type(self.stop) is types.IntType and type(self.start) is types.IntType and type(
                self.mutex) is types.BooleanType:
            pass
        else:
            raise RegisterValueException('Register init func type error')
        if len(self.targets) is 0:
            msg = 'no target'
            raise RegisterDataException(msg)
        if self.start > self.stop:
            msg = 'start > stop'
            raise RegisterDataException(msg) 
開發者ID:S4kur4,項目名稱:Sepia,代碼行數:14,代碼來源:register.py

示例13: _is_primitive_types

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def _is_primitive_types(obj):
    return isinstance(obj, (types.BooleanType, types.LongType, types.IntType, types.FloatType, types.StringType, types.UnicodeType)) 
開發者ID:zstackio,項目名稱:zstack-utility,代碼行數:4,代碼來源:jsonobject.py

示例14: humannum

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def humannum(data, unit=None, include=None, exclude=None):

    if isinstance(data, types.DictType):

        data = data.copy()

        keys = set(data.keys())
        if include is not None:
            keys = keys & set(include)

        if exclude is not None:
            keys = keys - set(exclude)

        for k in keys:
            data[k] = humannum(data[k])

        return data

    elif isinstance(data, types.BooleanType):
        # We have to deal with bool because for historical reason bool is
        # subclass of int.
        # When bool is introduced into python 2.2 it is represented with int,
        # similar to C.
        return data

    elif isinstance(data, types.ListType):
        return [humannum(x) for x in data]

    elif isinstance(data, types.StringTypes):
        return data

    elif isinstance(data, integer_types):
        return humannum_int(data, unit=unit)

    elif isinstance(data, types.FloatType):
        if data > 999:
            return humannum_int(int(data), unit=unit)
        elif abs(data) < 0.0000000001:
            return '0'
        else:
            return '%.2f' % (data)

    else:
        return data 
開發者ID:bsc-s2,項目名稱:pykit,代碼行數:46,代碼來源:humannum.py

示例15: ini_write

# 需要導入模塊: import types [as 別名]
# 或者: from types import BooleanType [as 別名]
def ini_write(f, d, comment=''):
    try:
        a = {'default':{}}
        for k,v in d.items():
            assert type(k) == StringType
            k = k.lower()
            if type(v) == DictType:
                if DEBUG:
                    print 'new section:' +k
                if k:
                    assert not a.has_key(k)
                    a[k] = {}
                aa = a[k]
                for kk,vv in v:
                    assert type(kk) == StringType
                    kk = kk.lower()
                    assert not aa.has_key(kk)
                    if type(vv) == BooleanType:
                        vv = int(vv)
                    if type(vv) == StringType:
                        vv = '"'+vv+'"'
                    aa[kk] = str(vv)
                    if DEBUG:
                        print 'a['+k+']['+kk+'] = '+str(vv)
            else:
                aa = a['']
                assert not aa.has_key(k)
                if type(v) == BooleanType:
                    v = int(v)
                if type(v) == StringType:
                    v = '"'+v+'"'
                aa[k] = str(v)
                if DEBUG:
                    print 'a[\'\']['+k+'] = '+str(v)
        r = open(f,'w')
        if comment:
            for c in comment.split('\n'):
                r.write('# '+c+'\n')
            r.write('\n')
        l = a.keys()
        l.sort()
        for k in l:
            if k:
                r.write('\n['+k+']\n')
            aa = a[k]
            ll = aa.keys()
            ll.sort()
            for kk in ll:
                r.write(kk+' = '+aa[kk]+'\n')
        success = True
    except:
        if DEBUG:
            print_exc()
        success = False
    try:
        r.close()
    except:
        pass
    return success 
開發者ID:soarpenguin,項目名稱:python-scripts,代碼行數:61,代碼來源:inifile.py


注:本文中的types.BooleanType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。