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


Python sys.hexversion方法代码示例

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


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

示例1: test_patched_errwindow

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def test_patched_errwindow(capfd, mocker, monkeypatch):
    """Test with a patched sys.hexversion and a fake Tk."""
    monkeypatch.setattr(checkpyver.sys, 'hexversion', 0x03040000)
    monkeypatch.setattr(checkpyver.sys, 'exit', lambda status: None)

    try:
        import tkinter  # pylint: disable=unused-import
    except ImportError:
        tk_mock = mocker.patch('qutebrowser.misc.checkpyver.Tk',
                               spec=['withdraw'], new_callable=mocker.Mock)
        msgbox_mock = mocker.patch('qutebrowser.misc.checkpyver.messagebox',
                                   spec=['showerror'])
    else:
        tk_mock = mocker.patch('qutebrowser.misc.checkpyver.Tk', autospec=True)
        msgbox_mock = mocker.patch('qutebrowser.misc.checkpyver.messagebox',
                                   autospec=True)

    checkpyver.check_python_version()
    stdout, stderr = capfd.readouterr()
    assert not stdout
    assert not stderr
    tk_mock.assert_called_with()
    tk_mock().withdraw.assert_called_with()
    msgbox_mock.showerror.assert_called_with("qutebrowser: Fatal error!",
                                             unittest.mock.ANY) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:27,代码来源:test_checkpyver.py

示例2: check_python_version

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def check_python_version():
    """Check if correct python version is run."""
    if sys.hexversion < 0x03050200:
        # We don't use .format() and print_function here just in case someone
        # still has < 2.6 installed.
        version_str = '.'.join(map(str, sys.version_info[:3]))
        text = ("At least Python 3.5.2 is required to run qutebrowser, but " +
                "it's running with " + version_str + ".\n")
        if (Tk and  # type: ignore[unreachable]
                '--no-err-windows' not in sys.argv):  # pragma: no cover
            root = Tk()
            root.withdraw()
            messagebox.showerror("qutebrowser: Fatal error!", text)
        else:
            sys.stderr.write(text)
            sys.stderr.flush()
        sys.exit(1) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:19,代码来源:checkpyver.py

示例3: _certifi_ssl_context

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def _certifi_ssl_context(self):
        if (sys.version_info.major == 2 and sys.hexversion >= 0x02070900 or
           sys.version_info.major == 3 and sys.hexversion >= 0x03040300):
            where = certifi.where()
            self._log(DEBUG1, 'certifi %s: %s', certifi.__version__, where)
            return ssl.create_default_context(
                purpose=ssl.Purpose.SERVER_AUTH,
                cafile=where)
        else:
            return None


#
# XXX USE OF cloud_ssl_context() IS DEPRECATED!
#
# If your operating system certificate store is out of date you can
# install certifi (https://pypi.python.org/pypi/certifi) and its CA
# bundle will be used for SSL server certificate verification when
# ssl_context is None.
# 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:22,代码来源:wfapi.py

示例4: flatten_nested_items

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def flatten_nested_items(dictionary):
    """
    Flatten a nested_dict.

    iterate through nested dictionary (with iterkeys() method)
         and return with nested keys flattened into a tuple
    """
    if sys.hexversion < 0x03000000:
        keys = dictionary.iterkeys
        keystr = "iterkeys"
    else:
        keys = dictionary.keys
        keystr = "keys"
    for key in keys():
        value = dictionary[key]
        if hasattr(value, keystr):
            for keykey, value in flatten_nested_items(value):
                yield (key,) + keykey, value
        else:
            yield (key,), value 
开发者ID:bunbun,项目名称:nested-dict,代码行数:22,代码来源:implementation.py

示例5: finalize_options

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def finalize_options(self):
        self.set_undefined_options('install_lib',
                                   ('install_dir', 'install_dir'))
        self.set_undefined_options('install',('install_layout','install_layout'))
        if sys.hexversion > 0x2060000:
            self.set_undefined_options('install',('prefix_option','prefix_option'))
        ei_cmd = self.get_finalized_command("egg_info")
        basename = pkg_resources.Distribution(
            None, None, ei_cmd.egg_name, ei_cmd.egg_version
        ).egg_name() + '.egg-info'

        if self.install_layout:
            if not self.install_layout.lower() in ['deb']:
                raise DistutilsOptionError("unknown value for --install-layout")
            self.install_layout = self.install_layout.lower()
            basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '')
        elif self.prefix_option or 'real_prefix' in sys.__dict__:
            # don't modify for virtualenv
            pass
        else:
            basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '')

        self.source = ei_cmd.egg_info
        self.target = os.path.join(self.install_dir, basename)
        self.outputs = [] 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:27,代码来源:install_egg_info.py

