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


Python sys.maxint方法代码示例

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


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

示例1: _auto_ssl_context

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def _auto_ssl_context():
        import OpenSSL, time, random
        pkey = OpenSSL.crypto.PKey()
        pkey.generate_key(OpenSSL.crypto.TYPE_RSA, 768)

        cert = OpenSSL.crypto.X509()

        cert.set_serial_number(random.randint(0, sys.maxint))
        cert.gmtime_adj_notBefore(0)
        cert.gmtime_adj_notAfter(60 * 60 * 24 * 365)
        cert.get_subject().CN = '*'
        cert.get_subject().O = 'Dummy Certificate'
        cert.get_issuer().CN = 'Untrusted Authority'
        cert.get_issuer().O = 'Self-Signed'
        cert.set_pubkey(pkey)
        cert.sign(pkey, 'md5')

        ctx = SSL.Context(SSL.SSLv23_METHOD)
        ctx.use_privatekey(pkey)
        ctx.use_certificate(cert)

        return ctx 
开发者ID:linuxscout,项目名称:mishkal,代码行数:24,代码来源:httpserver.py

示例2: rename

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def rename(src, dst):
        # Try atomic or pseudo-atomic rename
        if _rename(src, dst):
            return
        # Fall back to "move away and replace"
        try:
            os.rename(src, dst)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
            old = "%s-%08x" % (dst, random.randint(0, sys.maxint))
            os.rename(dst, old)
            os.rename(src, dst)
            try:
                os.unlink(old)
            except Exception:
                pass 
开发者ID:jojoin,项目名称:cutout,代码行数:19,代码来源:posixemulation.py

示例3: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def __init__(self):
      buildstep.LogLineObserver.__init__(self)

      # Counts of various reports.
      self.num_reports = None
      self.num_added = 0
      self.num_removed = 0
      self.num_changed = 0

      # Reports to notify the user about; a list of tuples of (title,
      # name, html-report).
      self.reports = []

      # Lines we couldn't parse.
      self.invalid_lines = []

      # Make sure we get all the data.
      self.setMaxLineLength(sys.maxint) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:20,代码来源:AnalyzerCompareCommand.py

示例4: distanceDomain

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def distanceDomain(domain, DomainDict, ccTldDict, tldDict):
	similarDomain = ""
	minDistance = sys.maxint
	level = domain.split(".")
	if len(level) <=1:
		return ("not a domain", sys.maxint)
	(domain2LD, domain3LD, domain2LDs, domain3LDs) = extractLevelDomain(domain, ccTldDict, tldDict)
	for popularDomain in DomainDict:
		distance = Levenshtein.distance(domain2LD.decode('utf-8'), popularDomain.decode('utf-8'))
		if distance < minDistance:
			minDistance = distance
			similarDomain = popularDomain
	#debug
	#sys.stdout.write("subdomain: %s, similarDomain: %s, minDistance: %d\n" % (subdomain, similarDomain, minDistance))
	if len(similarDomain) > 0:
		return (similarDomain, minDistance/float(len(similarDomain)))
	else:
		return (domain2LD, 0)

# check whether a domain contains invalid TLD 
开发者ID:hanzhang0116,项目名称:BotDigger,代码行数:22,代码来源:BotDigger.py

示例5: threeSumClosest

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def threeSumClosest(A, B):
    i , n = 0 , len(A)
    A = sorted(A)
    diff = sys.maxint
    close_sum = 0
    while i <= n-3:
        j , k = i+1 , n-1
        sum = A[i] + A[j] + A[k]
        if sum == B:
            return sum
        if diff > abs(sum - B):
            diff += abs(sum-B)
            close_sum = sum
        if sum < B:
            j += 1
        else:
            k -= 1
        i += 1
    return close_sum 
开发者ID:thundergolfer,项目名称:interview-with-python,代码行数:21,代码来源:closetsum.py

示例6: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def __init__(self, interface_dict, rpc_prefix):

		mp_conf = {"use_bin_type":True}
		super().__init__(
				pack_params  = {
						"use_bin_type":True
					},
				# unpack_param = {
				# 		'raw'             : True,
				# 		'max_buffer_size' : sys.maxint,
				# 		'max_str_len'     : sys.maxint,
				# 		'max_bin_len'     : sys.maxint,
				# 		'max_array_len'   : sys.maxint,
				# 		'max_map_len'     : sys.maxint,
				# 		'max_ext_len'     : sys.maxint,
				# 	},
			)

		self.log = logging.getLogger("Main.{}-Interface".format(rpc_prefix))
		self.mdict = interface_dict
		self.log.info("Connection") 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:23,代码来源:server.py

示例7: base36_to_int

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def base36_to_int(s):
    """
    Converts a base 36 string to an ``int``. Raises ``ValueError` if the
    input won't fit into an int.
    """
    # To prevent overconsumption of server resources, reject any
    # base36 string that is long than 13 base36 digits (13 digits
    # is sufficient to base36-encode any 64-bit integer)
    if len(s) > 13:
        raise ValueError("Base36 input too large")
    value = int(s, 36)
    # ... then do a final check that the value will fit into an int to avoid
    # returning a long (#15067). The long type was removed in Python 3.
    if six.PY2 and value > sys.maxint:
        raise ValueError("Base36 input too large")
    return value 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:18,代码来源:http.py

示例8: int_to_base36

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def int_to_base36(i):
    """
    Converts an integer to a base36 string
    """
    char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
    if i < 0:
        raise ValueError("Negative base36 conversion input.")
    if six.PY2:
        if not isinstance(i, six.integer_types):
            raise TypeError("Non-integer base36 conversion input.")
        if i > sys.maxint:
            raise ValueError("Base36 conversion input too large.")
    if i < 36:
        return char_set[i]
    b36 = ''
    while i != 0:
        i, n = divmod(i, 36)
        b36 = char_set[n] + b36
    return b36 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:21,代码来源:http.py

