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


Python Type类代码示例

本文整理汇总了Python中Type的典型用法代码示例。如果您正苦于以下问题:Python Type类的具体用法?Python Type怎么用?Python Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: dumpQ

def dumpQ(u):
    qname, qtype, qclass = u.getQuestion()
    print
    'qname=%s, qtype=%d(%s), qclass=%d(%s)' \
    % (qname,
       qtype, Type.typestr(qtype),
       qclass, Class.classstr(qclass))
开发者ID:alanchavez88,项目名称:theHarvester,代码行数:7,代码来源:Lib.py

示例2: dumpRR

def dumpRR(u):
    name, type, klass, ttl, rdlength = u.getRRheader()
    typename = Type.typestr(type)
    print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
              % (name,
                 type, typename,
                 klass, Class.classstr(klass),
                 ttl)
    mname = 'get%sdata' % typename
    if hasattr(u, mname):
        print '  formatted rdata:', getattr(u, mname)()
    else:
        print '  binary rdata:', u.getbytes(rdlength)
开发者ID:tvelazquez,项目名称:theharvester,代码行数:13,代码来源:Lib.py

示例3: storeRR

 def storeRR(self,u):
     r={}
     r['name'],r['type'],r['class'],r['ttl'],r['rdlength'] = u.getRRheader()
     r['typename'] = Type.typestr(r['type'])
     r['classstr'] = Class.classstr(r['class'])
     #print 'name=%s, type=%d(%s), class=%d(%s), ttl=%d' \
     #      % (name,
     #        type, typename,
     #        klass, Class.classstr(class),
     #        ttl)
     mname = 'get%sdata' % r['typename']
     if hasattr(u, mname):
         r['data']=getattr(u, mname)()
     else:
         r['data']=u.getbytes(r['rdlength'])
     return r
开发者ID:tvelazquez,项目名称:theharvester,代码行数:16,代码来源:Lib.py

示例4: get_views_task

def get_views_task ():
    types  = Type.get_types()
    lookup = OpLookup.OpLookup()
    report = []
    for asset_type in types:
        search  = {'__order__':      'views DESC',
                   'asset_types_id':  asset_type['id']}

        try:
            results = lookup(search)
        except:
            results = []

        acl = ACL()
        results = acl.filter_assets ("co" , results)

        if not results:
            continue
        if len(results) > REPORT_ITEM_SZ:
            results = results[:REPORT_ITEM_SZ]

        report.append((asset_type['name'], results))
    return report
开发者ID:manolodd,项目名称:activae,代码行数:23,代码来源:PageReport.py

示例5: get_24h_task

def get_24h_task ():
    types  = Type.get_types()
    lookup = OpLookup.OpLookup()
    report = []
    for asset_type in types:
        search  = {'__order__':      'date_created DESC',
                   'asset_types_id':  asset_type['id'],
                   'date_created-':  'DATE_SUB(NOW(),INTERVAL 1 DAY)'}

        try:
            results = lookup(search)
        except:
            results = []

        acl = ACL()
        results = acl.filter_assets ("co" , results)

        if not results:
            continue
        if len(results) > REPORT_ITEM_SZ:
            results = results[:REPORT_ITEM_SZ]

        report.append((asset_type['name'], results))
    return report
开发者ID:manolodd,项目名称:activae,代码行数:24,代码来源:PageReport.py

示例6: storeQ

 def storeQ(self,u):
     q={}
     q['qname'], q['qtype'], q['qclass'] = u.getQuestion()
     q['qtypestr']=Type.typestr(q['qtype'])
     q['qclassstr']=Class.classstr(q['qclass'])
     return q
开发者ID:tvelazquez,项目名称:theharvester,代码行数:6,代码来源:Lib.py

示例7: verify

	def verify(p1t1, p1t2, p2t1, p2t2):
		first = [t in Type.resistances(p2t1, p2t2) for t in Type.weaknesses(p1t1, p1t2)]
		second = [t in Type.resistances(p1t1, p1t2) for t in Type.weaknesses(p2t1, p2t2)]
		return all(first) and all(second)
