本文整理汇总了Python中six.add_move函数的典型用法代码示例。如果您正苦于以下问题:Python add_move函数的具体用法?Python add_move怎么用?Python add_move使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_move函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_custom_move_module
def test_custom_move_module(self):
attr = six.MovedModule("spam", "six", "six")
six.add_move(attr)
six.remove_move("spam")
assert not hasattr(six.moves, "spam")
attr = six.MovedModule("spam", "six", "six")
six.add_move(attr)
from six.moves import spam
assert spam is six
six.remove_move("spam")
assert not hasattr(six.moves, "spam")
开发者ID:A-Maze,项目名称:A-Pc,代码行数:11,代码来源:test_six.py
示例2: test_custom_move_attribute
def test_custom_move_attribute(self):
attr = six.MovedAttribute("spam", "six", "six", "u", "u")
six.add_move(attr)
six.remove_move("spam")
assert not hasattr(six.moves, "spam")
attr = six.MovedAttribute("spam", "six", "six", "u", "u")
six.add_move(attr)
from six.moves import spam
assert spam is six.u
six.remove_move("spam")
assert not hasattr(six.moves, "spam")
开发者ID:A-Maze,项目名称:A-Pc,代码行数:11,代码来源:test_six.py
示例3: TestMakePrefixes
#!/usr/bin/env python
import shutil
import tempfile
from unittest import TestCase
import six
six.add_move(six.MovedModule('mock', 'mock', 'unittest.mock'))
from six.moves import mock
from ansibullbot.utils.component_tools import AnsibleComponentMatcher as ComponentMatcher
from ansibullbot.utils.component_tools import make_prefixes
from ansibullbot.utils.git_tools import GitRepoWrapper
from ansibullbot.utils.file_tools import FileIndexer
from ansibullbot.utils.systemtools import run_command
class TestMakePrefixes(TestCase):
def test_simple_path_is_split_correctly(self):
fp = u'lib/ansible/foo/bar'
prefixes = make_prefixes(fp)
assert len(prefixes) == len(fp)
assert fp in prefixes
assert prefixes[0] == fp
assert prefixes[-1] == u'l'
class GitShallowRepo(GitRepoWrapper):
"""Perform a shallow copy"""
开发者ID:jctanner,项目名称:ansibullbot,代码行数:30,代码来源:test_component_tools.py
示例4: limit
import time
from xml.etree import cElementTree as et
import six
six.add_move(six.MovedAttribute('html_escape', 'cgi', 'html', 'escape'))
from six.moves import html_escape
from . import Device
from ..color import get_profiles, limit_to_gamut
CAPABILITY_ID2NAME = dict((
('10006', "onoff"),
('10008', "levelcontrol"),
('30008', "sleepfader"),
('30009', "levelcontrol_move"),
('3000A', "levelcontrol_stop"),
('10300', "colorcontrol"),
('30301', "colortemperature"),
))
CAPABILITY_NAME2ID = dict(
(val, cap) for cap, val in CAPABILITY_ID2NAME.items())
# acceptable values for 'onoff'
OFF = 0
ON = 1
TOGGLE = 2
def limit(value, min_val, max_val):
"""Returns value clipped to the range [min_val, max_val]"""
return max(min_val, min(value, max_val))
开发者ID:gstorer,项目名称:pywemo,代码行数:30,代码来源:bridge.py
示例5: add_move
# This file is part of reddit_api.
#
# reddit_api is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# reddit_api is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with reddit_api. If not, see <http://www.gnu.org/licenses/>.
from six import MovedAttribute, add_move
add_move(MovedAttribute("HTTPError", "urllib2", "urllib.error"))
add_move(MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"))
add_move(MovedAttribute("Request", "urllib2", "urllib.request"))
add_move(MovedAttribute("URLError", "urllib2", "urllib.error"))
add_move(MovedAttribute("build_opener", "urllib2", "urllib.request"))
add_move(MovedAttribute("quote", "urllib2", "urllib.parse"))
add_move(MovedAttribute("urlencode", "urllib", "urllib.parse"))
add_move(MovedAttribute("urljoin", "urlparse", "urllib.parse"))
开发者ID:robftz,项目名称:reddit_api,代码行数:25,代码来源:backport.py
示例6:
import six
six.add_move(six.MovedModule('mox', 'mox', 'mox3.mox'))
开发者ID:Acidburn0zzz,项目名称:python-glanceclient,代码行数:2,代码来源:__init__.py
示例7: add_move
from __future__ import print_function
import time
from six.moves import xrange
from six import add_move, MovedModule
add_move(MovedModule('autopy', 'autopy', 'autopy3'))
from six.moves import autopy
def take_screenshot(filename, delay):
for i in xrange(1, delay+1):
time.sleep(1)
print(i)
autopy.bitmap.capture_screen().save(filename)
autopy.alert.alert('A screenshot has been saved.')
开发者ID:csettles,项目名称:climgur,代码行数:15,代码来源:screenshot.py
示例8:
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from __future__ import absolute_import
import six
moves = [
six.MovedAttribute("getoutput", "commands", "subprocess"),
]
for m in moves:
six.add_move(m)
# Here, we can't use six.Moved* methods because being able to import asyncio vs
# trollius is not strictly Py 2 vs Py 3, but rather asyncio for >=3.4, and
# possibly 3.3 with Tulip, and trollius for 2 and <=3.2, and 3.3 without Tulip.
# We can no longer direct assign to six.moves, so let's just leave it here so
# we don't need to keep try/except importing asyncio.
try:
import asyncio # noqa
except ImportError:
import trollius as asyncio # noqa
开发者ID:20after4,项目名称:qtile,代码行数:30,代码来源:__init__.py
示例9: formatter_help_inline
"""formatters we use
"""
# stdlib
import cgi
# pypi
import formencode
import six
six.add_move(six.MovedAttribute("html_escape", "cgi", "html", "escape", "escape"))
from six.moves import html_escape
def formatter_help_inline(error):
"""
Formatter that escapes the error, wraps the error in a span with
class ``help-inline``, and doesn't add a ``<br>`` ; somewhat compatible with twitter's bootstrap
"""
return '<span class="help-inline">%s</span>\n' % formencode.rewritingparser.html_quote(error)
def formatter_hidden(error):
"""
returns a hidden field with the error in the name
"""
return '<input type="hidden" name="%s" />\n' % html_escape(error)
def formatter_nobr(error):
"""
This is a variant of the htmlfill `default_formatter`, in which a trailing <br/> is not included
开发者ID:jvanasco,项目名称:pyramid_formencode_classic,代码行数:30,代码来源:formatters.py
示例10: add_move
def add_move(mod):
_six.add_move(mod)
# https://bitbucket.org/gutworth/six/issues/116/enable-importing-from-within-custom
_six._importer._add_module(mod, "moves." + mod.name)
开发者ID:rhinstaller,项目名称:blivet,代码行数:4,代码来源:test_compat.py
示例11: add_move
import os
import unittest
from six import add_move, MovedModule
add_move(MovedModule('test_support', 'test.test_support', 'test.support'))
from six.moves import test_support
import vcr
from ..orbital_gateway import Order, Profile, Reversal
from .live_orbital_gateway_certification import Certification
TEST_DATA_DIR = os.path.dirname(__file__)
def create_sequence(current_value):
# if we are here
while True:
yield str(current_value)
current_value += 1
class TestProfileFunctions(unittest.TestCase):
def setUp(self):
# setup test env vars
self.env = test_support.EnvironmentVarGuard()
self.env.set('ORBITAL_PASSWORD', 'potato')
self.env.set('ORBITAL_MERCHANT_ID', '1234')
self.env.set('ORBITAL_USERNAME', 'yeah')
self.c = Certification(
开发者ID:SendOutCards,项目名称:chase,代码行数:31,代码来源:test_chase.py
示例12: add_moves
def add_moves():
add_move(MovedAttribute('HTTPError', 'urllib2', 'urllib.error'))
add_move(MovedAttribute('HTTPCookieProcessor', 'urllib2',
'urllib.request'))
add_move(MovedAttribute('Request', 'urllib2', 'urllib.request'))
add_move(MovedAttribute('URLError', 'urllib2', 'urllib.error'))
add_move(MovedAttribute('build_opener', 'urllib2', 'urllib.request'))
add_move(MovedAttribute('quote', 'urllib2', 'urllib.parse'))
add_move(MovedAttribute('urlencode', 'urllib', 'urllib.parse'))
add_move(MovedAttribute('urljoin', 'urlparse', 'urllib.parse'))
开发者ID:andrewcase,项目名称:praw,代码行数:10,代码来源:backport.py
示例13:
# from http://stackoverflow.com/questions/28215214/how-to-add-custom-renames-in-six
import six
mod = six.MovedModule('mock', 'mock', 'unittest.mock')
six.add_move(mod)
six._importer._add_module(mod, "moves." + mod.name)
# issue open at https://bitbucket.org/gutworth/six/issue/116/enable-importing-from-within-custom
开发者ID:Nextpertise,项目名称:tinyrpc,代码行数:8,代码来源:_compat.py
示例14: Copyright
#
# Copyright (c) 2019, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
"""Unit tests for the logfileparser module."""
import io
import os
import sys
import tempfile
import unittest
from six import add_move, MovedModule
add_move(MovedModule('mock', 'mock', 'unittest.mock'))
from six.moves import mock
from six.moves.urllib.request import urlopen
import numpy
import cclib
__filedir__ = os.path.dirname(__file__)
__filepath__ = os.path.realpath(__filedir__)
__datadir__ = os.path.join(__filepath__, "..", "..")
class FileWrapperTest(unittest.TestCase):
def test_file_seek(self):
开发者ID:cclib,项目名称:cclib,代码行数:31,代码来源:testlogfileparser.py
示例15: MovedModule
__all__ = ['utf8_cat']
from six import PY3
from six import MovedModule
from six import MovedAttribute
from six import add_move
attributes = [
MovedModule('xmlrpc_client', 'xmlrpclib', 'xmlrpc.client'),
MovedAttribute('HTTPError', 'urllib2', 'urllib.error'),
MovedAttribute('URLError', 'urllib2', 'urllib.error'),
MovedAttribute('Request', 'urllib2', 'urllib.request'),
MovedAttribute('urlopen', 'urllib2', 'urllib.request'),
MovedAttribute('urllib_version', 'urllib2', 'urllib.request', '__version__'),
MovedAttribute('urlparse', 'urlparse', 'urllib.parse'),
]
for attr in attributes:
add_move(attr)
del attr
del attributes
if PY3:
def utf8_cat(f):
"""Read the given file in utf8 encoding"""
return open(f, encoding='utf8').read()
else:
def utf8_cat(f):
"""Read the given file in utf8 encoding"""
return open(f).read().decode('utf8')
开发者ID:Augus-Wang,项目名称:xunlei_vip,代码行数:30,代码来源:backport.py
示例16:
* Symbol : contains a constant, a variable or a predicate. Instantiated before executing the datalog program
* Function : represents f[X]
* Operation : made of an operator and 2 operands. Instantiated when an operator is applied to a symbol while executing the datalog program
* Lambda : represents a lambda function, used in expressions
* Aggregate : represents calls to aggregation method, e.g. min(X)
"""
import ast
from collections import defaultdict, OrderedDict
import inspect
import os
import re
import string
import six
six.add_move(six.MovedModule('UserList', 'UserList', 'collections'))
from six.moves import builtins, xrange, UserList
import sys
import weakref
PY3 = sys.version_info[0] == 3
func_code = '__code__' if PY3 else 'func_code'
try:
from . import pyEngine
except ValueError:
import pyEngine
pyDatalog = None #circ: later set by pyDatalog to avoid circular import
""" global variable to differentiate between in-line queries and pyDatalog program / ask"""
ProgramMode = False
开发者ID:52nlp,项目名称:pydatalog,代码行数:31,代码来源:pyParser.py
注:本文中的six.add_move函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论