From 4b123773bb267cb0803502b94894800e7ff0817e Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Fri, 17 Oct 2014 19:25:45 +0400 Subject: [PATCH] Django 1.7 Py3K fix --- .../MockSdk3.4/Lib/collections/__init__.py | 1129 ++++ .../MockSdk3.4/Lib/collections/__main__.py | 38 + .../MockSdk3.4/Lib/collections/abc.py | 2 + python/testData/MockSdk3.4/Lib/datetime.py | 2136 ++++++ python/testData/MockSdk3.4/Lib/io.py | 92 + python/testData/MockSdk3.4/Lib/numbers.py | 394 ++ python/testData/MockSdk3.4/Lib/re.py | 368 ++ python/testData/MockSdk3.4/bin/python3.4 | 1 + .../testData/MockSdk3.4/python_stubs/_io.py | 1517 +++++ .../MockSdk3.4/python_stubs/builtins.py | 5864 +++++++++++++++++ .../testData/MockSdk3.4/python_stubs/sys.py | 601 ++ .../jetbrains/python/fixtures/PyTestCase.java | 4 +- 12 files changed, 12144 insertions(+), 2 deletions(-) create mode 100644 python/testData/MockSdk3.4/Lib/collections/__init__.py create mode 100644 python/testData/MockSdk3.4/Lib/collections/__main__.py create mode 100644 python/testData/MockSdk3.4/Lib/collections/abc.py create mode 100644 python/testData/MockSdk3.4/Lib/datetime.py create mode 100644 python/testData/MockSdk3.4/Lib/io.py create mode 100644 python/testData/MockSdk3.4/Lib/numbers.py create mode 100644 python/testData/MockSdk3.4/Lib/re.py create mode 100644 python/testData/MockSdk3.4/bin/python3.4 create mode 100644 python/testData/MockSdk3.4/python_stubs/_io.py create mode 100644 python/testData/MockSdk3.4/python_stubs/builtins.py create mode 100644 python/testData/MockSdk3.4/python_stubs/sys.py diff --git a/python/testData/MockSdk3.4/Lib/collections/__init__.py b/python/testData/MockSdk3.4/Lib/collections/__init__.py new file mode 100644 index 000000000000..d6deb6a7b262 --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/collections/__init__.py @@ -0,0 +1,1129 @@ +__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList', + 'UserString', 'Counter', 'OrderedDict', 'ChainMap'] + +# For backwards compatibility, continue to make the collections ABCs +# available through the collections module. +from _collections_abc import * +import _collections_abc +__all__ += _collections_abc.__all__ + +from _collections import deque, defaultdict +from operator import itemgetter as _itemgetter, eq as _eq +from keyword import iskeyword as _iskeyword +import sys as _sys +import heapq as _heapq +from _weakref import proxy as _proxy +from itertools import repeat as _repeat, chain as _chain, starmap as _starmap +from reprlib import recursive_repr as _recursive_repr + +################################################################################ +### OrderedDict +################################################################################ + +class _Link(object): + __slots__ = 'prev', 'next', 'key', '__weakref__' + +class OrderedDict(dict): + 'Dictionary that remembers insertion order' + # An inherited dict maps keys to values. + # The inherited dict provides __getitem__, __len__, __contains__, and get. + # The remaining methods are order-aware. + # Big-O running times for all methods are the same as regular dictionaries. + + # The internal self.__map dict maps keys to links in a doubly linked list. + # The circular doubly linked list starts and ends with a sentinel element. + # The sentinel element never gets deleted (this simplifies the algorithm). + # The sentinel is in self.__hardroot with a weakref proxy in self.__root. + # The prev links are weakref proxies (to prevent circular references). + # Individual links are kept alive by the hard reference in self.__map. + # Those hard references disappear when a key is deleted from an OrderedDict. + + def __init__(self, *args, **kwds): + '''Initialize an ordered dictionary. The signature is the same as + regular dictionaries, but keyword arguments are not recommended because + their insertion order is arbitrary. + + ''' + if len(args) > 1: + raise TypeError('expected at most 1 arguments, got %d' % len(args)) + try: + self.__root + except AttributeError: + self.__hardroot = _Link() + self.__root = root = _proxy(self.__hardroot) + root.prev = root.next = root + self.__map = {} + self.__update(*args, **kwds) + + def __setitem__(self, key, value, + dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link): + 'od.__setitem__(i, y) <==> od[i]=y' + # Setting a new item creates a new link at the end of the linked list, + # and the inherited dictionary is updated with the new key/value pair. + if key not in self: + self.__map[key] = link = Link() + root = self.__root + last = root.prev + link.prev, link.next, link.key = last, root, key + last.next = link + root.prev = proxy(link) + dict_setitem(self, key, value) + + def __delitem__(self, key, dict_delitem=dict.__delitem__): + 'od.__delitem__(y) <==> del od[y]' + # Deleting an existing item uses self.__map to find the link which gets + # removed by updating the links in the predecessor and successor nodes. + dict_delitem(self, key) + link = self.__map.pop(key) + link_prev = link.prev + link_next = link.next + link_prev.next = link_next + link_next.prev = link_prev + + def __iter__(self): + 'od.__iter__() <==> iter(od)' + # Traverse the linked list in order. + root = self.__root + curr = root.next + while curr is not root: + yield curr.key + curr = curr.next + + def __reversed__(self): + 'od.__reversed__() <==> reversed(od)' + # Traverse the linked list in reverse order. + root = self.__root + curr = root.prev + while curr is not root: + yield curr.key + curr = curr.prev + + def clear(self): + 'od.clear() -> None. Remove all items from od.' + root = self.__root + root.prev = root.next = root + self.__map.clear() + dict.clear(self) + + def popitem(self, last=True): + '''od.popitem() -> (k, v), return and remove a (key, value) pair. + Pairs are returned in LIFO order if last is true or FIFO order if false. + + ''' + if not self: + raise KeyError('dictionary is empty') + root = self.__root + if last: + link = root.prev + link_prev = link.prev + link_prev.next = root + root.prev = link_prev + else: + link = root.next + link_next = link.next + root.next = link_next + link_next.prev = root + key = link.key + del self.__map[key] + value = dict.pop(self, key) + return key, value + + def move_to_end(self, key, last=True): + '''Move an existing element to the end (or beginning if last==False). + + Raises KeyError if the element does not exist. + When last=True, acts like a fast version of self[key]=self.pop(key). + + ''' + link = self.__map[key] + link_prev = link.prev + link_next = link.next + link_prev.next = link_next + link_next.prev = link_prev + root = self.__root + if last: + last = root.prev + link.prev = last + link.next = root + last.next = root.prev = link + else: + first = root.next + link.prev = root + link.next = first + root.next = first.prev = link + + def __sizeof__(self): + sizeof = _sys.getsizeof + n = len(self) + 1 # number of links including root + size = sizeof(self.__dict__) # instance dictionary + size += sizeof(self.__map) * 2 # internal dict and inherited dict + size += sizeof(self.__hardroot) * n # link objects + size += sizeof(self.__root) * n # proxy objects + return size + + update = __update = MutableMapping.update + keys = MutableMapping.keys + values = MutableMapping.values + items = MutableMapping.items + __ne__ = MutableMapping.__ne__ + + __marker = object() + + def pop(self, key, default=__marker): + '''od.pop(k[,d]) -> v, remove specified key and return the corresponding + value. If key is not found, d is returned if given, otherwise KeyError + is raised. + + ''' + if key in self: + result = self[key] + del self[key] + return result + if default is self.__marker: + raise KeyError(key) + return default + + def setdefault(self, key, default=None): + 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od' + if key in self: + return self[key] + self[key] = default + return default + + @_recursive_repr() + def __repr__(self): + 'od.__repr__() <==> repr(od)' + if not self: + return '%s()' % (self.__class__.__name__,) + return '%s(%r)' % (self.__class__.__name__, list(self.items())) + + def __reduce__(self): + 'Return state information for pickling' + inst_dict = vars(self).copy() + for k in vars(OrderedDict()): + inst_dict.pop(k, None) + return self.__class__, (), inst_dict or None, None, iter(self.items()) + + def copy(self): + 'od.copy() -> a shallow copy of od' + return self.__class__(self) + + @classmethod + def fromkeys(cls, iterable, value=None): + '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S. + If not specified, the value defaults to None. + + ''' + self = cls() + for key in iterable: + self[key] = value + return self + + def __eq__(self, other): + '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive + while comparison to a regular mapping is order-insensitive. + + ''' + if isinstance(other, OrderedDict): + return dict.__eq__(self, other) and all(map(_eq, self, other)) + return dict.__eq__(self, other) + + +################################################################################ +### namedtuple +################################################################################ + +_class_template = """\ +from builtins import property as _property, tuple as _tuple +from operator import itemgetter as _itemgetter +from collections import OrderedDict + +class {typename}(tuple): + '{typename}({arg_list})' + + __slots__ = () + + _fields = {field_names!r} + + def __new__(_cls, {arg_list}): + 'Create new instance of {typename}({arg_list})' + return _tuple.__new__(_cls, ({arg_list})) + + @classmethod + def _make(cls, iterable, new=tuple.__new__, len=len): + 'Make a new {typename} object from a sequence or iterable' + result = new(cls, iterable) + if len(result) != {num_fields:d}: + raise TypeError('Expected {num_fields:d} arguments, got %d' % len(result)) + return result + + def _replace(_self, **kwds): + 'Return a new {typename} object replacing specified fields with new values' + result = _self._make(map(kwds.pop, {field_names!r}, _self)) + if kwds: + raise ValueError('Got unexpected field names: %r' % list(kwds)) + return result + + def __repr__(self): + 'Return a nicely formatted representation string' + return self.__class__.__name__ + '({repr_fmt})' % self + + @property + def __dict__(self): + 'A new OrderedDict mapping field names to their values' + return OrderedDict(zip(self._fields, self)) + + def _asdict(self): + 'Return a new OrderedDict which maps field names to their values.' + return self.__dict__ + + def __getnewargs__(self): + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) + + def __getstate__(self): + 'Exclude the OrderedDict from pickling' + return None + +{field_defs} +""" + +_repr_template = '{name}=%r' + +_field_template = '''\ + {name} = _property(_itemgetter({index:d}), doc='Alias for field number {index:d}') +''' + +def namedtuple(typename, field_names, verbose=False, rename=False): + """Returns a new subclass of tuple with named fields. + + >>> Point = namedtuple('Point', ['x', 'y']) + >>> Point.__doc__ # docstring for the new class + 'Point(x, y)' + >>> p = Point(11, y=22) # instantiate with positional args or keywords + >>> p[0] + p[1] # indexable like a plain tuple + 33 + >>> x, y = p # unpack like a regular tuple + >>> x, y + (11, 22) + >>> p.x + p.y # fields also accessable by name + 33 + >>> d = p._asdict() # convert to a dictionary + >>> d['x'] + 11 + >>> Point(**d) # convert from a dictionary + Point(x=11, y=22) + >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields + Point(x=100, y=22) + + """ + + # Validate the field names. At the user's option, either generate an error + # message or automatically replace the field name with a valid name. + if isinstance(field_names, str): + field_names = field_names.replace(',', ' ').split() + field_names = list(map(str, field_names)) + if rename: + seen = set() + for index, name in enumerate(field_names): + if (not name.isidentifier() + or _iskeyword(name) + or name.startswith('_') + or name in seen): + field_names[index] = '_%d' % index + seen.add(name) + for name in [typename] + field_names: + if not name.isidentifier(): + raise ValueError('Type names and field names must be valid ' + 'identifiers: %r' % name) + if _iskeyword(name): + raise ValueError('Type names and field names cannot be a ' + 'keyword: %r' % name) + seen = set() + for name in field_names: + if name.startswith('_') and not rename: + raise ValueError('Field names cannot start with an underscore: ' + '%r' % name) + if name in seen: + raise ValueError('Encountered duplicate field name: %r' % name) + seen.add(name) + + # Fill-in the class template + class_definition = _class_template.format( + typename = typename, + field_names = tuple(field_names), + num_fields = len(field_names), + arg_list = repr(tuple(field_names)).replace("'", "")[1:-1], + repr_fmt = ', '.join(_repr_template.format(name=name) + for name in field_names), + field_defs = '\n'.join(_field_template.format(index=index, name=name) + for index, name in enumerate(field_names)) + ) + + # Execute the template string in a temporary namespace and support + # tracing utilities by setting a value for frame.f_globals['__name__'] + namespace = dict(__name__='namedtuple_%s' % typename) + exec(class_definition, namespace) + result = namespace[typename] + result._source = class_definition + if verbose: + print(result._source) + + # For pickling to work, the __module__ variable needs to be set to the frame + # where the named tuple is created. Bypass this step in environments where + # sys._getframe is not defined (Jython for example) or sys._getframe is not + # defined for arguments greater than 0 (IronPython). + try: + result.__module__ = _sys._getframe(1).f_globals.get('__name__', '__main__') + except (AttributeError, ValueError): + pass + + return result + + +######################################################################## +### Counter +######################################################################## + +def _count_elements(mapping, iterable): + 'Tally elements from the iterable.' + mapping_get = mapping.get + for elem in iterable: + mapping[elem] = mapping_get(elem, 0) + 1 + +try: # Load C helper function if available + from _collections import _count_elements +except ImportError: + pass + +class Counter(dict): + '''Dict subclass for counting hashable items. Sometimes called a bag + or multiset. Elements are stored as dictionary keys and their counts + are stored as dictionary values. + + >>> c = Counter('abcdeabcdabcaba') # count elements from a string + + >>> c.most_common(3) # three most common elements + [('a', 5), ('b', 4), ('c', 3)] + >>> sorted(c) # list all unique elements + ['a', 'b', 'c', 'd', 'e'] + >>> ''.join(sorted(c.elements())) # list elements with repetitions + 'aaaaabbbbcccdde' + >>> sum(c.values()) # total of all counts + 15 + + >>> c['a'] # count of letter 'a' + 5 + >>> for elem in 'shazam': # update counts from an iterable + ... c[elem] += 1 # by adding 1 to each element's count + >>> c['a'] # now there are seven 'a' + 7 + >>> del c['b'] # remove all 'b' + >>> c['b'] # now there are zero 'b' + 0 + + >>> d = Counter('simsalabim') # make another counter + >>> c.update(d) # add in the second counter + >>> c['a'] # now there are nine 'a' + 9 + + >>> c.clear() # empty the counter + >>> c + Counter() + + Note: If a count is set to zero or reduced to zero, it will remain + in the counter until the entry is deleted or the counter is cleared: + + >>> c = Counter('aaabbc') + >>> c['b'] -= 2 # reduce the count of 'b' by two + >>> c.most_common() # 'b' is still in, but its count is zero + [('a', 3), ('c', 1), ('b', 0)] + + ''' + # References: + # http://en.wikipedia.org/wiki/Multiset + # http://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html + # http://www.demo2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm + # http://code.activestate.com/recipes/259174/ + # Knuth, TAOCP Vol. II section 4.6.3 + + def __init__(self, iterable=None, **kwds): + '''Create a new, empty Counter object. And if given, count elements + from an input iterable. Or, initialize the count from another mapping + of elements to their counts. + + >>> c = Counter() # a new, empty counter + >>> c = Counter('gallahad') # a new counter from an iterable + >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping + >>> c = Counter(a=4, b=2) # a new counter from keyword args + + ''' + super().__init__() + self.update(iterable, **kwds) + + def __missing__(self, key): + 'The count of elements not in the Counter is zero.' + # Needed so that self[missing_item] does not raise KeyError + return 0 + + def most_common(self, n=None): + '''List the n most common elements and their counts from the most + common to the least. If n is None, then list all element counts. + + >>> Counter('abcdeabcdabcaba').most_common(3) + [('a', 5), ('b', 4), ('c', 3)] + + ''' + # Emulate Bag.sortedByCount from Smalltalk + if n is None: + return sorted(self.items(), key=_itemgetter(1), reverse=True) + return _heapq.nlargest(n, self.items(), key=_itemgetter(1)) + + def elements(self): + '''Iterator over elements repeating each as many times as its count. + + >>> c = Counter('ABCABC') + >>> sorted(c.elements()) + ['A', 'A', 'B', 'B', 'C', 'C'] + + # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 + >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) + >>> product = 1 + >>> for factor in prime_factors.elements(): # loop over factors + ... product *= factor # and multiply them + >>> product + 1836 + + Note, if an element's count has been set to zero or is a negative + number, elements() will ignore it. + + ''' + # Emulate Bag.do from Smalltalk and Multiset.begin from C++. + return _chain.from_iterable(_starmap(_repeat, self.items())) + + # Override dict methods where necessary + + @classmethod + def fromkeys(cls, iterable, v=None): + # There is no equivalent method for counters because setting v=1 + # means that no element can have a count greater than one. + raise NotImplementedError( + 'Counter.fromkeys() is undefined. Use Counter(iterable) instead.') + + def update(self, iterable=None, **kwds): + '''Like dict.update() but add counts instead of replacing them. + + Source can be an iterable, a dictionary, or another Counter instance. + + >>> c = Counter('which') + >>> c.update('witch') # add elements from another iterable + >>> d = Counter('watch') + >>> c.update(d) # add elements from another counter + >>> c['h'] # four 'h' in which, witch, and watch + 4 + + ''' + # The regular dict.update() operation makes no sense here because the + # replace behavior results in the some of original untouched counts + # being mixed-in with all of the other counts for a mismash that + # doesn't have a straight-forward interpretation in most counting + # contexts. Instead, we implement straight-addition. Both the inputs + # and outputs are allowed to contain zero and negative counts. + + if iterable is not None: + if isinstance(iterable, Mapping): + if self: + self_get = self.get + for elem, count in iterable.items(): + self[elem] = count + self_get(elem, 0) + else: + super().update(iterable) # fast path when counter is empty + else: + _count_elements(self, iterable) + if kwds: + self.update(kwds) + + def subtract(self, iterable=None, **kwds): + '''Like dict.update() but subtracts counts instead of replacing them. + Counts can be reduced below zero. Both the inputs and outputs are + allowed to contain zero and negative counts. + + Source can be an iterable, a dictionary, or another Counter instance. + + >>> c = Counter('which') + >>> c.subtract('witch') # subtract elements from another iterable + >>> c.subtract(Counter('watch')) # subtract elements from another counter + >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch + 0 + >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch + -1 + + ''' + if iterable is not None: + self_get = self.get + if isinstance(iterable, Mapping): + for elem, count in iterable.items(): + self[elem] = self_get(elem, 0) - count + else: + for elem in iterable: + self[elem] = self_get(elem, 0) - 1 + if kwds: + self.subtract(kwds) + + def copy(self): + 'Return a shallow copy.' + return self.__class__(self) + + def __reduce__(self): + return self.__class__, (dict(self),) + + def __delitem__(self, elem): + 'Like dict.__delitem__() but does not raise KeyError for missing values.' + if elem in self: + super().__delitem__(elem) + + def __repr__(self): + if not self: + return '%s()' % self.__class__.__name__ + try: + items = ', '.join(map('%r: %r'.__mod__, self.most_common())) + return '%s({%s})' % (self.__class__.__name__, items) + except TypeError: + # handle case where values are not orderable + return '{0}({1!r})'.format(self.__class__.__name__, dict(self)) + + # Multiset-style mathematical operations discussed in: + # Knuth TAOCP Volume II section 4.6.3 exercise 19 + # and at http://en.wikipedia.org/wiki/Multiset + # + # Outputs guaranteed to only include positive counts. + # + # To strip negative and zero counts, add-in an empty counter: + # c += Counter() + + def __add__(self, other): + '''Add counts from two counters. + + >>> Counter('abbb') + Counter('bcc') + Counter({'b': 4, 'c': 2, 'a': 1}) + + ''' + if not isinstance(other, Counter): + return NotImplemented + result = Counter() + for elem, count in self.items(): + newcount = count + other[elem] + if newcount > 0: + result[elem] = newcount + for elem, count in other.items(): + if elem not in self and count > 0: + result[elem] = count + return result + + def __sub__(self, other): + ''' Subtract count, but keep only results with positive counts. + + >>> Counter('abbbc') - Counter('bccd') + Counter({'b': 2, 'a': 1}) + + ''' + if not isinstance(other, Counter): + return NotImplemented + result = Counter() + for elem, count in self.items(): + newcount = count - other[elem] + if newcount > 0: + result[elem] = newcount + for elem, count in other.items(): + if elem not in self and count < 0: + result[elem] = 0 - count + return result + + def __or__(self, other): + '''Union is the maximum of value in either of the input counters. + + >>> Counter('abbb') | Counter('bcc') + Counter({'b': 3, 'c': 2, 'a': 1}) + + ''' + if not isinstance(other, Counter): + return NotImplemented + result = Counter() + for elem, count in self.items(): + other_count = other[elem] + newcount = other_count if count < other_count else count + if newcount > 0: + result[elem] = newcount + for elem, count in other.items(): + if elem not in self and count > 0: + result[elem] = count + return result + + def __and__(self, other): + ''' Intersection is the minimum of corresponding counts. + + >>> Counter('abbb') & Counter('bcc') + Counter({'b': 1}) + + ''' + if not isinstance(other, Counter): + return NotImplemented + result = Counter() + for elem, count in self.items(): + other_count = other[elem] + newcount = count if count < other_count else other_count + if newcount > 0: + result[elem] = newcount + return result + + def __pos__(self): + 'Adds an empty counter, effectively stripping negative and zero counts' + return self + Counter() + + def __neg__(self): + '''Subtracts from an empty counter. Strips positive and zero counts, + and flips the sign on negative counts. + + ''' + return Counter() - self + + def _keep_positive(self): + '''Internal method to strip elements with a negative or zero count''' + nonpositive = [elem for elem, count in self.items() if not count > 0] + for elem in nonpositive: + del self[elem] + return self + + def __iadd__(self, other): + '''Inplace add from another counter, keeping only positive counts. + + >>> c = Counter('abbb') + >>> c += Counter('bcc') + >>> c + Counter({'b': 4, 'c': 2, 'a': 1}) + + ''' + for elem, count in other.items(): + self[elem] += count + return self._keep_positive() + + def __isub__(self, other): + '''Inplace subtract counter, but keep only results with positive counts. + + >>> c = Counter('abbbc') + >>> c -= Counter('bccd') + >>> c + Counter({'b': 2, 'a': 1}) + + ''' + for elem, count in other.items(): + self[elem] -= count + return self._keep_positive() + + def __ior__(self, other): + '''Inplace union is the maximum of value from either counter. + + >>> c = Counter('abbb') + >>> c |= Counter('bcc') + >>> c + Counter({'b': 3, 'c': 2, 'a': 1}) + + ''' + for elem, other_count in other.items(): + count = self[elem] + if other_count > count: + self[elem] = other_count + return self._keep_positive() + + def __iand__(self, other): + '''Inplace intersection is the minimum of corresponding counts. + + >>> c = Counter('abbb') + >>> c &= Counter('bcc') + >>> c + Counter({'b': 1}) + + ''' + for elem, count in self.items(): + other_count = other[elem] + if other_count < count: + self[elem] = other_count + return self._keep_positive() + + +######################################################################## +### ChainMap (helper for configparser and string.Template) +######################################################################## + +class ChainMap(MutableMapping): + ''' A ChainMap groups multiple dicts (or other mappings) together + to create a single, updateable view. + + The underlying mappings are stored in a list. That list is public and can + accessed or updated using the *maps* attribute. There is no other state. + + Lookups search the underlying mappings successively until a key is found. + In contrast, writes, updates, and deletions only operate on the first + mapping. + + ''' + + def __init__(self, *maps): + '''Initialize a ChainMap by setting *maps* to the given mappings. + If no mappings are provided, a single empty dictionary is used. + + ''' + self.maps = list(maps) or [{}] # always at least one map + + def __missing__(self, key): + raise KeyError(key) + + def __getitem__(self, key): + for mapping in self.maps: + try: + return mapping[key] # can't use 'key in mapping' with defaultdict + except KeyError: + pass + return self.__missing__(key) # support subclasses that define __missing__ + + def get(self, key, default=None): + return self[key] if key in self else default + + def __len__(self): + return len(set().union(*self.maps)) # reuses stored hash values if possible + + def __iter__(self): + return iter(set().union(*self.maps)) + + def __contains__(self, key): + return any(key in m for m in self.maps) + + def __bool__(self): + return any(self.maps) + + @_recursive_repr() + def __repr__(self): + return '{0.__class__.__name__}({1})'.format( + self, ', '.join(map(repr, self.maps))) + + @classmethod + def fromkeys(cls, iterable, *args): + 'Create a ChainMap with a single dict created from the iterable.' + return cls(dict.fromkeys(iterable, *args)) + + def copy(self): + 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]' + return self.__class__(self.maps[0].copy(), *self.maps[1:]) + + __copy__ = copy + + def new_child(self, m=None): # like Django's Context.push() + ''' + New ChainMap with a new map followed by all previous maps. If no + map is provided, an empty dict is used. + ''' + if m is None: + m = {} + return self.__class__(m, *self.maps) + + @property + def parents(self): # like Django's Context.pop() + 'New ChainMap from maps[1:].' + return self.__class__(*self.maps[1:]) + + def __setitem__(self, key, value): + self.maps[0][key] = value + + def __delitem__(self, key): + try: + del self.maps[0][key] + except KeyError: + raise KeyError('Key not found in the first mapping: {!r}'.format(key)) + + def popitem(self): + 'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.' + try: + return self.maps[0].popitem() + except KeyError: + raise KeyError('No keys found in the first mapping.') + + def pop(self, key, *args): + 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].' + try: + return self.maps[0].pop(key, *args) + except KeyError: + raise KeyError('Key not found in the first mapping: {!r}'.format(key)) + + def clear(self): + 'Clear maps[0], leaving maps[1:] intact.' + self.maps[0].clear() + + +################################################################################ +### UserDict +################################################################################ + +class UserDict(MutableMapping): + + # Start by filling-out the abstract methods + def __init__(self, dict=None, **kwargs): + self.data = {} + if dict is not None: + self.update(dict) + if len(kwargs): + self.update(kwargs) + def __len__(self): return len(self.data) + def __getitem__(self, key): + if key in self.data: + return self.data[key] + if hasattr(self.__class__, "__missing__"): + return self.__class__.__missing__(self, key) + raise KeyError(key) + def __setitem__(self, key, item): self.data[key] = item + def __delitem__(self, key): del self.data[key] + def __iter__(self): + return iter(self.data) + + # Modify __contains__ to work correctly when __missing__ is present + def __contains__(self, key): + return key in self.data + + # Now, add the methods in dicts but not in MutableMapping + def __repr__(self): return repr(self.data) + def copy(self): + if self.__class__ is UserDict: + return UserDict(self.data.copy()) + import copy + data = self.data + try: + self.data = {} + c = copy.copy(self) + finally: + self.data = data + c.update(self) + return c + @classmethod + def fromkeys(cls, iterable, value=None): + d = cls() + for key in iterable: + d[key] = value + return d + + + +################################################################################ +### UserList +################################################################################ + +class UserList(MutableSequence): + """A more or less complete user-defined wrapper around list objects.""" + def __init__(self, initlist=None): + self.data = [] + if initlist is not None: + # XXX should this accept an arbitrary sequence? + if type(initlist) == type(self.data): + self.data[:] = initlist + elif isinstance(initlist, UserList): + self.data[:] = initlist.data[:] + else: + self.data = list(initlist) + def __repr__(self): return repr(self.data) + def __lt__(self, other): return self.data < self.__cast(other) + def __le__(self, other): return self.data <= self.__cast(other) + def __eq__(self, other): return self.data == self.__cast(other) + def __ne__(self, other): return self.data != self.__cast(other) + def __gt__(self, other): return self.data > self.__cast(other) + def __ge__(self, other): return self.data >= self.__cast(other) + def __cast(self, other): + return other.data if isinstance(other, UserList) else other + def __contains__(self, item): return item in self.data + def __len__(self): return len(self.data) + def __getitem__(self, i): return self.data[i] + def __setitem__(self, i, item): self.data[i] = item + def __delitem__(self, i): del self.data[i] + def __add__(self, other): + if isinstance(other, UserList): + return self.__class__(self.data + other.data) + elif isinstance(other, type(self.data)): + return self.__class__(self.data + other) + return self.__class__(self.data + list(other)) + def __radd__(self, other): + if isinstance(other, UserList): + return self.__class__(other.data + self.data) + elif isinstance(other, type(self.data)): + return self.__class__(other + self.data) + return self.__class__(list(other) + self.data) + def __iadd__(self, other): + if isinstance(other, UserList): + self.data += other.data + elif isinstance(other, type(self.data)): + self.data += other + else: + self.data += list(other) + return self + def __mul__(self, n): + return self.__class__(self.data*n) + __rmul__ = __mul__ + def __imul__(self, n): + self.data *= n + return self + def append(self, item): self.data.append(item) + def insert(self, i, item): self.data.insert(i, item) + def pop(self, i=-1): return self.data.pop(i) + def remove(self, item): self.data.remove(item) + def clear(self): self.data.clear() + def copy(self): return self.__class__(self) + def count(self, item): return self.data.count(item) + def index(self, item, *args): return self.data.index(item, *args) + def reverse(self): self.data.reverse() + def sort(self, *args, **kwds): self.data.sort(*args, **kwds) + def extend(self, other): + if isinstance(other, UserList): + self.data.extend(other.data) + else: + self.data.extend(other) + + + +################################################################################ +### UserString +################################################################################ + +class UserString(Sequence): + def __init__(self, seq): + if isinstance(seq, str): + self.data = seq + elif isinstance(seq, UserString): + self.data = seq.data[:] + else: + self.data = str(seq) + def __str__(self): return str(self.data) + def __repr__(self): return repr(self.data) + def __int__(self): return int(self.data) + def __float__(self): return float(self.data) + def __complex__(self): return complex(self.data) + def __hash__(self): return hash(self.data) + + def __eq__(self, string): + if isinstance(string, UserString): + return self.data == string.data + return self.data == string + def __ne__(self, string): + if isinstance(string, UserString): + return self.data != string.data + return self.data != string + def __lt__(self, string): + if isinstance(string, UserString): + return self.data < string.data + return self.data < string + def __le__(self, string): + if isinstance(string, UserString): + return self.data <= string.data + return self.data <= string + def __gt__(self, string): + if isinstance(string, UserString): + return self.data > string.data + return self.data > string + def __ge__(self, string): + if isinstance(string, UserString): + return self.data >= string.data + return self.data >= string + + def __contains__(self, char): + if isinstance(char, UserString): + char = char.data + return char in self.data + + def __len__(self): return len(self.data) + def __getitem__(self, index): return self.__class__(self.data[index]) + def __add__(self, other): + if isinstance(other, UserString): + return self.__class__(self.data + other.data) + elif isinstance(other, str): + return self.__class__(self.data + other) + return self.__class__(self.data + str(other)) + def __radd__(self, other): + if isinstance(other, str): + return self.__class__(other + self.data) + return self.__class__(str(other) + self.data) + def __mul__(self, n): + return self.__class__(self.data*n) + __rmul__ = __mul__ + def __mod__(self, args): + return self.__class__(self.data % args) + + # the following methods are defined in alphabetical order: + def capitalize(self): return self.__class__(self.data.capitalize()) + def center(self, width, *args): + return self.__class__(self.data.center(width, *args)) + def count(self, sub, start=0, end=_sys.maxsize): + if isinstance(sub, UserString): + sub = sub.data + return self.data.count(sub, start, end) + def encode(self, encoding=None, errors=None): # XXX improve this? + if encoding: + if errors: + return self.__class__(self.data.encode(encoding, errors)) + return self.__class__(self.data.encode(encoding)) + return self.__class__(self.data.encode()) + def endswith(self, suffix, start=0, end=_sys.maxsize): + return self.data.endswith(suffix, start, end) + def expandtabs(self, tabsize=8): + return self.__class__(self.data.expandtabs(tabsize)) + def find(self, sub, start=0, end=_sys.maxsize): + if isinstance(sub, UserString): + sub = sub.data + return self.data.find(sub, start, end) + def format(self, *args, **kwds): + return self.data.format(*args, **kwds) + def index(self, sub, start=0, end=_sys.maxsize): + return self.data.index(sub, start, end) + def isalpha(self): return self.data.isalpha() + def isalnum(self): return self.data.isalnum() + def isdecimal(self): return self.data.isdecimal() + def isdigit(self): return self.data.isdigit() + def isidentifier(self): return self.data.isidentifier() + def islower(self): return self.data.islower() + def isnumeric(self): return self.data.isnumeric() + def isspace(self): return self.data.isspace() + def istitle(self): return self.data.istitle() + def isupper(self): return self.data.isupper() + def join(self, seq): return self.data.join(seq) + def ljust(self, width, *args): + return self.__class__(self.data.ljust(width, *args)) + def lower(self): return self.__class__(self.data.lower()) + def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars)) + def partition(self, sep): + return self.data.partition(sep) + def replace(self, old, new, maxsplit=-1): + if isinstance(old, UserString): + old = old.data + if isinstance(new, UserString): + new = new.data + return self.__class__(self.data.replace(old, new, maxsplit)) + def rfind(self, sub, start=0, end=_sys.maxsize): + if isinstance(sub, UserString): + sub = sub.data + return self.data.rfind(sub, start, end) + def rindex(self, sub, start=0, end=_sys.maxsize): + return self.data.rindex(sub, start, end) + def rjust(self, width, *args): + return self.__class__(self.data.rjust(width, *args)) + def rpartition(self, sep): + return self.data.rpartition(sep) + def rstrip(self, chars=None): + return self.__class__(self.data.rstrip(chars)) + def split(self, sep=None, maxsplit=-1): + return self.data.split(sep, maxsplit) + def rsplit(self, sep=None, maxsplit=-1): + return self.data.rsplit(sep, maxsplit) + def splitlines(self, keepends=False): return self.data.splitlines(keepends) + def startswith(self, prefix, start=0, end=_sys.maxsize): + return self.data.startswith(prefix, start, end) + def strip(self, chars=None): return self.__class__(self.data.strip(chars)) + def swapcase(self): return self.__class__(self.data.swapcase()) + def title(self): return self.__class__(self.data.title()) + def translate(self, *args): + return self.__class__(self.data.translate(*args)) + def upper(self): return self.__class__(self.data.upper()) + def zfill(self, width): return self.__class__(self.data.zfill(width)) diff --git a/python/testData/MockSdk3.4/Lib/collections/__main__.py b/python/testData/MockSdk3.4/Lib/collections/__main__.py new file mode 100644 index 000000000000..763e38e0c40c --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/collections/__main__.py @@ -0,0 +1,38 @@ +################################################################################ +### Simple tests +################################################################################ + +# verify that instances can be pickled +from collections import namedtuple +from pickle import loads, dumps +Point = namedtuple('Point', 'x, y', True) +p = Point(x=10, y=20) +assert p == loads(dumps(p)) + +# test and demonstrate ability to override methods +class Point(namedtuple('Point', 'x y')): + __slots__ = () + @property + def hypot(self): + return (self.x ** 2 + self.y ** 2) ** 0.5 + def __str__(self): + return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot) + +for p in Point(3, 4), Point(14, 5/7.): + print (p) + +class Point(namedtuple('Point', 'x y')): + 'Point class with optimized _make() and _replace() without error-checking' + __slots__ = () + _make = classmethod(tuple.__new__) + def _replace(self, _map=map, **kwds): + return self._make(_map(kwds.get, ('x', 'y'), self)) + +print(Point(11, 22)._replace(x=100)) + +Point3D = namedtuple('Point3D', Point._fields + ('z',)) +print(Point3D.__doc__) + +import doctest, collections +TestResults = namedtuple('TestResults', 'failed attempted') +print(TestResults(*doctest.testmod(collections))) diff --git a/python/testData/MockSdk3.4/Lib/collections/abc.py b/python/testData/MockSdk3.4/Lib/collections/abc.py new file mode 100644 index 000000000000..891600d16bee --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/collections/abc.py @@ -0,0 +1,2 @@ +from _collections_abc import * +from _collections_abc import __all__ diff --git a/python/testData/MockSdk3.4/Lib/datetime.py b/python/testData/MockSdk3.4/Lib/datetime.py new file mode 100644 index 000000000000..1789714034c9 --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/datetime.py @@ -0,0 +1,2136 @@ +"""Concrete date/time and related types. + +See http://www.iana.org/time-zones/repository/tz-link.html for +time zone and DST data sources. +""" + +import time as _time +import math as _math + +def _cmp(x, y): + return 0 if x == y else 1 if x > y else -1 + +MINYEAR = 1 +MAXYEAR = 9999 +_MAXORDINAL = 3652059 # date.max.toordinal() + +# Utility functions, adapted from Python's Demo/classes/Dates.py, which +# also assumes the current Gregorian calendar indefinitely extended in +# both directions. Difference: Dates.py calls January 1 of year 0 day +# number 1. The code here calls January 1 of year 1 day number 1. This is +# to match the definition of the "proleptic Gregorian" calendar in Dershowitz +# and Reingold's "Calendrical Calculations", where it's the base calendar +# for all computations. See the book for algorithms for converting between +# proleptic Gregorian ordinals and many other calendar systems. + +# -1 is a placeholder for indexing purposes. +_DAYS_IN_MONTH = [-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +_DAYS_BEFORE_MONTH = [-1] # -1 is a placeholder for indexing purposes. +dbm = 0 +for dim in _DAYS_IN_MONTH[1:]: + _DAYS_BEFORE_MONTH.append(dbm) + dbm += dim +del dbm, dim + +def _is_leap(year): + "year -> 1 if leap year, else 0." + return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) + +def _days_before_year(year): + "year -> number of days before January 1st of year." + y = year - 1 + return y*365 + y//4 - y//100 + y//400 + +def _days_in_month(year, month): + "year, month -> number of days in that month in that year." + assert 1 <= month <= 12, month + if month == 2 and _is_leap(year): + return 29 + return _DAYS_IN_MONTH[month] + +def _days_before_month(year, month): + "year, month -> number of days in year preceding first day of month." + assert 1 <= month <= 12, 'month must be in 1..12' + return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year)) + +def _ymd2ord(year, month, day): + "year, month, day -> ordinal, considering 01-Jan-0001 as day 1." + assert 1 <= month <= 12, 'month must be in 1..12' + dim = _days_in_month(year, month) + assert 1 <= day <= dim, ('day must be in 1..%d' % dim) + return (_days_before_year(year) + + _days_before_month(year, month) + + day) + +_DI400Y = _days_before_year(401) # number of days in 400 years +_DI100Y = _days_before_year(101) # " " " " 100 " +_DI4Y = _days_before_year(5) # " " " " 4 " + +# A 4-year cycle has an extra leap day over what we'd get from pasting +# together 4 single years. +assert _DI4Y == 4 * 365 + 1 + +# Similarly, a 400-year cycle has an extra leap day over what we'd get from +# pasting together 4 100-year cycles. +assert _DI400Y == 4 * _DI100Y + 1 + +# OTOH, a 100-year cycle has one fewer leap day than we'd get from +# pasting together 25 4-year cycles. +assert _DI100Y == 25 * _DI4Y - 1 + +def _ord2ymd(n): + "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." + + # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years + # repeats exactly every 400 years. The basic strategy is to find the + # closest 400-year boundary at or before n, then work with the offset + # from that boundary to n. Life is much clearer if we subtract 1 from + # n first -- then the values of n at 400-year boundaries are exactly + # those divisible by _DI400Y: + # + # D M Y n n-1 + # -- --- ---- ---------- ---------------- + # 31 Dec -400 -_DI400Y -_DI400Y -1 + # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary + # ... + # 30 Dec 000 -1 -2 + # 31 Dec 000 0 -1 + # 1 Jan 001 1 0 400-year boundary + # 2 Jan 001 2 1 + # 3 Jan 001 3 2 + # ... + # 31 Dec 400 _DI400Y _DI400Y -1 + # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary + n -= 1 + n400, n = divmod(n, _DI400Y) + year = n400 * 400 + 1 # ..., -399, 1, 401, ... + + # Now n is the (non-negative) offset, in days, from January 1 of year, to + # the desired date. Now compute how many 100-year cycles precede n. + # Note that it's possible for n100 to equal 4! In that case 4 full + # 100-year cycles precede the desired day, which implies the desired + # day is December 31 at the end of a 400-year cycle. + n100, n = divmod(n, _DI100Y) + + # Now compute how many 4-year cycles precede it. + n4, n = divmod(n, _DI4Y) + + # And now how many single years. Again n1 can be 4, and again meaning + # that the desired day is December 31 at the end of the 4-year cycle. + n1, n = divmod(n, 365) + + year += n100 * 100 + n4 * 4 + n1 + if n1 == 4 or n100 == 4: + assert n == 0 + return year-1, 12, 31 + + # Now the year is correct, and n is the offset from January 1. We find + # the month via an estimate that's either exact or one too large. + leapyear = n1 == 3 and (n4 != 24 or n100 == 3) + assert leapyear == _is_leap(year) + month = (n + 50) >> 5 + preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear) + if preceding > n: # estimate is too large + month -= 1 + preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear) + n -= preceding + assert 0 <= n < _days_in_month(year, month) + + # Now the year and month are correct, and n is the offset from the + # start of that month: we're done! + return year, month, n+1 + +# Month and day names. For localized versions, see the calendar module. +_MONTHNAMES = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +_DAYNAMES = [None, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] + + +def _build_struct_time(y, m, d, hh, mm, ss, dstflag): + wday = (_ymd2ord(y, m, d) + 6) % 7 + dnum = _days_before_month(y, m) + d + return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag)) + +def _format_time(hh, mm, ss, us): + # Skip trailing microseconds when us==0. + result = "%02d:%02d:%02d" % (hh, mm, ss) + if us: + result += ".%06d" % us + return result + +# Correctly substitute for %z and %Z escapes in strftime formats. +def _wrap_strftime(object, format, timetuple): + # Don't call utcoffset() or tzname() unless actually needed. + freplace = None # the string to use for %f + zreplace = None # the string to use for %z + Zreplace = None # the string to use for %Z + + # Scan format for %z and %Z escapes, replacing as needed. + newformat = [] + push = newformat.append + i, n = 0, len(format) + while i < n: + ch = format[i] + i += 1 + if ch == '%': + if i < n: + ch = format[i] + i += 1 + if ch == 'f': + if freplace is None: + freplace = '%06d' % getattr(object, + 'microsecond', 0) + newformat.append(freplace) + elif ch == 'z': + if zreplace is None: + zreplace = "" + if hasattr(object, "utcoffset"): + offset = object.utcoffset() + if offset is not None: + sign = '+' + if offset.days < 0: + offset = -offset + sign = '-' + h, m = divmod(offset, timedelta(hours=1)) + assert not m % timedelta(minutes=1), "whole minute" + m //= timedelta(minutes=1) + zreplace = '%c%02d%02d' % (sign, h, m) + assert '%' not in zreplace + newformat.append(zreplace) + elif ch == 'Z': + if Zreplace is None: + Zreplace = "" + if hasattr(object, "tzname"): + s = object.tzname() + if s is not None: + # strftime is going to have at this: escape % + Zreplace = s.replace('%', '%%') + newformat.append(Zreplace) + else: + push('%') + push(ch) + else: + push('%') + else: + push(ch) + newformat = "".join(newformat) + return _time.strftime(newformat, timetuple) + +def _call_tzinfo_method(tzinfo, methname, tzinfoarg): + if tzinfo is None: + return None + return getattr(tzinfo, methname)(tzinfoarg) + +# Just raise TypeError if the arg isn't None or a string. +def _check_tzname(name): + if name is not None and not isinstance(name, str): + raise TypeError("tzinfo.tzname() must return None or string, " + "not '%s'" % type(name)) + +# name is the offset-producing method, "utcoffset" or "dst". +# offset is what it returned. +# If offset isn't None or timedelta, raises TypeError. +# If offset is None, returns None. +# Else offset is checked for being in range, and a whole # of minutes. +# If it is, its integer value is returned. Else ValueError is raised. +def _check_utc_offset(name, offset): + assert name in ("utcoffset", "dst") + if offset is None: + return + if not isinstance(offset, timedelta): + raise TypeError("tzinfo.%s() must return None " + "or timedelta, not '%s'" % (name, type(offset))) + if offset % timedelta(minutes=1) or offset.microseconds: + raise ValueError("tzinfo.%s() must return a whole number " + "of minutes, got %s" % (name, offset)) + if not -timedelta(1) < offset < timedelta(1): + raise ValueError("%s()=%s, must be must be strictly between" + " -timedelta(hours=24) and timedelta(hours=24)" + % (name, offset)) + +def _check_date_fields(year, month, day): + if not isinstance(year, int): + raise TypeError('int expected') + if not MINYEAR <= year <= MAXYEAR: + raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), year) + if not 1 <= month <= 12: + raise ValueError('month must be in 1..12', month) + dim = _days_in_month(year, month) + if not 1 <= day <= dim: + raise ValueError('day must be in 1..%d' % dim, day) + +def _check_time_fields(hour, minute, second, microsecond): + if not isinstance(hour, int): + raise TypeError('int expected') + if not 0 <= hour <= 23: + raise ValueError('hour must be in 0..23', hour) + if not 0 <= minute <= 59: + raise ValueError('minute must be in 0..59', minute) + if not 0 <= second <= 59: + raise ValueError('second must be in 0..59', second) + if not 0 <= microsecond <= 999999: + raise ValueError('microsecond must be in 0..999999', microsecond) + +def _check_tzinfo_arg(tz): + if tz is not None and not isinstance(tz, tzinfo): + raise TypeError("tzinfo argument must be None or of a tzinfo subclass") + +def _cmperror(x, y): + raise TypeError("can't compare '%s' to '%s'" % ( + type(x).__name__, type(y).__name__)) + +class timedelta: + """Represent the difference between two datetime objects. + + Supported operators: + + - add, subtract timedelta + - unary plus, minus, abs + - compare to timedelta + - multiply, divide by int + + In addition, datetime supports subtraction of two datetime objects + returning a timedelta, and addition or subtraction of a datetime + and a timedelta giving a datetime. + + Representation: (days, seconds, microseconds). Why? Because I + felt like it. + """ + __slots__ = '_days', '_seconds', '_microseconds' + + def __new__(cls, days=0, seconds=0, microseconds=0, + milliseconds=0, minutes=0, hours=0, weeks=0): + # Doing this efficiently and accurately in C is going to be difficult + # and error-prone, due to ubiquitous overflow possibilities, and that + # C double doesn't have enough bits of precision to represent + # microseconds over 10K years faithfully. The code here tries to make + # explicit where go-fast assumptions can be relied on, in order to + # guide the C implementation; it's way more convoluted than speed- + # ignoring auto-overflow-to-long idiomatic Python could be. + + # XXX Check that all inputs are ints or floats. + + # Final values, all integer. + # s and us fit in 32-bit signed ints; d isn't bounded. + d = s = us = 0 + + # Normalize everything to days, seconds, microseconds. + days += weeks*7 + seconds += minutes*60 + hours*3600 + microseconds += milliseconds*1000 + + # Get rid of all fractions, and normalize s and us. + # Take a deep breath . + if isinstance(days, float): + dayfrac, days = _math.modf(days) + daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) + assert daysecondswhole == int(daysecondswhole) # can't overflow + s = int(daysecondswhole) + assert days == int(days) + d = int(days) + else: + daysecondsfrac = 0.0 + d = days + assert isinstance(daysecondsfrac, float) + assert abs(daysecondsfrac) <= 1.0 + assert isinstance(d, int) + assert abs(s) <= 24 * 3600 + # days isn't referenced again before redefinition + + if isinstance(seconds, float): + secondsfrac, seconds = _math.modf(seconds) + assert seconds == int(seconds) + seconds = int(seconds) + secondsfrac += daysecondsfrac + assert abs(secondsfrac) <= 2.0 + else: + secondsfrac = daysecondsfrac + # daysecondsfrac isn't referenced again + assert isinstance(secondsfrac, float) + assert abs(secondsfrac) <= 2.0 + + assert isinstance(seconds, int) + days, seconds = divmod(seconds, 24*3600) + d += days + s += int(seconds) # can't overflow + assert isinstance(s, int) + assert abs(s) <= 2 * 24 * 3600 + # seconds isn't referenced again before redefinition + + usdouble = secondsfrac * 1e6 + assert abs(usdouble) < 2.1e6 # exact value not critical + # secondsfrac isn't referenced again + + if isinstance(microseconds, float): + microseconds += usdouble + microseconds = round(microseconds, 0) + seconds, microseconds = divmod(microseconds, 1e6) + assert microseconds == int(microseconds) + assert seconds == int(seconds) + days, seconds = divmod(seconds, 24.*3600.) + assert days == int(days) + assert seconds == int(seconds) + d += int(days) + s += int(seconds) # can't overflow + assert isinstance(s, int) + assert abs(s) <= 3 * 24 * 3600 + else: + seconds, microseconds = divmod(microseconds, 1000000) + days, seconds = divmod(seconds, 24*3600) + d += days + s += int(seconds) # can't overflow + assert isinstance(s, int) + assert abs(s) <= 3 * 24 * 3600 + microseconds = float(microseconds) + microseconds += usdouble + microseconds = round(microseconds, 0) + assert abs(s) <= 3 * 24 * 3600 + assert abs(microseconds) < 3.1e6 + + # Just a little bit of carrying possible for microseconds and seconds. + assert isinstance(microseconds, float) + assert int(microseconds) == microseconds + us = int(microseconds) + seconds, us = divmod(us, 1000000) + s += seconds # cant't overflow + assert isinstance(s, int) + days, s = divmod(s, 24*3600) + d += days + + assert isinstance(d, int) + assert isinstance(s, int) and 0 <= s < 24*3600 + assert isinstance(us, int) and 0 <= us < 1000000 + + self = object.__new__(cls) + + self._days = d + self._seconds = s + self._microseconds = us + if abs(d) > 999999999: + raise OverflowError("timedelta # of days is too large: %d" % d) + + return self + + def __repr__(self): + if self._microseconds: + return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__, + self._days, + self._seconds, + self._microseconds) + if self._seconds: + return "%s(%d, %d)" % ('datetime.' + self.__class__.__name__, + self._days, + self._seconds) + return "%s(%d)" % ('datetime.' + self.__class__.__name__, self._days) + + def __str__(self): + mm, ss = divmod(self._seconds, 60) + hh, mm = divmod(mm, 60) + s = "%d:%02d:%02d" % (hh, mm, ss) + if self._days: + def plural(n): + return n, abs(n) != 1 and "s" or "" + s = ("%d day%s, " % plural(self._days)) + s + if self._microseconds: + s = s + ".%06d" % self._microseconds + return s + + def total_seconds(self): + """Total seconds in the duration.""" + return ((self.days * 86400 + self.seconds)*10**6 + + self.microseconds) / 10**6 + + # Read-only field accessors + @property + def days(self): + """days""" + return self._days + + @property + def seconds(self): + """seconds""" + return self._seconds + + @property + def microseconds(self): + """microseconds""" + return self._microseconds + + def __add__(self, other): + if isinstance(other, timedelta): + # for CPython compatibility, we cannot use + # our __class__ here, but need a real timedelta + return timedelta(self._days + other._days, + self._seconds + other._seconds, + self._microseconds + other._microseconds) + return NotImplemented + + __radd__ = __add__ + + def __sub__(self, other): + if isinstance(other, timedelta): + # for CPython compatibility, we cannot use + # our __class__ here, but need a real timedelta + return timedelta(self._days - other._days, + self._seconds - other._seconds, + self._microseconds - other._microseconds) + return NotImplemented + + def __rsub__(self, other): + if isinstance(other, timedelta): + return -self + other + return NotImplemented + + def __neg__(self): + # for CPython compatibility, we cannot use + # our __class__ here, but need a real timedelta + return timedelta(-self._days, + -self._seconds, + -self._microseconds) + + def __pos__(self): + return self + + def __abs__(self): + if self._days < 0: + return -self + else: + return self + + def __mul__(self, other): + if isinstance(other, int): + # for CPython compatibility, we cannot use + # our __class__ here, but need a real timedelta + return timedelta(self._days * other, + self._seconds * other, + self._microseconds * other) + if isinstance(other, float): + a, b = other.as_integer_ratio() + return self * a / b + return NotImplemented + + __rmul__ = __mul__ + + def _to_microseconds(self): + return ((self._days * (24*3600) + self._seconds) * 1000000 + + self._microseconds) + + def __floordiv__(self, other): + if not isinstance(other, (int, timedelta)): + return NotImplemented + usec = self._to_microseconds() + if isinstance(other, timedelta): + return usec // other._to_microseconds() + if isinstance(other, int): + return timedelta(0, 0, usec // other) + + def __truediv__(self, other): + if not isinstance(other, (int, float, timedelta)): + return NotImplemented + usec = self._to_microseconds() + if isinstance(other, timedelta): + return usec / other._to_microseconds() + if isinstance(other, int): + return timedelta(0, 0, usec / other) + if isinstance(other, float): + a, b = other.as_integer_ratio() + return timedelta(0, 0, b * usec / a) + + def __mod__(self, other): + if isinstance(other, timedelta): + r = self._to_microseconds() % other._to_microseconds() + return timedelta(0, 0, r) + return NotImplemented + + def __divmod__(self, other): + if isinstance(other, timedelta): + q, r = divmod(self._to_microseconds(), + other._to_microseconds()) + return q, timedelta(0, 0, r) + return NotImplemented + + # Comparisons of timedelta objects with other. + + def __eq__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) == 0 + else: + return False + + def __ne__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) != 0 + else: + return True + + def __le__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) <= 0 + else: + _cmperror(self, other) + + def __lt__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) < 0 + else: + _cmperror(self, other) + + def __ge__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) >= 0 + else: + _cmperror(self, other) + + def __gt__(self, other): + if isinstance(other, timedelta): + return self._cmp(other) > 0 + else: + _cmperror(self, other) + + def _cmp(self, other): + assert isinstance(other, timedelta) + return _cmp(self._getstate(), other._getstate()) + + def __hash__(self): + return hash(self._getstate()) + + def __bool__(self): + return (self._days != 0 or + self._seconds != 0 or + self._microseconds != 0) + + # Pickle support. + + def _getstate(self): + return (self._days, self._seconds, self._microseconds) + + def __reduce__(self): + return (self.__class__, self._getstate()) + +timedelta.min = timedelta(-999999999) +timedelta.max = timedelta(days=999999999, hours=23, minutes=59, seconds=59, + microseconds=999999) +timedelta.resolution = timedelta(microseconds=1) + +class date: + """Concrete date type. + + Constructors: + + __new__() + fromtimestamp() + today() + fromordinal() + + Operators: + + __repr__, __str__ + __cmp__, __hash__ + __add__, __radd__, __sub__ (add/radd only with timedelta arg) + + Methods: + + timetuple() + toordinal() + weekday() + isoweekday(), isocalendar(), isoformat() + ctime() + strftime() + + Properties (readonly): + year, month, day + """ + __slots__ = '_year', '_month', '_day' + + def __new__(cls, year, month=None, day=None): + """Constructor. + + Arguments: + + year, month, day (required, base 1) + """ + if (isinstance(year, bytes) and len(year) == 4 and + 1 <= year[2] <= 12 and month is None): # Month is sane + # Pickle support + self = object.__new__(cls) + self.__setstate(year) + return self + _check_date_fields(year, month, day) + self = object.__new__(cls) + self._year = year + self._month = month + self._day = day + return self + + # Additional constructors + + @classmethod + def fromtimestamp(cls, t): + "Construct a date from a POSIX timestamp (like time.time())." + y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) + return cls(y, m, d) + + @classmethod + def today(cls): + "Construct a date from time.time()." + t = _time.time() + return cls.fromtimestamp(t) + + @classmethod + def fromordinal(cls, n): + """Contruct a date from a proleptic Gregorian ordinal. + + January 1 of year 1 is day 1. Only the year, month and day are + non-zero in the result. + """ + y, m, d = _ord2ymd(n) + return cls(y, m, d) + + # Conversions to string + + def __repr__(self): + """Convert to formal string, for repr(). + + >>> dt = datetime(2010, 1, 1) + >>> repr(dt) + 'datetime.datetime(2010, 1, 1, 0, 0)' + + >>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc) + >>> repr(dt) + 'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)' + """ + return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__, + self._year, + self._month, + self._day) + # XXX These shouldn't depend on time.localtime(), because that + # clips the usable dates to [1970 .. 2038). At least ctime() is + # easily done without using strftime() -- that's better too because + # strftime("%c", ...) is locale specific. + + + def ctime(self): + "Return ctime() style string." + weekday = self.toordinal() % 7 or 7 + return "%s %s %2d 00:00:00 %04d" % ( + _DAYNAMES[weekday], + _MONTHNAMES[self._month], + self._day, self._year) + + def strftime(self, fmt): + "Format using strftime()." + return _wrap_strftime(self, fmt, self.timetuple()) + + def __format__(self, fmt): + if len(fmt) != 0: + return self.strftime(fmt) + return str(self) + + def isoformat(self): + """Return the date formatted according to ISO. + + This is 'YYYY-MM-DD'. + + References: + - http://www.w3.org/TR/NOTE-datetime + - http://www.cl.cam.ac.uk/~mgk25/iso-time.html + """ + return "%04d-%02d-%02d" % (self._year, self._month, self._day) + + __str__ = isoformat + + # Read-only field accessors + @property + def year(self): + """year (1-9999)""" + return self._year + + @property + def month(self): + """month (1-12)""" + return self._month + + @property + def day(self): + """day (1-31)""" + return self._day + + # Standard conversions, __cmp__, __hash__ (and helpers) + + def timetuple(self): + "Return local time tuple compatible with time.localtime()." + return _build_struct_time(self._year, self._month, self._day, + 0, 0, 0, -1) + + def toordinal(self): + """Return proleptic Gregorian ordinal for the year, month and day. + + January 1 of year 1 is day 1. Only the year, month and day values + contribute to the result. + """ + return _ymd2ord(self._year, self._month, self._day) + + def replace(self, year=None, month=None, day=None): + """Return a new date with new values for the specified fields.""" + if year is None: + year = self._year + if month is None: + month = self._month + if day is None: + day = self._day + _check_date_fields(year, month, day) + return date(year, month, day) + + # Comparisons of date objects with other. + + def __eq__(self, other): + if isinstance(other, date): + return self._cmp(other) == 0 + return NotImplemented + + def __ne__(self, other): + if isinstance(other, date): + return self._cmp(other) != 0 + return NotImplemented + + def __le__(self, other): + if isinstance(other, date): + return self._cmp(other) <= 0 + return NotImplemented + + def __lt__(self, other): + if isinstance(other, date): + return self._cmp(other) < 0 + return NotImplemented + + def __ge__(self, other): + if isinstance(other, date): + return self._cmp(other) >= 0 + return NotImplemented + + def __gt__(self, other): + if isinstance(other, date): + return self._cmp(other) > 0 + return NotImplemented + + def _cmp(self, other): + assert isinstance(other, date) + y, m, d = self._year, self._month, self._day + y2, m2, d2 = other._year, other._month, other._day + return _cmp((y, m, d), (y2, m2, d2)) + + def __hash__(self): + "Hash." + return hash(self._getstate()) + + # Computations + + def __add__(self, other): + "Add a date to a timedelta." + if isinstance(other, timedelta): + o = self.toordinal() + other.days + if 0 < o <= _MAXORDINAL: + return date.fromordinal(o) + raise OverflowError("result out of range") + return NotImplemented + + __radd__ = __add__ + + def __sub__(self, other): + """Subtract two dates, or a date and a timedelta.""" + if isinstance(other, timedelta): + return self + timedelta(-other.days) + if isinstance(other, date): + days1 = self.toordinal() + days2 = other.toordinal() + return timedelta(days1 - days2) + return NotImplemented + + def weekday(self): + "Return day of the week, where Monday == 0 ... Sunday == 6." + return (self.toordinal() + 6) % 7 + + # Day-of-the-week and week-of-the-year, according to ISO + + def isoweekday(self): + "Return day of the week, where Monday == 1 ... Sunday == 7." + # 1-Jan-0001 is a Monday + return self.toordinal() % 7 or 7 + + def isocalendar(self): + """Return a 3-tuple containing ISO year, week number, and weekday. + + The first ISO week of the year is the (Mon-Sun) week + containing the year's first Thursday; everything else derives + from that. + + The first week is 1; Monday is 1 ... Sunday is 7. + + ISO calendar algorithm taken from + http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm + """ + year = self._year + week1monday = _isoweek1monday(year) + today = _ymd2ord(self._year, self._month, self._day) + # Internally, week and day have origin 0 + week, day = divmod(today - week1monday, 7) + if week < 0: + year -= 1 + week1monday = _isoweek1monday(year) + week, day = divmod(today - week1monday, 7) + elif week >= 52: + if today >= _isoweek1monday(year+1): + year += 1 + week = 0 + return year, week+1, day+1 + + # Pickle support. + + def _getstate(self): + yhi, ylo = divmod(self._year, 256) + return bytes([yhi, ylo, self._month, self._day]), + + def __setstate(self, string): + if len(string) != 4 or not (1 <= string[2] <= 12): + raise TypeError("not enough arguments") + yhi, ylo, self._month, self._day = string + self._year = yhi * 256 + ylo + + def __reduce__(self): + return (self.__class__, self._getstate()) + +_date_class = date # so functions w/ args named "date" can get at the class + +date.min = date(1, 1, 1) +date.max = date(9999, 12, 31) +date.resolution = timedelta(days=1) + +class tzinfo: + """Abstract base class for time zone info classes. + + Subclasses must override the name(), utcoffset() and dst() methods. + """ + __slots__ = () + def tzname(self, dt): + "datetime -> string name of time zone." + raise NotImplementedError("tzinfo subclass must override tzname()") + + def utcoffset(self, dt): + "datetime -> minutes east of UTC (negative for west of UTC)" + raise NotImplementedError("tzinfo subclass must override utcoffset()") + + def dst(self, dt): + """datetime -> DST offset in minutes east of UTC. + + Return 0 if DST not in effect. utcoffset() must include the DST + offset. + """ + raise NotImplementedError("tzinfo subclass must override dst()") + + def fromutc(self, dt): + "datetime in UTC -> datetime in local time." + + if not isinstance(dt, datetime): + raise TypeError("fromutc() requires a datetime argument") + if dt.tzinfo is not self: + raise ValueError("dt.tzinfo is not self") + + dtoff = dt.utcoffset() + if dtoff is None: + raise ValueError("fromutc() requires a non-None utcoffset() " + "result") + + # See the long comment block at the end of this file for an + # explanation of this algorithm. + dtdst = dt.dst() + if dtdst is None: + raise ValueError("fromutc() requires a non-None dst() result") + delta = dtoff - dtdst + if delta: + dt += delta + dtdst = dt.dst() + if dtdst is None: + raise ValueError("fromutc(): dt.dst gave inconsistent " + "results; cannot convert") + return dt + dtdst + + # Pickle support. + + def __reduce__(self): + getinitargs = getattr(self, "__getinitargs__", None) + if getinitargs: + args = getinitargs() + else: + args = () + getstate = getattr(self, "__getstate__", None) + if getstate: + state = getstate() + else: + state = getattr(self, "__dict__", None) or None + if state is None: + return (self.__class__, args) + else: + return (self.__class__, args, state) + +_tzinfo_class = tzinfo + +class time: + """Time with time zone. + + Constructors: + + __new__() + + Operators: + + __repr__, __str__ + __cmp__, __hash__ + + Methods: + + strftime() + isoformat() + utcoffset() + tzname() + dst() + + Properties (readonly): + hour, minute, second, microsecond, tzinfo + """ + + def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None): + """Constructor. + + Arguments: + + hour, minute (required) + second, microsecond (default to zero) + tzinfo (default to None) + """ + self = object.__new__(cls) + if isinstance(hour, bytes) and len(hour) == 6: + # Pickle support + self.__setstate(hour, minute or None) + return self + _check_tzinfo_arg(tzinfo) + _check_time_fields(hour, minute, second, microsecond) + self._hour = hour + self._minute = minute + self._second = second + self._microsecond = microsecond + self._tzinfo = tzinfo + return self + + # Read-only field accessors + @property + def hour(self): + """hour (0-23)""" + return self._hour + + @property + def minute(self): + """minute (0-59)""" + return self._minute + + @property + def second(self): + """second (0-59)""" + return self._second + + @property + def microsecond(self): + """microsecond (0-999999)""" + return self._microsecond + + @property + def tzinfo(self): + """timezone info object""" + return self._tzinfo + + # Standard conversions, __hash__ (and helpers) + + # Comparisons of time objects with other. + + def __eq__(self, other): + if isinstance(other, time): + return self._cmp(other, allow_mixed=True) == 0 + else: + return False + + def __ne__(self, other): + if isinstance(other, time): + return self._cmp(other, allow_mixed=True) != 0 + else: + return True + + def __le__(self, other): + if isinstance(other, time): + return self._cmp(other) <= 0 + else: + _cmperror(self, other) + + def __lt__(self, other): + if isinstance(other, time): + return self._cmp(other) < 0 + else: + _cmperror(self, other) + + def __ge__(self, other): + if isinstance(other, time): + return self._cmp(other) >= 0 + else: + _cmperror(self, other) + + def __gt__(self, other): + if isinstance(other, time): + return self._cmp(other) > 0 + else: + _cmperror(self, other) + + def _cmp(self, other, allow_mixed=False): + assert isinstance(other, time) + mytz = self._tzinfo + ottz = other._tzinfo + myoff = otoff = None + + if mytz is ottz: + base_compare = True + else: + myoff = self.utcoffset() + otoff = other.utcoffset() + base_compare = myoff == otoff + + if base_compare: + return _cmp((self._hour, self._minute, self._second, + self._microsecond), + (other._hour, other._minute, other._second, + other._microsecond)) + if myoff is None or otoff is None: + if allow_mixed: + return 2 # arbitrary non-zero value + else: + raise TypeError("cannot compare naive and aware times") + myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1) + othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1) + return _cmp((myhhmm, self._second, self._microsecond), + (othhmm, other._second, other._microsecond)) + + def __hash__(self): + """Hash.""" + tzoff = self.utcoffset() + if not tzoff: # zero or None + return hash(self._getstate()[0]) + h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff, + timedelta(hours=1)) + assert not m % timedelta(minutes=1), "whole minute" + m //= timedelta(minutes=1) + if 0 <= h < 24: + return hash(time(h, m, self.second, self.microsecond)) + return hash((h, m, self.second, self.microsecond)) + + # Conversion to string + + def _tzstr(self, sep=":"): + """Return formatted timezone offset (+xx:xx) or None.""" + off = self.utcoffset() + if off is not None: + if off.days < 0: + sign = "-" + off = -off + else: + sign = "+" + hh, mm = divmod(off, timedelta(hours=1)) + assert not mm % timedelta(minutes=1), "whole minute" + mm //= timedelta(minutes=1) + assert 0 <= hh < 24 + off = "%s%02d%s%02d" % (sign, hh, sep, mm) + return off + + def __repr__(self): + """Convert to formal string, for repr().""" + if self._microsecond != 0: + s = ", %d, %d" % (self._second, self._microsecond) + elif self._second != 0: + s = ", %d" % self._second + else: + s = "" + s= "%s(%d, %d%s)" % ('datetime.' + self.__class__.__name__, + self._hour, self._minute, s) + if self._tzinfo is not None: + assert s[-1:] == ")" + s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" + return s + + def isoformat(self): + """Return the time formatted according to ISO. + + This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if + self.microsecond == 0. + """ + s = _format_time(self._hour, self._minute, self._second, + self._microsecond) + tz = self._tzstr() + if tz: + s += tz + return s + + __str__ = isoformat + + def strftime(self, fmt): + """Format using strftime(). The date part of the timestamp passed + to underlying strftime should not be used. + """ + # The year must be >= 1000 else Python's strftime implementation + # can raise a bogus exception. + timetuple = (1900, 1, 1, + self._hour, self._minute, self._second, + 0, 1, -1) + return _wrap_strftime(self, fmt, timetuple) + + def __format__(self, fmt): + if len(fmt) != 0: + return self.strftime(fmt) + return str(self) + + # Timezone functions + + def utcoffset(self): + """Return the timezone offset in minutes east of UTC (negative west of + UTC).""" + if self._tzinfo is None: + return None + offset = self._tzinfo.utcoffset(None) + _check_utc_offset("utcoffset", offset) + return offset + + def tzname(self): + """Return the timezone name. + + Note that the name is 100% informational -- there's no requirement that + it mean anything in particular. For example, "GMT", "UTC", "-500", + "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies. + """ + if self._tzinfo is None: + return None + name = self._tzinfo.tzname(None) + _check_tzname(name) + return name + + def dst(self): + """Return 0 if DST is not in effect, or the DST offset (in minutes + eastward) if DST is in effect. + + This is purely informational; the DST offset has already been added to + the UTC offset returned by utcoffset() if applicable, so there's no + need to consult dst() unless you're interested in displaying the DST + info. + """ + if self._tzinfo is None: + return None + offset = self._tzinfo.dst(None) + _check_utc_offset("dst", offset) + return offset + + def replace(self, hour=None, minute=None, second=None, microsecond=None, + tzinfo=True): + """Return a new time with new values for the specified fields.""" + if hour is None: + hour = self.hour + if minute is None: + minute = self.minute + if second is None: + second = self.second + if microsecond is None: + microsecond = self.microsecond + if tzinfo is True: + tzinfo = self.tzinfo + _check_time_fields(hour, minute, second, microsecond) + _check_tzinfo_arg(tzinfo) + return time(hour, minute, second, microsecond, tzinfo) + + def __bool__(self): + if self.second or self.microsecond: + return True + offset = self.utcoffset() or timedelta(0) + return timedelta(hours=self.hour, minutes=self.minute) != offset + + # Pickle support. + + def _getstate(self): + us2, us3 = divmod(self._microsecond, 256) + us1, us2 = divmod(us2, 256) + basestate = bytes([self._hour, self._minute, self._second, + us1, us2, us3]) + if self._tzinfo is None: + return (basestate,) + else: + return (basestate, self._tzinfo) + + def __setstate(self, string, tzinfo): + if len(string) != 6 or string[0] >= 24: + raise TypeError("an integer is required") + (self._hour, self._minute, self._second, + us1, us2, us3) = string + self._microsecond = (((us1 << 8) | us2) << 8) | us3 + if tzinfo is None or isinstance(tzinfo, _tzinfo_class): + self._tzinfo = tzinfo + else: + raise TypeError("bad tzinfo state arg %r" % tzinfo) + + def __reduce__(self): + return (time, self._getstate()) + +_time_class = time # so functions w/ args named "time" can get at the class + +time.min = time(0, 0, 0) +time.max = time(23, 59, 59, 999999) +time.resolution = timedelta(microseconds=1) + +class datetime(date): + """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]]) + + The year, month and day arguments are required. tzinfo may be None, or an + instance of a tzinfo subclass. The remaining arguments may be ints. + """ + + __slots__ = date.__slots__ + ( + '_hour', '_minute', '_second', + '_microsecond', '_tzinfo') + def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0, + microsecond=0, tzinfo=None): + if isinstance(year, bytes) and len(year) == 10: + # Pickle support + self = date.__new__(cls, year[:4]) + self.__setstate(year, month) + return self + _check_tzinfo_arg(tzinfo) + _check_time_fields(hour, minute, second, microsecond) + self = date.__new__(cls, year, month, day) + self._hour = hour + self._minute = minute + self._second = second + self._microsecond = microsecond + self._tzinfo = tzinfo + return self + + # Read-only field accessors + @property + def hour(self): + """hour (0-23)""" + return self._hour + + @property + def minute(self): + """minute (0-59)""" + return self._minute + + @property + def second(self): + """second (0-59)""" + return self._second + + @property + def microsecond(self): + """microsecond (0-999999)""" + return self._microsecond + + @property + def tzinfo(self): + """timezone info object""" + return self._tzinfo + + @classmethod + def fromtimestamp(cls, t, tz=None): + """Construct a datetime from a POSIX timestamp (like time.time()). + + A timezone info object may be passed in as well. + """ + + _check_tzinfo_arg(tz) + + converter = _time.localtime if tz is None else _time.gmtime + + t, frac = divmod(t, 1.0) + us = int(frac * 1e6) + + # If timestamp is less than one microsecond smaller than a + # full second, us can be rounded up to 1000000. In this case, + # roll over to seconds, otherwise, ValueError is raised + # by the constructor. + if us == 1000000: + t += 1 + us = 0 + y, m, d, hh, mm, ss, weekday, jday, dst = converter(t) + ss = min(ss, 59) # clamp out leap seconds if the platform has them + result = cls(y, m, d, hh, mm, ss, us, tz) + if tz is not None: + result = tz.fromutc(result) + return result + + @classmethod + def utcfromtimestamp(cls, t): + "Construct a UTC datetime from a POSIX timestamp (like time.time())." + t, frac = divmod(t, 1.0) + us = int(frac * 1e6) + + # If timestamp is less than one microsecond smaller than a + # full second, us can be rounded up to 1000000. In this case, + # roll over to seconds, otherwise, ValueError is raised + # by the constructor. + if us == 1000000: + t += 1 + us = 0 + y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) + ss = min(ss, 59) # clamp out leap seconds if the platform has them + return cls(y, m, d, hh, mm, ss, us) + + # XXX This is supposed to do better than we *can* do by using time.time(), + # XXX if the platform supports a more accurate way. The C implementation + # XXX uses gettimeofday on platforms that have it, but that isn't + # XXX available from Python. So now() may return different results + # XXX across the implementations. + @classmethod + def now(cls, tz=None): + "Construct a datetime from time.time() and optional time zone info." + t = _time.time() + return cls.fromtimestamp(t, tz) + + @classmethod + def utcnow(cls): + "Construct a UTC datetime from time.time()." + t = _time.time() + return cls.utcfromtimestamp(t) + + @classmethod + def combine(cls, date, time): + "Construct a datetime from a given date and a given time." + if not isinstance(date, _date_class): + raise TypeError("date argument must be a date instance") + if not isinstance(time, _time_class): + raise TypeError("time argument must be a time instance") + return cls(date.year, date.month, date.day, + time.hour, time.minute, time.second, time.microsecond, + time.tzinfo) + + def timetuple(self): + "Return local time tuple compatible with time.localtime()." + dst = self.dst() + if dst is None: + dst = -1 + elif dst: + dst = 1 + else: + dst = 0 + return _build_struct_time(self.year, self.month, self.day, + self.hour, self.minute, self.second, + dst) + + def timestamp(self): + "Return POSIX timestamp as float" + if self._tzinfo is None: + return _time.mktime((self.year, self.month, self.day, + self.hour, self.minute, self.second, + -1, -1, -1)) + self.microsecond / 1e6 + else: + return (self - _EPOCH).total_seconds() + + def utctimetuple(self): + "Return UTC time tuple compatible with time.gmtime()." + offset = self.utcoffset() + if offset: + self -= offset + y, m, d = self.year, self.month, self.day + hh, mm, ss = self.hour, self.minute, self.second + return _build_struct_time(y, m, d, hh, mm, ss, 0) + + def date(self): + "Return the date part." + return date(self._year, self._month, self._day) + + def time(self): + "Return the time part, with tzinfo None." + return time(self.hour, self.minute, self.second, self.microsecond) + + def timetz(self): + "Return the time part, with same tzinfo." + return time(self.hour, self.minute, self.second, self.microsecond, + self._tzinfo) + + def replace(self, year=None, month=None, day=None, hour=None, + minute=None, second=None, microsecond=None, tzinfo=True): + """Return a new datetime with new values for the specified fields.""" + if year is None: + year = self.year + if month is None: + month = self.month + if day is None: + day = self.day + if hour is None: + hour = self.hour + if minute is None: + minute = self.minute + if second is None: + second = self.second + if microsecond is None: + microsecond = self.microsecond + if tzinfo is True: + tzinfo = self.tzinfo + _check_date_fields(year, month, day) + _check_time_fields(hour, minute, second, microsecond) + _check_tzinfo_arg(tzinfo) + return datetime(year, month, day, hour, minute, second, + microsecond, tzinfo) + + def astimezone(self, tz=None): + if tz is None: + if self.tzinfo is None: + raise ValueError("astimezone() requires an aware datetime") + ts = (self - _EPOCH) // timedelta(seconds=1) + localtm = _time.localtime(ts) + local = datetime(*localtm[:6]) + try: + # Extract TZ data if available + gmtoff = localtm.tm_gmtoff + zone = localtm.tm_zone + except AttributeError: + # Compute UTC offset and compare with the value implied + # by tm_isdst. If the values match, use the zone name + # implied by tm_isdst. + delta = local - datetime(*_time.gmtime(ts)[:6]) + dst = _time.daylight and localtm.tm_isdst > 0 + gmtoff = -(_time.altzone if dst else _time.timezone) + if delta == timedelta(seconds=gmtoff): + tz = timezone(delta, _time.tzname[dst]) + else: + tz = timezone(delta) + else: + tz = timezone(timedelta(seconds=gmtoff), zone) + + elif not isinstance(tz, tzinfo): + raise TypeError("tz argument must be an instance of tzinfo") + + mytz = self.tzinfo + if mytz is None: + raise ValueError("astimezone() requires an aware datetime") + + if tz is mytz: + return self + + # Convert self to UTC, and attach the new time zone object. + myoffset = self.utcoffset() + if myoffset is None: + raise ValueError("astimezone() requires an aware datetime") + utc = (self - myoffset).replace(tzinfo=tz) + + # Convert from UTC to tz's local time. + return tz.fromutc(utc) + + # Ways to produce a string. + + def ctime(self): + "Return ctime() style string." + weekday = self.toordinal() % 7 or 7 + return "%s %s %2d %02d:%02d:%02d %04d" % ( + _DAYNAMES[weekday], + _MONTHNAMES[self._month], + self._day, + self._hour, self._minute, self._second, + self._year) + + def isoformat(self, sep='T'): + """Return the time formatted according to ISO. + + This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if + self.microsecond == 0. + + If self.tzinfo is not None, the UTC offset is also attached, giving + 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'. + + Optional argument sep specifies the separator between date and + time, default 'T'. + """ + s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, + sep) + + _format_time(self._hour, self._minute, self._second, + self._microsecond)) + off = self.utcoffset() + if off is not None: + if off.days < 0: + sign = "-" + off = -off + else: + sign = "+" + hh, mm = divmod(off, timedelta(hours=1)) + assert not mm % timedelta(minutes=1), "whole minute" + mm //= timedelta(minutes=1) + s += "%s%02d:%02d" % (sign, hh, mm) + return s + + def __repr__(self): + """Convert to formal string, for repr().""" + L = [self._year, self._month, self._day, # These are never zero + self._hour, self._minute, self._second, self._microsecond] + if L[-1] == 0: + del L[-1] + if L[-1] == 0: + del L[-1] + s = ", ".join(map(str, L)) + s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s) + if self._tzinfo is not None: + assert s[-1:] == ")" + s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" + return s + + def __str__(self): + "Convert to string, for str()." + return self.isoformat(sep=' ') + + @classmethod + def strptime(cls, date_string, format): + 'string, format -> new datetime parsed from a string (like time.strptime()).' + import _strptime + return _strptime._strptime_datetime(cls, date_string, format) + + def utcoffset(self): + """Return the timezone offset in minutes east of UTC (negative west of + UTC).""" + if self._tzinfo is None: + return None + offset = self._tzinfo.utcoffset(self) + _check_utc_offset("utcoffset", offset) + return offset + + def tzname(self): + """Return the timezone name. + + Note that the name is 100% informational -- there's no requirement that + it mean anything in particular. For example, "GMT", "UTC", "-500", + "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies. + """ + name = _call_tzinfo_method(self._tzinfo, "tzname", self) + _check_tzname(name) + return name + + def dst(self): + """Return 0 if DST is not in effect, or the DST offset (in minutes + eastward) if DST is in effect. + + This is purely informational; the DST offset has already been added to + the UTC offset returned by utcoffset() if applicable, so there's no + need to consult dst() unless you're interested in displaying the DST + info. + """ + if self._tzinfo is None: + return None + offset = self._tzinfo.dst(self) + _check_utc_offset("dst", offset) + return offset + + # Comparisons of datetime objects with other. + + def __eq__(self, other): + if isinstance(other, datetime): + return self._cmp(other, allow_mixed=True) == 0 + elif not isinstance(other, date): + return NotImplemented + else: + return False + + def __ne__(self, other): + if isinstance(other, datetime): + return self._cmp(other, allow_mixed=True) != 0 + elif not isinstance(other, date): + return NotImplemented + else: + return True + + def __le__(self, other): + if isinstance(other, datetime): + return self._cmp(other) <= 0 + elif not isinstance(other, date): + return NotImplemented + else: + _cmperror(self, other) + + def __lt__(self, other): + if isinstance(other, datetime): + return self._cmp(other) < 0 + elif not isinstance(other, date): + return NotImplemented + else: + _cmperror(self, other) + + def __ge__(self, other): + if isinstance(other, datetime): + return self._cmp(other) >= 0 + elif not isinstance(other, date): + return NotImplemented + else: + _cmperror(self, other) + + def __gt__(self, other): + if isinstance(other, datetime): + return self._cmp(other) > 0 + elif not isinstance(other, date): + return NotImplemented + else: + _cmperror(self, other) + + def _cmp(self, other, allow_mixed=False): + assert isinstance(other, datetime) + mytz = self._tzinfo + ottz = other._tzinfo + myoff = otoff = None + + if mytz is ottz: + base_compare = True + else: + myoff = self.utcoffset() + otoff = other.utcoffset() + base_compare = myoff == otoff + + if base_compare: + return _cmp((self._year, self._month, self._day, + self._hour, self._minute, self._second, + self._microsecond), + (other._year, other._month, other._day, + other._hour, other._minute, other._second, + other._microsecond)) + if myoff is None or otoff is None: + if allow_mixed: + return 2 # arbitrary non-zero value + else: + raise TypeError("cannot compare naive and aware datetimes") + # XXX What follows could be done more efficiently... + diff = self - other # this will take offsets into account + if diff.days < 0: + return -1 + return diff and 1 or 0 + + def __add__(self, other): + "Add a datetime and a timedelta." + if not isinstance(other, timedelta): + return NotImplemented + delta = timedelta(self.toordinal(), + hours=self._hour, + minutes=self._minute, + seconds=self._second, + microseconds=self._microsecond) + delta += other + hour, rem = divmod(delta.seconds, 3600) + minute, second = divmod(rem, 60) + if 0 < delta.days <= _MAXORDINAL: + return datetime.combine(date.fromordinal(delta.days), + time(hour, minute, second, + delta.microseconds, + tzinfo=self._tzinfo)) + raise OverflowError("result out of range") + + __radd__ = __add__ + + def __sub__(self, other): + "Subtract two datetimes, or a datetime and a timedelta." + if not isinstance(other, datetime): + if isinstance(other, timedelta): + return self + -other + return NotImplemented + + days1 = self.toordinal() + days2 = other.toordinal() + secs1 = self._second + self._minute * 60 + self._hour * 3600 + secs2 = other._second + other._minute * 60 + other._hour * 3600 + base = timedelta(days1 - days2, + secs1 - secs2, + self._microsecond - other._microsecond) + if self._tzinfo is other._tzinfo: + return base + myoff = self.utcoffset() + otoff = other.utcoffset() + if myoff == otoff: + return base + if myoff is None or otoff is None: + raise TypeError("cannot mix naive and timezone-aware time") + return base + otoff - myoff + + def __hash__(self): + tzoff = self.utcoffset() + if tzoff is None: + return hash(self._getstate()[0]) + days = _ymd2ord(self.year, self.month, self.day) + seconds = self.hour * 3600 + self.minute * 60 + self.second + return hash(timedelta(days, seconds, self.microsecond) - tzoff) + + # Pickle support. + + def _getstate(self): + yhi, ylo = divmod(self._year, 256) + us2, us3 = divmod(self._microsecond, 256) + us1, us2 = divmod(us2, 256) + basestate = bytes([yhi, ylo, self._month, self._day, + self._hour, self._minute, self._second, + us1, us2, us3]) + if self._tzinfo is None: + return (basestate,) + else: + return (basestate, self._tzinfo) + + def __setstate(self, string, tzinfo): + (yhi, ylo, self._month, self._day, self._hour, + self._minute, self._second, us1, us2, us3) = string + self._year = yhi * 256 + ylo + self._microsecond = (((us1 << 8) | us2) << 8) | us3 + if tzinfo is None or isinstance(tzinfo, _tzinfo_class): + self._tzinfo = tzinfo + else: + raise TypeError("bad tzinfo state arg %r" % tzinfo) + + def __reduce__(self): + return (self.__class__, self._getstate()) + + +datetime.min = datetime(1, 1, 1) +datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999) +datetime.resolution = timedelta(microseconds=1) + + +def _isoweek1monday(year): + # Helper to calculate the day number of the Monday starting week 1 + # XXX This could be done more efficiently + THURSDAY = 3 + firstday = _ymd2ord(year, 1, 1) + firstweekday = (firstday + 6) % 7 # See weekday() above + week1monday = firstday - firstweekday + if firstweekday > THURSDAY: + week1monday += 7 + return week1monday + +class timezone(tzinfo): + __slots__ = '_offset', '_name' + + # Sentinel value to disallow None + _Omitted = object() + def __new__(cls, offset, name=_Omitted): + if not isinstance(offset, timedelta): + raise TypeError("offset must be a timedelta") + if name is cls._Omitted: + if not offset: + return cls.utc + name = None + elif not isinstance(name, str): + raise TypeError("name must be a string") + if not cls._minoffset <= offset <= cls._maxoffset: + raise ValueError("offset must be a timedelta" + " strictly between -timedelta(hours=24) and" + " timedelta(hours=24).") + if (offset.microseconds != 0 or + offset.seconds % 60 != 0): + raise ValueError("offset must be a timedelta" + " representing a whole number of minutes") + return cls._create(offset, name) + + @classmethod + def _create(cls, offset, name=None): + self = tzinfo.__new__(cls) + self._offset = offset + self._name = name + return self + + def __getinitargs__(self): + """pickle support""" + if self._name is None: + return (self._offset,) + return (self._offset, self._name) + + def __eq__(self, other): + if type(other) != timezone: + return False + return self._offset == other._offset + + def __hash__(self): + return hash(self._offset) + + def __repr__(self): + """Convert to formal string, for repr(). + + >>> tz = timezone.utc + >>> repr(tz) + 'datetime.timezone.utc' + >>> tz = timezone(timedelta(hours=-5), 'EST') + >>> repr(tz) + "datetime.timezone(datetime.timedelta(-1, 68400), 'EST')" + """ + if self is self.utc: + return 'datetime.timezone.utc' + if self._name is None: + return "%s(%r)" % ('datetime.' + self.__class__.__name__, + self._offset) + return "%s(%r, %r)" % ('datetime.' + self.__class__.__name__, + self._offset, self._name) + + def __str__(self): + return self.tzname(None) + + def utcoffset(self, dt): + if isinstance(dt, datetime) or dt is None: + return self._offset + raise TypeError("utcoffset() argument must be a datetime instance" + " or None") + + def tzname(self, dt): + if isinstance(dt, datetime) or dt is None: + if self._name is None: + return self._name_from_offset(self._offset) + return self._name + raise TypeError("tzname() argument must be a datetime instance" + " or None") + + def dst(self, dt): + if isinstance(dt, datetime) or dt is None: + return None + raise TypeError("dst() argument must be a datetime instance" + " or None") + + def fromutc(self, dt): + if isinstance(dt, datetime): + if dt.tzinfo is not self: + raise ValueError("fromutc: dt.tzinfo " + "is not self") + return dt + self._offset + raise TypeError("fromutc() argument must be a datetime instance" + " or None") + + _maxoffset = timedelta(hours=23, minutes=59) + _minoffset = -_maxoffset + + @staticmethod + def _name_from_offset(delta): + if delta < timedelta(0): + sign = '-' + delta = -delta + else: + sign = '+' + hours, rest = divmod(delta, timedelta(hours=1)) + minutes = rest // timedelta(minutes=1) + return 'UTC{}{:02d}:{:02d}'.format(sign, hours, minutes) + +timezone.utc = timezone._create(timedelta(0)) +timezone.min = timezone._create(timezone._minoffset) +timezone.max = timezone._create(timezone._maxoffset) +_EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc) + +# Some time zone algebra. For a datetime x, let +# x.n = x stripped of its timezone -- its naive time. +# x.o = x.utcoffset(), and assuming that doesn't raise an exception or +# return None +# x.d = x.dst(), and assuming that doesn't raise an exception or +# return None +# x.s = x's standard offset, x.o - x.d +# +# Now some derived rules, where k is a duration (timedelta). +# +# 1. x.o = x.s + x.d +# This follows from the definition of x.s. +# +# 2. If x and y have the same tzinfo member, x.s = y.s. +# This is actually a requirement, an assumption we need to make about +# sane tzinfo classes. +# +# 3. The naive UTC time corresponding to x is x.n - x.o. +# This is again a requirement for a sane tzinfo class. +# +# 4. (x+k).s = x.s +# This follows from #2, and that datimetimetz+timedelta preserves tzinfo. +# +# 5. (x+k).n = x.n + k +# Again follows from how arithmetic is defined. +# +# Now we can explain tz.fromutc(x). Let's assume it's an interesting case +# (meaning that the various tzinfo methods exist, and don't blow up or return +# None when called). +# +# The function wants to return a datetime y with timezone tz, equivalent to x. +# x is already in UTC. +# +# By #3, we want +# +# y.n - y.o = x.n [1] +# +# The algorithm starts by attaching tz to x.n, and calling that y. So +# x.n = y.n at the start. Then it wants to add a duration k to y, so that [1] +# becomes true; in effect, we want to solve [2] for k: +# +# (y+k).n - (y+k).o = x.n [2] +# +# By #1, this is the same as +# +# (y+k).n - ((y+k).s + (y+k).d) = x.n [3] +# +# By #5, (y+k).n = y.n + k, which equals x.n + k because x.n=y.n at the start. +# Substituting that into [3], +# +# x.n + k - (y+k).s - (y+k).d = x.n; the x.n terms cancel, leaving +# k - (y+k).s - (y+k).d = 0; rearranging, +# k = (y+k).s - (y+k).d; by #4, (y+k).s == y.s, so +# k = y.s - (y+k).d +# +# On the RHS, (y+k).d can't be computed directly, but y.s can be, and we +# approximate k by ignoring the (y+k).d term at first. Note that k can't be +# very large, since all offset-returning methods return a duration of magnitude +# less than 24 hours. For that reason, if y is firmly in std time, (y+k).d must +# be 0, so ignoring it has no consequence then. +# +# In any case, the new value is +# +# z = y + y.s [4] +# +# It's helpful to step back at look at [4] from a higher level: it's simply +# mapping from UTC to tz's standard time. +# +# At this point, if +# +# z.n - z.o = x.n [5] +# +# we have an equivalent time, and are almost done. The insecurity here is +# at the start of daylight time. Picture US Eastern for concreteness. The wall +# time jumps from 1:59 to 3:00, and wall hours of the form 2:MM don't make good +# sense then. The docs ask that an Eastern tzinfo class consider such a time to +# be EDT (because it's "after 2"), which is a redundant spelling of 1:MM EST +# on the day DST starts. We want to return the 1:MM EST spelling because that's +# the only spelling that makes sense on the local wall clock. +# +# In fact, if [5] holds at this point, we do have the standard-time spelling, +# but that takes a bit of proof. We first prove a stronger result. What's the +# difference between the LHS and RHS of [5]? Let +# +# diff = x.n - (z.n - z.o) [6] +# +# Now +# z.n = by [4] +# (y + y.s).n = by #5 +# y.n + y.s = since y.n = x.n +# x.n + y.s = since z and y are have the same tzinfo member, +# y.s = z.s by #2 +# x.n + z.s +# +# Plugging that back into [6] gives +# +# diff = +# x.n - ((x.n + z.s) - z.o) = expanding +# x.n - x.n - z.s + z.o = cancelling +# - z.s + z.o = by #2 +# z.d +# +# So diff = z.d. +# +# If [5] is true now, diff = 0, so z.d = 0 too, and we have the standard-time +# spelling we wanted in the endcase described above. We're done. Contrarily, +# if z.d = 0, then we have a UTC equivalent, and are also done. +# +# If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to +# add to z (in effect, z is in tz's standard time, and we need to shift the +# local clock into tz's daylight time). +# +# Let +# +# z' = z + z.d = z + diff [7] +# +# and we can again ask whether +# +# z'.n - z'.o = x.n [8] +# +# If so, we're done. If not, the tzinfo class is insane, according to the +# assumptions we've made. This also requires a bit of proof. As before, let's +# compute the difference between the LHS and RHS of [8] (and skipping some of +# the justifications for the kinds of substitutions we've done several times +# already): +# +# diff' = x.n - (z'.n - z'.o) = replacing z'.n via [7] +# x.n - (z.n + diff - z'.o) = replacing diff via [6] +# x.n - (z.n + x.n - (z.n - z.o) - z'.o) = +# x.n - z.n - x.n + z.n - z.o + z'.o = cancel x.n +# - z.n + z.n - z.o + z'.o = cancel z.n +# - z.o + z'.o = #1 twice +# -z.s - z.d + z'.s + z'.d = z and z' have same tzinfo +# z'.d - z.d +# +# So z' is UTC-equivalent to x iff z'.d = z.d at this point. If they are equal, +# we've found the UTC-equivalent so are done. In fact, we stop with [7] and +# return z', not bothering to compute z'.d. +# +# How could z.d and z'd differ? z' = z + z.d [7], so merely moving z' by +# a dst() offset, and starting *from* a time already in DST (we know z.d != 0), +# would have to change the result dst() returns: we start in DST, and moving +# a little further into it takes us out of DST. +# +# There isn't a sane case where this can happen. The closest it gets is at +# the end of DST, where there's an hour in UTC with no spelling in a hybrid +# tzinfo class. In US Eastern, that's 5:MM UTC = 0:MM EST = 1:MM EDT. During +# that hour, on an Eastern clock 1:MM is taken as being in standard time (6:MM +# UTC) because the docs insist on that, but 0:MM is taken as being in daylight +# time (4:MM UTC). There is no local time mapping to 5:MM UTC. The local +# clock jumps from 1:59 back to 1:00 again, and repeats the 1:MM hour in +# standard time. Since that's what the local clock *does*, we want to map both +# UTC hours 5:MM and 6:MM to 1:MM Eastern. The result is ambiguous +# in local time, but so it goes -- it's the way the local clock works. +# +# When x = 5:MM UTC is the input to this algorithm, x.o=0, y.o=-5 and y.d=0, +# so z=0:MM. z.d=60 (minutes) then, so [5] doesn't hold and we keep going. +# z' = z + z.d = 1:MM then, and z'.d=0, and z'.d - z.d = -60 != 0 so [8] +# (correctly) concludes that z' is not UTC-equivalent to x. +# +# Because we know z.d said z was in daylight time (else [5] would have held and +# we would have stopped then), and we know z.d != z'.d (else [8] would have held +# and we have stopped then), and there are only 2 possible values dst() can +# return in Eastern, it follows that z'.d must be 0 (which it is in the example, +# but the reasoning doesn't depend on the example -- it depends on there being +# two possible dst() outcomes, one zero and the other non-zero). Therefore +# z' must be in standard time, and is the spelling we want in this case. +# +# Note again that z' is not UTC-equivalent as far as the hybrid tzinfo class is +# concerned (because it takes z' as being in standard time rather than the +# daylight time we intend here), but returning it gives the real-life "local +# clock repeats an hour" behavior when mapping the "unspellable" UTC hour into +# tz. +# +# When the input is 6:MM, z=1:MM and z.d=0, and we stop at once, again with +# the 1:MM standard time spelling we want. +# +# So how can this break? One of the assumptions must be violated. Two +# possibilities: +# +# 1) [2] effectively says that y.s is invariant across all y belong to a given +# time zone. This isn't true if, for political reasons or continental drift, +# a region decides to change its base offset from UTC. +# +# 2) There may be versions of "double daylight" time where the tail end of +# the analysis gives up a step too early. I haven't thought about that +# enough to say. +# +# In any case, it's clear that the default fromutc() is strong enough to handle +# "almost all" time zones: so long as the standard offset is invariant, it +# doesn't matter if daylight time transition points change from year to year, or +# if daylight time is skipped in some years; it doesn't matter how large or +# small dst() may get within its bounds; and it doesn't even matter if some +# perverse time zone returns a negative dst()). So a breaking case must be +# pretty bizarre, and a tzinfo subclass can override fromutc() if it is. + +try: + from _datetime import * +except ImportError: + pass +else: + # Clean up unused names + del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH, + _DI100Y, _DI400Y, _DI4Y, _MAXORDINAL, _MONTHNAMES, + _build_struct_time, _call_tzinfo_method, _check_date_fields, + _check_time_fields, _check_tzinfo_arg, _check_tzname, + _check_utc_offset, _cmp, _cmperror, _date_class, _days_before_month, + _days_before_year, _days_in_month, _format_time, _is_leap, + _isoweek1monday, _math, _ord2ymd, _time, _time_class, _tzinfo_class, + _wrap_strftime, _ymd2ord) + # XXX Since import * above excludes names that start with _, + # docstring does not get overwritten. In the future, it may be + # appropriate to maintain a single module level docstring and + # remove the following line. + from _datetime import __doc__ diff --git a/python/testData/MockSdk3.4/Lib/io.py b/python/testData/MockSdk3.4/Lib/io.py new file mode 100644 index 000000000000..8d68f1e42409 --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/io.py @@ -0,0 +1,92 @@ +"""The io module provides the Python interfaces to stream handling. The +builtin open function is defined in this module. + +At the top of the I/O hierarchy is the abstract base class IOBase. It +defines the basic interface to a stream. Note, however, that there is no +separation between reading and writing to streams; implementations are +allowed to raise an OSError if they do not support a given operation. + +Extending IOBase is RawIOBase which deals simply with the reading and +writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide +an interface to OS files. + +BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its +subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer +streams that are readable, writable, and both respectively. +BufferedRandom provides a buffered interface to random access +streams. BytesIO is a simple stream of in-memory bytes. + +Another IOBase subclass, TextIOBase, deals with the encoding and decoding +of streams into text. TextIOWrapper, which extends it, is a buffered text +interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO +is a in-memory stream for text. + +Argument names are not part of the specification, and only the arguments +of open() are intended to be used as keyword arguments. + +data: + +DEFAULT_BUFFER_SIZE + + An int containing the default buffer size used by the module's buffered + I/O classes. open() uses the file's blksize (as obtained by os.stat) if + possible. +""" +# New I/O library conforming to PEP 3116. + +__author__ = ("Guido van Rossum , " + "Mike Verdone , " + "Mark Russell , " + "Antoine Pitrou , " + "Amaury Forgeot d'Arc , " + "Benjamin Peterson ") + +__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO", + "BytesIO", "StringIO", "BufferedIOBase", + "BufferedReader", "BufferedWriter", "BufferedRWPair", + "BufferedRandom", "TextIOBase", "TextIOWrapper", + "UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"] + + +import _io +import abc + +from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation, + open, FileIO, BytesIO, StringIO, BufferedReader, + BufferedWriter, BufferedRWPair, BufferedRandom, + IncrementalNewlineDecoder, TextIOWrapper) + +OpenWrapper = _io.open # for compatibility with _pyio + +# Pretend this exception was created here. +UnsupportedOperation.__module__ = "io" + +# for seek() +SEEK_SET = 0 +SEEK_CUR = 1 +SEEK_END = 2 + +# Declaring ABCs in C is tricky so we do it here. +# Method descriptions and default implementations are inherited from the C +# version however. +class IOBase(_io._IOBase, metaclass=abc.ABCMeta): + __doc__ = _io._IOBase.__doc__ + +class RawIOBase(_io._RawIOBase, IOBase): + __doc__ = _io._RawIOBase.__doc__ + +class BufferedIOBase(_io._BufferedIOBase, IOBase): + __doc__ = _io._BufferedIOBase.__doc__ + +class TextIOBase(_io._TextIOBase, IOBase): + __doc__ = _io._TextIOBase.__doc__ + +RawIOBase.register(FileIO) + +for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom, + BufferedRWPair): + BufferedIOBase.register(klass) + +for klass in (StringIO, TextIOWrapper): + TextIOBase.register(klass) +del klass diff --git a/python/testData/MockSdk3.4/Lib/numbers.py b/python/testData/MockSdk3.4/Lib/numbers.py new file mode 100644 index 000000000000..b206457dfc04 --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/numbers.py @@ -0,0 +1,394 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) for numbers, according to PEP 3141. + +TODO: Fill out more detailed documentation on the operators.""" + +from abc import ABCMeta, abstractmethod + +__all__ = ["Number", "Complex", "Real", "Rational", "Integral"] + +class Number(metaclass=ABCMeta): + """All numbers inherit from this class. + + If you just want to check if an argument x is a number, without + caring what kind, use isinstance(x, Number). + """ + __slots__ = () + + # Concrete numeric types must provide their own hash implementation + __hash__ = None + + +## Notes on Decimal +## ---------------- +## Decimal has all of the methods specified by the Real abc, but it should +## not be registered as a Real because decimals do not interoperate with +## binary floats (i.e. Decimal('3.14') + 2.71828 is undefined). But, +## abstract reals are expected to interoperate (i.e. R1 + R2 should be +## expected to work if R1 and R2 are both Reals). + +class Complex(Number): + """Complex defines the operations that work on the builtin complex type. + + In short, those are: a conversion to complex, .real, .imag, +, -, + *, /, abs(), .conjugate, ==, and !=. + + If it is given heterogenous arguments, and doesn't have special + knowledge about them, it should fall back to the builtin complex + type as described below. + """ + + __slots__ = () + + @abstractmethod + def __complex__(self): + """Return a builtin complex instance. Called for complex(self).""" + + def __bool__(self): + """True if self != 0. Called for bool(self).""" + return self != 0 + + @property + @abstractmethod + def real(self): + """Retrieve the real component of this number. + + This should subclass Real. + """ + raise NotImplementedError + + @property + @abstractmethod + def imag(self): + """Retrieve the imaginary component of this number. + + This should subclass Real. + """ + raise NotImplementedError + + @abstractmethod + def __add__(self, other): + """self + other""" + raise NotImplementedError + + @abstractmethod + def __radd__(self, other): + """other + self""" + raise NotImplementedError + + @abstractmethod + def __neg__(self): + """-self""" + raise NotImplementedError + + @abstractmethod + def __pos__(self): + """+self""" + raise NotImplementedError + + def __sub__(self, other): + """self - other""" + return self + -other + + def __rsub__(self, other): + """other - self""" + return -self + other + + @abstractmethod + def __mul__(self, other): + """self * other""" + raise NotImplementedError + + @abstractmethod + def __rmul__(self, other): + """other * self""" + raise NotImplementedError + + @abstractmethod + def __truediv__(self, other): + """self / other: Should promote to float when necessary.""" + raise NotImplementedError + + @abstractmethod + def __rtruediv__(self, other): + """other / self""" + raise NotImplementedError + + @abstractmethod + def __pow__(self, exponent): + """self**exponent; should promote to float or complex when necessary.""" + raise NotImplementedError + + @abstractmethod + def __rpow__(self, base): + """base ** self""" + raise NotImplementedError + + @abstractmethod + def __abs__(self): + """Returns the Real distance from 0. Called for abs(self).""" + raise NotImplementedError + + @abstractmethod + def conjugate(self): + """(x+y*i).conjugate() returns (x-y*i).""" + raise NotImplementedError + + @abstractmethod + def __eq__(self, other): + """self == other""" + raise NotImplementedError + + def __ne__(self, other): + """self != other""" + # The default __ne__ doesn't negate __eq__ until 3.0. + return not (self == other) + +Complex.register(complex) + + +class Real(Complex): + """To Complex, Real adds the operations that work on real numbers. + + In short, those are: a conversion to float, trunc(), divmod, + %, <, <=, >, and >=. + + Real also provides defaults for the derived operations. + """ + + __slots__ = () + + @abstractmethod + def __float__(self): + """Any Real can be converted to a native float object. + + Called for float(self).""" + raise NotImplementedError + + @abstractmethod + def __trunc__(self): + """trunc(self): Truncates self to an Integral. + + Returns an Integral i such that: + * i>0 iff self>0; + * abs(i) <= abs(self); + * for any Integral j satisfying the first two conditions, + abs(i) >= abs(j) [i.e. i has "maximal" abs among those]. + i.e. "truncate towards 0". + """ + raise NotImplementedError + + @abstractmethod + def __floor__(self): + """Finds the greatest Integral <= self.""" + raise NotImplementedError + + @abstractmethod + def __ceil__(self): + """Finds the least Integral >= self.""" + raise NotImplementedError + + @abstractmethod + def __round__(self, ndigits=None): + """Rounds self to ndigits decimal places, defaulting to 0. + + If ndigits is omitted or None, returns an Integral, otherwise + returns a Real. Rounds half toward even. + """ + raise NotImplementedError + + def __divmod__(self, other): + """divmod(self, other): The pair (self // other, self % other). + + Sometimes this can be computed faster than the pair of + operations. + """ + return (self // other, self % other) + + def __rdivmod__(self, other): + """divmod(other, self): The pair (self // other, self % other). + + Sometimes this can be computed faster than the pair of + operations. + """ + return (other // self, other % self) + + @abstractmethod + def __floordiv__(self, other): + """self // other: The floor() of self/other.""" + raise NotImplementedError + + @abstractmethod + def __rfloordiv__(self, other): + """other // self: The floor() of other/self.""" + raise NotImplementedError + + @abstractmethod + def __mod__(self, other): + """self % other""" + raise NotImplementedError + + @abstractmethod + def __rmod__(self, other): + """other % self""" + raise NotImplementedError + + @abstractmethod + def __lt__(self, other): + """self < other + + < on Reals defines a total ordering, except perhaps for NaN.""" + raise NotImplementedError + + @abstractmethod + def __le__(self, other): + """self <= other""" + raise NotImplementedError + + # Concrete implementations of Complex abstract methods. + def __complex__(self): + """complex(self) == complex(float(self), 0)""" + return complex(float(self)) + + @property + def real(self): + """Real numbers are their real component.""" + return +self + + @property + def imag(self): + """Real numbers have no imaginary component.""" + return 0 + + def conjugate(self): + """Conjugate is a no-op for Reals.""" + return +self + +Real.register(float) + + +class Rational(Real): + """.numerator and .denominator should be in lowest terms.""" + + __slots__ = () + + @property + @abstractmethod + def numerator(self): + raise NotImplementedError + + @property + @abstractmethod + def denominator(self): + raise NotImplementedError + + # Concrete implementation of Real's conversion to float. + def __float__(self): + """float(self) = self.numerator / self.denominator + + It's important that this conversion use the integer's "true" + division rather than casting one side to float before dividing + so that ratios of huge integers convert without overflowing. + + """ + return self.numerator / self.denominator + + +class Integral(Rational): + """Integral adds a conversion to int and the bit-string operations.""" + + __slots__ = () + + @abstractmethod + def __int__(self): + """int(self)""" + raise NotImplementedError + + def __index__(self): + """Called whenever an index is needed, such as in slicing""" + return int(self) + + @abstractmethod + def __pow__(self, exponent, modulus=None): + """self ** exponent % modulus, but maybe faster. + + Accept the modulus argument if you want to support the + 3-argument version of pow(). Raise a TypeError if exponent < 0 + or any argument isn't Integral. Otherwise, just implement the + 2-argument version described in Complex. + """ + raise NotImplementedError + + @abstractmethod + def __lshift__(self, other): + """self << other""" + raise NotImplementedError + + @abstractmethod + def __rlshift__(self, other): + """other << self""" + raise NotImplementedError + + @abstractmethod + def __rshift__(self, other): + """self >> other""" + raise NotImplementedError + + @abstractmethod + def __rrshift__(self, other): + """other >> self""" + raise NotImplementedError + + @abstractmethod + def __and__(self, other): + """self & other""" + raise NotImplementedError + + @abstractmethod + def __rand__(self, other): + """other & self""" + raise NotImplementedError + + @abstractmethod + def __xor__(self, other): + """self ^ other""" + raise NotImplementedError + + @abstractmethod + def __rxor__(self, other): + """other ^ self""" + raise NotImplementedError + + @abstractmethod + def __or__(self, other): + """self | other""" + raise NotImplementedError + + @abstractmethod + def __ror__(self, other): + """other | self""" + raise NotImplementedError + + @abstractmethod + def __invert__(self): + """~self""" + raise NotImplementedError + + # Concrete implementations of Rational and Real abstract methods. + def __float__(self): + """float(self) == float(int(self))""" + return float(int(self)) + + @property + def numerator(self): + """Integers are their own numerators.""" + return +self + + @property + def denominator(self): + """Integers have a denominator of 1.""" + return 1 + +Integral.register(int) diff --git a/python/testData/MockSdk3.4/Lib/re.py b/python/testData/MockSdk3.4/Lib/re.py new file mode 100644 index 000000000000..2e4d87c3f5c8 --- /dev/null +++ b/python/testData/MockSdk3.4/Lib/re.py @@ -0,0 +1,368 @@ +# +# Secret Labs' Regular Expression Engine +# +# re-compatible interface for the sre matching engine +# +# Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. +# +# This version of the SRE library can be redistributed under CNRI's +# Python 1.6 license. For any other use, please contact Secret Labs +# AB (info@pythonware.com). +# +# Portions of this engine have been developed in cooperation with +# CNRI. Hewlett-Packard provided funding for 1.6 integration and +# other compatibility work. +# + +r"""Support for regular expressions (RE). + +This module provides regular expression matching operations similar to +those found in Perl. It supports both 8-bit and Unicode strings; both +the pattern and the strings being processed can contain null bytes and +characters outside the US ASCII range. + +Regular expressions can contain both special and ordinary characters. +Most ordinary characters, like "A", "a", or "0", are the simplest +regular expressions; they simply match themselves. You can +concatenate ordinary characters, so last matches the string 'last'. + +The special characters are: + "." Matches any character except a newline. + "^" Matches the start of the string. + "$" Matches the end of the string or just before the newline at + the end of the string. + "*" Matches 0 or more (greedy) repetitions of the preceding RE. + Greedy means that it will match as many repetitions as possible. + "+" Matches 1 or more (greedy) repetitions of the preceding RE. + "?" Matches 0 or 1 (greedy) of the preceding RE. + *?,+?,?? Non-greedy versions of the previous three special characters. + {m,n} Matches from m to n repetitions of the preceding RE. + {m,n}? Non-greedy version of the above. + "\\" Either escapes special characters or signals a special sequence. + [] Indicates a set of characters. + A "^" as the first character indicates a complementing set. + "|" A|B, creates an RE that will match either A or B. + (...) Matches the RE inside the parentheses. + The contents can be retrieved or matched later in the string. + (?aiLmsux) Set the A, I, L, M, S, U, or X flag for the RE (see below). + (?:...) Non-grouping version of regular parentheses. + (?P...) The substring matched by the group is accessible by name. + (?P=name) Matches the text matched earlier by the group named name. + (?#...) A comment; ignored. + (?=...) Matches if ... matches next, but doesn't consume the string. + (?!...) Matches if ... doesn't match next. + (?<=...) Matches if preceded by ... (must be fixed length). + (?= 0x02020000: + __all__.append("finditer") + def finditer(pattern, string, flags=0): + """Return an iterator over all non-overlapping matches in the + string. For each match, the iterator returns a match object. + + Empty matches are included in the result.""" + return _compile(pattern, flags).finditer(string) + +def compile(pattern, flags=0): + "Compile a regular expression pattern, returning a pattern object." + return _compile(pattern, flags) + +def purge(): + "Clear the regular expression caches" + _cache.clear() + _cache_repl.clear() + +def template(pattern, flags=0): + "Compile a template pattern, returning a pattern object" + return _compile(pattern, flags|T) + +_alphanum_str = frozenset( + "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") +_alphanum_bytes = frozenset( + b"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") + +def escape(pattern): + """ + Escape all the characters in pattern except ASCII letters, numbers and '_'. + """ + if isinstance(pattern, str): + alphanum = _alphanum_str + s = list(pattern) + for i, c in enumerate(pattern): + if c not in alphanum: + if c == "\000": + s[i] = "\\000" + else: + s[i] = "\\" + c + return "".join(s) + else: + alphanum = _alphanum_bytes + s = [] + esc = ord(b"\\") + for c in pattern: + if c in alphanum: + s.append(c) + else: + if c == 0: + s.extend(b"\\000") + else: + s.append(esc) + s.append(c) + return bytes(s) + +# -------------------------------------------------------------------- +# internals + +_cache = {} +_cache_repl = {} + +_pattern_type = type(sre_compile.compile("", 0)) + +_MAXCACHE = 512 +def _compile(pattern, flags): + # internal: compile pattern + bypass_cache = flags & DEBUG + if not bypass_cache: + try: + return _cache[type(pattern), pattern, flags] + except KeyError: + pass + if isinstance(pattern, _pattern_type): + if flags: + raise ValueError( + "Cannot process flags argument with a compiled pattern") + return pattern + if not sre_compile.isstring(pattern): + raise TypeError("first argument must be string or compiled pattern") + p = sre_compile.compile(pattern, flags) + if not bypass_cache: + if len(_cache) >= _MAXCACHE: + _cache.clear() + _cache[type(pattern), pattern, flags] = p + return p + +def _compile_repl(repl, pattern): + # internal: compile replacement pattern + try: + return _cache_repl[repl, pattern] + except KeyError: + pass + p = sre_parse.parse_template(repl, pattern) + if len(_cache_repl) >= _MAXCACHE: + _cache_repl.clear() + _cache_repl[repl, pattern] = p + return p + +def _expand(pattern, match, template): + # internal: match.expand implementation hook + template = sre_parse.parse_template(template, pattern) + return sre_parse.expand_template(template, match) + +def _subx(pattern, template): + # internal: pattern.sub/subn implementation helper + template = _compile_repl(template, pattern) + if not template[0] and len(template[1]) == 1: + # literal replacement + return template[1][0] + def filter(match, template=template): + return sre_parse.expand_template(template, match) + return filter + +# register myself for pickling + +import copyreg + +def _pickle(p): + return _compile, (p.pattern, p.flags) + +copyreg.pickle(_pattern_type, _pickle, _compile) + +# -------------------------------------------------------------------- +# experimental stuff (see python-dev discussions for details) + +class Scanner: + def __init__(self, lexicon, flags=0): + from sre_constants import BRANCH, SUBPATTERN + self.lexicon = lexicon + # combine phrases into a compound pattern + p = [] + s = sre_parse.Pattern() + s.flags = flags + for phrase, action in lexicon: + p.append(sre_parse.SubPattern(s, [ + (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))), + ])) + s.groups = len(p)+1 + p = sre_parse.SubPattern(s, [(BRANCH, (None, p))]) + self.scanner = sre_compile.compile(p) + def scan(self, string): + result = [] + append = result.append + match = self.scanner.scanner(string).match + i = 0 + while 1: + m = match() + if not m: + break + j = m.end() + if i == j: + break + action = self.lexicon[m.lastindex-1][1] + if callable(action): + self.match = m + action = action(self, m.group()) + if action is not None: + append(action) + i = j + return result, string[i:] diff --git a/python/testData/MockSdk3.4/bin/python3.4 b/python/testData/MockSdk3.4/bin/python3.4 new file mode 100644 index 000000000000..586f986fd3af --- /dev/null +++ b/python/testData/MockSdk3.4/bin/python3.4 @@ -0,0 +1 @@ +# placeholder for python interpreter diff --git a/python/testData/MockSdk3.4/python_stubs/_io.py b/python/testData/MockSdk3.4/python_stubs/_io.py new file mode 100644 index 000000000000..214d63caec65 --- /dev/null +++ b/python/testData/MockSdk3.4/python_stubs/_io.py @@ -0,0 +1,1517 @@ +# encoding: utf-8 +# module _io calls itself io +# from (built-in) +# by generator 1.135 +""" +The io module provides the Python interfaces to stream handling. The +builtin open function is defined in this module. + +At the top of the I/O hierarchy is the abstract base class IOBase. It +defines the basic interface to a stream. Note, however, that there is no +separation between reading and writing to streams; implementations are +allowed to raise an IOError if they do not support a given operation. + +Extending IOBase is RawIOBase which deals simply with the reading and +writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide +an interface to OS files. + +BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its +subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer +streams that are readable, writable, and both respectively. +BufferedRandom provides a buffered interface to random access +streams. BytesIO is a simple stream of in-memory bytes. + +Another IOBase subclass, TextIOBase, deals with the encoding and decoding +of streams into text. TextIOWrapper, which extends it, is a buffered text +interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO +is a in-memory stream for text. + +Argument names are not part of the specification, and only the arguments +of open() are intended to be used as keyword arguments. + +data: + +DEFAULT_BUFFER_SIZE + + An int containing the default buffer size used by the module's buffered + I/O classes. open() uses the file's blksize (as obtained by os.stat) if + possible. +""" +# no imports + +# Variables with simple values + +DEFAULT_BUFFER_SIZE = 8192 + +# functions + +def open(name, mode=None, buffering=None): # known case of _io.open + """ + open(file, mode='r', buffering=-1, encoding=None, + errors=None, newline=None, closefd=True, opener=None) -> file object + + Open file and return a stream. Raise IOError upon failure. + + file is either a text or byte string giving the name (and the path + if the file isn't in the current working directory) of the file to + be opened or an integer file descriptor of the file to be + wrapped. (If a file descriptor is given, it is closed when the + returned I/O object is closed, unless closefd is set to False.) + + mode is an optional string that specifies the mode in which the file + is opened. It defaults to 'r' which means open for reading in text + mode. Other common values are 'w' for writing (truncating the file if + it already exists), 'x' for creating and writing to a new file, and + 'a' for appending (which on some Unix systems, means that all writes + append to the end of the file regardless of the current seek position). + In text mode, if encoding is not specified the encoding used is platform + dependent: locale.getpreferredencoding(False) is called to get the + current locale encoding. (For reading and writing raw bytes use binary + mode and leave encoding unspecified.) The available modes are: + + ========= =============================================================== + Character Meaning + --------- --------------------------------------------------------------- + 'r' open for reading (default) + 'w' open for writing, truncating the file first + 'x' create a new file and open it for writing + 'a' open for writing, appending to the end of the file if it exists + 'b' binary mode + 't' text mode (default) + '+' open a disk file for updating (reading and writing) + 'U' universal newline mode (deprecated) + ========= =============================================================== + + The default mode is 'rt' (open for reading text). For binary random + access, the mode 'w+b' opens and truncates the file to 0 bytes, while + 'r+b' opens the file without truncation. The 'x' mode implies 'w' and + raises an `FileExistsError` if the file already exists. + + Python distinguishes between files opened in binary and text modes, + even when the underlying operating system doesn't. Files opened in + binary mode (appending 'b' to the mode argument) return contents as + bytes objects without any decoding. In text mode (the default, or when + 't' is appended to the mode argument), the contents of the file are + returned as strings, the bytes having been first decoded using a + platform-dependent encoding or using the specified encoding if given. + + 'U' mode is deprecated and will raise an exception in future versions + of Python. It has no effect in Python 3. Use newline to control + universal newlines mode. + + buffering is an optional integer used to set the buffering policy. + Pass 0 to switch buffering off (only allowed in binary mode), 1 to select + line buffering (only usable in text mode), and an integer > 1 to indicate + the size of a fixed-size chunk buffer. When no buffering argument is + given, the default buffering policy works as follows: + + * Binary files are buffered in fixed-size chunks; the size of the buffer + is chosen using a heuristic trying to determine the underlying device's + "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. + On many systems, the buffer will typically be 4096 or 8192 bytes long. + + * "Interactive" text files (files for which isatty() returns True) + use line buffering. Other text files use the policy described above + for binary files. + + encoding is the name of the encoding used to decode or encode the + file. This should only be used in text mode. The default encoding is + platform dependent, but any encoding supported by Python can be + passed. See the codecs module for the list of supported encodings. + + errors is an optional string that specifies how encoding errors are to + be handled---this argument should not be used in binary mode. Pass + 'strict' to raise a ValueError exception if there is an encoding error + (the default of None has the same effect), or pass 'ignore' to ignore + errors. (Note that ignoring encoding errors can lead to data loss.) + See the documentation for codecs.register or run 'help(codecs.Codec)' + for a list of the permitted encoding error strings. + + newline controls how universal newlines works (it only applies to text + mode). It can be None, '', '\n', '\r', and '\r\n'. It works as + follows: + + * On input, if newline is None, universal newlines mode is + enabled. Lines in the input can end in '\n', '\r', or '\r\n', and + these are translated into '\n' before being returned to the + caller. If it is '', universal newline mode is enabled, but line + endings are returned to the caller untranslated. If it has any of + the other legal values, input lines are only terminated by the given + string, and the line ending is returned to the caller untranslated. + + * On output, if newline is None, any '\n' characters written are + translated to the system default line separator, os.linesep. If + newline is '' or '\n', no translation takes place. If newline is any + of the other legal values, any '\n' characters written are translated + to the given string. + + If closefd is False, the underlying file descriptor will be kept open + when the file is closed. This does not work when a file name is given + and must be True in that case. + + A custom opener can be used by passing a callable as *opener*. The + underlying file descriptor for the file object is then obtained by + calling *opener* with (*file*, *flags*). *opener* must return an open + file descriptor (passing os.open as *opener* results in functionality + similar to passing None). + + open() returns a file object whose type depends on the mode, and + through which the standard file operations such as reading and writing + are performed. When open() is used to open a file in a text mode ('w', + 'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open + a file in a binary mode, the returned class varies: in read binary + mode, it returns a BufferedReader; in write binary and append binary + modes, it returns a BufferedWriter, and in read/write mode, it returns + a BufferedRandom. + + It is also possible to use a string or bytearray as a file for both + reading and writing. For strings StringIO can be used like a file + opened in a text mode, and for bytes a BytesIO can be used like a file + opened in a binary mode. + """ + return file('/dev/null') + +# classes + +from .OSError import OSError + +class BlockingIOError(OSError): + """ I/O operation would block. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .object import object + +class _IOBase(object): + """ + The abstract base class for all I/O classes, acting on streams of + bytes. There is no public constructor. + + This class provides dummy implementations for many methods that + derived classes can override selectively; the default implementations + represent a file that cannot be read, written or seeked. + + Even though IOBase does not declare read, readinto, or write because + their signatures will vary, implementations and clients should + consider those methods part of the interface. Also, implementations + may raise UnsupportedOperation when operations they do not support are + called. + + The basic type used for binary data read from or written to a file is + bytes. bytearrays are accepted too, and in some cases (such as + readinto) needed. Text I/O classes work with str data. + + Note that calling any method (except additional calls to close(), + which are ignored) on a closed stream should raise a ValueError. + + IOBase (and its subclasses) support the iterator protocol, meaning + that an IOBase object can be iterated over yielding the lines in a + stream. + + IOBase also supports the :keyword:`with` statement. In this example, + fp is closed after the suite of the with statement is complete: + + with open('spam.txt', 'r') as fp: + fp.write('Spam and eggs!') + """ + def close(self, *args, **kwargs): # real signature unknown + """ + Flush and close the IO object. + + This method has no effect if the file is already closed. + """ + pass + + def fileno(self, *args, **kwargs): # real signature unknown + """ + Returns underlying file descriptor if one exists. + + An IOError is raised if the IO object does not use a file descriptor. + """ + pass + + def flush(self, *args, **kwargs): # real signature unknown + """ + Flush write buffers, if applicable. + + This is not implemented for read-only and non-blocking streams. + """ + pass + + def isatty(self, *args, **kwargs): # real signature unknown + """ + Return whether this is an 'interactive' stream. + + Return False if it can't be determined. + """ + pass + + def readable(self, *args, **kwargs): # real signature unknown + """ + Return whether object was opened for reading. + + If False, read() will raise UnsupportedOperation. + """ + pass + + def readline(self, *args, **kwargs): # real signature unknown + """ + Read and return a line from the stream. + + If limit is specified, at most limit bytes will be read. + + The line terminator is always b'\n' for binary files; for text + files, the newlines argument to open can be used to select the line + terminator(s) recognized. + """ + pass + + def readlines(self, *args, **kwargs): # real signature unknown + """ + Return a list of lines from the stream. + + hint can be specified to control the number of lines read: no more + lines will be read if the total size (in bytes/characters) of all + lines so far exceeds hint. + """ + pass + + def seek(self, *args, **kwargs): # real signature unknown + """ + Change stream position. + + Change the stream position to the given byte offset. The offset is + interpreted relative to the position indicated by whence. Values + for whence are: + + * 0 -- start of stream (the default); offset should be zero or positive + * 1 -- current stream position; offset may be negative + * 2 -- end of stream; offset is usually negative + + Return the new absolute position. + """ + pass + + def seekable(self, *args, **kwargs): # real signature unknown + """ + Return whether object supports random access. + + If False, seek(), tell() and truncate() will raise UnsupportedOperation. + This method may need to do a test seek(). + """ + pass + + def tell(self, *args, **kwargs): # real signature unknown + """ Return current stream position. """ + pass + + def truncate(self, *args, **kwargs): # real signature unknown + """ + Truncate file to size bytes. + + File pointer is left unchanged. Size defaults to the current IO + position as reported by tell(). Returns the new size. + """ + pass + + def writable(self, *args, **kwargs): # real signature unknown + """ + Return whether object was opened for writing. + + If False, write() will raise UnsupportedOperation. + """ + pass + + def writelines(self, *args, **kwargs): # real signature unknown + pass + + def _checkClosed(self, *args, **kwargs): # real signature unknown + pass + + def _checkReadable(self, *args, **kwargs): # real signature unknown + pass + + def _checkSeekable(self, *args, **kwargs): # real signature unknown + pass + + def _checkWritable(self, *args, **kwargs): # real signature unknown + pass + + def __del__(self, *args, **kwargs): # real signature unknown + """ """ + pass + + def __enter__(self, *args, **kwargs): # real signature unknown + pass + + def __exit__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __dict__ = None # (!) real value is '' + + +from ._IOBase import _IOBase + +class _BufferedIOBase(_IOBase): + """ + Base class for buffered IO objects. + + The main difference with RawIOBase is that the read() method + supports omitting the size argument, and does not have a default + implementation that defers to readinto(). + + In addition, read(), readinto() and write() may raise + BlockingIOError if the underlying raw stream is in non-blocking + mode and not ready; unlike their raw counterparts, they will never + return None. + + A typical implementation should not inherit from a RawIOBase + implementation, but wrap one. + """ + def detach(self, *args, **kwargs): # real signature unknown + """ + Disconnect this buffer from its underlying raw stream and return it. + + After the raw stream has been detached, the buffer is in an unusable + state. + """ + pass + + def read(self, *args, **kwargs): # real signature unknown + """ + Read and return up to n bytes. + + If the argument is omitted, None, or negative, reads and + returns all data until EOF. + + If the argument is positive, and the underlying raw stream is + not 'interactive', multiple raw reads may be issued to satisfy + the byte count (unless EOF is reached first). But for + interactive raw streams (as well as sockets and pipes), at most + one raw read will be issued, and a short result does not imply + that EOF is imminent. + + Returns an empty bytes object on EOF. + + Returns None if the underlying raw stream was open in non-blocking + mode and no data is available at the moment. + """ + pass + + def read1(self, *args, **kwargs): # real signature unknown + """ + Read and return up to n bytes, with at most one read() call + to the underlying raw stream. A short result does not imply + that EOF is imminent. + + Returns an empty bytes object on EOF. + """ + pass + + def readinto(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write the given buffer to the IO stream. + + Returns the number of bytes written, which is never less than + len(b). + + Raises BlockingIOError if the buffer is full and the + underlying raw stream cannot accept more data at the moment. + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from ._BufferedIOBase import _BufferedIOBase + +class BufferedRandom(_BufferedIOBase): + """ + A buffered interface to random access streams. + + The constructor creates a reader and writer for a seekable stream, + raw, given in the first argument. If the buffer_size is omitted it + defaults to DEFAULT_BUFFER_SIZE. + """ + def close(self, *args, **kwargs): # real signature unknown + pass + + def detach(self, *args, **kwargs): # real signature unknown + pass + + def fileno(self, *args, **kwargs): # real signature unknown + pass + + def flush(self, *args, **kwargs): # real signature unknown + pass + + def isatty(self, *args, **kwargs): # real signature unknown + pass + + def peek(self, *args, **kwargs): # real signature unknown + pass + + def read(self, *args, **kwargs): # real signature unknown + pass + + def read1(self, *args, **kwargs): # real signature unknown + pass + + def readable(self, *args, **kwargs): # real signature unknown + pass + + def readinto(self, *args, **kwargs): # real signature unknown + pass + + def readline(self, *args, **kwargs): # real signature unknown + pass + + def seek(self, *args, **kwargs): # real signature unknown + pass + + def seekable(self, *args, **kwargs): # real signature unknown + pass + + def tell(self, *args, **kwargs): # real signature unknown + pass + + def truncate(self, *args, **kwargs): # real signature unknown + pass + + def writable(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + pass + + def _dealloc_warn(self, *args, **kwargs): # real signature unknown + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + name = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + raw = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + _finalizing = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._BufferedIOBase import _BufferedIOBase + +class BufferedReader(_BufferedIOBase): + """ Create a new buffered reader using the given readable raw IO object. """ + def close(self, *args, **kwargs): # real signature unknown + pass + + def detach(self, *args, **kwargs): # real signature unknown + pass + + def fileno(self, *args, **kwargs): # real signature unknown + pass + + def flush(self, *args, **kwargs): # real signature unknown + pass + + def isatty(self, *args, **kwargs): # real signature unknown + pass + + def peek(self, *args, **kwargs): # real signature unknown + pass + + def read(self, *args, **kwargs): # real signature unknown + pass + + def read1(self, *args, **kwargs): # real signature unknown + pass + + def readable(self, *args, **kwargs): # real signature unknown + pass + + def readinto(self, *args, **kwargs): # real signature unknown + pass + + def readline(self, *args, **kwargs): # real signature unknown + pass + + def seek(self, *args, **kwargs): # real signature unknown + pass + + def seekable(self, *args, **kwargs): # real signature unknown + pass + + def tell(self, *args, **kwargs): # real signature unknown + pass + + def truncate(self, *args, **kwargs): # real signature unknown + pass + + def writable(self, *args, **kwargs): # real signature unknown + pass + + def _dealloc_warn(self, *args, **kwargs): # real signature unknown + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + name = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + raw = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + _finalizing = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._BufferedIOBase import _BufferedIOBase + +class BufferedRWPair(_BufferedIOBase): + """ + A buffered reader and writer object together. + + A buffered reader object and buffered writer object put together to + form a sequential IO object that can read and write. This is typically + used with a socket or two-way pipe. + + reader and writer are RawIOBase objects that are readable and + writeable respectively. If the buffer_size is omitted it defaults to + DEFAULT_BUFFER_SIZE. + """ + def close(self, *args, **kwargs): # real signature unknown + pass + + def flush(self, *args, **kwargs): # real signature unknown + pass + + def isatty(self, *args, **kwargs): # real signature unknown + pass + + def peek(self, *args, **kwargs): # real signature unknown + pass + + def read(self, *args, **kwargs): # real signature unknown + pass + + def read1(self, *args, **kwargs): # real signature unknown + pass + + def readable(self, *args, **kwargs): # real signature unknown + pass + + def readinto(self, *args, **kwargs): # real signature unknown + pass + + def writable(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._BufferedIOBase import _BufferedIOBase + +class BufferedWriter(_BufferedIOBase): + """ + A buffer for a writeable sequential RawIO object. + + The constructor creates a BufferedWriter for the given writeable raw + stream. If the buffer_size is not given, it defaults to + DEFAULT_BUFFER_SIZE. + """ + def close(self, *args, **kwargs): # real signature unknown + pass + + def detach(self, *args, **kwargs): # real signature unknown + pass + + def fileno(self, *args, **kwargs): # real signature unknown + pass + + def flush(self, *args, **kwargs): # real signature unknown + pass + + def isatty(self, *args, **kwargs): # real signature unknown + pass + + def readable(self, *args, **kwargs): # real signature unknown + pass + + def seek(self, *args, **kwargs): # real signature unknown + pass + + def seekable(self, *args, **kwargs): # real signature unknown + pass + + def tell(self, *args, **kwargs): # real signature unknown + pass + + def truncate(self, *args, **kwargs): # real signature unknown + pass + + def writable(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + pass + + def _dealloc_warn(self, *args, **kwargs): # real signature unknown + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + name = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + raw = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + _finalizing = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._BufferedIOBase import _BufferedIOBase + +class BytesIO(_BufferedIOBase): + """ + BytesIO([buffer]) -> object + + Create a buffered I/O implementation using an in-memory bytes + buffer, ready for reading and writing. + """ + def close(self): # real signature unknown; restored from __doc__ + """ close() -> None. Disable all I/O operations. """ + pass + + def flush(self): # real signature unknown; restored from __doc__ + """ flush() -> None. Does nothing. """ + pass + + def getbuffer(self): # real signature unknown; restored from __doc__ + """ + getbuffer() -> bytes. + + Get a read-write view over the contents of the BytesIO object. + """ + pass + + def getvalue(self): # real signature unknown; restored from __doc__ + """ + getvalue() -> bytes. + + Retrieve the entire contents of the BytesIO object. + """ + pass + + def isatty(self): # real signature unknown; restored from __doc__ + """ + isatty() -> False. + + Always returns False since BytesIO objects are not connected + to a tty-like device. + """ + pass + + def read(self, size=None): # real signature unknown; restored from __doc__ + """ + read([size]) -> read at most size bytes, returned as a string. + + If the size argument is negative, read until EOF is reached. + Return an empty string at EOF. + """ + pass + + def read1(self, size): # real signature unknown; restored from __doc__ + """ + read1(size) -> read at most size bytes, returned as a string. + + If the size argument is negative or omitted, read until EOF is reached. + Return an empty string at EOF. + """ + pass + + def readable(self): # real signature unknown; restored from __doc__ + """ readable() -> bool. Returns True if the IO object can be read. """ + pass + + def readinto(self, bytearray): # real signature unknown; restored from __doc__ + """ + readinto(bytearray) -> int. Read up to len(b) bytes into b. + + Returns number of bytes read (0 for EOF), or None if the object + is set not to block as has no data to read. + """ + pass + + def readline(self, size=None): # real signature unknown; restored from __doc__ + """ + readline([size]) -> next line from the file, as a string. + + Retain newline. A non-negative size argument limits the maximum + number of bytes to return (an incomplete line may be returned then). + Return an empty string at EOF. + """ + pass + + def readlines(self, size=None): # real signature unknown; restored from __doc__ + """ + readlines([size]) -> list of strings, each a line from the file. + + Call readline() repeatedly and return a list of the lines so read. + The optional size argument, if given, is an approximate bound on the + total number of bytes in the lines returned. + """ + return [] + + def seek(self, pos, whence=0): # real signature unknown; restored from __doc__ + """ + seek(pos, whence=0) -> int. Change stream position. + + Seek to byte offset pos relative to position indicated by whence: + 0 Start of stream (the default). pos should be >= 0; + 1 Current position - pos may be negative; + 2 End of stream - pos usually negative. + Returns the new absolute position. + """ + pass + + def seekable(self): # real signature unknown; restored from __doc__ + """ seekable() -> bool. Returns True if the IO object can be seeked. """ + pass + + def tell(self): # real signature unknown; restored from __doc__ + """ tell() -> current file position, an integer """ + pass + + def truncate(self, size=None): # real signature unknown; restored from __doc__ + """ + truncate([size]) -> int. Truncate the file to at most size bytes. + + Size defaults to the current file position, as returned by tell(). + The current file position is unchanged. Returns the new size. + """ + pass + + def writable(self): # real signature unknown; restored from __doc__ + """ writable() -> bool. Returns True if the IO object can be written. """ + pass + + def write(self, bytes): # real signature unknown; restored from __doc__ + """ + write(bytes) -> int. Write bytes to file. + + Return the number of bytes written. + """ + pass + + def writelines(self, sequence_of_strings): # real signature unknown; restored from __doc__ + """ + writelines(sequence_of_strings) -> None. Write strings to the file. + + Note that newlines are not added. The sequence can be any iterable + object producing strings. This is equivalent to calling write() for + each string. + """ + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, buffer=None): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __setstate__(self, *args, **kwargs): # real signature unknown + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """True if the file is closed.""" + + + +from ._IOBase import _IOBase + +class _RawIOBase(_IOBase): + """ Base class for raw binary I/O. """ + def read(self, *args, **kwargs): # real signature unknown + pass + + def readall(self, *args, **kwargs): # real signature unknown + """ Read until EOF, using multiple read() call. """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from ._RawIOBase import _RawIOBase + +class FileIO(_RawIOBase): + """ + file(name: str[, mode: str][, opener: None]) -> file IO object + + Open a file. The mode can be 'r', 'w', 'x' or 'a' for reading (default), + writing, exclusive creation or appending. The file will be created if it + doesn't exist when opened for writing or appending; it will be truncated + when opened for writing. A `FileExistsError` will be raised if it already + exists when opened for creating. Opening a file for creating implies + writing so this mode behaves in a similar way to 'w'.Add a '+' to the mode + to allow simultaneous reading and writing. A custom opener can be used by + passing a callable as *opener*. The underlying file descriptor for the file + object is then obtained by calling opener with (*name*, *flags*). + *opener* must return an open file descriptor (passing os.open as *opener* + results in functionality similar to passing None). + """ + def close(self): # real signature unknown; restored from __doc__ + """ + close() -> None. Close the file. + + A closed file cannot be used for further I/O operations. close() may be + called more than once without error. Changes the fileno to -1. + """ + pass + + def fileno(self): # real signature unknown; restored from __doc__ + """ + fileno() -> int. "file descriptor". + + This is needed for lower-level file interfaces, such the fcntl module. + """ + pass + + def isatty(self): # real signature unknown; restored from __doc__ + """ isatty() -> bool. True if the file is connected to a tty device. """ + pass + + def read(self, size=-1): # known case of _io.FileIO.read + """ + read(size: int) -> bytes. read at most size bytes, returned as bytes. + + Only makes one system call, so less data may be returned than requested + In non-blocking mode, returns None if no data is available. + On end-of-file, returns ''. + """ + return "" + + def readable(self): # real signature unknown; restored from __doc__ + """ readable() -> bool. True if file was opened in a read mode. """ + pass + + def readall(self): # real signature unknown; restored from __doc__ + """ + readall() -> bytes. read all data from the file, returned as bytes. + + In non-blocking mode, returns as much as is immediately available, + or None if no data is available. On end-of-file, returns ''. + """ + pass + + def readinto(self): # real signature unknown; restored from __doc__ + """ readinto() -> Same as RawIOBase.readinto(). """ + pass + + def seek(self, offset, whence=None): # real signature unknown; restored from __doc__ + """ + seek(offset: int[, whence: int]) -> None. Move to new file position. + + Argument offset is a byte count. Optional argument whence defaults to + 0 (offset from start of file, offset should be >= 0); other values are 1 + (move relative to current position, positive or negative), and 2 (move + relative to end of file, usually negative, although many platforms allow + seeking beyond the end of a file). + Note that not all file objects are seekable. + """ + pass + + def seekable(self): # real signature unknown; restored from __doc__ + """ seekable() -> bool. True if file supports random-access. """ + pass + + def tell(self): # real signature unknown; restored from __doc__ + """ tell() -> int. Current file position """ + pass + + def truncate(self, size=None): # real signature unknown; restored from __doc__ + """ + truncate([size: int]) -> None. Truncate the file to at most size bytes. + + Size defaults to the current file position, as returned by tell().The current file position is changed to the value of size. + """ + pass + + def writable(self): # real signature unknown; restored from __doc__ + """ writable() -> bool. True if file was opened in a write mode. """ + pass + + def write(self, b): # real signature unknown; restored from __doc__ + """ + write(b: bytes) -> int. Write bytes b to file, return number written. + + Only makes one system call, so not all of the data may be written. + The number of bytes actually written is returned. + """ + pass + + def _dealloc_warn(self, *args, **kwargs): # real signature unknown + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """True if the file is closed""" + + closefd = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """True if the file descriptor will be closed""" + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """String giving the file mode""" + + _finalizing = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from .object import object + +class IncrementalNewlineDecoder(object): + """ + Codec used when reading a file in universal newlines mode. It wraps + another incremental decoder, translating \r\n and \r into \n. It also + records the types of newlines encountered. When used with + translate=False, it ensures that the newline sequence is returned in + one piece. When used with decoder=None, it expects unicode strings as + decode input and translates newlines without first invoking an external + decoder. + """ + def decode(self, *args, **kwargs): # real signature unknown + pass + + def getstate(self, *args, **kwargs): # real signature unknown + pass + + def reset(self, *args, **kwargs): # real signature unknown + pass + + def setstate(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + newlines = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._IOBase import _IOBase + +class _TextIOBase(_IOBase): + """ + Base class for text I/O. + + This class provides a character and line based interface to stream + I/O. There is no readinto method because Python's character strings + are immutable. There is no public constructor. + """ + def detach(self, *args, **kwargs): # real signature unknown + """ + Separate the underlying buffer from the TextIOBase and return it. + + After the underlying buffer has been detached, the TextIO is in an + unusable state. + """ + pass + + def read(self, *args, **kwargs): # real signature unknown + """ + Read at most n characters from stream. + + Read from underlying buffer until we have n characters or we hit EOF. + If n is negative or omitted, read until EOF. + """ + pass + + def readline(self, *args, **kwargs): # real signature unknown + """ + Read until newline or EOF. + + Returns an empty string if EOF is hit immediately. + """ + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write string to stream. + Returns the number of characters written (which is always equal to + the length of the string). + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """Encoding of the text stream. + +Subclasses should override. +""" + + errors = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """The error setting of the decoder or encoder. + +Subclasses should override. +""" + + newlines = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """Line endings translated so far. + +Only line endings translated during reading are considered. + +Subclasses should override. +""" + + + +from ._TextIOBase import _TextIOBase + +class StringIO(_TextIOBase): + """ + Text I/O implementation using an in-memory buffer. + + The initial_value argument sets the value of object. The newline + argument is like the one of TextIOWrapper's constructor. + """ + def close(self, *args, **kwargs): # real signature unknown + """ + Close the IO object. Attempting any further operation after the + object is closed will raise a ValueError. + + This method has no effect if the file is already closed. + """ + pass + + def getvalue(self, *args, **kwargs): # real signature unknown + """ Retrieve the entire contents of the object. """ + pass + + def read(self, *args, **kwargs): # real signature unknown + """ + Read at most n characters, returned as a string. + + If the argument is negative or omitted, read until EOF + is reached. Return an empty string at EOF. + """ + pass + + def readable(self): # real signature unknown; restored from __doc__ + """ readable() -> bool. Returns True if the IO object can be read. """ + pass + + def readline(self, *args, **kwargs): # real signature unknown + """ + Read until newline or EOF. + + Returns an empty string if EOF is hit immediately. + """ + pass + + def seek(self, *args, **kwargs): # real signature unknown + """ + Change stream position. + + Seek to character offset pos relative to position indicated by whence: + 0 Start of stream (the default). pos should be >= 0; + 1 Current position - pos must be 0; + 2 End of stream - pos must be 0. + Returns the new absolute position. + """ + pass + + def seekable(self): # real signature unknown; restored from __doc__ + """ seekable() -> bool. Returns True if the IO object can be seeked. """ + pass + + def tell(self, *args, **kwargs): # real signature unknown + """ Tell the current file position. """ + pass + + def truncate(self, *args, **kwargs): # real signature unknown + """ + Truncate size to pos. + + The pos argument defaults to the current file position, as + returned by tell(). The current file position is unchanged. + Returns the new absolute position. + """ + pass + + def writable(self): # real signature unknown; restored from __doc__ + """ writable() -> bool. Returns True if the IO object can be written. """ + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write string to file. + + Returns the number of characters written, which is always equal to + the length of the string. + """ + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __setstate__(self, *args, **kwargs): # real signature unknown + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + line_buffering = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + newlines = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from ._TextIOBase import _TextIOBase + +class TextIOWrapper(_TextIOBase): + """ + Character and line based layer over a BufferedIOBase object, buffer. + + encoding gives the name of the encoding that the stream will be + decoded or encoded with. It defaults to locale.getpreferredencoding(False). + + errors determines the strictness of encoding and decoding (see + help(codecs.Codec) or the documentation for codecs.register) and + defaults to "strict". + + newline controls how line endings are handled. It can be None, '', + '\n', '\r', and '\r\n'. It works as follows: + + * On input, if newline is None, universal newlines mode is + enabled. Lines in the input can end in '\n', '\r', or '\r\n', and + these are translated into '\n' before being returned to the + caller. If it is '', universal newline mode is enabled, but line + endings are returned to the caller untranslated. If it has any of + the other legal values, input lines are only terminated by the given + string, and the line ending is returned to the caller untranslated. + + * On output, if newline is None, any '\n' characters written are + translated to the system default line separator, os.linesep. If + newline is '' or '\n', no translation takes place. If newline is any + of the other legal values, any '\n' characters written are translated + to the given string. + + If line_buffering is True, a call to flush is implied when a call to + write contains a newline character. + """ + def close(self, *args, **kwargs): # real signature unknown + pass + + def detach(self, *args, **kwargs): # real signature unknown + pass + + def fileno(self, *args, **kwargs): # real signature unknown + pass + + def flush(self, *args, **kwargs): # real signature unknown + pass + + def isatty(self, *args, **kwargs): # real signature unknown + pass + + def read(self, *args, **kwargs): # real signature unknown + pass + + def readable(self, *args, **kwargs): # real signature unknown + pass + + def readline(self, *args, **kwargs): # real signature unknown + pass + + def seek(self, *args, **kwargs): # real signature unknown + pass + + def seekable(self, *args, **kwargs): # real signature unknown + pass + + def tell(self, *args, **kwargs): # real signature unknown + pass + + def truncate(self, *args, **kwargs): # real signature unknown + pass + + def writable(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + pass + + def __getstate__(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + buffer = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + errors = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + line_buffering = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + name = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + newlines = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + _CHUNK_SIZE = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + _finalizing = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from .ValueError import ValueError + +from .OSError import OSError + +class UnsupportedOperation(ValueError, OSError): + # no doc + def __init__(self, *args, **kwargs): # real signature unknown + pass + + __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """list of weak references to the object (if defined)""" + + + +from .object import object + +class __loader__(object): + """ + Meta path import for built-in modules. + + All methods are either class or static methods to avoid the need to + instantiate the class. + """ + @classmethod + def find_module(cls, *args, **kwargs): # real signature unknown + """ + Find the built-in module. + + If 'path' is ever specified then the search is considered a failure. + + This method is deprecated. Use find_spec() instead. + """ + pass + + @classmethod + def find_spec(cls, *args, **kwargs): # real signature unknown + pass + + @classmethod + def get_code(cls, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have code objects. """ + pass + + @classmethod + def get_source(cls, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have source code. """ + pass + + @classmethod + def is_package(cls, *args, **kwargs): # real signature unknown + """ Return False as built-in modules are never packages. """ + pass + + @classmethod + def load_module(cls, *args, **kwargs): # real signature unknown + """ Load a built-in module. """ + pass + + def module_repr(module): # reliably restored by inspect + """ + Return repr for the module. + + The method is deprecated. The import machinery does the job itself. + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """list of weak references to the object (if defined)""" + + + __dict__ = None # (!) real value is '' + + +# variables with complex values + +__spec__ = None # (!) real value is '' + diff --git a/python/testData/MockSdk3.4/python_stubs/builtins.py b/python/testData/MockSdk3.4/python_stubs/builtins.py new file mode 100644 index 000000000000..bc425c814cd8 --- /dev/null +++ b/python/testData/MockSdk3.4/python_stubs/builtins.py @@ -0,0 +1,5864 @@ +# encoding: utf-8 +# module builtins +# from (built-in) +# by generator 1.135 +""" +Built-in functions, exceptions, and other objects. + +Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices. +""" +# no imports + +# Variables with simple values +# definition of False omitted +# definition of None omitted +# definition of True omitted +# definition of __debug__ omitted + +# functions +from object import object + +def abs(number): # real signature unknown; restored from __doc__ + """ + abs(number) -> number + + Return the absolute value of the argument. + """ + return 0 + +def all(iterable): # real signature unknown; restored from __doc__ + """ + all(iterable) -> bool + + Return True if bool(x) is True for all values x in the iterable. + If the iterable is empty, return True. + """ + return False + +def any(iterable): # real signature unknown; restored from __doc__ + """ + any(iterable) -> bool + + Return True if bool(x) is True for any x in the iterable. + If the iterable is empty, return False. + """ + return False + +def ascii(p_object): # real signature unknown; restored from __doc__ + """ + ascii(object) -> string + + As repr(), return a string containing a printable representation of an + object, but escape the non-ASCII characters in the string returned by + repr() using \x, \u or \U escapes. This generates a string similar + to that returned by repr() in Python 2. + """ + return "" + +def bin(number): # real signature unknown; restored from __doc__ + """ + bin(number) -> string + + Return the binary representation of an integer. + + >>> bin(2796202) + '0b1010101010101010101010' + """ + return "" + +def callable(p_object): # real signature unknown; restored from __doc__ + """ + callable(object) -> bool + + Return whether the object is callable (i.e., some kind of function). + Note that classes are callable, as are instances of classes with a + __call__() method. + """ + return False + +def chr(i): # real signature unknown; restored from __doc__ + """ + chr(i) -> Unicode character + + Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. + """ + return "" + +def compile(source, filename, mode, flags=None, dont_inherit=None): # real signature unknown; restored from __doc__ + """ + compile(source, filename, mode[, flags[, dont_inherit]]) -> code object + + Compile the source (a Python module, statement or expression) + into a code object that can be executed by exec() or eval(). + The filename will be used for run-time error messages. + The mode must be 'exec' to compile a module, 'single' to compile a + single (interactive) statement, or 'eval' to compile an expression. + The flags argument, if present, controls which future statements influence + the compilation of the code. + The dont_inherit argument, if non-zero, stops the compilation inheriting + the effects of any future statements in effect in the code calling + compile; if absent or zero these statements do influence the compilation, + in addition to any features explicitly specified. + """ + pass + +def copyright(*args, **kwargs): # real signature unknown + """ + interactive prompt objects for printing the license text, a list of + contributors and the copyright notice. + """ + pass + +def credits(*args, **kwargs): # real signature unknown + """ + interactive prompt objects for printing the license text, a list of + contributors and the copyright notice. + """ + pass + +def delattr(p_object, name): # real signature unknown; restored from __doc__ + """ + delattr(object, name) + + Delete a named attribute on an object; delattr(x, 'y') is equivalent to + ``del x.y''. + """ + pass + +def dir(p_object=None): # real signature unknown; restored from __doc__ + """ + dir([object]) -> list of strings + + If called without an argument, return the names in the current scope. + Else, return an alphabetized list of names comprising (some of) the attributes + of the given object, and of attributes reachable from it. + If the object supplies a method named __dir__, it will be used; otherwise + the default dir() logic is used and returns: + for a module object: the module's attributes. + for a class object: its attributes, and recursively the attributes + of its bases. + for any other object: its attributes, its class's attributes, and + recursively the attributes of its class's base classes. + """ + return [] + +def divmod(x, y): # known case of builtins.divmod + """ + divmod(x, y) -> (div, mod) + + Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x. + """ + return (0, 0) + +def eval(source, globals=None, locals=None): # real signature unknown; restored from __doc__ + """ + eval(source[, globals[, locals]]) -> value + + Evaluate the source in the context of globals and locals. + The source may be a string representing a Python expression + or a code object as returned by compile(). + The globals must be a dictionary and locals can be any mapping, + defaulting to the current globals and locals. + If only globals is given, locals defaults to it. + """ + pass + +def exec(p_object, globals=None, locals=None): # real signature unknown; restored from __doc__ + """ + exec(object[, globals[, locals]]) + + Read and execute code from an object, which can be a string or a code + object. + The globals and locals are dictionaries, defaulting to the current + globals and locals. If only globals is given, locals defaults to it. + """ + pass + +def exit(*args, **kwargs): # real signature unknown + pass + +def format(value, format_spec=None): # real signature unknown; restored from __doc__ + """ + format(value[, format_spec]) -> string + + Returns value.__format__(format_spec) + format_spec defaults to "" + """ + return "" + +def getattr(object, name, default=None): # known special case of getattr + """ + getattr(object, name[, default]) -> value + + Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y. + When a default argument is given, it is returned when the attribute doesn't + exist; without it, an exception is raised in that case. + """ + pass + +def globals(): # real signature unknown; restored from __doc__ + """ + globals() -> dictionary + + Return the dictionary containing the current scope's global variables. + """ + return {} + +def hasattr(p_object, name): # real signature unknown; restored from __doc__ + """ + hasattr(object, name) -> bool + + Return whether the object has an attribute with the given name. + (This is done by calling getattr(object, name) and catching AttributeError.) + """ + return False + +def hash(p_object): # real signature unknown; restored from __doc__ + """ + hash(object) -> integer + + Return a hash value for the object. Two objects with the same value have + the same hash value. The reverse is not necessarily true, but likely. + """ + return 0 + +def help(): # real signature unknown; restored from __doc__ + """ + Define the builtin 'help'. + + This is a wrapper around pydoc.help that provides a helpful message + when 'help' is typed at the Python interactive prompt. + + Calling help() at the Python prompt starts an interactive help session. + Calling help(thing) prints help for the python object 'thing'. + """ + pass + +def hex(number): # real signature unknown; restored from __doc__ + """ + hex(number) -> string + + Return the hexadecimal representation of an integer. + + >>> hex(3735928559) + '0xdeadbeef' + """ + return "" + +def id(p_object): # real signature unknown; restored from __doc__ + """ + id(object) -> integer + + Return the identity of an object. This is guaranteed to be unique among + simultaneously existing objects. (Hint: it's the object's memory address.) + """ + return 0 + +def input(prompt=None): # real signature unknown; restored from __doc__ + """ + input([prompt]) -> string + + Read a string from standard input. The trailing newline is stripped. + If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. + On Unix, GNU readline is used if enabled. The prompt string, if given, + is printed without a trailing newline before reading. + """ + return "" + +def isinstance(p_object, class_or_type_or_tuple): # real signature unknown; restored from __doc__ + """ + isinstance(object, class-or-type-or-tuple) -> bool + + Return whether an object is an instance of a class or of a subclass thereof. + With a type as second argument, return whether that is the object's type. + The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for + isinstance(x, A) or isinstance(x, B) or ... (etc.). + """ + return False + +def issubclass(C, B): # real signature unknown; restored from __doc__ + """ + issubclass(C, B) -> bool + + Return whether class C is a subclass (i.e., a derived class) of class B. + When using a tuple as the second argument issubclass(X, (A, B, ...)), + is a shortcut for issubclass(X, A) or issubclass(X, B) or ... (etc.). + """ + return False + +def iter(source, sentinel=None): # known special case of iter + """ + iter(iterable) -> iterator + iter(callable, sentinel) -> iterator + + Get an iterator from an object. In the first form, the argument must + supply its own iterator, or be a sequence. + In the second form, the callable is called until it returns the sentinel. + """ + pass + +def len(p_object): # real signature unknown; restored from __doc__ + """ + len(object) + + Return the number of items of a sequence or mapping. + """ + pass + +def license(*args, **kwargs): # real signature unknown + """ + interactive prompt objects for printing the license text, a list of + contributors and the copyright notice. + """ + pass + +def locals(): # real signature unknown; restored from __doc__ + """ + locals() -> dictionary + + Update and return a dictionary containing the current scope's local variables. + """ + return {} + +def max(*args, key=None): # known special case of max + """ + max(iterable[, key=func]) -> value + max(a, b, c, ...[, key=func]) -> value + + With a single iterable argument, return its largest item. + With two or more arguments, return the largest argument. + """ + pass + +def min(*args, key=None): # known special case of min + """ + min(iterable[, key=func]) -> value + min(a, b, c, ...[, key=func]) -> value + + With a single iterable argument, return its smallest item. + With two or more arguments, return the smallest argument. + """ + pass + +def next(iterator, default=None): # real signature unknown; restored from __doc__ + """ + next(iterator[, default]) + + Return the next item from the iterator. If default is given and the iterator + is exhausted, it is returned instead of raising StopIteration. + """ + pass + +def oct(number): # real signature unknown; restored from __doc__ + """ + oct(number) -> string + + Return the octal representation of an integer. + + >>> oct(342391) + '0o1234567' + """ + return "" + +def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True): # known special case of open + """ + open(file, mode='r', buffering=-1, encoding=None, + errors=None, newline=None, closefd=True, opener=None) -> file object + + Open file and return a stream. Raise IOError upon failure. + + file is either a text or byte string giving the name (and the path + if the file isn't in the current working directory) of the file to + be opened or an integer file descriptor of the file to be + wrapped. (If a file descriptor is given, it is closed when the + returned I/O object is closed, unless closefd is set to False.) + + mode is an optional string that specifies the mode in which the file + is opened. It defaults to 'r' which means open for reading in text + mode. Other common values are 'w' for writing (truncating the file if + it already exists), 'x' for creating and writing to a new file, and + 'a' for appending (which on some Unix systems, means that all writes + append to the end of the file regardless of the current seek position). + In text mode, if encoding is not specified the encoding used is platform + dependent: locale.getpreferredencoding(False) is called to get the + current locale encoding. (For reading and writing raw bytes use binary + mode and leave encoding unspecified.) The available modes are: + + ========= =============================================================== + Character Meaning + --------- --------------------------------------------------------------- + 'r' open for reading (default) + 'w' open for writing, truncating the file first + 'x' create a new file and open it for writing + 'a' open for writing, appending to the end of the file if it exists + 'b' binary mode + 't' text mode (default) + '+' open a disk file for updating (reading and writing) + 'U' universal newline mode (deprecated) + ========= =============================================================== + + The default mode is 'rt' (open for reading text). For binary random + access, the mode 'w+b' opens and truncates the file to 0 bytes, while + 'r+b' opens the file without truncation. The 'x' mode implies 'w' and + raises an `FileExistsError` if the file already exists. + + Python distinguishes between files opened in binary and text modes, + even when the underlying operating system doesn't. Files opened in + binary mode (appending 'b' to the mode argument) return contents as + bytes objects without any decoding. In text mode (the default, or when + 't' is appended to the mode argument), the contents of the file are + returned as strings, the bytes having been first decoded using a + platform-dependent encoding or using the specified encoding if given. + + 'U' mode is deprecated and will raise an exception in future versions + of Python. It has no effect in Python 3. Use newline to control + universal newlines mode. + + buffering is an optional integer used to set the buffering policy. + Pass 0 to switch buffering off (only allowed in binary mode), 1 to select + line buffering (only usable in text mode), and an integer > 1 to indicate + the size of a fixed-size chunk buffer. When no buffering argument is + given, the default buffering policy works as follows: + + * Binary files are buffered in fixed-size chunks; the size of the buffer + is chosen using a heuristic trying to determine the underlying device's + "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`. + On many systems, the buffer will typically be 4096 or 8192 bytes long. + + * "Interactive" text files (files for which isatty() returns True) + use line buffering. Other text files use the policy described above + for binary files. + + encoding is the name of the encoding used to decode or encode the + file. This should only be used in text mode. The default encoding is + platform dependent, but any encoding supported by Python can be + passed. See the codecs module for the list of supported encodings. + + errors is an optional string that specifies how encoding errors are to + be handled---this argument should not be used in binary mode. Pass + 'strict' to raise a ValueError exception if there is an encoding error + (the default of None has the same effect), or pass 'ignore' to ignore + errors. (Note that ignoring encoding errors can lead to data loss.) + See the documentation for codecs.register or run 'help(codecs.Codec)' + for a list of the permitted encoding error strings. + + newline controls how universal newlines works (it only applies to text + mode). It can be None, '', '\n', '\r', and '\r\n'. It works as + follows: + + * On input, if newline is None, universal newlines mode is + enabled. Lines in the input can end in '\n', '\r', or '\r\n', and + these are translated into '\n' before being returned to the + caller. If it is '', universal newline mode is enabled, but line + endings are returned to the caller untranslated. If it has any of + the other legal values, input lines are only terminated by the given + string, and the line ending is returned to the caller untranslated. + + * On output, if newline is None, any '\n' characters written are + translated to the system default line separator, os.linesep. If + newline is '' or '\n', no translation takes place. If newline is any + of the other legal values, any '\n' characters written are translated + to the given string. + + If closefd is False, the underlying file descriptor will be kept open + when the file is closed. This does not work when a file name is given + and must be True in that case. + + A custom opener can be used by passing a callable as *opener*. The + underlying file descriptor for the file object is then obtained by + calling *opener* with (*file*, *flags*). *opener* must return an open + file descriptor (passing os.open as *opener* results in functionality + similar to passing None). + + open() returns a file object whose type depends on the mode, and + through which the standard file operations such as reading and writing + are performed. When open() is used to open a file in a text mode ('w', + 'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open + a file in a binary mode, the returned class varies: in read binary + mode, it returns a BufferedReader; in write binary and append binary + modes, it returns a BufferedWriter, and in read/write mode, it returns + a BufferedRandom. + + It is also possible to use a string or bytearray as a file for both + reading and writing. For strings StringIO can be used like a file + opened in a text mode, and for bytes a BytesIO can be used like a file + opened in a binary mode. + """ + pass + +def ord(c): # real signature unknown; restored from __doc__ + """ + ord(c) -> integer + + Return the integer ordinal of a one-character string. + """ + return 0 + +def pow(x, y, z=None): # real signature unknown; restored from __doc__ + """ + pow(x, y[, z]) -> number + + With two arguments, equivalent to x**y. With three arguments, + equivalent to (x**y) % z, but may be more efficient (e.g. for ints). + """ + return 0 + +def print(*args, sep=' ', end='\n', file=None): # known special case of print + """ + print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) + + Prints the values to a stream, or to sys.stdout by default. + Optional keyword arguments: + file: a file-like object (stream); defaults to the current sys.stdout. + sep: string inserted between values, default a space. + end: string appended after the last value, default a newline. + flush: whether to forcibly flush the stream. + """ + pass + +def quit(*args, **kwargs): # real signature unknown + pass + +def repr(p_object): # real signature unknown; restored from __doc__ + """ + repr(object) -> string + + Return the canonical string representation of the object. + For most object types, eval(repr(object)) == object. + """ + return "" + +def round(number, ndigits=None): # real signature unknown; restored from __doc__ + """ + round(number[, ndigits]) -> number + + Round a number to a given precision in decimal digits (default 0 digits). + This returns an int when called with one argument, otherwise the + same type as the number. ndigits may be negative. + """ + return 0 + +def setattr(p_object, name, value): # real signature unknown; restored from __doc__ + """ + setattr(object, name, value) + + Set a named attribute on an object; setattr(x, 'y', v) is equivalent to + ``x.y = v''. + """ + pass + +def sorted(iterable, key=None, reverse=False): # real signature unknown; restored from __doc__ + """ sorted(iterable, key=None, reverse=False) --> new sorted list """ + pass + +def sum(iterable, start=None): # real signature unknown; restored from __doc__ + """ + sum(iterable[, start]) -> value + + Return the sum of an iterable of numbers (NOT strings) plus the value + of parameter 'start' (which defaults to 0). When the iterable is + empty, return start. + """ + pass + +def vars(p_object=None): # real signature unknown; restored from __doc__ + """ + vars([object]) -> dictionary + + Without arguments, equivalent to locals(). + With an argument, equivalent to object.__dict__. + """ + return {} + +def __build_class__(func, name, *bases, metaclass=None, **kwds): # real signature unknown; restored from __doc__ + """ + __build_class__(func, name, *bases, metaclass=None, **kwds) -> class + + Internal helper function used by the class statement. + """ + pass + +def __import__(name, globals=None, locals=None, fromlist=(), level=0): # real signature unknown; restored from __doc__ + """ + __import__(name, globals=None, locals=None, fromlist=(), level=0) -> module + + Import a module. Because this function is meant for use by the Python + interpreter and not for general use it is better to use + importlib.import_module() to programmatically import a module. + + The globals argument is only used to determine the context; + they are not modified. The locals argument is unused. The fromlist + should be a list of names to emulate ``from name import ...'', or an + empty list to emulate ``import name''. + When importing a module from a package, note that __import__('A.B', ...) + returns package A when fromlist is empty, but its submodule B when + fromlist is not empty. Level is used to determine whether to perform + absolute or relative imports. 0 is absolute while a positive number + is the number of parent directories to search relative to the current module. + """ + pass + +# classes + + +class __generator(object): + '''A mock class representing the generator function type.''' + def __init__(self): + self.gi_code = None + self.gi_frame = None + self.gi_running = 0 + + def __iter__(self): + '''Defined to support iteration over container.''' + pass + + def __next__(self): + '''Return the next item from the container.''' + pass + + def close(self): + '''Raises new GeneratorExit exception inside the generator to terminate the iteration.''' + pass + + def send(self, value): + '''Resumes the generator and "sends" a value that becomes the result of the current yield-expression.''' + pass + + def throw(self, type, value=None, traceback=None): + '''Used to raise an exception inside the generator.''' + pass + + +class __function(object): + '''A mock class representing function type.''' + + def __init__(self): + self.__name__ = '' + self.__doc__ = '' + self.__dict__ = '' + self.__module__ = '' + + self.__defaults__ = {} + self.__globals__ = {} + self.__closure__ = None + self.__code__ = None + self.__name__ = '' + + self.__annotations__ = {} + self.__kwdefaults__ = {} + + self.__qualname__ = '' + + +class __method(object): + '''A mock class representing method type.''' + + def __init__(self): + + self.__func__ = None + self.__self__ = None + + +class __namedtuple(tuple): + '''A mock base class for named tuples.''' + + __slots__ = () + _fields = () + + def __new__(cls, *args, **kwargs): + 'Create a new instance of the named tuple.' + return tuple.__new__(cls, *args) + + @classmethod + def _make(cls, iterable, new=tuple.__new__, len=len): + 'Make a new named tuple object from a sequence or iterable.' + return new(cls, iterable) + + def __repr__(self): + return '' + + def _asdict(self): + 'Return a new dict which maps field types to their values.' + return {} + + def _replace(self, **kwargs): + 'Return a new named tuple object replacing specified fields with new values.' + return self + + def __getnewargs__(self): + return tuple(self) + +class object: + """ The most base type """ + def __delattr__(self, *args, **kwargs): # real signature unknown + """ Implement delattr(self, name). """ + pass + + def __dir__(self): # real signature unknown; restored from __doc__ + """ + __dir__() -> list + default dir() implementation + """ + return [] + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + """ default object formatter """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self): # known special case of object.__init__ + """ Initialize self. See help(type(self)) for accurate signature. """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self int + size of object in memory, in bytes + """ + return 0 + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + @classmethod # known case + def __subclasshook__(cls, subclass): # known special case of object.__subclasshook__ + """ + Abstract classes can override this to customize issubclass(). + + This is invoked early on by abc.ABCMeta.__subclasscheck__(). + It should return True, False or NotImplemented. If it returns + NotImplemented, the normal algorithm is used. Otherwise, it + overrides the normal algorithm (and the outcome is cached). + """ + pass + + __class__ = None # (!) forward: type, real value is '' + __dict__ = {} + __doc__ = '' + __module__ = '' + + +from .object import object + +class BaseException(object): + """ Common base class for all exceptions """ + def with_traceback(self, tb): # real signature unknown; restored from __doc__ + """ + Exception.with_traceback(tb) -- + set self.__traceback__ to tb and return self. + """ + pass + + def __delattr__(self, *args, **kwargs): # real signature unknown + """ Implement delattr(self, name). """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __setattr__(self, *args, **kwargs): # real signature unknown + """ Implement setattr(self, name, value). """ + pass + + def __setstate__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + args = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + __cause__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception cause""" + + __context__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception context""" + + __suppress_context__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + __traceback__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __dict__ = None # (!) real value is '' + + +from .BaseException import BaseException + +class Exception(BaseException): + """ Common base class for all non-exit exceptions. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class ArithmeticError(Exception): + """ Base class for arithmetic errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class AssertionError(Exception): + """ Assertion failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class AttributeError(Exception): + """ Attribute not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class WindowsError(Exception): + """ Base class for I/O related errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + characters_written = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + errno = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """POSIX exception code""" + + filename = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception filename""" + + filename2 = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """second exception filename""" + + strerror = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception strerror""" + + winerror = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """Win32 exception code""" + + + +OSError = WindowsError + + +IOError = WindowsError + + +EnvironmentError = WindowsError + + +from .OSError import OSError + +class BlockingIOError(OSError): + """ I/O operation would block. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .object import object + +class int(object): + """ + int(x=0) -> integer + int(x, base=10) -> integer + + Convert a number or string to an integer, or return 0 if no arguments + are given. If x is a number, return x.__int__(). For floating point + numbers, this truncates towards zero. + + If x is not a number or if base is given, then x must be a string, + bytes, or bytearray instance representing an integer literal in the + given base. The literal can be preceded by '+' or '-' and be surrounded + by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. + Base 0 means to interpret the base from the string as an integer literal. + >>> int('0b100', base=0) + 4 + """ + def bit_length(self): # real signature unknown; restored from __doc__ + """ + int.bit_length() -> int + + Number of bits necessary to represent self in binary. + >>> bin(37) + '0b100101' + >>> (37).bit_length() + 6 + """ + return 0 + + def conjugate(self, *args, **kwargs): # real signature unknown + """ Returns self, the complex conjugate of any int. """ + pass + + @classmethod # known case + def from_bytes(cls, bytes, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + int.from_bytes(bytes, byteorder, *, signed=False) -> int + + Return the integer represented by the given array of bytes. + + The bytes argument must either support the buffer protocol or be an + iterable object producing bytes. Bytes and bytearray are examples of + built-in objects that support the buffer protocol. + + The byteorder argument determines the byte order used to represent the + integer. If byteorder is 'big', the most significant byte is at the + beginning of the byte array. If byteorder is 'little', the most + significant byte is at the end of the byte array. To request the native + byte order of the host system, use `sys.byteorder' as the byte order value. + + The signed keyword-only argument indicates whether two's complement is + used to represent the integer. + """ + pass + + def to_bytes(self, length, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + int.to_bytes(length, byteorder, *, signed=False) -> bytes + + Return an array of bytes representing an integer. + + The integer is represented using length bytes. An OverflowError is + raised if the integer is not representable with the given number of + bytes. + + The byteorder argument determines the byte order used to represent the + integer. If byteorder is 'big', the most significant byte is at the + beginning of the byte array. If byteorder is 'little', the most + significant byte is at the end of the byte array. To request the native + byte order of the host system, use `sys.byteorder' as the byte order value. + + The signed keyword-only argument determines whether two's complement is + used to represent the integer. If signed is False and a negative integer + is given, an OverflowError is raised. + """ + pass + + def __abs__(self, *args, **kwargs): # real signature unknown + """ abs(self) """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __and__(self, *args, **kwargs): # real signature unknown + """ Return self&value. """ + pass + + def __bool__(self, *args, **kwargs): # real signature unknown + """ self != 0 """ + pass + + def __ceil__(self, *args, **kwargs): # real signature unknown + """ Ceiling of an Integral returns itself. """ + pass + + def __divmod__(self, *args, **kwargs): # real signature unknown + """ Return divmod(self, value). """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __float__(self, *args, **kwargs): # real signature unknown + """ float(self) """ + pass + + def __floordiv__(self, *args, **kwargs): # real signature unknown + """ Return self//value. """ + pass + + def __floor__(self, *args, **kwargs): # real signature unknown + """ Flooring an Integral returns itself. """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __index__(self, *args, **kwargs): # real signature unknown + """ Return self converted to an integer, if self is suitable for use as an index into a list. """ + pass + + def __init__(self, x, base=10): # known special case of int.__init__ + """ + int(x=0) -> integer + int(x, base=10) -> integer + + Convert a number or string to an integer, or return 0 if no arguments + are given. If x is a number, return x.__int__(). For floating point + numbers, this truncates towards zero. + + If x is not a number or if base is given, then x must be a string, + bytes, or bytearray instance representing an integer literal in the + given base. The literal can be preceded by '+' or '-' and be surrounded + by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. + Base 0 means to interpret the base from the string as an integer literal. + >>> int('0b100', base=0) + 4 + # (copied from class doc) + """ + pass + + def __int__(self, *args, **kwargs): # real signature unknown + """ int(self) """ + pass + + def __invert__(self, *args, **kwargs): # real signature unknown + """ ~self """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lshift__(self, *args, **kwargs): # real signature unknown + """ Return self<>self. """ + pass + + def __rshift__(self, *args, **kwargs): # real signature unknown + """ Return self>>value. """ + pass + + def __rsub__(self, *args, **kwargs): # real signature unknown + """ Return value-self. """ + pass + + def __rtruediv__(self, *args, **kwargs): # real signature unknown + """ Return value/self. """ + pass + + def __rxor__(self, *args, **kwargs): # real signature unknown + """ Return value^self. """ + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + """ Returns size in memory, in bytes """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + def __sub__(self, *args, **kwargs): # real signature unknown + """ Return self-value. """ + pass + + def __truediv__(self, *args, **kwargs): # real signature unknown + """ Return self/value. """ + pass + + def __trunc__(self, *args, **kwargs): # real signature unknown + """ Truncating an Integral returns itself. """ + pass + + def __xor__(self, *args, **kwargs): # real signature unknown + """ Return self^value. """ + pass + + denominator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the denominator of a rational number in lowest terms""" + + imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the imaginary part of a complex number""" + + numerator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the numerator of a rational number in lowest terms""" + + real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the real part of a complex number""" + + + +from .int import int + +class bool(int): + """ + bool(x) -> bool + + Returns True when the argument x is true, False otherwise. + The builtins True and False are the only two instances of the class bool. + The class bool is a subclass of the class int, and cannot be subclassed. + """ + def __and__(self, *args, **kwargs): # real signature unknown + """ Return self&value. """ + pass + + def __init__(self, x): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __or__(self, *args, **kwargs): # real signature unknown + """ Return self|value. """ + pass + + def __rand__(self, *args, **kwargs): # real signature unknown + """ Return value&self. """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __ror__(self, *args, **kwargs): # real signature unknown + """ Return value|self. """ + pass + + def __rxor__(self, *args, **kwargs): # real signature unknown + """ Return value^self. """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + def __xor__(self, *args, **kwargs): # real signature unknown + """ Return self^value. """ + pass + + +from .OSError import OSError + +class ConnectionError(OSError): + """ Connection error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .ConnectionError import ConnectionError + +class BrokenPipeError(ConnectionError): + """ Broken pipe. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .Exception import Exception + +class BufferError(Exception): + """ Buffer error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .object import object + +class bytearray(object): + """ + bytearray(iterable_of_ints) -> bytearray + bytearray(string, encoding[, errors]) -> bytearray + bytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer + bytearray(int) -> bytes array of size given by the parameter initialized with null bytes + bytearray() -> empty bytes array + + Construct an mutable bytearray object from: + - an iterable yielding integers in range(256) + - a text string encoded using the specified encoding + - a bytes or a buffer object + - any object implementing the buffer API. + - an integer + """ + def append(self, p_int): # real signature unknown; restored from __doc__ + """ + B.append(int) -> None + + Append a single item to the end of B. + """ + pass + + def capitalize(self): # real signature unknown; restored from __doc__ + """ + B.capitalize() -> copy of B + + Return a copy of B with only its first character capitalized (ASCII) + and the rest lower-cased. + """ + pass + + def center(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.center(width[, fillchar]) -> copy of B + + Return B centered in a string of length width. Padding is + done using the specified fill character (default is a space). + """ + pass + + def clear(self): # real signature unknown; restored from __doc__ + """ + B.clear() -> None + + Remove all items from B. + """ + pass + + def copy(self): # real signature unknown; restored from __doc__ + """ + B.copy() -> bytearray + + Return a copy of B. + """ + return bytearray + + def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.count(sub[, start[, end]]) -> int + + Return the number of non-overlapping occurrences of subsection sub in + bytes B[start:end]. Optional arguments start and end are interpreted + as in slice notation. + """ + return 0 + + def decode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__ + """ + B.decode(encoding='utf-8', errors='strict') -> str + + Decode B using the codec registered for encoding. Default encoding + is 'utf-8'. errors may be given to set a different error + handling scheme. Default is 'strict' meaning that encoding errors raise + a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' + as well as any other name registered with codecs.register_error that is + able to handle UnicodeDecodeErrors. + """ + return "" + + def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.endswith(suffix[, start[, end]]) -> bool + + Return True if B ends with the specified suffix, False otherwise. + With optional start, test B beginning at that position. + With optional end, stop comparing B at that position. + suffix can also be a tuple of bytes to try. + """ + return False + + def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__ + """ + B.expandtabs(tabsize=8) -> copy of B + + Return a copy of B where all tab characters are expanded using spaces. + If tabsize is not given, a tab size of 8 characters is assumed. + """ + pass + + def extend(self, iterable_of_ints): # real signature unknown; restored from __doc__ + """ + B.extend(iterable_of_ints) -> None + + Append all the elements from the iterator or sequence to the + end of B. + """ + pass + + def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.find(sub[, start[, end]]) -> int + + Return the lowest index in B where subsection sub is found, + such that sub is contained within B[start,end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + @classmethod # known case + def fromhex(cls, string): # real signature unknown; restored from __doc__ + """ + bytearray.fromhex(string) -> bytearray (static method) + + Create a bytearray object from a string of hexadecimal numbers. + Spaces between two numbers are accepted. + Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\xb9\x01\xef'). + """ + return bytearray + + def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.index(sub[, start[, end]]) -> int + + Like B.find() but raise ValueError when the subsection is not found. + """ + return 0 + + def insert(self, index, p_int): # real signature unknown; restored from __doc__ + """ + B.insert(index, int) -> None + + Insert a single item into the bytearray before the given index. + """ + pass + + def isalnum(self): # real signature unknown; restored from __doc__ + """ + B.isalnum() -> bool + + Return True if all characters in B are alphanumeric + and there is at least one character in B, False otherwise. + """ + return False + + def isalpha(self): # real signature unknown; restored from __doc__ + """ + B.isalpha() -> bool + + Return True if all characters in B are alphabetic + and there is at least one character in B, False otherwise. + """ + return False + + def isdigit(self): # real signature unknown; restored from __doc__ + """ + B.isdigit() -> bool + + Return True if all characters in B are digits + and there is at least one character in B, False otherwise. + """ + return False + + def islower(self): # real signature unknown; restored from __doc__ + """ + B.islower() -> bool + + Return True if all cased characters in B are lowercase and there is + at least one cased character in B, False otherwise. + """ + return False + + def isspace(self): # real signature unknown; restored from __doc__ + """ + B.isspace() -> bool + + Return True if all characters in B are whitespace + and there is at least one character in B, False otherwise. + """ + return False + + def istitle(self): # real signature unknown; restored from __doc__ + """ + B.istitle() -> bool + + Return True if B is a titlecased string and there is at least one + character in B, i.e. uppercase characters may only follow uncased + characters and lowercase characters only cased ones. Return False + otherwise. + """ + return False + + def isupper(self): # real signature unknown; restored from __doc__ + """ + B.isupper() -> bool + + Return True if all cased characters in B are uppercase and there is + at least one cased character in B, False otherwise. + """ + return False + + def join(self, iterable_of_bytes): # real signature unknown; restored from __doc__ + """ + B.join(iterable_of_bytes) -> bytearray + + Concatenate any number of bytes/bytearray objects, with B + in between each pair, and return the result as a new bytearray. + """ + return bytearray + + def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.ljust(width[, fillchar]) -> copy of B + + Return B left justified in a string of length width. Padding is + done using the specified fill character (default is a space). + """ + pass + + def lower(self): # real signature unknown; restored from __doc__ + """ + B.lower() -> copy of B + + Return a copy of B with all ASCII characters converted to lowercase. + """ + pass + + def lstrip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.lstrip([bytes]) -> bytearray + + Strip leading bytes contained in the argument + and return the result as a new bytearray. + If the argument is omitted, strip leading ASCII whitespace. + """ + return bytearray + + @staticmethod # known case + def maketrans(frm, to): # real signature unknown; restored from __doc__ + """ + B.maketrans(frm, to) -> translation table + + Return a translation table (a bytes object of length 256) suitable + for use in the bytes or bytearray translate method where each byte + in frm is mapped to the byte at the same position in to. + The bytes objects frm and to must be of the same length. + """ + pass + + def partition(self, sep): # real signature unknown; restored from __doc__ + """ + B.partition(sep) -> (head, sep, tail) + + Search for the separator sep in B, and return the part before it, + the separator itself, and the part after it. If the separator is not + found, returns B and two empty bytearray objects. + """ + pass + + def pop(self, index=None): # real signature unknown; restored from __doc__ + """ + B.pop([index]) -> int + + Remove and return a single item from B. If no index + argument is given, will pop the last value. + """ + return 0 + + def remove(self, p_int): # real signature unknown; restored from __doc__ + """ + B.remove(int) -> None + + Remove the first occurrence of a value in B. + """ + pass + + def replace(self, old, new, count=None): # real signature unknown; restored from __doc__ + """ + B.replace(old, new[, count]) -> bytearray + + Return a copy of B with all occurrences of subsection + old replaced by new. If the optional argument count is + given, only the first count occurrences are replaced. + """ + return bytearray + + def reverse(self): # real signature unknown; restored from __doc__ + """ + B.reverse() -> None + + Reverse the order of the values in B in place. + """ + pass + + def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.rfind(sub[, start[, end]]) -> int + + Return the highest index in B where subsection sub is found, + such that sub is contained within B[start,end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.rindex(sub[, start[, end]]) -> int + + Like B.rfind() but raise ValueError when the subsection is not found. + """ + return 0 + + def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.rjust(width[, fillchar]) -> copy of B + + Return B right justified in a string of length width. Padding is + done using the specified fill character (default is a space) + """ + pass + + def rpartition(self, sep): # real signature unknown; restored from __doc__ + """ + B.rpartition(sep) -> (head, sep, tail) + + Search for the separator sep in B, starting at the end of B, + and return the part before it, the separator itself, and the + part after it. If the separator is not found, returns two empty + bytearray objects and B. + """ + pass + + def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + B.rsplit(sep=None, maxsplit=-1) -> list of bytearrays + + Return a list of the sections in B, using sep as the delimiter, + starting at the end of B and working to the front. + If sep is not given, B is split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + If maxsplit is given, at most maxsplit splits are done. + """ + return [] + + def rstrip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.rstrip([bytes]) -> bytearray + + Strip trailing bytes contained in the argument + and return the result as a new bytearray. + If the argument is omitted, strip trailing ASCII whitespace. + """ + return bytearray + + def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + B.split(sep=None, maxsplit=-1) -> list of bytearrays + + Return a list of the sections in B, using sep as the delimiter. + If sep is not given, B is split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + If maxsplit is given, at most maxsplit splits are done. + """ + return [] + + def splitlines(self, keepends=None): # real signature unknown; restored from __doc__ + """ + B.splitlines([keepends]) -> list of lines + + Return a list of the lines in B, breaking at line boundaries. + Line breaks are not included in the resulting list unless keepends + is given and true. + """ + return [] + + def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.startswith(prefix[, start[, end]]) -> bool + + Return True if B starts with the specified prefix, False otherwise. + With optional start, test B beginning at that position. + With optional end, stop comparing B at that position. + prefix can also be a tuple of bytes to try. + """ + return False + + def strip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.strip([bytes]) -> bytearray + + Strip leading and trailing bytes contained in the argument + and return the result as a new bytearray. + If the argument is omitted, strip ASCII whitespace. + """ + return bytearray + + def swapcase(self): # real signature unknown; restored from __doc__ + """ + B.swapcase() -> copy of B + + Return a copy of B with uppercase ASCII characters converted + to lowercase ASCII and vice versa. + """ + pass + + def title(self): # real signature unknown; restored from __doc__ + """ + B.title() -> copy of B + + Return a titlecased version of B, i.e. ASCII words start with uppercase + characters, all remaining cased characters have lowercase. + """ + pass + + def translate(self, table, deletechars=None): # real signature unknown; restored from __doc__ + """ + B.translate(table[, deletechars]) -> bytearray + + Return a copy of B, where all characters occurring in the + optional argument deletechars are removed, and the remaining + characters have been mapped through the given translation + table, which must be a bytes object of length 256. + """ + return bytearray + + def upper(self): # real signature unknown; restored from __doc__ + """ + B.upper() -> copy of B + + Return a copy of B with all ASCII characters converted to uppercase. + """ + pass + + def zfill(self, width): # real signature unknown; restored from __doc__ + """ + B.zfill(width) -> copy of B + + Pad a numeric string B with zeros on the left, to fill a field + of the specified width. B is never truncated. + """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __alloc__(self): # real signature unknown; restored from __doc__ + """ + B.__alloc__() -> int + + Return the number of bytes actually allocated. + """ + return 0 + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __delitem__(self, *args, **kwargs): # real signature unknown + """ Delete self[key]. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __iadd__(self, *args, **kwargs): # real signature unknown + """ Implement self+=value. """ + pass + + def __imul__(self, *args, **kwargs): # real signature unknown + """ Implement self*=value. """ + pass + + def __init__(self, source=None, encoding=None, errors='strict'): # known special case of bytearray.__init__ + """ + bytearray(iterable_of_ints) -> bytearray + bytearray(string, encoding[, errors]) -> bytearray + bytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer + bytearray(int) -> bytes array of size given by the parameter initialized with null bytes + bytearray() -> empty bytes array + + Construct an mutable bytearray object from: + - an iterable yielding integers in range(256) + - a text string encoded using the specified encoding + - a bytes or a buffer object + - any object implementing the buffer API. + - an integer + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self int + + Returns the size of B in memory, in bytes + """ + return 0 + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + __hash__ = None + + +from .object import object + +class bytes(object): + """ + bytes(iterable_of_ints) -> bytes + bytes(string, encoding[, errors]) -> bytes + bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer + bytes(int) -> bytes object of size given by the parameter initialized with null bytes + bytes() -> empty bytes object + + Construct an immutable array of bytes from: + - an iterable yielding integers in range(256) + - a text string encoded using the specified encoding + - any object implementing the buffer API. + - an integer + """ + def capitalize(self): # real signature unknown; restored from __doc__ + """ + B.capitalize() -> copy of B + + Return a copy of B with only its first character capitalized (ASCII) + and the rest lower-cased. + """ + pass + + def center(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.center(width[, fillchar]) -> copy of B + + Return B centered in a string of length width. Padding is + done using the specified fill character (default is a space). + """ + pass + + def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.count(sub[, start[, end]]) -> int + + Return the number of non-overlapping occurrences of substring sub in + string B[start:end]. Optional arguments start and end are interpreted + as in slice notation. + """ + return 0 + + def decode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__ + """ + B.decode(encoding='utf-8', errors='strict') -> str + + Decode B using the codec registered for encoding. Default encoding + is 'utf-8'. errors may be given to set a different error + handling scheme. Default is 'strict' meaning that encoding errors raise + a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' + as well as any other name registerd with codecs.register_error that is + able to handle UnicodeDecodeErrors. + """ + return "" + + def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.endswith(suffix[, start[, end]]) -> bool + + Return True if B ends with the specified suffix, False otherwise. + With optional start, test B beginning at that position. + With optional end, stop comparing B at that position. + suffix can also be a tuple of bytes to try. + """ + return False + + def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__ + """ + B.expandtabs(tabsize=8) -> copy of B + + Return a copy of B where all tab characters are expanded using spaces. + If tabsize is not given, a tab size of 8 characters is assumed. + """ + pass + + def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.find(sub[, start[, end]]) -> int + + Return the lowest index in B where substring sub is found, + such that sub is contained within B[start:end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + @classmethod # known case + def fromhex(cls, string): # real signature unknown; restored from __doc__ + """ + bytes.fromhex(string) -> bytes + + Create a bytes object from a string of hexadecimal numbers. + Spaces between two numbers are accepted. + Example: bytes.fromhex('B9 01EF') -> b'\xb9\x01\xef'. + """ + return b"" + + def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.index(sub[, start[, end]]) -> int + + Like B.find() but raise ValueError when the substring is not found. + """ + return 0 + + def isalnum(self): # real signature unknown; restored from __doc__ + """ + B.isalnum() -> bool + + Return True if all characters in B are alphanumeric + and there is at least one character in B, False otherwise. + """ + return False + + def isalpha(self): # real signature unknown; restored from __doc__ + """ + B.isalpha() -> bool + + Return True if all characters in B are alphabetic + and there is at least one character in B, False otherwise. + """ + return False + + def isdigit(self): # real signature unknown; restored from __doc__ + """ + B.isdigit() -> bool + + Return True if all characters in B are digits + and there is at least one character in B, False otherwise. + """ + return False + + def islower(self): # real signature unknown; restored from __doc__ + """ + B.islower() -> bool + + Return True if all cased characters in B are lowercase and there is + at least one cased character in B, False otherwise. + """ + return False + + def isspace(self): # real signature unknown; restored from __doc__ + """ + B.isspace() -> bool + + Return True if all characters in B are whitespace + and there is at least one character in B, False otherwise. + """ + return False + + def istitle(self): # real signature unknown; restored from __doc__ + """ + B.istitle() -> bool + + Return True if B is a titlecased string and there is at least one + character in B, i.e. uppercase characters may only follow uncased + characters and lowercase characters only cased ones. Return False + otherwise. + """ + return False + + def isupper(self): # real signature unknown; restored from __doc__ + """ + B.isupper() -> bool + + Return True if all cased characters in B are uppercase and there is + at least one cased character in B, False otherwise. + """ + return False + + def join(self, iterable_of_bytes): # real signature unknown; restored from __doc__ + """ + B.join(iterable_of_bytes) -> bytes + + Concatenate any number of bytes objects, with B in between each pair. + Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'. + """ + return b"" + + def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.ljust(width[, fillchar]) -> copy of B + + Return B left justified in a string of length width. Padding is + done using the specified fill character (default is a space). + """ + pass + + def lower(self): # real signature unknown; restored from __doc__ + """ + B.lower() -> copy of B + + Return a copy of B with all ASCII characters converted to lowercase. + """ + pass + + def lstrip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.lstrip([bytes]) -> bytes + + Strip leading bytes contained in the argument. + If the argument is omitted, strip leading ASCII whitespace. + """ + return b"" + + @staticmethod # known case + def maketrans(frm, to): # real signature unknown; restored from __doc__ + """ + B.maketrans(frm, to) -> translation table + + Return a translation table (a bytes object of length 256) suitable + for use in the bytes or bytearray translate method where each byte + in frm is mapped to the byte at the same position in to. + The bytes objects frm and to must be of the same length. + """ + pass + + def partition(self, sep): # real signature unknown; restored from __doc__ + """ + B.partition(sep) -> (head, sep, tail) + + Search for the separator sep in B, and return the part before it, + the separator itself, and the part after it. If the separator is not + found, returns B and two empty bytes objects. + """ + pass + + def replace(self, old, new, count=None): # real signature unknown; restored from __doc__ + """ + B.replace(old, new[, count]) -> bytes + + Return a copy of B with all occurrences of subsection + old replaced by new. If the optional argument count is + given, only first count occurances are replaced. + """ + return b"" + + def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.rfind(sub[, start[, end]]) -> int + + Return the highest index in B where substring sub is found, + such that sub is contained within B[start:end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.rindex(sub[, start[, end]]) -> int + + Like B.rfind() but raise ValueError when the substring is not found. + """ + return 0 + + def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + B.rjust(width[, fillchar]) -> copy of B + + Return B right justified in a string of length width. Padding is + done using the specified fill character (default is a space) + """ + pass + + def rpartition(self, sep): # real signature unknown; restored from __doc__ + """ + B.rpartition(sep) -> (head, sep, tail) + + Search for the separator sep in B, starting at the end of B, + and return the part before it, the separator itself, and the + part after it. If the separator is not found, returns two empty + bytes objects and B. + """ + pass + + def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + B.rsplit(sep=None, maxsplit=-1) -> list of bytes + + Return a list of the sections in B, using sep as the delimiter, + starting at the end of B and working to the front. + If sep is not given, B is split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + If maxsplit is given, at most maxsplit splits are done. + """ + return [] + + def rstrip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.rstrip([bytes]) -> bytes + + Strip trailing bytes contained in the argument. + If the argument is omitted, strip trailing ASCII whitespace. + """ + return b"" + + def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + B.split(sep=None, maxsplit=-1) -> list of bytes + + Return a list of the sections in B, using sep as the delimiter. + If sep is not specified or is None, B is split on ASCII whitespace + characters (space, tab, return, newline, formfeed, vertical tab). + If maxsplit is given, at most maxsplit splits are done. + """ + return [] + + def splitlines(self, keepends=None): # real signature unknown; restored from __doc__ + """ + B.splitlines([keepends]) -> list of lines + + Return a list of the lines in B, breaking at line boundaries. + Line breaks are not included in the resulting list unless keepends + is given and true. + """ + return [] + + def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.startswith(prefix[, start[, end]]) -> bool + + Return True if B starts with the specified prefix, False otherwise. + With optional start, test B beginning at that position. + With optional end, stop comparing B at that position. + prefix can also be a tuple of bytes to try. + """ + return False + + def strip(self, bytes=None): # real signature unknown; restored from __doc__ + """ + B.strip([bytes]) -> bytes + + Strip leading and trailing bytes contained in the argument. + If the argument is omitted, strip leading and trailing ASCII whitespace. + """ + return b"" + + def swapcase(self): # real signature unknown; restored from __doc__ + """ + B.swapcase() -> copy of B + + Return a copy of B with uppercase ASCII characters converted + to lowercase ASCII and vice versa. + """ + pass + + def title(self): # real signature unknown; restored from __doc__ + """ + B.title() -> copy of B + + Return a titlecased version of B, i.e. ASCII words start with uppercase + characters, all remaining cased characters have lowercase. + """ + pass + + def translate(self, table, deletechars=None): # real signature unknown; restored from __doc__ + """ + B.translate(table[, deletechars]) -> bytes + + Return a copy of B, where all characters occurring in the + optional argument deletechars are removed, and the remaining + characters have been mapped through the given translation + table, which must be a bytes object of length 256. + """ + return b"" + + def upper(self): # real signature unknown; restored from __doc__ + """ + B.upper() -> copy of B + + Return a copy of B with all ASCII characters converted to uppercase. + """ + pass + + def zfill(self, width): # real signature unknown; restored from __doc__ + """ + B.zfill(width) -> copy of B + + Pad a numeric string B with zeros on the left, to fill a field + of the specified width. B is never truncated. + """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, value=b'', encoding=None, errors='strict'): # known special case of bytes.__init__ + """ + bytes(iterable_of_ints) -> bytes + bytes(string, encoding[, errors]) -> bytes + bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer + bytes(int) -> bytes object of size given by the parameter initialized with null bytes + bytes() -> empty bytes object + + Construct an immutable array of bytes from: + - an iterable yielding integers in range(256) + - a text string encoded using the specified encoding + - any object implementing the buffer API. + - an integer + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self size of B in memory, in bytes """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + +from .Exception import Exception + +class Warning(Exception): + """ Base class for warning categories. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Warning import Warning + +class BytesWarning(Warning): + """ + Base class for warnings about bytes and buffer related problems, mostly + related to conversion from str or comparing to str. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .OSError import OSError + +class ChildProcessError(OSError): + """ Child process error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .object import object + +class classmethod(object): + """ + classmethod(function) -> method + + Convert a function to be a class method. + + A class method receives the class as implicit first argument, + just like an instance method receives the instance. + To declare a class method, use this idiom: + + class C: + def f(cls, arg1, arg2, ...): ... + f = classmethod(f) + + It can be called either on the class (e.g. C.f()) or on an instance + (e.g. C().f()). The instance is ignored except for its class. + If a class method is called for a derived class, the derived class + object is passed as the implied first argument. + + Class methods are different than C++ or Java static methods. + If you want those, see the staticmethod builtin. + """ + def __get__(self, *args, **kwargs): # real signature unknown + """ Return an attribute of instance, which is of type owner. """ + pass + + def __init__(self, function): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + __func__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + __isabstractmethod__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __dict__ = None # (!) real value is '' + + +from .object import object + +class complex(object): + """ + complex(real[, imag]) -> complex number + + Create a complex number from a real part and an optional imaginary part. + This is equivalent to (real + imag*1j) where imag defaults to 0. + """ + def conjugate(self): # real signature unknown; restored from __doc__ + """ + complex.conjugate() -> complex + + Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j. + """ + return complex + + def __abs__(self, *args, **kwargs): # real signature unknown + """ abs(self) """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __bool__(self, *args, **kwargs): # real signature unknown + """ self != 0 """ + pass + + def __divmod__(self, *args, **kwargs): # real signature unknown + """ Return divmod(self, value). """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __float__(self, *args, **kwargs): # real signature unknown + """ float(self) """ + pass + + def __floordiv__(self, *args, **kwargs): # real signature unknown + """ Return self//value. """ + pass + + def __format__(self): # real signature unknown; restored from __doc__ + """ + complex.__format__() -> str + + Convert to a string according to format_spec. + """ + return "" + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, real, imag=None): # real signature unknown; restored from __doc__ + pass + + def __int__(self, *args, **kwargs): # real signature unknown + """ int(self) """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self new empty dictionary + dict(mapping) -> new dictionary initialized from a mapping object's + (key, value) pairs + dict(iterable) -> new dictionary initialized as if via: + d = {} + for k, v in iterable: + d[k] = v + dict(**kwargs) -> new dictionary initialized with the name=value pairs + in the keyword argument list. For example: dict(one=1, two=2) + """ + def clear(self): # real signature unknown; restored from __doc__ + """ D.clear() -> None. Remove all items from D. """ + pass + + def copy(self): # real signature unknown; restored from __doc__ + """ D.copy() -> a shallow copy of D """ + pass + + @staticmethod # known case + def fromkeys(*args, **kwargs): # real signature unknown + """ Returns a new dict with keys from iterable and values equal to value. """ + pass + + def get(self, k, d=None): # real signature unknown; restored from __doc__ + """ D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. """ + pass + + def items(self): # real signature unknown; restored from __doc__ + """ D.items() -> a set-like object providing a view on D's items """ + pass + + def keys(self): # real signature unknown; restored from __doc__ + """ D.keys() -> a set-like object providing a view on D's keys """ + pass + + def pop(self, k, d=None): # real signature unknown; restored from __doc__ + """ + D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + If key is not found, d is returned if given, otherwise KeyError is raised + """ + pass + + def popitem(self): # real signature unknown; restored from __doc__ + """ + D.popitem() -> (k, v), remove and return some (key, value) pair as a + 2-tuple; but raise KeyError if D is empty. + """ + pass + + def setdefault(self, k, d=None): # real signature unknown; restored from __doc__ + """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """ + pass + + def update(self, E=None, **F): # known special case of dict.update + """ + D.update([E, ]**F) -> None. Update D from dict/iterable E and F. + If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] + If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v + In either case, this is followed by: for k in F: D[k] = F[k] + """ + pass + + def values(self): # real signature unknown; restored from __doc__ + """ D.values() -> an object providing a view on D's values """ + pass + + def __contains__(self, *args, **kwargs): # real signature unknown + """ True if D has a key k, else False. """ + pass + + def __delitem__(self, *args, **kwargs): # real signature unknown + """ Delete self[key]. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __init__(self, seq=None, **kwargs): # known special case of dict.__init__ + """ + dict() -> new empty dictionary + dict(mapping) -> new dictionary initialized from a mapping object's + (key, value) pairs + dict(iterable) -> new dictionary initialized as if via: + d = {} + for k, v in iterable: + d[k] = v + dict(**kwargs) -> new dictionary initialized with the name=value pairs + in the keyword argument list. For example: dict(one=1, two=2) + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self size of D in memory, in bytes """ + pass + + __hash__ = None + + +from .object import object + +class enumerate(object): + """ + enumerate(iterable[, start]) -> iterator for index, value of iterable + + Return an enumerate object. iterable must be another object that supports + iteration. The enumerate object yields pairs containing a count (from + start, which defaults to zero) and a value yielded by the iterable argument. + enumerate is useful for obtaining an indexed list: + (0, seq[0]), (1, seq[1]), (2, seq[2]), ... + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, iterable, start=0): # known special case of enumerate.__init__ + """ Initialize self. See help(type(self)) for accurate signature. """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + +from .Exception import Exception + +class EOFError(Exception): + """ Read beyond end of file. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .OSError import OSError + +class FileExistsError(OSError): + """ File already exists. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .OSError import OSError + +class FileNotFoundError(OSError): + """ File not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .object import object + +class filter(object): + """ + filter(function or None, iterable) --> filter object + + Return an iterator yielding those items of iterable for which function(item) + is true. If function is None, return the items that are true. + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, function_or_None, iterable): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + +from .object import object + +class float(object): + """ + float(x) -> floating point number + + Convert a string or number to a floating point number, if possible. + """ + def as_integer_ratio(self): # real signature unknown; restored from __doc__ + """ + float.as_integer_ratio() -> (int, int) + + Return a pair of integers, whose ratio is exactly equal to the original + float and with a positive denominator. + Raise OverflowError on infinities and a ValueError on NaNs. + + >>> (10.0).as_integer_ratio() + (10, 1) + >>> (0.0).as_integer_ratio() + (0, 1) + >>> (-.25).as_integer_ratio() + (-1, 4) + """ + pass + + def conjugate(self, *args, **kwargs): # real signature unknown + """ Return self, the complex conjugate of any float. """ + pass + + def fromhex(self, string): # real signature unknown; restored from __doc__ + """ + float.fromhex(string) -> float + + Create a floating-point number from a hexadecimal string. + >>> float.fromhex('0x1.ffffp10') + 2047.984375 + >>> float.fromhex('-0x1p-1074') + -5e-324 + """ + return 0.0 + + def hex(self): # real signature unknown; restored from __doc__ + """ + float.hex() -> string + + Return a hexadecimal representation of a floating-point number. + >>> (-0.1).hex() + '-0x1.999999999999ap-4' + >>> 3.14159.hex() + '0x1.921f9f01b866ep+1' + """ + return "" + + def is_integer(self, *args, **kwargs): # real signature unknown + """ Return True if the float is an integer. """ + pass + + def __abs__(self, *args, **kwargs): # real signature unknown + """ abs(self) """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __bool__(self, *args, **kwargs): # real signature unknown + """ self != 0 """ + pass + + def __divmod__(self, *args, **kwargs): # real signature unknown + """ Return divmod(self, value). """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __float__(self, *args, **kwargs): # real signature unknown + """ float(self) """ + pass + + def __floordiv__(self, *args, **kwargs): # real signature unknown + """ Return self//value. """ + pass + + def __format__(self, format_spec): # real signature unknown; restored from __doc__ + """ + float.__format__(format_spec) -> string + + Formats the float according to format_spec. + """ + return "" + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getformat__(self, typestr): # real signature unknown; restored from __doc__ + """ + float.__getformat__(typestr) -> string + + You probably don't want to use this function. It exists mainly to be + used in Python's test suite. + + typestr must be 'double' or 'float'. This function returns whichever of + 'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the + format of floating point numbers used by the C type named by typestr. + """ + return "" + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, x): # real signature unknown; restored from __doc__ + pass + + def __int__(self, *args, **kwargs): # real signature unknown + """ int(self) """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self None + + You probably don't want to use this function. It exists mainly to be + used in Python's test suite. + + typestr must be 'double' or 'float'. fmt must be one of 'unknown', + 'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be + one of the latter two if it appears to match the underlying C reality. + + Override the automatic determination of C-level floating point type. + This affects how floats are converted to and from binary strings. + """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + def __sub__(self, *args, **kwargs): # real signature unknown + """ Return self-value. """ + pass + + def __truediv__(self, *args, **kwargs): # real signature unknown + """ Return self/value. """ + pass + + def __trunc__(self, *args, **kwargs): # real signature unknown + """ Return the Integral closest to x between 0 and x. """ + pass + + imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the imaginary part of a complex number""" + + real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """the real part of a complex number""" + + + +from .ArithmeticError import ArithmeticError + +class FloatingPointError(ArithmeticError): + """ Floating point operation failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .object import object + +class frozenset(object): + """ + frozenset() -> empty frozenset object + frozenset(iterable) -> frozenset object + + Build an immutable unordered collection of unique elements. + """ + def copy(self, *args, **kwargs): # real signature unknown + """ Return a shallow copy of a set. """ + pass + + def difference(self, *args, **kwargs): # real signature unknown + """ + Return the difference of two or more sets as a new set. + + (i.e. all elements that are in this set but not the others.) + """ + pass + + def intersection(self, *args, **kwargs): # real signature unknown + """ + Return the intersection of two sets as a new set. + + (i.e. all elements that are in both sets.) + """ + pass + + def isdisjoint(self, *args, **kwargs): # real signature unknown + """ Return True if two sets have a null intersection. """ + pass + + def issubset(self, *args, **kwargs): # real signature unknown + """ Report whether another set contains this set. """ + pass + + def issuperset(self, *args, **kwargs): # real signature unknown + """ Report whether this set contains another set. """ + pass + + def symmetric_difference(self, *args, **kwargs): # real signature unknown + """ + Return the symmetric difference of two sets as a new set. + + (i.e. all elements that are in exactly one of the sets.) + """ + pass + + def union(self, *args, **kwargs): # real signature unknown + """ + Return the union of sets as a new set. + + (i.e. all elements that are in either set.) + """ + pass + + def __and__(self, *args, **kwargs): # real signature unknown + """ Return self&value. """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, seq=()): # known special case of frozenset.__init__ + """ Initialize self. See help(type(self)) for accurate signature. """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self size of S in memory, in bytes """ + pass + + def __sub__(self, *args, **kwargs): # real signature unknown + """ Return self-value. """ + pass + + def __xor__(self, *args, **kwargs): # real signature unknown + """ Return self^value. """ + pass + + +from .Warning import Warning + +class FutureWarning(Warning): + """ + Base class for warnings about constructs that will change semantically + in the future. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .BaseException import BaseException + +class GeneratorExit(BaseException): + """ Request that a generator exit. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class ImportError(Exception): + """ Import can't find module, or can't find name in module. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + msg = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception message""" + + name = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """module name""" + + path = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """module path""" + + + +from .Warning import Warning + +class ImportWarning(Warning): + """ Base class for warnings about probable mistakes in module imports """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class SyntaxError(Exception): + """ Invalid syntax. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + filename = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception filename""" + + lineno = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception lineno""" + + msg = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception msg""" + + offset = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception offset""" + + print_file_and_line = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception print_file_and_line""" + + text = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception text""" + + + +from .SyntaxError import SyntaxError + +class IndentationError(SyntaxError): + """ Improper indentation. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .Exception import Exception + +class LookupError(Exception): + """ Base class for lookup errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .LookupError import LookupError + +class IndexError(LookupError): + """ Sequence index out of range. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .OSError import OSError + +class InterruptedError(OSError): + """ Interrupted by signal. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .OSError import OSError + +class IsADirectoryError(OSError): + """ Operation doesn't work on directories. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .BaseException import BaseException + +class KeyboardInterrupt(BaseException): + """ Program interrupted by user. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .LookupError import LookupError + +class KeyError(LookupError): + """ Mapping key not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + +from .object import object + +class list(object): + """ + list() -> new empty list + list(iterable) -> new list initialized from iterable's items + """ + def append(self, p_object): # real signature unknown; restored from __doc__ + """ L.append(object) -> None -- append object to end """ + pass + + def clear(self): # real signature unknown; restored from __doc__ + """ L.clear() -> None -- remove all items from L """ + pass + + def copy(self): # real signature unknown; restored from __doc__ + """ L.copy() -> list -- a shallow copy of L """ + return [] + + def count(self, value): # real signature unknown; restored from __doc__ + """ L.count(value) -> integer -- return number of occurrences of value """ + return 0 + + def extend(self, iterable): # real signature unknown; restored from __doc__ + """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """ + pass + + def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ + """ + L.index(value, [start, [stop]]) -> integer -- return first index of value. + Raises ValueError if the value is not present. + """ + return 0 + + def insert(self, index, p_object): # real signature unknown; restored from __doc__ + """ L.insert(index, object) -- insert object before index """ + pass + + def pop(self, index=None): # real signature unknown; restored from __doc__ + """ + L.pop([index]) -> item -- remove and return item at index (default last). + Raises IndexError if list is empty or index is out of range. + """ + pass + + def remove(self, value): # real signature unknown; restored from __doc__ + """ + L.remove(value) -> None -- remove first occurrence of value. + Raises ValueError if the value is not present. + """ + pass + + def reverse(self): # real signature unknown; restored from __doc__ + """ L.reverse() -- reverse *IN PLACE* """ + pass + + def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__ + """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """ + pass + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __delitem__(self, *args, **kwargs): # real signature unknown + """ Delete self[key]. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __iadd__(self, *args, **kwargs): # real signature unknown + """ Implement self+=value. """ + pass + + def __imul__(self, *args, **kwargs): # real signature unknown + """ Implement self*=value. """ + pass + + def __init__(self, seq=()): # known special case of list.__init__ + """ + list() -> new empty list + list(iterable) -> new list initialized from iterable's items + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self map object + + Make an iterator that computes the function using arguments from + each of the iterables. Stops when the shortest iterable is exhausted. + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, func, *iterables): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + +from .Exception import Exception + +class MemoryError(Exception): + """ Out of memory. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .object import object + +class memoryview(object): + """ + memoryview(object) + + Create a new memoryview object which references the given object. + """ + def cast(self, format, shape=None): # real signature unknown; restored from __doc__ + """ + M.cast(format[, shape]) -> memoryview + + Cast a memoryview to a new format or shape. + """ + return memoryview + + def release(self): # real signature unknown; restored from __doc__ + """ + M.release() -> None + + Release the underlying buffer exposed by the memoryview object. + """ + pass + + def tobytes(self): # real signature unknown; restored from __doc__ + """ + M.tobytes() -> bytes + + Return the data in the buffer as a byte string. + """ + return b"" + + def tolist(self): # real signature unknown; restored from __doc__ + """ + M.tolist() -> list + + Return the data in the buffer as a list of elements. + """ + return [] + + def __delitem__(self, *args, **kwargs): # real signature unknown + """ Delete self[key]. """ + pass + + def __enter__(self, *args, **kwargs): # real signature unknown + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __exit__(self, *args, **kwargs): # real signature unknown + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, p_object): # real signature unknown; restored from __doc__ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self property attribute + + fget is a function to be used for getting an attribute value, and likewise + fset is a function for setting, and fdel a function for del'ing, an + attribute. Typical use is to define a managed attribute x: + + class C(object): + def getx(self): return self._x + def setx(self, value): self._x = value + def delx(self): del self._x + x = property(getx, setx, delx, "I'm the 'x' property.") + + Decorators make defining new properties or modifying existing ones easy: + + class C(object): + @property + def x(self): + "I am the 'x' property." + return self._x + @x.setter + def x(self, value): + self._x = value + @x.deleter + def x(self): + del self._x + """ + def deleter(self, *args, **kwargs): # real signature unknown + """ Descriptor to change the deleter on a property. """ + pass + + def getter(self, *args, **kwargs): # real signature unknown + """ Descriptor to change the getter on a property. """ + pass + + def setter(self, *args, **kwargs): # real signature unknown + """ Descriptor to change the setter on a property. """ + pass + + def __delete__(self, *args, **kwargs): # real signature unknown + """ Delete an attribute of instance. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __get__(self, *args, **kwargs): # real signature unknown + """ Return an attribute of instance, which is of type owner. """ + pass + + def __init__(self, fget=None, fset=None, fdel=None, doc=None): # known special case of property.__init__ + """ + property(fget=None, fset=None, fdel=None, doc=None) -> property attribute + + fget is a function to be used for getting an attribute value, and likewise + fset is a function for setting, and fdel a function for del'ing, an + attribute. Typical use is to define a managed attribute x: + + class C(object): + def getx(self): return self._x + def setx(self, value): self._x = value + def delx(self): del self._x + x = property(getx, setx, delx, "I'm the 'x' property.") + + Decorators make defining new properties or modifying existing ones easy: + + class C(object): + @property + def x(self): + "I am the 'x' property." + return self._x + @x.setter + def x(self, value): + self._x = value + @x.deleter + def x(self): + del self._x + + # (copied from class doc) + """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __set__(self, *args, **kwargs): # real signature unknown + """ Set an attribute of instance to value. """ + pass + + fdel = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + fget = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + fset = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + __isabstractmethod__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +from .object import object + +class range(object): + """ + range(stop) -> range object + range(start, stop[, step]) -> range object + + Return a virtual sequence of numbers from start to stop by step. + """ + def count(self, value): # real signature unknown; restored from __doc__ + """ rangeobject.count(value) -> integer -- return number of occurrences of value """ + return 0 + + def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ + """ + rangeobject.index(value, [start, [stop]]) -> integer -- return index of value. + Raise ValueError if the value is not present. + """ + return 0 + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, stop): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self reverse iterator over values of the sequence + + Return a reverse iterator + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, sequence): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __length_hint__(self, *args, **kwargs): # real signature unknown + """ Private method returning an estimate of len(list(it)). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + def __setstate__(self, *args, **kwargs): # real signature unknown + """ Set state information for unpickling. """ + pass + + +from .Warning import Warning + +class RuntimeWarning(Warning): + """ Base class for warnings about dubious runtime behavior. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .object import object + +class set(object): + """ + set() -> new empty set object + set(iterable) -> new set object + + Build an unordered collection of unique elements. + """ + def add(self, *args, **kwargs): # real signature unknown + """ + Add an element to a set. + + This has no effect if the element is already present. + """ + pass + + def clear(self, *args, **kwargs): # real signature unknown + """ Remove all elements from this set. """ + pass + + def copy(self, *args, **kwargs): # real signature unknown + """ Return a shallow copy of a set. """ + pass + + def difference(self, *args, **kwargs): # real signature unknown + """ + Return the difference of two or more sets as a new set. + + (i.e. all elements that are in this set but not the others.) + """ + pass + + def difference_update(self, *args, **kwargs): # real signature unknown + """ Remove all elements of another set from this set. """ + pass + + def discard(self, *args, **kwargs): # real signature unknown + """ + Remove an element from a set if it is a member. + + If the element is not a member, do nothing. + """ + pass + + def intersection(self, *args, **kwargs): # real signature unknown + """ + Return the intersection of two sets as a new set. + + (i.e. all elements that are in both sets.) + """ + pass + + def intersection_update(self, *args, **kwargs): # real signature unknown + """ Update a set with the intersection of itself and another. """ + pass + + def isdisjoint(self, *args, **kwargs): # real signature unknown + """ Return True if two sets have a null intersection. """ + pass + + def issubset(self, *args, **kwargs): # real signature unknown + """ Report whether another set contains this set. """ + pass + + def issuperset(self, *args, **kwargs): # real signature unknown + """ Report whether this set contains another set. """ + pass + + def pop(self, *args, **kwargs): # real signature unknown + """ + Remove and return an arbitrary set element. + Raises KeyError if the set is empty. + """ + pass + + def remove(self, *args, **kwargs): # real signature unknown + """ + Remove an element from a set; it must be a member. + + If the element is not a member, raise a KeyError. + """ + pass + + def symmetric_difference(self, *args, **kwargs): # real signature unknown + """ + Return the symmetric difference of two sets as a new set. + + (i.e. all elements that are in exactly one of the sets.) + """ + pass + + def symmetric_difference_update(self, *args, **kwargs): # real signature unknown + """ Update a set with the symmetric difference of itself and another. """ + pass + + def union(self, *args, **kwargs): # real signature unknown + """ + Return the union of sets as a new set. + + (i.e. all elements that are in either set.) + """ + pass + + def update(self, *args, **kwargs): # real signature unknown + """ Update a set with the union of itself and others. """ + pass + + def __and__(self, *args, **kwargs): # real signature unknown + """ Return self&value. """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __iand__(self, *args, **kwargs): # real signature unknown + """ Return self&=value. """ + pass + + def __init__(self, seq=()): # known special case of set.__init__ + """ + set() -> new empty set object + set(iterable) -> new set object + + Build an unordered collection of unique elements. + # (copied from class doc) + """ + pass + + def __ior__(self, *args, **kwargs): # real signature unknown + """ Return self|=value. """ + pass + + def __isub__(self, *args, **kwargs): # real signature unknown + """ Return self-=value. """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __ixor__(self, *args, **kwargs): # real signature unknown + """ Return self^=value. """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self size of S in memory, in bytes """ + pass + + def __sub__(self, *args, **kwargs): # real signature unknown + """ Return self-value. """ + pass + + def __xor__(self, *args, **kwargs): # real signature unknown + """ Return self^value. """ + pass + + __hash__ = None + + +from .object import object + +class slice(object): + """ + slice(stop) + slice(start, stop[, step]) + + Create a slice object. This is used for extended slicing (e.g. a[0:10:2]). + """ + def indices(self, len): # real signature unknown; restored from __doc__ + """ + S.indices(len) -> (start, stop, stride) + + Assuming a sequence of length len, calculate the start and stop + indices, and the stride length of the extended slice described by + S. Out of bounds indices are clipped in a manner consistent with the + handling of normal slices. + """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __init__(self, stop): # real signature unknown; restored from __doc__ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self method + + Convert a function to be a static method. + + A static method does not receive an implicit first argument. + To declare a static method, use this idiom: + + class C: + def f(arg1, arg2, ...): ... + f = staticmethod(f) + + It can be called either on the class (e.g. C.f()) or on an instance + (e.g. C().f()). The instance is ignored except for its class. + + Static methods in Python are similar to those found in Java or C++. + For a more advanced concept, see the classmethod builtin. + """ + def __get__(self, *args, **kwargs): # real signature unknown + """ Return an attribute of instance, which is of type owner. """ + pass + + def __init__(self, function): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + __func__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + __isabstractmethod__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __dict__ = None # (!) real value is '' + + +from .Exception import Exception + +class StopIteration(Exception): + """ Signal the end from iterator.__next__(). """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + value = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """generator return value""" + + + +from .object import object + +class str(object): + """ + str(object='') -> str + str(bytes_or_buffer[, encoding[, errors]]) -> str + + Create a new string object from the given object. If encoding or + errors is specified, then the object must expose a data buffer + that will be decoded using the given encoding and error handler. + Otherwise, returns the result of object.__str__() (if defined) + or repr(object). + encoding defaults to sys.getdefaultencoding(). + errors defaults to 'strict'. + """ + def capitalize(self): # real signature unknown; restored from __doc__ + """ + S.capitalize() -> str + + Return a capitalized version of S, i.e. make the first character + have upper case and the rest lower case. + """ + return "" + + def casefold(self): # real signature unknown; restored from __doc__ + """ + S.casefold() -> str + + Return a version of S suitable for caseless comparisons. + """ + return "" + + def center(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.center(width[, fillchar]) -> str + + Return S centered in a string of length width. Padding is + done using the specified fill character (default is a space) + """ + return "" + + def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.count(sub[, start[, end]]) -> int + + Return the number of non-overlapping occurrences of substring sub in + string S[start:end]. Optional arguments start and end are + interpreted as in slice notation. + """ + return 0 + + def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__ + """ + S.encode(encoding='utf-8', errors='strict') -> bytes + + Encode S using the codec registered for encoding. Default encoding + is 'utf-8'. errors may be given to set a different error + handling scheme. Default is 'strict' meaning that encoding errors raise + a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and + 'xmlcharrefreplace' as well as any other name registered with + codecs.register_error that can handle UnicodeEncodeErrors. + """ + return b"" + + def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.endswith(suffix[, start[, end]]) -> bool + + Return True if S ends with the specified suffix, False otherwise. + With optional start, test S beginning at that position. + With optional end, stop comparing S at that position. + suffix can also be a tuple of strings to try. + """ + return False + + def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__ + """ + S.expandtabs(tabsize=8) -> str + + Return a copy of S where all tab characters are expanded using spaces. + If tabsize is not given, a tab size of 8 characters is assumed. + """ + return "" + + def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.find(sub[, start[, end]]) -> int + + Return the lowest index in S where substring sub is found, + such that sub is contained within S[start:end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + def format(*args, **kwargs): # known special case of str.format + """ + S.format(*args, **kwargs) -> str + + Return a formatted version of S, using substitutions from args and kwargs. + The substitutions are identified by braces ('{' and '}'). + """ + pass + + def format_map(self, mapping): # real signature unknown; restored from __doc__ + """ + S.format_map(mapping) -> str + + Return a formatted version of S, using substitutions from mapping. + The substitutions are identified by braces ('{' and '}'). + """ + return "" + + def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.index(sub[, start[, end]]) -> int + + Like S.find() but raise ValueError when the substring is not found. + """ + return 0 + + def isalnum(self): # real signature unknown; restored from __doc__ + """ + S.isalnum() -> bool + + Return True if all characters in S are alphanumeric + and there is at least one character in S, False otherwise. + """ + return False + + def isalpha(self): # real signature unknown; restored from __doc__ + """ + S.isalpha() -> bool + + Return True if all characters in S are alphabetic + and there is at least one character in S, False otherwise. + """ + return False + + def isdecimal(self): # real signature unknown; restored from __doc__ + """ + S.isdecimal() -> bool + + Return True if there are only decimal characters in S, + False otherwise. + """ + return False + + def isdigit(self): # real signature unknown; restored from __doc__ + """ + S.isdigit() -> bool + + Return True if all characters in S are digits + and there is at least one character in S, False otherwise. + """ + return False + + def isidentifier(self): # real signature unknown; restored from __doc__ + """ + S.isidentifier() -> bool + + Return True if S is a valid identifier according + to the language definition. + + Use keyword.iskeyword() to test for reserved identifiers + such as "def" and "class". + """ + return False + + def islower(self): # real signature unknown; restored from __doc__ + """ + S.islower() -> bool + + Return True if all cased characters in S are lowercase and there is + at least one cased character in S, False otherwise. + """ + return False + + def isnumeric(self): # real signature unknown; restored from __doc__ + """ + S.isnumeric() -> bool + + Return True if there are only numeric characters in S, + False otherwise. + """ + return False + + def isprintable(self): # real signature unknown; restored from __doc__ + """ + S.isprintable() -> bool + + Return True if all characters in S are considered + printable in repr() or S is empty, False otherwise. + """ + return False + + def isspace(self): # real signature unknown; restored from __doc__ + """ + S.isspace() -> bool + + Return True if all characters in S are whitespace + and there is at least one character in S, False otherwise. + """ + return False + + def istitle(self): # real signature unknown; restored from __doc__ + """ + S.istitle() -> bool + + Return True if S is a titlecased string and there is at least one + character in S, i.e. upper- and titlecase characters may only + follow uncased characters and lowercase characters only cased ones. + Return False otherwise. + """ + return False + + def isupper(self): # real signature unknown; restored from __doc__ + """ + S.isupper() -> bool + + Return True if all cased characters in S are uppercase and there is + at least one cased character in S, False otherwise. + """ + return False + + def join(self, iterable): # real signature unknown; restored from __doc__ + """ + S.join(iterable) -> str + + Return a string which is the concatenation of the strings in the + iterable. The separator between elements is S. + """ + return "" + + def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.ljust(width[, fillchar]) -> str + + Return S left-justified in a Unicode string of length width. Padding is + done using the specified fill character (default is a space). + """ + return "" + + def lower(self): # real signature unknown; restored from __doc__ + """ + S.lower() -> str + + Return a copy of the string S converted to lowercase. + """ + return "" + + def lstrip(self, chars=None): # real signature unknown; restored from __doc__ + """ + S.lstrip([chars]) -> str + + Return a copy of the string S with leading whitespace removed. + If chars is given and not None, remove characters in chars instead. + """ + return "" + + def maketrans(self, *args, **kwargs): # real signature unknown + """ + Return a translation table usable for str.translate(). + + If there is only one argument, it must be a dictionary mapping Unicode + ordinals (integers) or characters to Unicode ordinals, strings or None. + Character keys will be then converted to ordinals. + If there are two arguments, they must be strings of equal length, and + in the resulting dictionary, each character in x will be mapped to the + character at the same position in y. If there is a third argument, it + must be a string, whose characters will be mapped to None in the result. + """ + pass + + def partition(self, sep): # real signature unknown; restored from __doc__ + """ + S.partition(sep) -> (head, sep, tail) + + Search for the separator sep in S, and return the part before it, + the separator itself, and the part after it. If the separator is not + found, return S and two empty strings. + """ + pass + + def replace(self, old, new, count=None): # real signature unknown; restored from __doc__ + """ + S.replace(old, new[, count]) -> str + + Return a copy of S with all occurrences of substring + old replaced by new. If the optional argument count is + given, only the first count occurrences are replaced. + """ + return "" + + def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.rfind(sub[, start[, end]]) -> int + + Return the highest index in S where substring sub is found, + such that sub is contained within S[start:end]. Optional + arguments start and end are interpreted as in slice notation. + + Return -1 on failure. + """ + return 0 + + def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.rindex(sub[, start[, end]]) -> int + + Like S.rfind() but raise ValueError when the substring is not found. + """ + return 0 + + def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.rjust(width[, fillchar]) -> str + + Return S right-justified in a string of length width. Padding is + done using the specified fill character (default is a space). + """ + return "" + + def rpartition(self, sep): # real signature unknown; restored from __doc__ + """ + S.rpartition(sep) -> (head, sep, tail) + + Search for the separator sep in S, starting at the end of S, and return + the part before it, the separator itself, and the part after it. If the + separator is not found, return two empty strings and S. + """ + pass + + def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + S.rsplit(sep=None, maxsplit=-1) -> list of strings + + Return a list of the words in S, using sep as the + delimiter string, starting at the end of the string and + working to the front. If maxsplit is given, at most maxsplit + splits are done. If sep is not specified, any whitespace string + is a separator. + """ + return [] + + def rstrip(self, chars=None): # real signature unknown; restored from __doc__ + """ + S.rstrip([chars]) -> str + + Return a copy of the string S with trailing whitespace removed. + If chars is given and not None, remove characters in chars instead. + """ + return "" + + def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ + """ + S.split(sep=None, maxsplit=-1) -> list of strings + + Return a list of the words in S, using sep as the + delimiter string. If maxsplit is given, at most maxsplit + splits are done. If sep is not specified or is None, any + whitespace string is a separator and empty strings are + removed from the result. + """ + return [] + + def splitlines(self, keepends=None): # real signature unknown; restored from __doc__ + """ + S.splitlines([keepends]) -> list of strings + + Return a list of the lines in S, breaking at line boundaries. + Line breaks are not included in the resulting list unless keepends + is given and true. + """ + return [] + + def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__ + """ + S.startswith(prefix[, start[, end]]) -> bool + + Return True if S starts with the specified prefix, False otherwise. + With optional start, test S beginning at that position. + With optional end, stop comparing S at that position. + prefix can also be a tuple of strings to try. + """ + return False + + def strip(self, chars=None): # real signature unknown; restored from __doc__ + """ + S.strip([chars]) -> str + + Return a copy of the string S with leading and trailing + whitespace removed. + If chars is given and not None, remove characters in chars instead. + """ + return "" + + def swapcase(self): # real signature unknown; restored from __doc__ + """ + S.swapcase() -> str + + Return a copy of S with uppercase characters converted to lowercase + and vice versa. + """ + return "" + + def title(self): # real signature unknown; restored from __doc__ + """ + S.title() -> str + + Return a titlecased version of S, i.e. words start with title case + characters, all remaining cased characters have lower case. + """ + return "" + + def translate(self, table): # real signature unknown; restored from __doc__ + """ + S.translate(table) -> str + + Return a copy of the string S, where all characters have been mapped + through the given translation table, which must be a mapping of + Unicode ordinals to Unicode ordinals, strings, or None. + Unmapped characters are left untouched. Characters mapped to None + are deleted. + """ + return "" + + def upper(self): # real signature unknown; restored from __doc__ + """ + S.upper() -> str + + Return a copy of S converted to uppercase. + """ + return "" + + def zfill(self, width): # real signature unknown; restored from __doc__ + """ + S.zfill(width) -> str + + Pad a numeric string S with zeros on the left, to fill a field + of the specified width. The string S is never truncated. + """ + return "" + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __format__(self, format_spec): # real signature unknown; restored from __doc__ + """ + S.__format__(format_spec) -> str + + Return a formatted version of S as described by format_spec. + """ + return "" + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, value='', encoding=None, errors='strict'): # known special case of str.__init__ + """ + str(object='') -> str + str(bytes_or_buffer[, encoding[, errors]]) -> str + + Create a new string object from the given object. If encoding or + errors is specified, then the object must expose a data buffer + that will be decoded using the given encoding and error handler. + Otherwise, returns the result of object.__str__() (if defined) + or repr(object). + encoding defaults to sys.getdefaultencoding(). + errors defaults to 'strict'. + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self size of S in memory, in bytes """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + +from .object import object + +class super(object): + """ + super() -> same as super(__class__, ) + super(type) -> unbound super object + super(type, obj) -> bound super object; requires isinstance(obj, type) + super(type, type2) -> bound super object; requires issubclass(type2, type) + Typical use to call a cooperative superclass method: + class C(B): + def meth(self, arg): + super().meth(arg) + This works for class methods too: + class C(B): + @classmethod + def cmeth(cls, arg): + super().cmeth(arg) + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __get__(self, *args, **kwargs): # real signature unknown + """ Return an attribute of instance, which is of type owner. """ + pass + + def __init__(self, type1=None, type2=None): # known special case of super.__init__ + """ + super() -> same as super(__class__, ) + super(type) -> unbound super object + super(type, obj) -> bound super object; requires isinstance(obj, type) + super(type, type2) -> bound super object; requires issubclass(type2, type) + Typical use to call a cooperative superclass method: + class C(B): + def meth(self, arg): + super().meth(arg) + This works for class methods too: + class C(B): + @classmethod + def cmeth(cls, arg): + super().cmeth(arg) + + # (copied from class doc) + """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + __self_class__ = property(lambda self: type(object)) + """the type of the instance invoking super(); may be None + + :type: type + """ + + __self__ = property(lambda self: type(object)) + """the instance invoking super(); may be None + + :type: type + """ + + __thisclass__ = property(lambda self: type(object)) + """the class invoking super() + + :type: type + """ + + + +from .Warning import Warning + +class SyntaxWarning(Warning): + """ Base class for warnings about dubious syntax. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class SystemError(Exception): + """ + Internal error in the Python interpreter. + + Please report this to the Python maintainer, along with the traceback, + the Python version, and the hardware/OS platform and version. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .BaseException import BaseException + +class SystemExit(BaseException): + """ Request to exit from the interpreter. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + code = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception code""" + + + +from .IndentationError import IndentationError + +class TabError(IndentationError): + """ Improper mixture of spaces and tabs. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .OSError import OSError + +class TimeoutError(OSError): + """ Timeout expired. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +from .object import object + +class tuple(object): + """ + tuple() -> empty tuple + tuple(iterable) -> tuple initialized from iterable's items + + If the argument is a tuple, the return value is the same object. + """ + def count(self, value): # real signature unknown; restored from __doc__ + """ T.count(value) -> integer -- return number of occurrences of value """ + return 0 + + def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__ + """ + T.index(value, [start, [stop]]) -> integer -- return first index of value. + Raises ValueError if the value is not present. + """ + return 0 + + def __add__(self, *args, **kwargs): # real signature unknown + """ Return self+value. """ + pass + + def __contains__(self, *args, **kwargs): # real signature unknown + """ Return key in self. """ + pass + + def __eq__(self, *args, **kwargs): # real signature unknown + """ Return self==value. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getitem__(self, *args, **kwargs): # real signature unknown + """ Return self[key]. """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, *args, **kwargs): # real signature unknown + """ Return self>=value. """ + pass + + def __gt__(self, *args, **kwargs): # real signature unknown + """ Return self>value. """ + pass + + def __hash__(self, *args, **kwargs): # real signature unknown + """ Return hash(self). """ + pass + + def __init__(self, seq=()): # known special case of tuple.__init__ + """ + tuple() -> empty tuple + tuple(iterable) -> tuple initialized from iterable's items + + If the argument is a tuple, the return value is the same object. + # (copied from class doc) + """ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + def __len__(self, *args, **kwargs): # real signature unknown + """ Return len(self). """ + pass + + def __le__(self, *args, **kwargs): # real signature unknown + """ Return self<=value. """ + pass + + def __lt__(self, *args, **kwargs): # real signature unknown + """ Return self the object's type + type(name, bases, dict) -> a new type + """ + def mro(self): # real signature unknown; restored from __doc__ + """ + mro() -> list + return a type's method resolution order + """ + return [] + + def __call__(self, *args, **kwargs): # real signature unknown + """ Call self as a function. """ + pass + + def __delattr__(self, *args, **kwargs): # real signature unknown + """ Implement delattr(self, name). """ + pass + + def __dir__(self): # real signature unknown; restored from __doc__ + """ + __dir__() -> list + specialized __dir__ implementation for types + """ + return [] + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(cls, what, bases=None, dict=None): # known special case of type.__init__ + """ + type(object_or_name, bases, dict) + type(object) -> the object's type + type(name, bases, dict) -> a new type + # (copied from class doc) + """ + pass + + def __instancecheck__(self): # real signature unknown; restored from __doc__ + """ + __instancecheck__() -> bool + check if an object is an instance + """ + return False + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __prepare__(self): # real signature unknown; restored from __doc__ + """ + __prepare__() -> dict + used to create the namespace for the class statement + """ + return {} + + def __repr__(self, *args, **kwargs): # real signature unknown + """ Return repr(self). """ + pass + + def __setattr__(self, *args, **kwargs): # real signature unknown + """ Implement setattr(self, name, value). """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ + __sizeof__() -> int + return memory consumption of the type object + """ + return 0 + + def __subclasscheck__(self): # real signature unknown; restored from __doc__ + """ + __subclasscheck__() -> bool + check if a class is a subclass + """ + return False + + def __subclasses__(self): # real signature unknown; restored from __doc__ + """ __subclasses__() -> list of immediate subclasses """ + return [] + + __abstractmethods__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __bases__ = ( + object, + ) + __base__ = object + __basicsize__ = 412 + __dictoffset__ = 132 + __dict__ = None # (!) real value is '' + __flags__ = -2146675712 + __itemsize__ = 20 + __mro__ = ( + None, # (!) forward: type, real value is '' + object, + ) + __name__ = 'type' + __qualname__ = 'type' + __text_signature__ = None + __weakrefoffset__ = 184 + + +from .Exception import Exception + +class TypeError(Exception): + """ Inappropriate argument type. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .NameError import NameError + +class UnboundLocalError(NameError): + """ Local name referenced but not bound to a value. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Exception import Exception + +class ValueError(Exception): + """ Inappropriate argument value (of correct type). """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .ValueError import ValueError + +class UnicodeError(ValueError): + """ Unicode related error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .UnicodeError import UnicodeError + +class UnicodeDecodeError(UnicodeError): + """ Unicode decoding error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception encoding""" + + end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception end""" + + object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception object""" + + reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception reason""" + + start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception start""" + + + +from .UnicodeError import UnicodeError + +class UnicodeEncodeError(UnicodeError): + """ Unicode encoding error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception encoding""" + + end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception end""" + + object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception object""" + + reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception reason""" + + start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception start""" + + + +from .UnicodeError import UnicodeError + +class UnicodeTranslateError(UnicodeError): + """ Unicode translation error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __str__(self, *args, **kwargs): # real signature unknown + """ Return str(self). """ + pass + + encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception encoding""" + + end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception end""" + + object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception object""" + + reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception reason""" + + start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """exception start""" + + + +from .Warning import Warning + +class UnicodeWarning(Warning): + """ + Base class for warnings about Unicode related problems, mostly + related to conversion problems. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .Warning import Warning + +class UserWarning(Warning): + """ Base class for warnings generated by user code. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .ArithmeticError import ArithmeticError + +class ZeroDivisionError(ArithmeticError): + """ Second argument to a division or modulo operation was zero. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + +from .object import object + +class zip(object): + """ + zip(iter1 [,iter2 [...]]) --> zip object + + Return a zip object whose .__next__() method returns a tuple where + the i-th element comes from the i-th iterable argument. The .__next__() + method continues until the shortest iterable in the argument sequence + is exhausted and then it raises StopIteration. + """ + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __init__(self, iter1, iter2=None, *some): # real signature unknown; restored from __doc__ + pass + + def __iter__(self, *args, **kwargs): # real signature unknown + """ Implement iter(self). """ + pass + + @staticmethod # known case of __new__ + def __new__(*args, **kwargs): # real signature unknown + """ Create and return a new object. See help(type) for accurate signature. """ + pass + + def __next__(self, *args, **kwargs): # real signature unknown + """ Implement next(self). """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + +from .object import object + +class __loader__(object): + """ + Meta path import for built-in modules. + + All methods are either class or static methods to avoid the need to + instantiate the class. + """ + def find_module(self, *args, **kwargs): # real signature unknown + """ + Find the built-in module. + + If 'path' is ever specified then the search is considered a failure. + + This method is deprecated. Use find_spec() instead. + """ + pass + + def find_spec(self, *args, **kwargs): # real signature unknown + pass + + def get_code(self, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have code objects. """ + pass + + def get_source(self, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have source code. """ + pass + + def is_package(self, *args, **kwargs): # real signature unknown + """ Return False as built-in modules are never packages. """ + pass + + def load_module(self, *args, **kwargs): # real signature unknown + """ Load a built-in module. """ + pass + + def module_repr(module): # reliably restored by inspect + """ + Return repr for the module. + + The method is deprecated. The import machinery does the job itself. + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """list of weak references to the object (if defined)""" + + + __dict__ = None # (!) real value is '' + + +# variables with complex values + +Ellipsis = None # (!) real value is '' + +NotImplemented = None # (!) real value is '' + +__spec__ = None # (!) real value is '' + diff --git a/python/testData/MockSdk3.4/python_stubs/sys.py b/python/testData/MockSdk3.4/python_stubs/sys.py new file mode 100644 index 000000000000..a64198bc33fa --- /dev/null +++ b/python/testData/MockSdk3.4/python_stubs/sys.py @@ -0,0 +1,601 @@ +# encoding: utf-8 +# module sys +# from (built-in) +# by generator 1.135 +""" +This module provides access to some objects used or maintained by the +interpreter and to functions that interact strongly with the interpreter. + +Dynamic objects: + +argv -- command line arguments; argv[0] is the script pathname if known +path -- module search path; path[0] is the script directory, else '' +modules -- dictionary of loaded modules + +displayhook -- called to show results in an interactive session +excepthook -- called to handle any uncaught exception other than SystemExit + To customize printing in an interactive session or to install a custom + top-level exception handler, assign other functions to replace these. + +stdin -- standard input file object; used by input() +stdout -- standard output file object; used by print() +stderr -- standard error object; used for error messages + By assigning other file objects (or objects that behave like files) + to these, it is possible to redirect all of the interpreter's I/O. + +last_type -- type of last uncaught exception +last_value -- value of last uncaught exception +last_traceback -- traceback of last uncaught exception + These three are only available in an interactive session after a + traceback has been printed. + +Static objects: + +builtin_module_names -- tuple of module names built into this interpreter +copyright -- copyright notice pertaining to this interpreter +exec_prefix -- prefix used to find the machine-specific Python library +executable -- absolute path of the executable binary of the Python interpreter +float_info -- a struct sequence with information about the float implementation. +float_repr_style -- string indicating the style of repr() output for floats +hash_info -- a struct sequence with information about the hash algorithm. +hexversion -- version information encoded as a single integer +implementation -- Python implementation information. +int_info -- a struct sequence with information about the int implementation. +maxsize -- the largest supported length of containers. +maxunicode -- the value of the largest Unicode codepoint +platform -- platform identifier +prefix -- prefix used to find the Python library +thread_info -- a struct sequence with information about the thread implementation. +version -- the version of this interpreter as a string +version_info -- version information as a named tuple +dllhandle -- [Windows only] integer handle of the Python DLL +winver -- [Windows only] version number of the Python DLL +__stdin__ -- the original stdin; don't touch! +__stdout__ -- the original stdout; don't touch! +__stderr__ -- the original stderr; don't touch! +__displayhook__ -- the original displayhook; don't touch! +__excepthook__ -- the original excepthook; don't touch! + +Functions: + +displayhook() -- print an object to the screen, and save it in builtins._ +excepthook() -- print an exception and its traceback to sys.stderr +exc_info() -- return thread-safe information about the current exception +exit() -- exit the interpreter by raising SystemExit +getdlopenflags() -- returns flags to be used for dlopen() calls +getprofile() -- get the global profiling function +getrefcount() -- return the reference count for an object (plus one :-) +getrecursionlimit() -- return the max recursion depth for the interpreter +getsizeof() -- return the size of an object in bytes +gettrace() -- get the global debug tracing function +setcheckinterval() -- control how often the interpreter checks for events +setdlopenflags() -- set the flags to be used for dlopen() calls +setprofile() -- set the global profiling function +setrecursionlimit() -- set the max recursion depth for the interpreter +settrace() -- set the global debug tracing function +""" +# no imports + +# Variables with simple values + +api_version = 1013 + +base_exec_prefix = 'C:\\Python34' + +base_prefix = 'C:\\Python34' + +byteorder = 'little' + +copyright = 'Copyright (c) 2001-2014 Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 BeOpen.com.\nAll Rights Reserved.\n\nCopyright (c) 1995-2001 Corporation for National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved.' + +dllhandle = 1705771008 + +dont_write_bytecode = False + +executable = 'C:\\Python34\\python.exe' + +exec_prefix = 'C:\\Python34' + +float_repr_style = 'short' + +hexversion = 50594288 + +maxsize = 2147483647 +maxunicode = 1114111 + +platform = 'win32' + +prefix = 'C:\\Python34' + +version = '3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]' + +winver = '3.4' + +_home = None + +__egginsert = 1 +__plen = 5 + +# functions + +def callstats(): # real signature unknown; restored from __doc__ + """ + callstats() -> tuple of integers + + Return a tuple of function call statistics, if CALL_PROFILE was defined + when Python was built. Otherwise, return None. + + When enabled, this function returns detailed, implementation-specific + details about the number of function calls executed. The return value is + a 11-tuple where the entries in the tuple are counts of: + 0. all function calls + 1. calls to PyFunction_Type objects + 2. PyFunction calls that do not create an argument tuple + 3. PyFunction calls that do not create an argument tuple + and bypass PyEval_EvalCodeEx() + 4. PyMethod calls + 5. PyMethod calls on bound methods + 6. PyType calls + 7. PyCFunction calls + 8. generator calls + 9. All other calls + 10. Number of stack pops performed by call_function() + """ + return () + +def call_tracing(func, args): # real signature unknown; restored from __doc__ + """ + call_tracing(func, args) -> object + + Call func(*args), while tracing is enabled. The tracing state is + saved, and restored afterwards. This is intended to be called from + a debugger from a checkpoint, to recursively debug some other code. + """ + return object() + +def displayhook(p_object): # real signature unknown; restored from __doc__ + """ + displayhook(object) -> None + + Print an object to sys.stdout and also save it in builtins._ + """ + pass + +def excepthook(exctype, value, traceback): # real signature unknown; restored from __doc__ + """ + excepthook(exctype, value, traceback) -> None + + Handle an exception by displaying it with a traceback on sys.stderr. + """ + pass + +def exc_info(): # real signature unknown; restored from __doc__ + """ + exc_info() -> (type, value, traceback) + + Return information about the most recent exception caught by an except + clause in the current stack frame or in an older stack frame. + """ + pass + +def exit(status=None): # real signature unknown; restored from __doc__ + """ + exit([status]) + + Exit the interpreter by raising SystemExit(status). + If the status is omitted or None, it defaults to zero (i.e., success). + If the status is an integer, it will be used as the system exit status. + If it is another kind of object, it will be printed and the system + exit status will be one (i.e., failure). + """ + pass + +def getallocatedblocks(): # real signature unknown; restored from __doc__ + """ + getallocatedblocks() -> integer + + Return the number of memory blocks currently allocated, regardless of their + size. + """ + return 0 + +def getcheckinterval(): # real signature unknown; restored from __doc__ + """ getcheckinterval() -> current check interval; see setcheckinterval(). """ + pass + +def getdefaultencoding(): # real signature unknown; restored from __doc__ + """ + getdefaultencoding() -> string + + Return the current default string encoding used by the Unicode + implementation. + """ + return "" + +def getfilesystemencoding(): # real signature unknown; restored from __doc__ + """ + getfilesystemencoding() -> string + + Return the encoding used to convert Unicode filenames in + operating system filenames. + """ + return "" + +def getprofile(): # real signature unknown; restored from __doc__ + """ + getprofile() + + Return the profiling function set with sys.setprofile. + See the profiler chapter in the library manual. + """ + pass + +def getrecursionlimit(): # real signature unknown; restored from __doc__ + """ + getrecursionlimit() + + Return the current value of the recursion limit, the maximum depth + of the Python interpreter stack. This limit prevents infinite + recursion from causing an overflow of the C stack and crashing Python. + """ + pass + +def getrefcount(p_object): # real signature unknown; restored from __doc__ + """ + getrefcount(object) -> integer + + Return the reference count of object. The count returned is generally + one higher than you might expect, because it includes the (temporary) + reference as an argument to getrefcount(). + """ + return 0 + +def getsizeof(p_object, default): # real signature unknown; restored from __doc__ + """ + getsizeof(object, default) -> int + + Return the size of object in bytes. + """ + return 0 + +def getswitchinterval(): # real signature unknown; restored from __doc__ + """ getswitchinterval() -> current thread switch interval; see setswitchinterval(). """ + pass + +def gettrace(): # real signature unknown; restored from __doc__ + """ + gettrace() + + Return the global debug tracing function set with sys.settrace. + See the debugger chapter in the library manual. + """ + pass + +def getwindowsversion(): # real signature unknown; restored from __doc__ + """ + getwindowsversion() + + Return information about the running version of Windows as a named tuple. + The members are named: major, minor, build, platform, service_pack, + service_pack_major, service_pack_minor, suite_mask, and product_type. For + backward compatibility, only the first 5 items are available by indexing. + All elements are numbers, except service_pack which is a string. Platform + may be 0 for win32s, 1 for Windows 9x/ME, 2 for Windows NT/2000/XP/Vista/7, + 3 for Windows CE. Product_type may be 1 for a workstation, 2 for a domain + controller, 3 for a server. + """ + pass + +def intern(string): # real signature unknown; restored from __doc__ + """ + intern(string) -> string + + ``Intern'' the given string. This enters the string in the (global) + table of interned strings whose purpose is to speed up dictionary lookups. + Return the string itself or the previously interned string object with the + same value. + """ + return "" + +def setcheckinterval(n): # real signature unknown; restored from __doc__ + """ + setcheckinterval(n) + + Tell the Python interpreter to check for asynchronous events every + n instructions. This also affects how often thread switches occur. + """ + pass + +def setprofile(function): # real signature unknown; restored from __doc__ + """ + setprofile(function) + + Set the profiling function. It will be called on each function call + and return. See the profiler chapter in the library manual. + """ + pass + +def setrecursionlimit(n): # real signature unknown; restored from __doc__ + """ + setrecursionlimit(n) + + Set the maximum depth of the Python interpreter stack to n. This + limit prevents infinite recursion from causing an overflow of the C + stack and crashing Python. The highest possible limit is platform- + dependent. + """ + pass + +def setswitchinterval(n): # real signature unknown; restored from __doc__ + """ + setswitchinterval(n) + + Set the ideal thread switching delay inside the Python interpreter + The actual frequency of switching threads can be lower if the + interpreter executes long sequences of uninterruptible code + (this is implementation-specific and workload-dependent). + + The parameter must represent the desired switching delay in seconds + A typical value is 0.005 (5 milliseconds). + """ + pass + +def settrace(function): # real signature unknown; restored from __doc__ + """ + settrace(function) + + Set the global debug tracing function. It will be called on each + function call. See the debugger chapter in the library manual. + """ + pass + +def _clear_type_cache(): # real signature unknown; restored from __doc__ + """ + _clear_type_cache() -> None + Clear the internal type lookup cache. + """ + pass + +def _current_frames(): # real signature unknown; restored from __doc__ + """ + _current_frames() -> dictionary + + Return a dictionary mapping each current thread T's thread id to T's + current stack frame. + + This function should be used for specialized purposes only. + """ + return {} + +def _debugmallocstats(): # real signature unknown; restored from __doc__ + """ + _debugmallocstats() + + Print summary info to stderr about the state of + pymalloc's structures. + + In Py_DEBUG mode, also perform some expensive internal consistency + checks. + """ + pass + +def _getframe(depth=None): # real signature unknown; restored from __doc__ + """ + _getframe([depth]) -> frameobject + + Return a frame object from the call stack. If optional integer depth is + given, return the frame object that many calls below the top of the stack. + If that is deeper than the call stack, ValueError is raised. The default + for depth is zero, returning the frame at the top of the call stack. + + This function should be used for internal and specialized + purposes only. + """ + pass + +def __displayhook__(*args, **kwargs): # real signature unknown + """ + displayhook(object) -> None + + Print an object to sys.stdout and also save it in builtins._ + """ + pass + +def __excepthook__(*args, **kwargs): # real signature unknown + """ + excepthook(exctype, value, traceback) -> None + + Handle an exception by displaying it with a traceback on sys.stderr. + """ + pass + +def __interactivehook__(): # reliably restored by inspect + # no doc + pass + +# classes + +from .object import object + +class __loader__(object): + """ + Meta path import for built-in modules. + + All methods are either class or static methods to avoid the need to + instantiate the class. + """ + @classmethod + def find_module(cls, *args, **kwargs): # real signature unknown + """ + Find the built-in module. + + If 'path' is ever specified then the search is considered a failure. + + This method is deprecated. Use find_spec() instead. + """ + pass + + @classmethod + def find_spec(cls, *args, **kwargs): # real signature unknown + pass + + @classmethod + def get_code(cls, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have code objects. """ + pass + + @classmethod + def get_source(cls, *args, **kwargs): # real signature unknown + """ Return None as built-in modules do not have source code. """ + pass + + @classmethod + def is_package(cls, *args, **kwargs): # real signature unknown + """ Return False as built-in modules are never packages. """ + pass + + @classmethod + def load_module(cls, *args, **kwargs): # real signature unknown + """ Load a built-in module. """ + pass + + def module_repr(module): # reliably restored by inspect + """ + Return repr for the module. + + The method is deprecated. The import machinery does the job itself. + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """list of weak references to the object (if defined)""" + + + __dict__ = None # (!) real value is '' + + +# variables with complex values + +argv = [] # real value of type skipped + +builtin_module_names = () # real value of type skipped + +flags = ( + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, +) + +float_info = ( + 1.7976931348623157e+308, + 1024, + 308, + 2.2250738585072014e-308, + -1021, + -307, + 15, + 53, + 2.220446049250313e-16, + 2, + 1, +) + +hash_info = ( + 32, + 2147483647, + 314159, + 0, + 1000003, + 'siphash24', + 64, + 128, + 0, +) + +implementation = None # (!) real value is '' + +int_info = ( + 15, + 2, +) + +meta_path = [ + __loader__, + None, # (!) real value is '' + None, # (!) real value is '' + None, # (!) real value is '' +] + +modules = {} # real value of type skipped + +path = [ + 'C:\\work\\ultimate\\out\\classes\\production\\python-helpers', + 'C:\\Python34\\lib\\site-packages\\setuptools-4.0.1-py3.4.egg', + 'C:\\Windows\\system32\\python34.zip', + 'C:\\Python34\\DLLs', + 'C:\\Python34\\lib', + 'C:\\Python34', + 'C:\\Python34\\lib\\site-packages', +] + +path_hooks = [ + None, # (!) real value is '' + None, # (!) real value is '' +] + +path_importer_cache = {} # real value of type skipped + +stderr = None # (!) real value is '' + +stdin = None # (!) real value is '' + +stdout = None # (!) real value is '' + +thread_info = ( + 'nt', + None, + None, +) + +version_info = ( + 3, + 4, + 1, + 'final', + 0, +) + +warnoptions = [] + +_mercurial = ( + 'CPython', + 'v3.4.1', + 'c0e311e010fc', +) + +_xoptions = {} + +__spec__ = None # (!) real value is '' + +__stderr__ = stderr + +__stdin__ = stdin + +__stdout__ = stdout + +# intermittent names +exc_value = Exception() +exc_traceback=None diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java index 222a3109716a..dbaf8b67059a 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java @@ -82,8 +82,8 @@ import java.util.*; */ @TestDataPath("$CONTENT_ROOT/../testData/") public abstract class PyTestCase extends UsefulTestCase { - public static String PYTHON_2_MOCK_SDK = "2.7"; - public static String PYTHON_3_MOCK_SDK = "3.2"; + public static final String PYTHON_2_MOCK_SDK = "2.7"; + public static final String PYTHON_3_MOCK_SDK = "3.4"; private static final PyLightProjectDescriptor ourPyDescriptor = new PyLightProjectDescriptor(PYTHON_2_MOCK_SDK); protected static final PyLightProjectDescriptor ourPy3Descriptor = new PyLightProjectDescriptor(PYTHON_3_MOCK_SDK);