示例9: _make_boundary

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def _make_boundary(text=None):
    # Craft a random boundary.  If text is given, ensure that the chosen
    # boundary doesn't appear in the text.
    token = random.randrange(sys.maxint)
    boundary = ('=' * 15) + (_fmt % token) + '=='
    if text is None:
        return boundary
    b = boundary
    counter = 0
    while True:
        cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
        if not cre.search(text):
            break
        b = boundary + '.' + str(counter)
        counter += 1
    return b 
开发者ID:glmcdona,项目名称:meddle,代码行数:18,代码来源:generator.py

示例10: read_data

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def read_data (self,setid,epoch,data):
		# unknown template, ignore it !
		if setid not in self.template:
			return

		extracted = {'epoch':epoch,'flows':1}
		format = self.template[setid]

		for what in format:
			offset,size = format[what]
			extracted[NAME[what]], = struct.unpack(CONVERT[(what,size)],data[offset:offset+size])

		# # reports the data decoding rate per thread
		# self.decoded +=1
		# if not self.decoded % 1000:
		# 	print "id %d decoded %ld flows" % (self.id,self.decoded)
		# 	sys.stdout.flush()
		# 	if self.decoded == sys.maxint:
		# 		self.decoded = self.decoded % 1000

		self.callback(extracted) 
开发者ID:Exa-Networks,项目名称:exaddos,代码行数:23,代码来源:ipfix.py

示例11: getLenStat

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def getLenStat(fileName, minLength=1000):
    """
        Get basic statistics concerning the lengths of the sequence.

        @param fileName: fasta file
        @type fileName: str
    """
    buf = ""
    c = 0
    bp = 0
    minLen = sys.maxint
    maxLen = 0
    totalBp = 0
    totalCount = 0
    for k, l in fas.getSequenceToBpDict(fileName).iteritems():
        totalCount += 1
        totalBp += l
        if l >= minLength:
            c += 1
            bp += l
            if l < minLen:
                minLen = l
            elif l > maxLen:
                maxLen = l

    buf += 'Bigger than %sbp (sequences: %s, Mbp: %s)\n' % (minLength, c, round(float(bp) / 1000000.0, 3))
    buf += 'Bigger than %sbp (min: %s, max %s, avg %s bp)\n' % (minLength, minLen, maxLen, round((float(bp) / c)))
    buf += 'Total (sequences: %s, Mbp: %s)\n' % (totalCount, round(float(totalBp) / 1000000.0, 3))
    return buf 
开发者ID:CAMI-challenge,项目名称:CAMISIM,代码行数:31,代码来源:soapdenovo.py

示例12: fifo

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def fifo(dout, din, re, we, empty, full, clk, maxFilling=sys.maxint):
    
    """ Synchronous fifo model based on a list.
    
    Ports:
    dout -- data out
    din -- data in
    re -- read enable
    we -- write enable
    empty -- empty indication flag
    full -- full indication flag
    clk -- clock input

    Optional parameter:
    maxFilling -- maximum fifo filling, "infinite" by default

    """
    
    memory = []

    @always(clk.posedge)
    def access():
        if we:
            memory.insert(0, din.val)
        if re:
            dout.next = memory.pop()
        filling = len(memory)
        empty.next = (filling == 0)
        full.next = (filling == maxFilling)

    return access 
开发者ID:myhdl,项目名称:myhdl,代码行数:33,代码来源:fifo.py

示例13: fifo2

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def fifo2(dout, din, re, we, empty, full, clk, maxFilling=sys.maxint):
    
    """ Synchronous fifo model based on a list.

    Ports:
    dout -- data out
    din -- data in
    re -- read enable
    we -- write enable
    empty -- empty indication flag
    full -- full indication flag
    clk -- clock input
    
    Optional parameter:
    maxFilling -- maximum fifo filling, "infinite" by default

    """
    
    memory = []

    @always(clk.posedge)
    def access():
        if we:
            memory.insert(0, din.val)
        if re:
            try:
                dout.next = memory.pop()
            except IndexError:
                raise Exception("Underflow -- Read from empty fifo")
        filling = len(memory)
        empty.next = (filling == 0)
        full.next = (filling == maxFilling)
        if filling > maxFilling:
            raise Exception("Overflow -- Max filling %s exceeded" % maxFilling)

    return access 
开发者ID:myhdl,项目名称:myhdl,代码行数:38,代码来源:fifo.py

示例14: _generate_unsigned_hash_code

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def _generate_unsigned_hash_code(strings, max_hash_value=sys.maxint):
  # type: (List[str], int) -> int
  """Generates a forever-fixed hash code for `strings`.

  The hash code generated is in the range [0, max_hash_value). Note that the
  hash code generated by farmhash.fingerprint64 is unsigned.
  """
  return farmhash.fingerprint64(json.dumps(strings)) % max_hash_value 
开发者ID:googlegenomics,项目名称:gcp-variant-transforms,代码行数:10,代码来源:hashing_util.py

示例15: test_copy

# 需要导入模块: import sys [as 别名]
# 或者: from sys import maxint [as 别名]
def test_copy(self):
        current = sys.getrecursionlimit()
        self.addCleanup(sys.setrecursionlimit, current)

        # can't use sys.maxint as this doesn't exist in Python 3
        sys.setrecursionlimit(int(10e8))
        # this segfaults without the fix in place
        copy.copy(Mock()) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:10,代码来源:testmock.py


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