示例6: testComplex

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def testComplex(self):
        if sys.hexversion < 0x2030000:
            # no kw-args to dict in 2.2 - not worth converting!
            return
        clsid = pythoncom.MakeIID("{CD637886-DB8B-4b04-98B5-25731E1495BE}")
        ctime, atime, wtime = self._getTestTimes()
        d = dict(cFileName="foo.txt",
                 clsid=clsid,
                 sizel=(1,2),
                 pointl=(3,4),
                 dwFileAttributes = win32con.FILE_ATTRIBUTE_NORMAL,
                 ftCreationTime=ctime,
                 ftLastAccessTime=atime,
                 ftLastWriteTime=wtime,
                 nFileSize=sys_maxsize + 1)
        self._testRT(d) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:testShell.py

示例7: __setattr2

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def __setattr2( self, name, value ):     # "running" getattr
    # to allow assignments to ROOT globals such as ROOT.gDebug
      if not name in self.__dict__:
         try:
          # assignment to an existing ROOT global (establishes proxy)
            setattr( self.__class__, name, _root.GetCppGlobal( name ) )
         except LookupError:
          # allow a few limited cases where new globals can be set
            if sys.hexversion >= 0x3000000:
               pylong = int
            else:
               pylong = long
            tcnv = { bool        : 'bool %s = %d;',
                     int         : 'int %s = %d;',
                     pylong      : 'long %s = %d;',
                     float       : 'double %s = %f;',
                     str         : 'string %s = "%s";' }
            try:
               _root.gROOT.ProcessLine( tcnv[ type(value) ] % (name,value) );
               setattr( self.__class__, name, _root.GetCppGlobal( name ) )
            except KeyError:
               pass           # can still assign normally, to the module

    # actual assignment through descriptor, or normal python way
      return super( self.__class__, self ).__setattr__( name, value ) 
开发者ID:dnanexus,项目名称:parliament2,代码行数:27,代码来源:ROOT.py

示例8: slugify

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def slugify(value):
    """
    Normalizes string, converts to lowercase, removes non-alpha characters,
    and converts spaces to hyphens.

    :param value: string value to slugify
    :type value: ``str``

    :return: slugified string value, suitable as a directory or filename
    :rtype: ``str``
    """
    if sys.hexversion >= 0x30303F0:
        value = unicodedata.normalize("NFKD", value).encode("ascii", "ignore")
        value = re.sub(br"[^\w\s-]", b"", value).strip().lower()
        return re.sub(br"[-\s]+", b"-", value).decode("ascii")
    else:
        value = unicodedata.normalize("NFKD", six.text_type(value)).encode(
            "ascii", "ignore"
        )
        value = six.text_type(re.sub(r"[^\w\s-]", "", value).strip().lower())
        return str(re.sub(r"[-\s]+", "-", value)) 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:23,代码来源:strings.py

示例9: readf

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def readf(fname,m='r',encoding='ISO8859-1'):
	if sys.hexversion>0x3000000 and not'b'in m:
		m+='b'
		f=open(fname,m)
		try:
			txt=f.read()
		finally:
			f.close()
		if encoding:
			txt=txt.decode(encoding)
		else:
			txt=txt.decode()
	else:
		f=open(fname,m)
		try:
			txt=f.read()
		finally:
			f.close()
	return txt 
开发者ID:MOSAIC-UA,项目名称:802.11ah-ns3,代码行数:21,代码来源:Utils.py

示例10: writef_win32

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def writef_win32(f,data,m='w',encoding='ISO8859-1'):
	if sys.hexversion>0x3000000 and not'b'in m:
		data=data.encode(encoding)
		m+='b'
	flags=os.O_CREAT|os.O_TRUNC|os.O_WRONLY|os.O_NOINHERIT
	if'b'in m:
		flags|=os.O_BINARY
	if'+'in m:
		flags|=os.O_RDWR
	try:
		fd=os.open(f,flags)
	except OSError:
		raise IOError('Cannot write to %r'%f)
	f=os.fdopen(fd,m)
	try:
		f.write(data)
	finally:
		f.close() 
开发者ID:MOSAIC-UA,项目名称:802.11ah-ns3,代码行数:20,代码来源:Utils.py

