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


Python builtins.object方法代码示例

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


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

示例1: push

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def push(self, data):
        """Push some new data into this object."""
        # Handle any previous leftovers
        data, self._partial = self._partial + data, ''
        # Crack into lines, but preserve the newlines on the end of each
        parts = NLCRE_crack.split(data)
        # The *ahem* interesting behaviour of re.split when supplied grouping
        # parentheses is that the last element of the resulting list is the
        # data after the final RE.  In the case of a NL/CR terminated string,
        # this is the empty string.
        self._partial = parts.pop()
        #GAN 29Mar09  bugs 1555570, 1721862  Confusion at 8K boundary ending with \r:
        # is there a \n to follow later?
        if not self._partial and parts and parts[-1].endswith('\r'):
            self._partial = parts.pop(-2)+parts.pop()
        # parts is a list of strings, alternating between the line contents
        # and the eol character(s).  Gather up a list of lines after
        # re-attaching the newlines.
        lines = []
        for i in range(len(parts) // 2):
            lines.append(parts[i*2] + parts[i*2+1])
        self.pushlines(lines) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:24,代码来源:feedparser.py

示例2: test_implements_py2_nonzero

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def test_implements_py2_nonzero(self):
        
        class EvenIsTrue(object):
            """
            An integer that evaluates to True if even.
            """
            def __init__(self, my_int):
                self.my_int = my_int
            def __bool__(self):
                return self.my_int % 2 == 0
            def __add__(self, other):
                return type(self)(self.my_int + other)

        k = EvenIsTrue(5)
        self.assertFalse(k)
        self.assertFalse(bool(k))
        self.assertTrue(k + 1)
        self.assertTrue(bool(k + 1))
        self.assertFalse(k + 2) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:21,代码来源:test_object.py

示例3: test_int_implements_py2_nonzero

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def test_int_implements_py2_nonzero(self):
        """
        Tests whether the newint object provides a __nonzero__ method that
        maps to __bool__ in case the user redefines __bool__ in a subclass of
        newint.
        """
        
        class EvenIsTrue(int):
            """
            An integer that evaluates to True if even.
            """
            def __bool__(self):
                return self % 2 == 0
            def __add__(self, other):
                val = super().__add__(other)
                return type(self)(val)

        k = EvenIsTrue(5)
        self.assertFalse(k)
        self.assertFalse(bool(k))
        self.assertTrue(k + 1)
        self.assertTrue(bool(k + 1))
        self.assertFalse(k + 2) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:25,代码来源:test_object.py

示例4: get_configuration_from_object

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def get_configuration_from_object(configuration_schema, target_object):
    """Get configuration, based on the values in a given object's fields.

    Args:
        configuration_schema (dict): a match between each target option to its
            sources.
        target_object (object): object to search target options in.

    Returns:
        dict: a match between each target option to the given value.
    """
    configuration = {}
    for target, option in six.iteritems(configuration_schema):
        for key in option.environment_variables:
            if hasattr(target_object, key):
                configuration[target] = getattr(target_object, key)
                break

    return configuration 
开发者ID:gregoil,项目名称:rotest,代码行数:21,代码来源:config.py

示例5: __init__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def __init__(self):
        # The last partial line pushed into this object.
        self._partial = ''
        # The list of full, pushed lines, in reverse order
        self._lines = []
        # The stack of false-EOF checking predicates.
        self._eofstack = []
        # A flag indicating whether the file has been closed or not.
        self._closed = False 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:11,代码来源:feedparser.py

示例6: close

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def close(self):
        """Parse all remaining data and return the root message object."""
        self._input.close()
        self._call_parse()
        root = self._pop_message()
        assert not self._msgstack
        # Look for final set of defects
        if root.get_content_maintype() == 'multipart' \
               and not root.is_multipart():
            defect = errors.MultipartInvariantViolationDefect()
            self.policy.handle_defect(root, defect)
        return root 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:14,代码来源:feedparser.py

示例7: __init__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def __init__(self, fp):
        # TODO(jhylton): Is there a better way to delegate using io?
        self.fp = fp
        self.read = self.fp.read
        self.readline = self.fp.readline
        # TODO(jhylton): Make sure an object with readlines() is also iterable
        if hasattr(self.fp, "readlines"):
            self.readlines = self.fp.readlines
        if hasattr(self.fp, "fileno"):
            self.fileno = self.fp.fileno
        else:
            self.fileno = lambda: None 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:14,代码来源:response.py

示例8: __init__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import object [as 别名]
def __init__(self, _factory=message.Message, **_3to2kwargs):
        if 'policy' in _3to2kwargs: policy = _3to2kwargs['policy']; del _3to2kwargs['policy']
        else: policy = compat32
        """_factory is called with no arguments to create a new message obj

        The policy keyword specifies a policy object that controls a number of
        aspects of the parser's operation.  The default policy maintains
        backward compatibility.

        """
        self._factory = _factory
        self.policy = policy
        try:
            _factory(policy=self.policy)
            self._factory_kwds = lambda: {'policy': self.policy}
        except TypeError:
            # Assume this is an old-style factory
            self._factory_kwds = lambda: {}
        self._input = BufferedSubFile()
        self._msgstack = []
        if PY3:
            self._parse = self._parsegen().__next__
        else:
            self._parse = self._parsegen().next
        self._cur = None
        self._last = None
        self._headersonly = False

    # Non-public interface for supporting Parser's headersonly flag 
开发者ID:remg427,项目名称:misp42splunk,代码行数:31,代码来源:feedparser.py


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