开发者ID:kgilbert-cmu,项目名称:PokemonTypes,代码行数:4,代码来源:stallmates.py

示例8: set

import sys

stallmates = set()

# i = 0
for pokemon1_t1 in Type.types:
	for pokemon1_t2 in Type.types:
		for pokemon2_t1 in Type.types:
			for pokemon2_t2 in Type.types:
				# sys.stdout.write("\r" + str(i))
				poke1 = frozenset([pokemon1_t1, pokemon1_t2])
				poke2 = frozenset([pokemon2_t1, pokemon2_t2])
				pair = frozenset([poke1,poke2])
				if pair in stallmates:
					continue
				first = [t in Type.resistances(pokemon2_t1, pokemon2_t2) for \
				         t in Type.weaknesses(pokemon1_t1, pokemon1_t2)]
				second = [t in Type.resistances(pokemon1_t1, pokemon1_t2) for \
					      t in Type.weaknesses(pokemon2_t1, pokemon2_t2)]
				if all(first) and all(second):
					# print "Found pair!"
					stallmates.add(pair)
				# i = i + 1
# sys.stdout.write("\n")

for [typing1, typing2] in stallmates:
	try:
		[p1_t1, p1_t2] = typing1
	except:
		p1_t2 = None
	try:
开发者ID:kgilbert-cmu,项目名称:PokemonTypes,代码行数:31,代码来源:stallmates.py

示例9: _compile_tags

    def _compile_tags (self):
        # Versions & Source
        version_of = None
        version    = self._db.get('version', None)
        versions   = [x['id'] for x in self._versions if x['id']!=self['id']]
        source     = self._parent_id
        if self['version'] != 1:
            version_of = self._replacements.get('replaces')

        # Formats
        has_formats  = None
        is_format_of = None
        if self._formats:
            format_list  =[x['format'] for x in self._formats if x['id']!=self['id']]
            has_formats  = dict.fromkeys(format_list).keys()
            for f in self._formats:
                if f['source'] == None and f['id'] != self['id']:
                    is_format_of = f['id']

        self._tags = {
            'Creator':          self._db.get('creator_id'),
            'Date':             max(self._db.get('date_modified'), self._db.get('date_edited'), self._db.get('date_created')),
            'Date Created':     self._db.get('date_created'),
            'Date (Modified)':  self._db.get('date_modified'),
            'Date Available':   self._db.get('date_available'),
            'Description':      self._db.get('description'),
            'Extent':           self._file.get('extent'),
            'Format':           self._file.get('formats_id'),
            'Has Format':       has_formats,
            'Has Part':         self._parts.get('has_parts_of'),
            'Has Version':      versions,
            'Identifier':       self._db.get('id'),
            'Is Format Of':     is_format_of,
            'Is Part Of':       self._parts.get('is_part_of'),
            'Is Referenced By': self._db.get('collections_id'),
            'Is Replaced By':   self._replacements.get('replaced_by'),
            'Is Version Of':    version_of,
            'Language':         self._db.get('language'),
            'Publisher':        self._db.get('publisher_id'),
            'Relation':         self._collection,
            'Replaces':         self._replacements.get('replaces'),
            'Source':           source,
            'Subject':          self._db.get('subject'),
            'Title':            self._db.get('title'),
            'Type':             self._db.get('asset_types_id'),
            'Rights':           self._db.get('licenses_id'),
            }

        if self['Creator']:
            self._tags['Creator'] = Auth.get_user_name (self['tags']['Creator'])
        if self['Publisher']:
            self._tags['Publisher'] = Auth.get_user_name (self['tags']['Publisher'])
        if self['Rights']:
            self._tags['Rights']    = License.get_license_name(self['tags']['Rights'])
        if self['Format']:
            self._tags['Format']    = Format.get_format_name (self['tags']['Format'])
        if self['Type']:
            self._tags['Type']      = Type.get_type_name (self['tags']['Type'])

        for key in self._tags.keys():
            if key.startswith('Date') and self._tags[key] == '0000-00-00 00:00:00':
                self._tags[key] = None
开发者ID:manolodd,项目名称:activae,代码行数:62,代码来源:Asset.py


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