示例11: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def __init__(cls,name,bases,dict):
		super(store_task_type,cls).__init__(name,bases,dict)
		name=cls.__name__
		if name.endswith('_task'):
			name=name.replace('_task','')
		if name!='evil'and name!='TaskBase':
			global classes
			if getattr(cls,'run_str',None):
				(f,dvars)=compile_fun(cls.run_str,cls.shell)
				cls.hcode=cls.run_str
				cls.orig_run_str=cls.run_str
				cls.run_str=None
				cls.run=f
				cls.vars=list(set(cls.vars+dvars))
				cls.vars.sort()
			elif getattr(cls,'run',None)and not'hcode'in cls.__dict__:
				cls.hcode=Utils.h_fun(cls.run)
			if sys.hexversion>0x3000000:
				cls.hcode=cls.hcode.encode('iso8859-1','xmlcharrefreplace')
			getattr(cls,'register',classes)[name]=cls 
开发者ID:MOSAIC-UA,项目名称:802.11ah-ns3,代码行数:22,代码来源:Task.py

示例12: check_invalid_constraints

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def check_invalid_constraints(self):
	feat=set([])
	for x in list(TaskGen.feats.values()):
		feat.union(set(x))
	for(x,y)in TaskGen.task_gen.prec.items():
		feat.add(x)
		feat.union(set(y))
	ext=set([])
	for x in TaskGen.task_gen.mappings.values():
		ext.add(x.__name__)
	invalid=ext&feat
	if invalid:
		Logs.error('The methods %r have invalid annotations:  @extension <-> @feature/@before_method/@after_method'%list(invalid))
	for cls in list(Task.classes.values()):
		if sys.hexversion>0x3000000 and issubclass(cls,Task.Task)and isinstance(cls.hcode,str):
			raise Errors.WafError('Class %r has hcode value %r of type <str>, expecting <bytes> (use Utils.h_cmd() ?)'%(cls,cls.hcode))
		for x in('before','after'):
			for y in Utils.to_list(getattr(cls,x,[])):
				if not Task.classes.get(y,None):
					Logs.error('Erroneous order constraint %r=%r on task class %r'%(x,y,cls.__name__))
		if getattr(cls,'rule',None):
			Logs.error('Erroneous attribute "rule" on task class %r (rename to "run_str")'%cls.__name__) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:24,代码来源:errcheck.py

示例13: read_json

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def read_json(self,convert=True,encoding='utf-8'):
		import json
		object_pairs_hook=None
		if convert and sys.hexversion<0x3000000:
			try:
				_type=unicode
			except NameError:
				_type=str
			def convert(value):
				if isinstance(value,list):
					return[convert(element)for element in value]
				elif isinstance(value,_type):
					return str(value)
				else:
					return value
			def object_pairs(pairs):
				return dict((str(pair[0]),convert(pair[1]))for pair in pairs)
			object_pairs_hook=object_pairs
		return json.loads(self.read(encoding=encoding),object_pairs_hook=object_pairs_hook) 
开发者ID:KTH,项目名称:royal-chaos,代码行数:21,代码来源:Node.py

示例14: makeAscii

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def makeAscii(data):
    log(repr(data), 5)
    #if sys.hexversion >= 0x02050000:
    #        return data

    try:
        return data.encode('ascii', "ignore")
    except:
        log("Hit except on : " + repr(data))
        s = u""
        for i in data:
            try:
                i.encode("ascii", "ignore")
            except:
                log("Can't convert character", 4)
                continue
            else:
                s += i

        log(repr(s), 5)
        return s


# This function handles stupid utf handling in python. 
开发者ID:dandygithub,项目名称:kodi,代码行数:26,代码来源:XbmcHelpers.py

示例15: test_implementation

# 需要导入模块: import sys [as 别名]
# 或者: from sys import hexversion [as 别名]
def test_implementation(self):
        # This test applies to all implementations equally.

        levels = {'alpha': 0xA, 'beta': 0xB, 'candidate': 0xC, 'final': 0xF}

        self.assertTrue(hasattr(sys.implementation, 'name'))
        self.assertTrue(hasattr(sys.implementation, 'version'))
        self.assertTrue(hasattr(sys.implementation, 'hexversion'))
        self.assertTrue(hasattr(sys.implementation, 'cache_tag'))

        version = sys.implementation.version
        self.assertEqual(version[:2], (version.major, version.minor))

        hexversion = (version.major << 24 | version.minor << 16 |
                      version.micro << 8 | levels[version.releaselevel] << 4 |
                      version.serial << 0)
        self.assertEqual(sys.implementation.hexversion, hexversion)

        # PEP 421 requires that .name be lower case.
        self.assertEqual(sys.implementation.name,
                         sys.implementation.name.lower()) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:test_sys.py


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