From 26ecc11963f7fc89fadcfddd91df5f8c549c6e29 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Mon, 30 Sep 2019 16:57:42 +0300 Subject: [PATCH] Revert fec8e404 and 6a55c56f in order to fix building dmg GitOrigin-RevId: 02f6104ca8bbd91cbac617af07161f46cc68159e --- python/helpers/python-skeletons/logging.py | 11 + .../multiprocessing/__init__.py | 280 + .../multiprocessing/managers.py | 76 + python/helpers/python-skeletons/sys.py | 9 + python/testData/MockSdk2.7/Lib/_abcoll.py | 601 ++ python/testData/MockSdk2.7/Lib/collections.py | 668 ++ python/testData/MockSdk2.7/Lib/io.py | 98 + python/testData/MockSdk2.7/Lib/re.py | 326 + .../MockSdk2.7/python_stubs/__builtin__.py | 5140 +++++++++++++++ .../testData/MockSdk2.7/python_stubs/_io.py | 1347 ++++ .../MockSdk2.7/python_stubs/datetime.py | 627 ++ .../MockSdk2.7/python_stubs/exceptions.py | 769 +++ .../testData/MockSdk2.7/python_stubs/sys.py | 463 ++ .../MockSdk3.7/Lib/_collections_abc.py | 1011 +++ .../MockSdk3.7/Lib/collections/__init__.py | 1279 ++++ .../MockSdk3.7/Lib/collections/abc.py | 2 + python/testData/MockSdk3.7/Lib/datetime.py | 2442 +++++++ python/testData/MockSdk3.7/Lib/io.py | 99 + python/testData/MockSdk3.7/Lib/re.py | 366 + .../testData/MockSdk3.7/python_stubs/_io.py | 1613 +++++ .../MockSdk3.7/python_stubs/builtins.py | 5858 +++++++++++++++++ .../testData/MockSdk3.7/python_stubs/sys.py | 704 ++ .../PyArgumentEqualDefaultInspection/test.py | 2 +- .../MethodsForLoggingExceptions/b.py | 5 + .../MethodsForLoggingExceptions/logging.py | 9 + .../NonexistentLoggerMethod/a.py | 4 + .../NonexistentLoggerMethod/logging.py | 6 + .../com/jetbrains/python/PyAddImportTest.java | 34 +- .../python/PyClassNameCompletionTest.java | 16 +- .../python/PyLineBreakpointTypeTest.kt | 17 +- .../com/jetbrains/python/PyNavigationTest.kt | 8 +- .../python/PyOptimizeImportsTest.java | 59 +- .../com/jetbrains/python/PyQuickDocTest.java | 28 +- .../python/PythonInspectionsTest.java | 15 +- .../com/jetbrains/python/PythonMockSdk.java | 26 +- .../jetbrains/python/fixtures/PyTestCase.java | 34 +- .../PyArgumentListInspectionTest.java | 5 + .../PyUnresolvedReferencesInspectionTest.java | 5 + .../quickFixes/PyAddImportQuickFixTest.java | 29 +- .../refactoring/PyInlineFunctionTest.kt | 6 +- 40 files changed, 23879 insertions(+), 218 deletions(-) create mode 100644 python/helpers/python-skeletons/logging.py create mode 100644 python/helpers/python-skeletons/multiprocessing/__init__.py create mode 100644 python/helpers/python-skeletons/multiprocessing/managers.py create mode 100644 python/helpers/python-skeletons/sys.py create mode 100644 python/testData/MockSdk2.7/Lib/_abcoll.py create mode 100644 python/testData/MockSdk2.7/Lib/collections.py create mode 100644 python/testData/MockSdk2.7/Lib/io.py create mode 100644 python/testData/MockSdk2.7/Lib/re.py create mode 100644 python/testData/MockSdk2.7/python_stubs/__builtin__.py create mode 100644 python/testData/MockSdk2.7/python_stubs/_io.py create mode 100644 python/testData/MockSdk2.7/python_stubs/datetime.py create mode 100644 python/testData/MockSdk2.7/python_stubs/exceptions.py create mode 100644 python/testData/MockSdk2.7/python_stubs/sys.py create mode 100644 python/testData/MockSdk3.7/Lib/_collections_abc.py create mode 100644 python/testData/MockSdk3.7/Lib/collections/__init__.py create mode 100644 python/testData/MockSdk3.7/Lib/collections/abc.py create mode 100644 python/testData/MockSdk3.7/Lib/datetime.py create mode 100644 python/testData/MockSdk3.7/Lib/io.py create mode 100644 python/testData/MockSdk3.7/Lib/re.py create mode 100644 python/testData/MockSdk3.7/python_stubs/_io.py create mode 100644 python/testData/MockSdk3.7/python_stubs/builtins.py create mode 100644 python/testData/MockSdk3.7/python_stubs/sys.py create mode 100644 python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/b.py create mode 100644 python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py create mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py create mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py diff --git a/python/helpers/python-skeletons/logging.py b/python/helpers/python-skeletons/logging.py new file mode 100644 index 000000000000..f121dbe263c4 --- /dev/null +++ b/python/helpers/python-skeletons/logging.py @@ -0,0 +1,11 @@ +"""Skeleton for 'logging' stdlib module.""" + +import logging + + +def getLogger(name=None): + """ + :type name: string + :rtype: logging.Logger + """ + pass diff --git a/python/helpers/python-skeletons/multiprocessing/__init__.py b/python/helpers/python-skeletons/multiprocessing/__init__.py new file mode 100644 index 000000000000..85329565ed39 --- /dev/null +++ b/python/helpers/python-skeletons/multiprocessing/__init__.py @@ -0,0 +1,280 @@ +"""Skeleton for 'multiprocessing' stdlib module.""" + + +from multiprocessing.pool import Pool + + +class Process(object): + def __init__(self, group=None, target=None, name=None, args=(), kwargs={}): + self.name = '' + self.daemon = False + self.authkey = None + self.exitcode = None + self.ident = 0 + self.pid = 0 + self.sentinel = None + + def run(self): + pass + + def start(self): + pass + + def terminate(self): + pass + + def join(self, timeout=None): + pass + + def is_alive(self): + return False + + +class ProcessError(Exception): + pass + + +class BufferTooShort(ProcessError): + pass + + +class AuthenticationError(ProcessError): + pass + + +class TimeoutError(ProcessError): + pass + + +class Connection(object): + def send(self, obj): + pass + + def recv(self): + pass + + def fileno(self): + return 0 + + def close(self): + pass + + def poll(self, timeout=None): + pass + + def send_bytes(self, buffer, offset=-1, size=-1): + pass + + def recv_bytes(self, maxlength=-1): + pass + + def recv_bytes_into(self, buffer, offset=-1): + pass + + def __enter__(self): + pass + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + + +def Pipe(duplex=True): + return Connection(), Connection() + + +class Queue(object): + def __init__(self, maxsize=-1): + self._maxsize = maxsize + + def qsize(self): + return 0 + + def empty(self): + return False + + def full(self): + return False + + def put(self, obj, block=True, timeout=None): + pass + + def put_nowait(self, obj): + pass + + def get(self, block=True, timeout=None): + pass + + def get_nowait(self): + pass + + def close(self): + pass + + def join_thread(self): + pass + + def cancel_join_thread(self): + pass + + +class SimpleQueue(object): + def empty(self): + return False + + def get(self): + pass + + def put(self, item): + pass + + +class JoinableQueue(multiprocessing.Queue): + def task_done(self): + pass + + def join(self): + pass + + +def active_children(): + """ + :rtype: list[multiprocessing.Process] + """ + return [] + + +def cpu_count(): + return 0 + + +def current_process(): + """ + :rtype: multiprocessing.Process + """ + return Process() + + +def freeze_support(): + pass + + +def get_all_start_methods(): + return [] + + +def get_context(method=None): + pass + + +def get_start_method(allow_none=False): + pass + + +def set_executable(path): + pass + + +def set_start_method(method): + pass + + +class Barrier(object): + def __init__(self, parties, action=None, timeout=None): + self.parties = parties + self.n_waiting = 0 + self.broken = False + + def wait(self, timeout=None): + pass + + def reset(self): + pass + + def abort(self): + pass + + +class Semaphore(object): + def __init__(self, value=1): + pass + + def acquire(self, blocking=True, timeout=None): + pass + + def release(self): + pass + + +class BoundedSemaphore(multiprocessing.Semaphore): + pass + + +class Condition(object): + def __init__(self, lock=None): + pass + + def acquire(self, *args): + pass + + def release(self): + pass + + def wait(self, timeout=None): + pass + + def wait_for(self, predicate, timeout=None): + pass + + def notify(self, n=1): + pass + + def notify_all(self): + pass + + +class Event(object): + def is_set(self): + return False + + def set(self): + pass + + def clear(self): + pass + + def wait(self, timeout=None): + pass + + +class Lock(object): + def acquire(self, blocking=True, timeout=-1): + pass + + def release(self): + pass + + +class RLock(object): + def acquire(self, blocking=True, timeout=-1): + pass + + def release(self): + pass + + def __enter__(self): + pass + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + + +def Value(typecode_or_type, *args, **kwargs): + pass + + +def Array(typecode_or_type, size_or_initializer, lock=True): + pass + + +def Manager(): + return multiprocessing.SyncManager() diff --git a/python/helpers/python-skeletons/multiprocessing/managers.py b/python/helpers/python-skeletons/multiprocessing/managers.py new file mode 100644 index 000000000000..53cf1b5de3f1 --- /dev/null +++ b/python/helpers/python-skeletons/multiprocessing/managers.py @@ -0,0 +1,76 @@ +"""Skeleton for 'multiprocessing.managers' stdlib module.""" + + +import threading +import queue +import multiprocessing +import multiprocessing.managers + + +class BaseManager(object): + def __init__(self, address=None, authkey=None): + self.address = address + + def start(self, initializer=None, initargs=None): + pass + + def get_server(self): + pass + + def connect(self): + pass + + def shutdown(self): + pass + + @classmethod + def register(cls, typeid, callable=None, proxytype=None, exposed=None, + method_to_typeid=None, create_method=None): + pass + + def __enter__(self): + pass + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + + +class SyncManager(multiprocessing.managers.BaseManager): + def Barrier(self, parties, action=None, timeout=None): + return threading.Barrier(parties, action, timeout) + + def BoundedSemaphore(self, value=None): + return threading.BoundedSemaphore(value) + + def Condition(self, lock=None): + return threading.Condition(lock) + + def Event(self): + return threading.Event() + + def Lock(self): + return threading.Lock() + + def Namespace(self): + pass + + def Queue(self, maxsize=None): + return queue.Queue() + + def RLock(self): + return threading.RLock() + + def Semaphore(self, value=None): + return threading.Semaphore(value) + + def Array(self, typecode, sequence): + pass + + def Value(self, typecode, value): + pass + + def dict(self, mapping_or_sequence): + pass + + def list(self, sequence): + pass diff --git a/python/helpers/python-skeletons/sys.py b/python/helpers/python-skeletons/sys.py new file mode 100644 index 000000000000..03956411c38e --- /dev/null +++ b/python/helpers/python-skeletons/sys.py @@ -0,0 +1,9 @@ +"""Skeleton for 'sys' stdlib module.""" + + +def getsizeof(object, default=None): + """ + :type default: T | None + :rtype: int | T + """ + return 0 diff --git a/python/testData/MockSdk2.7/Lib/_abcoll.py b/python/testData/MockSdk2.7/Lib/_abcoll.py new file mode 100644 index 000000000000..e7376e4a56af --- /dev/null +++ b/python/testData/MockSdk2.7/Lib/_abcoll.py @@ -0,0 +1,601 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) for collections, according to PEP 3119. + +DON'T USE THIS MODULE DIRECTLY! The classes here should be imported +via collections; they are defined here only to alleviate certain +bootstrapping issues. Unit tests are in test_collections. +""" + +from abc import ABCMeta, abstractmethod +import sys + +__all__ = ["Hashable", "Iterable", "Iterator", + "Sized", "Container", "Callable", + "Set", "MutableSet", + "Mapping", "MutableMapping", + "MappingView", "KeysView", "ItemsView", "ValuesView", + "Sequence", "MutableSequence", + ] + +### ONE-TRICK PONIES ### + +def _hasattr(C, attr): + try: + return any(attr in B.__dict__ for B in C.__mro__) + except AttributeError: + # Old-style class + return hasattr(C, attr) + + +class Hashable: + __metaclass__ = ABCMeta + + @abstractmethod + def __hash__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Hashable: + try: + for B in C.__mro__: + if "__hash__" in B.__dict__: + if B.__dict__["__hash__"]: + return True + break + except AttributeError: + # Old-style class + if getattr(C, "__hash__", None): + return True + return NotImplemented + + +class Iterable: + __metaclass__ = ABCMeta + + @abstractmethod + def __iter__(self): + while False: + yield None + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterable: + if _hasattr(C, "__iter__"): + return True + return NotImplemented + +Iterable.register(str) + + +class Iterator(Iterable): + + @abstractmethod + def next(self): + raise StopIteration + + def __iter__(self): + return self + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterator: + if _hasattr(C, "next") and _hasattr(C, "__iter__"): + return True + return NotImplemented + + +class Sized: + __metaclass__ = ABCMeta + + @abstractmethod + def __len__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Sized: + if _hasattr(C, "__len__"): + return True + return NotImplemented + + +class Container: + __metaclass__ = ABCMeta + + @abstractmethod + def __contains__(self, x): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Container: + if _hasattr(C, "__contains__"): + return True + return NotImplemented + + +class Callable: + __metaclass__ = ABCMeta + + @abstractmethod + def __call__(self, *args, **kwds): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Callable: + if _hasattr(C, "__call__"): + return True + return NotImplemented + + +### SETS ### + + +class Set(Sized, Iterable, Container): + """A set is a finite, iterable container. + + This class provides concrete generic implementations of all + methods except for __contains__, __iter__ and __len__. + + To override the comparisons (presumably for speed, as the + semantics are fixed), all you have to do is redefine __le__ and + then the other operations will automatically follow suit. + """ + + def __le__(self, other): + if not isinstance(other, Set): + return NotImplemented + if len(self) > len(other): + return False + for elem in self: + if elem not in other: + return False + return True + + def __lt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) < len(other) and self.__le__(other) + + def __gt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return other < self + + def __ge__(self, other): + if not isinstance(other, Set): + return NotImplemented + return other <= self + + def __eq__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) == len(other) and self.__le__(other) + + def __ne__(self, other): + return not (self == other) + + @classmethod + def _from_iterable(cls, it): + '''Construct an instance of the class from any iterable input. + + Must override this method if the class constructor signature + does not accept an iterable for an input. + ''' + return cls(it) + + def __and__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + return self._from_iterable(value for value in other if value in self) + + def isdisjoint(self, other): + for value in other: + if value in self: + return False + return True + + def __or__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + chain = (e for s in (self, other) for e in s) + return self._from_iterable(chain) + + def __sub__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return self._from_iterable(value for value in self + if value not in other) + + def __xor__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return (self - other) | (other - self) + + # Sets are not hashable by default, but subclasses can change this + __hash__ = None + + def _hash(self): + """Compute the hash value of a set. + + Note that we don't define __hash__: not all sets are hashable. + But if you define a hashable set type, its __hash__ should + call this function. + + This must be compatible __eq__. + + All sets ought to compare equal if they contain the same + elements, regardless of how they are implemented, and + regardless of the order of the elements; so there's not much + freedom for __eq__ or __hash__. We match the algorithm used + by the built-in frozenset type. + """ + MAX = sys.maxint + MASK = 2 * MAX + 1 + n = len(self) + h = 1927868237 * (n + 1) + h &= MASK + for x in self: + hx = hash(x) + h ^= (hx ^ (hx << 16) ^ 89869747) * 3644798167 + h &= MASK + h = h * 69069 + 907133923 + h &= MASK + if h > MAX: + h -= MASK + 1 + if h == -1: + h = 590923713 + return h + +Set.register(frozenset) + + +class MutableSet(Set): + + @abstractmethod + def add(self, value): + """Add an element.""" + raise NotImplementedError + + @abstractmethod + def discard(self, value): + """Remove an element. Do not raise an exception if absent.""" + raise NotImplementedError + + def remove(self, value): + """Remove an element. If not a member, raise a KeyError.""" + if value not in self: + raise KeyError(value) + self.discard(value) + + def pop(self): + """Return the popped value. Raise KeyError if empty.""" + it = iter(self) + try: + value = next(it) + except StopIteration: + raise KeyError + self.discard(value) + return value + + def clear(self): + """This is slow (creates N new iterators!) but effective.""" + try: + while True: + self.pop() + except KeyError: + pass + + def __ior__(self, it): + for value in it: + self.add(value) + return self + + def __iand__(self, it): + for value in (self - it): + self.discard(value) + return self + + def __ixor__(self, it): + if it is self: + self.clear() + else: + if not isinstance(it, Set): + it = self._from_iterable(it) + for value in it: + if value in self: + self.discard(value) + else: + self.add(value) + return self + + def __isub__(self, it): + if it is self: + self.clear() + else: + for value in it: + self.discard(value) + return self + +MutableSet.register(set) + + +### MAPPINGS ### + + +class Mapping(Sized, Iterable, Container): + + @abstractmethod + def __getitem__(self, key): + raise KeyError + + def get(self, key, default=None): + try: + return self[key] + except KeyError: + return default + + def __contains__(self, key): + try: + self[key] + except KeyError: + return False + else: + return True + + def iterkeys(self): + return iter(self) + + def itervalues(self): + for key in self: + yield self[key] + + def iteritems(self): + for key in self: + yield (key, self[key]) + + def keys(self): + return list(self) + + def items(self): + return [(key, self[key]) for key in self] + + def values(self): + return [self[key] for key in self] + + # Mappings are not hashable by default, but subclasses can change this + __hash__ = None + + def __eq__(self, other): + if not isinstance(other, Mapping): + return NotImplemented + return dict(self.items()) == dict(other.items()) + + def __ne__(self, other): + return not (self == other) + +class MappingView(Sized): + + def __init__(self, mapping): + self._mapping = mapping + + def __len__(self): + return len(self._mapping) + + def __repr__(self): + return '{0.__class__.__name__}({0._mapping!r})'.format(self) + + +class KeysView(MappingView, Set): + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, key): + return key in self._mapping + + def __iter__(self): + for key in self._mapping: + yield key + + +class ItemsView(MappingView, Set): + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, item): + key, value = item + try: + v = self._mapping[key] + except KeyError: + return False + else: + return v == value + + def __iter__(self): + for key in self._mapping: + yield (key, self._mapping[key]) + + +class ValuesView(MappingView): + + def __contains__(self, value): + for key in self._mapping: + if value == self._mapping[key]: + return True + return False + + def __iter__(self): + for key in self._mapping: + yield self._mapping[key] + + +class MutableMapping(Mapping): + + @abstractmethod + def __setitem__(self, key, value): + raise KeyError + + @abstractmethod + def __delitem__(self, key): + raise KeyError + + __marker = object() + + def pop(self, key, default=__marker): + try: + value = self[key] + except KeyError: + if default is self.__marker: + raise + return default + else: + del self[key] + return value + + def popitem(self): + try: + key = next(iter(self)) + except StopIteration: + raise KeyError + value = self[key] + del self[key] + return key, value + + def clear(self): + try: + while True: + self.popitem() + except KeyError: + pass + + def update(*args, **kwds): + if len(args) > 2: + raise TypeError("update() takes at most 2 positional " + "arguments ({} given)".format(len(args))) + elif not args: + raise TypeError("update() takes at least 1 argument (0 given)") + self = args[0] + other = args[1] if len(args) >= 2 else () + + if isinstance(other, Mapping): + for key in other: + self[key] = other[key] + elif hasattr(other, "keys"): + for key in other.keys(): + self[key] = other[key] + else: + for key, value in other: + self[key] = value + for key, value in kwds.items(): + self[key] = value + + def setdefault(self, key, default=None): + try: + return self[key] + except KeyError: + self[key] = default + return default + +MutableMapping.register(dict) + + +### SEQUENCES ### + + +class Sequence(Sized, Iterable, Container): + """All the operations on a read-only sequence. + + Concrete subclasses must override __new__ or __init__, + __getitem__, and __len__. + """ + + @abstractmethod + def __getitem__(self, index): + raise IndexError + + def __iter__(self): + i = 0 + try: + while True: + v = self[i] + yield v + i += 1 + except IndexError: + return + + def __contains__(self, value): + for v in self: + if v == value: + return True + return False + + def __reversed__(self): + for i in reversed(range(len(self))): + yield self[i] + + def index(self, value): + for i, v in enumerate(self): + if v == value: + return i + raise ValueError + + def count(self, value): + return sum(1 for v in self if v == value) + +Sequence.register(tuple) +Sequence.register(basestring) +Sequence.register(buffer) +Sequence.register(xrange) + + +class MutableSequence(Sequence): + + @abstractmethod + def __setitem__(self, index, value): + raise IndexError + + @abstractmethod + def __delitem__(self, index): + raise IndexError + + @abstractmethod + def insert(self, index, value): + raise IndexError + + def append(self, value): + self.insert(len(self), value) + + def reverse(self): + n = len(self) + for i in range(n//2): + self[i], self[n-i-1] = self[n-i-1], self[i] + + def extend(self, values): + for v in values: + self.append(v) + + def pop(self, index=-1): + v = self[index] + del self[index] + return v + + def remove(self, value): + del self[self.index(value)] + + def __iadd__(self, values): + self.extend(values) + return self + +MutableSequence.register(list) diff --git a/python/testData/MockSdk2.7/Lib/collections.py b/python/testData/MockSdk2.7/Lib/collections.py new file mode 100644 index 000000000000..958e523b6c70 --- /dev/null +++ b/python/testData/MockSdk2.7/Lib/collections.py @@ -0,0 +1,668 @@ +__all__ = ['Counter', 'deque', 'defaultdict', 'namedtuple', 'OrderedDict'] +# For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. +# They should however be considered an integral part of collections.py. +from _abcoll import * +import _abcoll +__all__ += _abcoll.__all__ + +from _collections import deque, defaultdict +from operator import itemgetter as _itemgetter +from keyword import iskeyword as _iskeyword +import sys as _sys +import heapq as _heapq +from itertools import repeat as _repeat, chain as _chain, starmap as _starmap + +try: + from thread import get_ident as _get_ident +except ImportError: + from dummy_thread import get_ident as _get_ident + + +################################################################################ +### OrderedDict +################################################################################ + +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). + # Each link is stored as a list of length three: [PREV, NEXT, KEY]. + + 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.__root = root = [] # sentinel node + root[:] = [root, root, None] + self.__map = {} + self.__update(*args, **kwds) + + def __setitem__(self, key, value, PREV=0, NEXT=1, dict_setitem=dict.__setitem__): + '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: + root = self.__root + last = root[PREV] + last[NEXT] = root[PREV] = self.__map[key] = [last, root, key] + dict_setitem(self, key, value) + + def __delitem__(self, key, PREV=0, NEXT=1, 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_prev, link_next, key = self.__map.pop(key) + link_prev[NEXT] = link_next + link_next[PREV] = link_prev + + def __iter__(self): + 'od.__iter__() <==> iter(od)' + # Traverse the linked list in order. + NEXT, KEY = 1, 2 + 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. + PREV, KEY = 0, 2 + 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.' + for node in self.__map.itervalues(): + del node[:] + root = self.__root + root[:] = [root, root, None] + self.__map.clear() + dict.clear(self) + + # -- the following methods do not depend on the internal structure -- + + def keys(self): + 'od.keys() -> list of keys in od' + return list(self) + + def values(self): + 'od.values() -> list of values in od' + return [self[key] for key in self] + + def items(self): + 'od.items() -> list of (key, value) pairs in od' + return [(key, self[key]) for key in self] + + def iterkeys(self): + 'od.iterkeys() -> an iterator over the keys in od' + return iter(self) + + def itervalues(self): + 'od.itervalues -> an iterator over the values in od' + for k in self: + yield self[k] + + def iteritems(self): + 'od.iteritems -> an iterator over the (key, value) pairs in od' + for k in self: + yield (k, self[k]) + + update = MutableMapping.update + + __update = update # let subclasses override update without breaking __init__ + + __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 + + 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') + key = next(reversed(self) if last else iter(self)) + value = self.pop(key) + return key, value + + def __repr__(self, _repr_running={}): + 'od.__repr__() <==> repr(od)' + call_key = id(self), _get_ident() + if call_key in _repr_running: + return '...' + _repr_running[call_key] = 1 + try: + if not self: + return '%s()' % (self.__class__.__name__,) + return '%s(%r)' % (self.__class__.__name__, self.items()) + finally: + del _repr_running[call_key] + + def __reduce__(self): + 'Return state information for pickling' + items = [[k, self[k]] for k in self] + inst_dict = vars(self).copy() + for k in vars(OrderedDict()): + inst_dict.pop(k, None) + if inst_dict: + return (self.__class__, (items,), inst_dict) + return self.__class__, (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 len(self)==len(other) and self.items() == other.items() + return dict.__eq__(self, other) + + def __ne__(self, other): + 'od.__ne__(y) <==> od!=y' + return not self == other + + # -- the following methods support python 3.x style dictionary views -- + + def viewkeys(self): + "od.viewkeys() -> a set-like object providing a view on od's keys" + return KeysView(self) + + def viewvalues(self): + "od.viewvalues() -> an object providing a view on od's values" + return ValuesView(self) + + def viewitems(self): + "od.viewitems() -> a set-like object providing a view on od's items" + return ItemsView(self) + + +################################################################################ +### namedtuple +################################################################################ + +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) + + """ + + # Parse and validate the field names. Validation serves two purposes, + # generating informative error messages and preventing template injection attacks. + if isinstance(field_names, basestring): + field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas + field_names = tuple(map(str, field_names)) + if rename: + names = list(field_names) + seen = set() + for i, name in enumerate(names): + if (not all(c.isalnum() or c=='_' for c in name) or _iskeyword(name) + or not name or name[0].isdigit() or name.startswith('_') + or name in seen): + names[i] = '_%d' % i + seen.add(name) + field_names = tuple(names) + for name in (typename,) + field_names: + if not all(c.isalnum() or c=='_' for c in name): + raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name) + if _iskeyword(name): + raise ValueError('Type names and field names cannot be a keyword: %r' % name) + if name[0].isdigit(): + raise ValueError('Type names and field names cannot start with a number: %r' % name) + seen_names = 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_names: + raise ValueError('Encountered duplicate field name: %r' % name) + seen_names.add(name) + + # Create and fill-in the class template + numfields = len(field_names) + argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes + reprtxt = ', '.join('%s=%%r' % name for name in field_names) + template = '''class %(typename)s(tuple): + '%(typename)s(%(argtxt)s)' \n + __slots__ = () \n + _fields = %(field_names)r \n + def __new__(_cls, %(argtxt)s): + 'Create new instance of %(typename)s(%(argtxt)s)' + return _tuple.__new__(_cls, (%(argtxt)s)) \n + @classmethod + def _make(cls, iterable, new=tuple.__new__, len=len): + 'Make a new %(typename)s object from a sequence or iterable' + result = new(cls, iterable) + if len(result) != %(numfields)d: + raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result)) + return result \n + def __repr__(self): + 'Return a nicely formatted representation string' + return '%(typename)s(%(reprtxt)s)' %% self \n + def _asdict(self): + 'Return a new OrderedDict which maps field names to their values' + return OrderedDict(zip(self._fields, self)) \n + __dict__ = property(_asdict) \n + def _replace(_self, **kwds): + 'Return a new %(typename)s 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' %% kwds.keys()) + return result \n + def __getnewargs__(self): + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) \n\n''' % locals() + for i, name in enumerate(field_names): + template += " %s = _property(_itemgetter(%d), doc='Alias for field number %d')\n" % (name, i, i) + if verbose: + print template + + # Execute the template string in a temporary namespace and + # support tracing utilities by setting a value for frame.f_globals['__name__'] + namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename, + OrderedDict=OrderedDict, _property=property, _tuple=tuple) + try: + exec template in namespace + except SyntaxError, e: + raise SyntaxError(e.message + ':\n' + template) + result = namespace[typename] + + # For pickling to work, the __module__ variable needs to be set to the frame + # where the named tuple is created. Bypass this step in enviroments 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 +######################################################################## + +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(Counter, self).__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.iteritems(), key=_itemgetter(1), reverse=True) + return _heapq.nlargest(n, self.iteritems(), 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.iteritems())) + + # 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.iteritems(): + self[elem] = self_get(elem, 0) + count + else: + super(Counter, self).update(iterable) # fast path when counter is empty + else: + self_get = self.get + for elem in iterable: + self[elem] = self_get(elem, 0) + 1 + 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(Counter, self).__delitem__(elem) + + def __repr__(self): + if not self: + return '%s()' % self.__class__.__name__ + items = ', '.join(map('%r: %r'.__mod__, self.most_common())) + return '%s({%s})' % (self.__class__.__name__, items) + + # 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 + + +if __name__ == '__main__': + # verify that instances can be pickled + from cPickle 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 + TestResults = namedtuple('TestResults', 'failed attempted') + print TestResults(*doctest.testmod()) diff --git a/python/testData/MockSdk2.7/Lib/io.py b/python/testData/MockSdk2.7/Lib/io.py new file mode 100644 index 000000000000..5c429c6e745a --- /dev/null +++ b/python/testData/MockSdk2.7/Lib/io.py @@ -0,0 +1,98 @@ +"""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 throw 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. +""" +# New I/O library conforming to PEP 3116. + +# XXX edge cases when switching between reading/writing +# XXX need to support 1 meaning line-buffered +# XXX whenever an argument is None, use the default value +# XXX read/write ops should check readable/writable +# XXX buffered readinto should work with arbitrary buffer objects +# XXX use incremental encoder for text output, at least for UTF-16 and UTF-8-SIG +# XXX check writable, readable and seekable in appropriate places + + +__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 + +# 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 + +class RawIOBase(_io._RawIOBase, IOBase): + pass + +class BufferedIOBase(_io._BufferedIOBase, IOBase): + pass + +class TextIOBase(_io._TextIOBase, IOBase): + pass + +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/MockSdk2.7/Lib/re.py b/python/testData/MockSdk2.7/Lib/re.py new file mode 100644 index 000000000000..6a0174308969 --- /dev/null +++ b/python/testData/MockSdk2.7/Lib/re.py @@ -0,0 +1,326 @@ +# +# 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. + (?iLmsux) Set the 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 cache" + _cache.clear() + _cache_repl.clear() + +def template(pattern, flags=0): + "Compile a template pattern, returning a pattern object" + return _compile(pattern, flags|T) + +_alphanum = {} +for c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890': + _alphanum[c] = 1 +del c + +def escape(pattern): + "Escape all non-alphanumeric characters in pattern." + s = list(pattern) + alphanum = _alphanum + for i, c in enumerate(pattern): + if c not in alphanum: + if c == "\000": + s[i] = "\\000" + else: + s[i] = "\\" + c + return pattern[:0].join(s) + +# -------------------------------------------------------------------- +# internals + +_cache = {} +_cache_repl = {} + +_pattern_type = type(sre_compile.compile("", 0)) + +_MAXCACHE = 100 + +def _compile(*key): + # internal: compile pattern + cachekey = (type(key[0]),) + key + p = _cache.get(cachekey) + if p is not None: + return p + pattern, flags = key + 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" + try: + p = sre_compile.compile(pattern, flags) + except error, v: + raise error, v # invalid expression + if len(_cache) >= _MAXCACHE: + _cache.clear() + _cache[cachekey] = p + return p + +def _compile_repl(*key): + # internal: compile replacement pattern + p = _cache_repl.get(key) + if p is not None: + return p + repl, pattern = key + try: + p = sre_parse.parse_template(repl, pattern) + except error, v: + raise error, v # invalid expression + if len(_cache_repl) >= _MAXCACHE: + _cache_repl.clear() + _cache_repl[key] = 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 copy_reg + +def _pickle(p): + return _compile, (p.pattern, p.flags) + +copy_reg.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 hasattr(action, '__call__'): + 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/MockSdk2.7/python_stubs/__builtin__.py b/python/testData/MockSdk2.7/python_stubs/__builtin__.py new file mode 100644 index 000000000000..67e2121de1f1 --- /dev/null +++ b/python/testData/MockSdk2.7/python_stubs/__builtin__.py @@ -0,0 +1,5140 @@ +# encoding: utf-8 +# module __builtin__ +# from (built-in) +# by generator 1.145 +from __future__ import print_function +""" +Built-in functions, exceptions, and other objects. + +Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices. +""" + +# imports +from exceptions import (ArithmeticError, AssertionError, AttributeError, + BaseException, BufferError, BytesWarning, DeprecationWarning, EOFError, + EnvironmentError, Exception, FloatingPointError, FutureWarning, + GeneratorExit, IOError, ImportError, ImportWarning, IndentationError, + IndexError, KeyError, KeyboardInterrupt, LookupError, MemoryError, + NameError, NotImplementedError, OSError, OverflowError, + PendingDeprecationWarning, ReferenceError, RuntimeError, RuntimeWarning, + StandardError, StopIteration, SyntaxError, SyntaxWarning, SystemError, + SystemExit, TabError, TypeError, UnboundLocalError, UnicodeDecodeError, + UnicodeEncodeError, UnicodeError, UnicodeTranslateError, UnicodeWarning, + UserWarning, ValueError, Warning, ZeroDivisionError) + + +# Variables with simple values + +False = False + +None = object() # real value of type replaced + +True = True + +__debug__ = True + +# functions + +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 apply(p_object, args=None, kwargs=None): # real signature unknown; restored from __doc__ + """ + apply(object[, args[, kwargs]]) -> value + + Call a callable object with positional arguments taken from the tuple args, + and keyword arguments taken from the optional dictionary kwargs. + Note that classes are callable, as are instances with a __call__() method. + + Deprecated since release 2.3. Instead, use the extended call syntax: + function(*args, **keywords). + """ + pass + +def bin(number): # real signature unknown; restored from __doc__ + """ + bin(number) -> string + + Return the binary representation of an integer or long integer. + """ + 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 with a __call__() method. + """ + return False + +def chr(i): # real signature unknown; restored from __doc__ + """ + chr(i) -> character + + Return a string of one character with ordinal i; 0 <= i < 256. + """ + return "" + +def cmp(x, y): # real signature unknown; restored from __doc__ + """ + cmp(x, y) -> integer + + Return negative if xy. + """ + return 0 + +def coerce(x, y): # real signature unknown; restored from __doc__ + """ + coerce(x, y) -> (x1, y1) + + Return a tuple consisting of the two numeric arguments converted to + a common type, using the same rules as used by arithmetic operations. + If coercion is not possible, raise TypeError. + """ + pass + +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 string (a Python module, statement or expression) + into a code object that can be executed by the exec statement 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 __builtin__.divmod + """ + divmod(x, y) -> (quotient, remainder) + + 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 execfile(filename, globals=None, locals=None): # real signature unknown; restored from __doc__ + """ + execfile(filename[, globals[, locals]]) + + Read and execute a Python script from a file. + 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 filter(function_or_none, sequence): # known special case of filter + """ + filter(function or None, sequence) -> list, tuple, or string + + Return those items of sequence for which function(item) is true. If + function is None, return the items that are true. If sequence is a tuple + or string, return the same type, else return a list. + """ + 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 exceptions.) + """ + 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(with_a_twist): # real signature unknown; restored from __doc__ + """ + Define the built-in 'help'. + This is a wrapper around pydoc.help (with a twist). + """ + pass + +def hex(number): # real signature unknown; restored from __doc__ + """ + hex(number) -> string + + Return the hexadecimal representation of an integer or long integer. + """ + 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]) -> value + + Equivalent to eval(raw_input(prompt)). + """ + 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 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(collection) -> 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) -> integer + + Return the number of items of a sequence or collection. + """ + return 0 + +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 map(function, sequence, *sequence_1): # real signature unknown; restored from __doc__ + """ + map(function, sequence[, sequence, ...]) -> list + + Return a list of the results of applying the function to the items of + the argument sequence(s). If more than one sequence is given, the + function is called with an argument list consisting of the corresponding + item of each sequence, substituting None for missing values when not all + sequences have the same length. If the function is None, return a list of + the items of the sequence (or a list of tuples if more than one sequence). + """ + return [] + +def max(*args, **kwargs): # 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, **kwargs): # 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 or long integer. + """ + return "" + +def open(name, mode=None, buffering=None): # real signature unknown; restored from __doc__ + """ + open(name[, mode[, buffering]]) -> file object + + Open a file using the file() type, returns a file object. This is the + preferred way to open a file. See file.__doc__ for further information. + """ + return file('/dev/null') + +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 longs). + """ + return 0 + +def print(*args, **kwargs): # known special case of print + """ + print(value, ..., sep=' ', end='\n', file=sys.stdout) + + 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. + """ + pass + +def quit(*args, **kwargs): # real signature unknown + pass + +def range(start=None, stop=None, step=None): # known special case of range + """ + range(stop) -> list of integers + range(start, stop[, step]) -> list of integers + + Return a list containing an arithmetic progression of integers. + range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0. + When step is given, it specifies the increment (or decrement). + For example, range(4) returns [0, 1, 2, 3]. The end point is omitted! + These are exactly the valid indices for a list of 4 elements. + """ + pass + +def raw_input(prompt=None): # real signature unknown; restored from __doc__ + """ + raw_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 reduce(function, sequence, initial=None): # real signature unknown; restored from __doc__ + """ + reduce(function, sequence[, initial]) -> value + + Apply a function of two arguments cumulatively to the items of a sequence, + from left to right, so as to reduce the sequence to a single value. + For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates + ((((1+2)+3)+4)+5). If initial is present, it is placed before the items + of the sequence in the calculation, and serves as a default when the + sequence is empty. + """ + pass + +def reload(module): # real signature unknown; restored from __doc__ + """ + reload(module) -> module + + Reload the module. The module must have been successfully imported before. + """ + 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]) -> floating point number + + Round a number to a given precision in decimal digits (default 0 digits). + This always returns a floating point number. Precision may be negative. + """ + return 0.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, cmp=None, key=None, reverse=False): # real signature unknown; restored from __doc__ + """ sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list """ + pass + +def sum(sequence, start=None): # real signature unknown; restored from __doc__ + """ + sum(sequence[, start]) -> value + + Return the sum of a sequence of numbers (NOT strings) plus the value + of parameter 'start' (which defaults to 0). When the sequence is + empty, return start. + """ + pass + +def unichr(i): # real signature unknown; restored from __doc__ + """ + unichr(i) -> Unicode character + + Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. + """ + return u"" + +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 zip(seq1, seq2, *more_seqs): # known special case of zip + """ + zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)] + + Return a list of tuples, where each tuple contains the i-th element + from each of the argument sequences. The returned list is truncated + in length to the length of the shortest argument sequence. + """ + pass + +def __import__(name, globals={}, locals={}, fromlist=[], level=-1): # real signature unknown; restored from __doc__ + """ + __import__(name, globals={}, locals={}, fromlist=[], level=-1) -> 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. -1 is the original strategy of attempting + both absolute and relative imports, 0 is absolute, a positive number + is the number of parent directories to search relative to the current module. + """ + pass + +# classes + +class ___Classobj: + '''A mock class representing the old style class base.''' + __module__ = '' + __class__ = None + + def __init__(self): + pass + __dict__ = {} + __doc__ = '' + + +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.func_defaults = {} + self.func_globals = {} + self.func_closure = None + self.func_code = None + self.func_name = '' + self.func_doc = '' + self.func_dict = '' + + self.__defaults__ = {} + self.__globals__ = {} + self.__closure__ = None + self.__code__ = None + self.__name__ = '' + + +class __method(object): + '''A mock class representing method type.''' + + def __init__(self): + + self.im_class = None + self.im_self = None + self.im_func = None + + 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, name): # real signature unknown; restored from __doc__ + """ x.__delattr__('name') <==> del x.name """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + """ default object formatter """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self): # known special case of object.__init__ + """ x.__init__(...) initializes x; see help(type(x)) for signature """ + pass + + @staticmethod # known case of __new__ + def __new__(cls, *more): # known special case of object.__new__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce_ex__(self, *args, **kwargs): # real signature unknown + """ helper for pickle """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ helper for pickle """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setattr__(self, name, value): # real signature unknown; restored from __doc__ + """ x.__setattr__('name', value) <==> x.name = value """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ + __sizeof__() -> int + size of object in memory, in bytes + """ + return 0 + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + 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__ = '' + + +class basestring(object): + """ Type basestring cannot be instantiated; it is the base for str and unicode. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class int(object): + """ + int(x=0) -> int or long + int(x, base=10) -> int or long + + Convert a number or string to an integer, or return 0 if no arguments + are given. If x is floating point, the conversion truncates towards zero. + If x is outside the integer range, the function returns a long instead. + + If x is not a number or if base is given, then x must be a string or + Unicode object 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 + + def __abs__(self): # real signature unknown; restored from __doc__ + """ x.__abs__() <==> abs(x) """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __and__(self, y): # real signature unknown; restored from __doc__ + """ x.__and__(y) <==> x&y """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __coerce__(self, y): # real signature unknown; restored from __doc__ + """ x.__coerce__(y) <==> coerce(x, y) """ + pass + + def __divmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__divmod__(y) <==> divmod(x, y) """ + pass + + def __div__(self, y): # real signature unknown; restored from __doc__ + """ x.__div__(y) <==> x/y """ + pass + + def __float__(self): # real signature unknown; restored from __doc__ + """ x.__float__() <==> float(x) """ + pass + + def __floordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__floordiv__(y) <==> x//y """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __hex__(self): # real signature unknown; restored from __doc__ + """ x.__hex__() <==> hex(x) """ + pass + + def __index__(self): # real signature unknown; restored from __doc__ + """ x[y:z] <==> x[y.__index__():z.__index__()] """ + pass + + def __init__(self, x, base=10): # known special case of int.__init__ + """ + int(x=0) -> int or long + int(x, base=10) -> int or long + + Convert a number or string to an integer, or return 0 if no arguments + are given. If x is floating point, the conversion truncates towards zero. + If x is outside the integer range, the function returns a long instead. + + If x is not a number or if base is given, then x must be a string or + Unicode object 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): # real signature unknown; restored from __doc__ + """ x.__int__() <==> int(x) """ + pass + + def __invert__(self): # real signature unknown; restored from __doc__ + """ x.__invert__() <==> ~x """ + pass + + def __long__(self): # real signature unknown; restored from __doc__ + """ x.__long__() <==> long(x) """ + pass + + def __lshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__lshift__(y) <==> x< x%y """ + pass + + def __mul__(self, y): # real signature unknown; restored from __doc__ + """ x.__mul__(y) <==> x*y """ + pass + + def __neg__(self): # real signature unknown; restored from __doc__ + """ x.__neg__() <==> -x """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __oct__(self): # real signature unknown; restored from __doc__ + """ x.__oct__() <==> oct(x) """ + pass + + def __or__(self, y): # real signature unknown; restored from __doc__ + """ x.__or__(y) <==> x|y """ + pass + + def __pos__(self): # real signature unknown; restored from __doc__ + """ x.__pos__() <==> +x """ + pass + + def __pow__(self, y, z=None): # real signature unknown; restored from __doc__ + """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __rand__(self, y): # real signature unknown; restored from __doc__ + """ x.__rand__(y) <==> y&x """ + pass + + def __rdivmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdivmod__(y) <==> divmod(y, x) """ + pass + + def __rdiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdiv__(y) <==> y/x """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rfloordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rfloordiv__(y) <==> y//x """ + pass + + def __rlshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rlshift__(y) <==> y< y%x """ + pass + + def __rmul__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmul__(y) <==> y*x """ + pass + + def __ror__(self, y): # real signature unknown; restored from __doc__ + """ x.__ror__(y) <==> y|x """ + pass + + def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__ + """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """ + pass + + def __rrshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rrshift__(y) <==> y>>x """ + pass + + def __rshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rshift__(y) <==> x>>y """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rtruediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rtruediv__(y) <==> y/x """ + pass + + def __rxor__(self, y): # real signature unknown; restored from __doc__ + """ x.__rxor__(y) <==> y^x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __truediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__truediv__(y) <==> x/y """ + pass + + def __trunc__(self, *args, **kwargs): # real signature unknown + """ Truncating an Integral returns itself. """ + pass + + def __xor__(self, y): # real signature unknown; restored from __doc__ + """ x.__xor__(y) <==> x^y """ + 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""" + + + +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, y): # real signature unknown; restored from __doc__ + """ x.__and__(y) <==> x&y """ + pass + + def __init__(self, x): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __or__(self, y): # real signature unknown; restored from __doc__ + """ x.__or__(y) <==> x|y """ + pass + + def __rand__(self, y): # real signature unknown; restored from __doc__ + """ x.__rand__(y) <==> y&x """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __ror__(self, y): # real signature unknown; restored from __doc__ + """ x.__ror__(y) <==> y|x """ + pass + + def __rxor__(self, y): # real signature unknown; restored from __doc__ + """ x.__rxor__(y) <==> y^x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __xor__(self, y): # real signature unknown; restored from __doc__ + """ x.__xor__(y) <==> x^y """ + pass + + +class buffer(object): + """ + buffer(object [, offset[, size]]) + + Create a new buffer object which references the given object. + The buffer will reference a slice of the target object from the + start of the object (or at the specified offset). The slice will + extend to the end of the target object (or with the specified size). + """ + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __delitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__delitem__(y) <==> del x[y] """ + pass + + def __delslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__delslice__(i, j) <==> del x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, p_object, offset=None, size=None): # real signature unknown; restored from __doc__ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __mul__(self, n): # real signature unknown; restored from __doc__ + """ x.__mul__(n) <==> x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + def __setitem__(self, i, y): # real signature unknown; restored from __doc__ + """ x.__setitem__(i, y) <==> x[i]=y """ + pass + + def __setslice__(self, i, j, y): # real signature unknown; restored from __doc__ + """ + x.__setslice__(i, j, y) <==> x[i:j]=y + + Use of negative indices is not supported. + """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + +class bytearray(object): + """ + bytearray(iterable_of_ints) -> bytearray. + bytearray(string, encoding[, errors]) -> bytearray. + bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray. + bytearray(memory_view) -> bytearray. + + 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 bytearray object + - any object implementing the buffer API. + + bytearray(int) -> bytearray. + + Construct a zero-initialized bytearray of the given length. + """ + 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 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=None, errors=None): # real signature unknown; restored from __doc__ + """ + B.decode([encoding[, errors]]) -> unicode object. + + Decodes B using the codec registered for encoding. encoding defaults + to the default encoding. 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 u"" + + 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 strings to try. + """ + return False + + def expandtabs(self, tabsize=None): # real signature unknown; restored from __doc__ + """ + B.expandtabs([tabsize]) -> 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_int): # real signature unknown; restored from __doc__ + """ + B.extend(iterable int) -> 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 + + 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) -> bytes + + Concatenates any number of bytearray objects, with B in between each pair. + """ + return "" + + 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. + If the argument is omitted, strip leading ASCII whitespace. + """ + return bytearray + + def partition(self, sep): # real signature unknown; restored from __doc__ + """ + B.partition(sep) -> (head, sep, tail) + + Searches for the separator sep in B, and returns 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 occurance of a value in B. + """ + 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 the first count occurrences are replaced. + """ + return "" + + 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) + + Searches for the separator sep in B, starting at the end of B, + and returns 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, maxsplit=None): # real signature unknown; restored from __doc__ + """ + B.rsplit(sep[, maxsplit]) -> list of bytearray + + 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. + If the argument is omitted, strip trailing ASCII whitespace. + """ + return bytearray + + def split(self, sep=None, maxsplit=None): # real signature unknown; restored from __doc__ + """ + B.split([sep[, maxsplit]]) -> list of bytearray + + 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=False): # real signature unknown; restored from __doc__ + """ + B.splitlines(keepends=False) -> 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 strings 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. + 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, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __alloc__(self): # real signature unknown; restored from __doc__ + """ + B.__alloc__() -> int + + Returns the number of bytes actually allocated. + """ + return 0 + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x """ + pass + + def __delitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__delitem__(y) <==> del x[y] """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __iadd__(self, y): # real signature unknown; restored from __doc__ + """ x.__iadd__(y) <==> x+=y """ + pass + + def __imul__(self, y): # real signature unknown; restored from __doc__ + """ x.__imul__(y) <==> x*=y """ + 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_bytearray) -> mutable copy of bytes_or_bytearray. + bytearray(memory_view) -> bytearray. + + 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 bytearray object + - any object implementing the buffer API. + + bytearray(int) -> bytearray. + + Construct a zero-initialized bytearray of the given length. + # (copied from class doc) + """ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + def __setitem__(self, i, y): # real signature unknown; restored from __doc__ + """ x.__setitem__(i, y) <==> x[i]=y """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ + B.__sizeof__() -> int + + Returns the size of B in memory, in bytes + """ + return 0 + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + +class str(basestring): + """ + str(object='') -> string + + Return a nice string representation of the object. + If the argument is a string, the return value is the same object. + """ + def capitalize(self): # real signature unknown; restored from __doc__ + """ + S.capitalize() -> string + + Return a copy of the string S with only its first character + capitalized. + """ + return "" + + def center(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.center(width[, fillchar]) -> string + + 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 decode(self, encoding=None, errors=None): # real signature unknown; restored from __doc__ + """ + S.decode([encoding[,errors]]) -> object + + Decodes S using the codec registered for encoding. encoding defaults + to the default encoding. 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 object() + + def encode(self, encoding=None, errors=None): # real signature unknown; restored from __doc__ + """ + S.encode([encoding[,errors]]) -> object + + Encodes S using the codec registered for encoding. encoding defaults + to the default encoding. 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 is able to handle UnicodeEncodeErrors. + """ + return object() + + 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=None): # real signature unknown; restored from __doc__ + """ + S.expandtabs([tabsize]) -> string + + 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(self, *args, **kwargs): # known special case of str.format + """ + S.format(*args, **kwargs) -> string + + Return a formatted version of S, using substitutions from args and kwargs. + The substitutions are identified by braces ('{' and '}'). + """ + pass + + 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 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 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 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. 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__ + """ + 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) -> string + + 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]) -> string + + Return S left-justified in a 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() -> string + + 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]) -> string or unicode + + Return a copy of the string S with leading whitespace removed. + If chars is given and not None, remove characters in chars instead. + If chars is unicode, S will be converted to unicode before stripping + """ + return "" + + 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]) -> string + + Return a copy of string 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]) -> string + + 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=None): # real signature unknown; restored from __doc__ + """ + S.rsplit([sep [,maxsplit]]) -> list of strings + + Return a list of the words in the string 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 or is None, any whitespace string + is a separator. + """ + return [] + + def rstrip(self, chars=None): # real signature unknown; restored from __doc__ + """ + S.rstrip([chars]) -> string or unicode + + Return a copy of the string S with trailing whitespace removed. + If chars is given and not None, remove characters in chars instead. + If chars is unicode, S will be converted to unicode before stripping + """ + return "" + + def split(self, sep=None, maxsplit=None): # real signature unknown; restored from __doc__ + """ + S.split([sep [,maxsplit]]) -> list of strings + + Return a list of the words in the string 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=False): # real signature unknown; restored from __doc__ + """ + S.splitlines(keepends=False) -> 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]) -> string or unicode + + 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. + If chars is unicode, S will be converted to unicode before stripping + """ + return "" + + def swapcase(self): # real signature unknown; restored from __doc__ + """ + S.swapcase() -> string + + Return a copy of the string S with uppercase characters + converted to lowercase and vice versa. + """ + return "" + + def title(self): # real signature unknown; restored from __doc__ + """ + S.title() -> string + + Return a titlecased version of S, i.e. words start with uppercase + characters, all remaining cased characters have lowercase. + """ + return "" + + def translate(self, table, deletechars=None): # real signature unknown; restored from __doc__ + """ + S.translate(table [,deletechars]) -> string + + Return a copy of the string S, 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 string of length 256 or None. + If the table argument is None, no translation is applied and + the operation simply removes the characters in deletechars. + """ + return "" + + def upper(self): # real signature unknown; restored from __doc__ + """ + S.upper() -> string + + Return a copy of the string S converted to uppercase. + """ + return "" + + def zfill(self, width): # real signature unknown; restored from __doc__ + """ + S.zfill(width) -> string + + 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 _formatter_field_name_split(self, *args, **kwargs): # real signature unknown + pass + + def _formatter_parser(self, *args, **kwargs): # real signature unknown + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __format__(self, format_spec): # real signature unknown; restored from __doc__ + """ + S.__format__(format_spec) -> string + + Return a formatted version of S as described by format_spec. + """ + return "" + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, string=''): # known special case of str.__init__ + """ + str(object='') -> string + + Return a nice string representation of the object. + If the argument is a string, the return value is the same object. + # (copied from class doc) + """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x%y """ + pass + + def __mul__(self, n): # real signature unknown; restored from __doc__ + """ x.__mul__(n) <==> x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmod__(y) <==> y%x """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ S.__sizeof__() -> size of S in memory, in bytes """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + +bytes = str + + +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 __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __get__(self, obj, type=None): # real signature unknown; restored from __doc__ + """ descr.__get__(obj[, type]) -> value """ + pass + + def __init__(self, function): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + __func__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +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): # real signature unknown; restored from __doc__ + """ x.__abs__() <==> abs(x) """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __coerce__(self, y): # real signature unknown; restored from __doc__ + """ x.__coerce__(y) <==> coerce(x, y) """ + pass + + def __divmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__divmod__(y) <==> divmod(x, y) """ + pass + + def __div__(self, y): # real signature unknown; restored from __doc__ + """ x.__div__(y) <==> x/y """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __float__(self): # real signature unknown; restored from __doc__ + """ x.__float__() <==> float(x) """ + pass + + def __floordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__floordiv__(y) <==> x//y """ + 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, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, real, imag=None): # real signature unknown; restored from __doc__ + pass + + def __int__(self): # real signature unknown; restored from __doc__ + """ x.__int__() <==> int(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __long__(self): # real signature unknown; restored from __doc__ + """ x.__long__() <==> long(x) """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x%y """ + pass + + def __mul__(self, y): # real signature unknown; restored from __doc__ + """ x.__mul__(y) <==> x*y """ + pass + + def __neg__(self): # real signature unknown; restored from __doc__ + """ x.__neg__() <==> -x """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __pos__(self): # real signature unknown; restored from __doc__ + """ x.__pos__() <==> +x """ + pass + + def __pow__(self, y, z=None): # real signature unknown; restored from __doc__ + """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __rdivmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdivmod__(y) <==> divmod(y, x) """ + pass + + def __rdiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdiv__(y) <==> y/x """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rfloordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rfloordiv__(y) <==> y//x """ + pass + + def __rmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmod__(y) <==> y%x """ + pass + + def __rmul__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmul__(y) <==> y*x """ + pass + + def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__ + """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rtruediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rtruediv__(y) <==> y/x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __truediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__truediv__(y) <==> x/y """ + pass + + imag = property(lambda self: 0.0) + """the imaginary part of a complex number + + :type: float + """ + + real = property(lambda self: 0.0) + """the real part of a complex number + + :type: float + """ + + + +class dict(object): + """ + 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) + """ + 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(S, v=None): # real signature unknown; restored from __doc__ + """ + dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v. + v defaults to None. + """ + 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 has_key(self, k): # real signature unknown; restored from __doc__ + """ D.has_key(k) -> True if D has a key k, else False """ + return False + + def items(self): # real signature unknown; restored from __doc__ + """ D.items() -> list of D's (key, value) pairs, as 2-tuples """ + return [] + + def iteritems(self): # real signature unknown; restored from __doc__ + """ D.iteritems() -> an iterator over the (key, value) items of D """ + pass + + def iterkeys(self): # real signature unknown; restored from __doc__ + """ D.iterkeys() -> an iterator over the keys of D """ + pass + + def itervalues(self): # real signature unknown; restored from __doc__ + """ D.itervalues() -> an iterator over the values of D """ + pass + + def keys(self): # real signature unknown; restored from __doc__ + """ D.keys() -> list of D's keys """ + return [] + + 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 present and has a .keys() method, does: for k in E: D[k] = E[k] + If E present and lacks .keys() method, 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() -> list of D's values """ + return [] + + def viewitems(self): # real signature unknown; restored from __doc__ + """ D.viewitems() -> a set-like object providing a view on D's items """ + pass + + def viewkeys(self): # real signature unknown; restored from __doc__ + """ D.viewkeys() -> a set-like object providing a view on D's keys """ + pass + + def viewvalues(self): # real signature unknown; restored from __doc__ + """ D.viewvalues() -> an object providing a view on D's values """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __contains__(self, k): # real signature unknown; restored from __doc__ + """ D.__contains__(k) -> True if D has a key k, else False """ + return False + + def __delitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__delitem__(y) <==> del x[y] """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + 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): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setitem__(self, i, y): # real signature unknown; restored from __doc__ + """ x.__setitem__(i, y) <==> x[i]=y """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ D.__sizeof__() -> size of D in memory, in bytes """ + pass + + __hash__ = None + + +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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __init__(self, iterable, start=0): # known special case of enumerate.__init__ + """ x.__init__(...) initializes x; see help(type(x)) for signature """ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class file(object): + """ + file(name[, mode[, buffering]]) -> file object + + Open a file. The mode can be 'r', 'w' or 'a' for reading (default), + writing 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. Add a 'b' to the mode for binary files. + Add a '+' to the mode to allow simultaneous reading and writing. + If the buffering argument is given, 0 means unbuffered, 1 means line + buffered, and larger numbers specify the buffer size. The preferred way + to open a file is with the builtin open() function. + Add a 'U' to mode to open the file for input with universal newline + support. Any line ending in the input file will be seen as a '\n' + in Python. Also, a file so opened gains the attribute 'newlines'; + the value for this attribute is one of None (no newline read yet), + '\r', '\n', '\r\n' or a tuple containing all the newline types seen. + + 'U' cannot be combined with 'w' or '+' mode. + """ + def close(self): # real signature unknown; restored from __doc__ + """ + close() -> None or (perhaps) an integer. Close the file. + + Sets data attribute .closed to True. A closed file cannot be used for + further I/O operations. close() may be called more than once without + error. Some kinds of file objects (for example, opened by popen()) + may return an exit status upon closing. + """ + pass + + def fileno(self): # real signature unknown; restored from __doc__ + """ + fileno() -> integer "file descriptor". + + This is needed for lower-level file interfaces, such os.read(). + """ + return 0 + + def flush(self): # real signature unknown; restored from __doc__ + """ flush() -> None. Flush the internal I/O buffer. """ + pass + + def isatty(self): # real signature unknown; restored from __doc__ + """ isatty() -> true or false. True if the file is connected to a tty device. """ + return False + + def next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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 or omitted, read until EOF is reached. + Notice that when in non-blocking mode, less data than what was requested + may be returned, even if no size parameter was given. + """ + pass + + def readinto(self): # real signature unknown; restored from __doc__ + """ readinto() -> Undocumented. Don't use this; it may go away. """ + 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, offset, whence=None): # real signature unknown; restored from __doc__ + """ + seek(offset[, whence]) -> 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). If the file is opened in text mode, + only offsets returned by tell() are legal. Use of other offsets causes + undefined behavior. + Note that not all file objects are seekable. + """ + pass + + def tell(self): # real signature unknown; restored from __doc__ + """ tell() -> current file position, an integer (may be a long integer). """ + pass + + def truncate(self, size=None): # real signature unknown; restored from __doc__ + """ + truncate([size]) -> None. Truncate the file to at most size bytes. + + Size defaults to the current file position, as returned by tell(). + """ + pass + + def write(self, p_str): # real signature unknown; restored from __doc__ + """ + write(str) -> None. Write string str to file. + + Note that due to buffering, flush() or close() may be needed before + the file on disk reflects the data written. + """ + pass + + def writelines(self, sequence_of_strings): # real signature unknown; restored from __doc__ + """ + writelines(sequence_of_strings) -> None. Write the 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 xreadlines(self): # real signature unknown; restored from __doc__ + """ + xreadlines() -> returns self. + + For backward compatibility. File objects now include the performance + optimizations previously implemented in the xreadlines module. + """ + pass + + def __delattr__(self, name): # real signature unknown; restored from __doc__ + """ x.__delattr__('name') <==> del x.name """ + pass + + def __enter__(self): # real signature unknown; restored from __doc__ + """ __enter__() -> self. """ + return self + + def __exit__(self, *excinfo): # real signature unknown; restored from __doc__ + """ __exit__(*excinfo) -> None. Closes the file. """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __init__(self, name, mode=None, buffering=None): # real signature unknown; restored from __doc__ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setattr__(self, name, value): # real signature unknown; restored from __doc__ + """ x.__setattr__('name', value) <==> x.name = value """ + pass + + closed = property(lambda self: True) + """True if the file is closed + + :type: bool + """ + + encoding = property(lambda self: '') + """file encoding + + :type: string + """ + + errors = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """Unicode error handler""" + + mode = property(lambda self: '') + """file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added) + + :type: string + """ + + name = property(lambda self: '') + """file name + + :type: string + """ + + newlines = property(lambda self: '') + """end-of-line convention used in this file + + :type: string + """ + + softspace = property(lambda self: True) + """flag indicating that a space needs to be printed; used by print + + :type: bool + """ + + + +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 + + @staticmethod # known case + def fromhex(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') + -4.9406564584124654e-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): # real signature unknown; restored from __doc__ + """ x.__abs__() <==> abs(x) """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __coerce__(self, y): # real signature unknown; restored from __doc__ + """ x.__coerce__(y) <==> coerce(x, y) """ + pass + + def __divmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__divmod__(y) <==> divmod(x, y) """ + pass + + def __div__(self, y): # real signature unknown; restored from __doc__ + """ x.__div__(y) <==> x/y """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __float__(self): # real signature unknown; restored from __doc__ + """ x.__float__() <==> float(x) """ + pass + + def __floordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__floordiv__(y) <==> x//y """ + 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, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.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, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, x): # real signature unknown; restored from __doc__ + pass + + def __int__(self): # real signature unknown; restored from __doc__ + """ x.__int__() <==> int(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __long__(self): # real signature unknown; restored from __doc__ + """ x.__long__() <==> long(x) """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x%y """ + pass + + def __mul__(self, y): # real signature unknown; restored from __doc__ + """ x.__mul__(y) <==> x*y """ + pass + + def __neg__(self): # real signature unknown; restored from __doc__ + """ x.__neg__() <==> -x """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __pos__(self): # real signature unknown; restored from __doc__ + """ x.__pos__() <==> +x """ + pass + + def __pow__(self, y, z=None): # real signature unknown; restored from __doc__ + """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __rdivmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdivmod__(y) <==> divmod(y, x) """ + pass + + def __rdiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdiv__(y) <==> y/x """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rfloordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rfloordiv__(y) <==> y//x """ + pass + + def __rmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmod__(y) <==> y%x """ + pass + + def __rmul__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmul__(y) <==> y*x """ + pass + + def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__ + """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rtruediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rtruediv__(y) <==> y/x """ + pass + + def __setformat__(self, typestr, fmt): # real signature unknown; restored from __doc__ + """ + float.__setformat__(typestr, fmt) -> 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): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __truediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__truediv__(y) <==> x/y """ + 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""" + + + +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 or more sets as a new set. + + (i.e. elements that are common to all of the 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, y): # real signature unknown; restored from __doc__ + """ x.__and__(y) <==> x&y """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x. """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, seq=()): # known special case of frozenset.__init__ + """ x.__init__(...) initializes x; see help(type(x)) for signature """ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __or__(self, y): # real signature unknown; restored from __doc__ + """ x.__or__(y) <==> x|y """ + pass + + def __rand__(self, y): # real signature unknown; restored from __doc__ + """ x.__rand__(y) <==> y&x """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __ror__(self, y): # real signature unknown; restored from __doc__ + """ x.__ror__(y) <==> y|x """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rxor__(self, y): # real signature unknown; restored from __doc__ + """ x.__rxor__(y) <==> y^x """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ S.__sizeof__() -> size of S in memory, in bytes """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __xor__(self, y): # real signature unknown; restored from __doc__ + """ x.__xor__(y) <==> x^y """ + pass + + +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) -- append object to end """ + pass + + 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) -- 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) -- 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, cmp=None, key=None, reverse=False): # real signature unknown; restored from __doc__ + """ + L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; + cmp(x, y) -> -1, 0, 1 + """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x """ + pass + + def __delitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__delitem__(y) <==> del x[y] """ + pass + + def __delslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__delslice__(i, j) <==> del x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __iadd__(self, y): # real signature unknown; restored from __doc__ + """ x.__iadd__(y) <==> x+=y """ + pass + + def __imul__(self, y): # real signature unknown; restored from __doc__ + """ x.__imul__(y) <==> x*=y """ + 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): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __reversed__(self): # real signature unknown; restored from __doc__ + """ L.__reversed__() -- return a reverse iterator over the list """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + def __setitem__(self, i, y): # real signature unknown; restored from __doc__ + """ x.__setitem__(i, y) <==> x[i]=y """ + pass + + def __setslice__(self, i, j, y): # real signature unknown; restored from __doc__ + """ + x.__setslice__(i, j, y) <==> x[i:j]=y + + Use of negative indices is not supported. + """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ L.__sizeof__() -- size of L in memory, in bytes """ + pass + + __hash__ = None + + +class long(object): + """ + long(x=0) -> long + long(x, base=10) -> long + + Convert a number or string to a long integer, or return 0L if no arguments + are given. If x is floating point, the conversion truncates towards zero. + + If x is not a number or if base is given, then x must be a string or + Unicode object 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) + 4L + """ + def bit_length(self): # real signature unknown; restored from __doc__ + """ + long.bit_length() -> int or long + + Number of bits necessary to represent self in binary. + >>> bin(37L) + '0b100101' + >>> (37L).bit_length() + 6 + """ + return 0 + + def conjugate(self, *args, **kwargs): # real signature unknown + """ Returns self, the complex conjugate of any long. """ + pass + + def __abs__(self): # real signature unknown; restored from __doc__ + """ x.__abs__() <==> abs(x) """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __and__(self, y): # real signature unknown; restored from __doc__ + """ x.__and__(y) <==> x&y """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __coerce__(self, y): # real signature unknown; restored from __doc__ + """ x.__coerce__(y) <==> coerce(x, y) """ + pass + + def __divmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__divmod__(y) <==> divmod(x, y) """ + pass + + def __div__(self, y): # real signature unknown; restored from __doc__ + """ x.__div__(y) <==> x/y """ + pass + + def __float__(self): # real signature unknown; restored from __doc__ + """ x.__float__() <==> float(x) """ + pass + + def __floordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__floordiv__(y) <==> x//y """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __hex__(self): # real signature unknown; restored from __doc__ + """ x.__hex__() <==> hex(x) """ + pass + + def __index__(self): # real signature unknown; restored from __doc__ + """ x[y:z] <==> x[y.__index__():z.__index__()] """ + pass + + def __init__(self, x=0): # real signature unknown; restored from __doc__ + pass + + def __int__(self): # real signature unknown; restored from __doc__ + """ x.__int__() <==> int(x) """ + pass + + def __invert__(self): # real signature unknown; restored from __doc__ + """ x.__invert__() <==> ~x """ + pass + + def __long__(self): # real signature unknown; restored from __doc__ + """ x.__long__() <==> long(x) """ + pass + + def __lshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__lshift__(y) <==> x< x%y """ + pass + + def __mul__(self, y): # real signature unknown; restored from __doc__ + """ x.__mul__(y) <==> x*y """ + pass + + def __neg__(self): # real signature unknown; restored from __doc__ + """ x.__neg__() <==> -x """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __oct__(self): # real signature unknown; restored from __doc__ + """ x.__oct__() <==> oct(x) """ + pass + + def __or__(self, y): # real signature unknown; restored from __doc__ + """ x.__or__(y) <==> x|y """ + pass + + def __pos__(self): # real signature unknown; restored from __doc__ + """ x.__pos__() <==> +x """ + pass + + def __pow__(self, y, z=None): # real signature unknown; restored from __doc__ + """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __rand__(self, y): # real signature unknown; restored from __doc__ + """ x.__rand__(y) <==> y&x """ + pass + + def __rdivmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdivmod__(y) <==> divmod(y, x) """ + pass + + def __rdiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdiv__(y) <==> y/x """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rfloordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rfloordiv__(y) <==> y//x """ + pass + + def __rlshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rlshift__(y) <==> y< y%x """ + pass + + def __rmul__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmul__(y) <==> y*x """ + pass + + def __ror__(self, y): # real signature unknown; restored from __doc__ + """ x.__ror__(y) <==> y|x """ + pass + + def __rpow__(self, x, z=None): # real signature unknown; restored from __doc__ + """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """ + pass + + def __rrshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rrshift__(y) <==> y>>x """ + pass + + def __rshift__(self, y): # real signature unknown; restored from __doc__ + """ x.__rshift__(y) <==> x>>y """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rtruediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rtruediv__(y) <==> y/x """ + pass + + def __rxor__(self, y): # real signature unknown; restored from __doc__ + """ x.__rxor__(y) <==> y^x """ + pass + + def __sizeof__(self, *args, **kwargs): # real signature unknown + """ Returns size in memory, in bytes """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __truediv__(self, y): # real signature unknown; restored from __doc__ + """ x.__truediv__(y) <==> x/y """ + pass + + def __trunc__(self, *args, **kwargs): # real signature unknown + """ Truncating an Integral returns itself. """ + pass + + def __xor__(self, y): # real signature unknown; restored from __doc__ + """ x.__xor__(y) <==> x^y """ + 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""" + + + +class memoryview(object): + """ + memoryview(object) + + Create a new memoryview object which references the given object. + """ + def tobytes(self, *args, **kwargs): # real signature unknown + pass + + def tolist(self, *args, **kwargs): # real signature unknown + pass + + def __delitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__delitem__(y) <==> del x[y] """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __init__(self, p_object): # real signature unknown; restored from __doc__ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setitem__(self, i, y): # real signature unknown; restored from __doc__ + """ x.__setitem__(i, y) <==> x[i]=y """ + pass + + format = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + itemsize = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + ndim = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + readonly = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + shape = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + strides = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + suboffsets = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +class property(object): + """ + 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 + """ + 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, obj): # real signature unknown; restored from __doc__ + """ descr.__delete__(obj) """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __get__(self, obj, type=None): # real signature unknown; restored from __doc__ + """ descr.__get__(obj[, type]) -> value """ + 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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __set__(self, obj, value): # real signature unknown; restored from __doc__ + """ descr.__set__(obj, 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 + + + +class reversed(object): + """ + reversed(sequence) -> reverse iterator over values of the sequence + + Return a reverse iterator + """ + def next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __init__(self, sequence): # real signature unknown; restored from __doc__ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + 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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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 or more sets as a new set. + + (i.e. elements that are common to all of the 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, y): # real signature unknown; restored from __doc__ + """ x.__and__(y) <==> x&y """ + pass + + def __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x. """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __iand__(self, y): # real signature unknown; restored from __doc__ + """ x.__iand__(y) <==> x&=y """ + 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, y): # real signature unknown; restored from __doc__ + """ x.__ior__(y) <==> x|=y """ + pass + + def __isub__(self, y): # real signature unknown; restored from __doc__ + """ x.__isub__(y) <==> x-=y """ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __ixor__(self, y): # real signature unknown; restored from __doc__ + """ x.__ixor__(y) <==> x^=y """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __or__(self, y): # real signature unknown; restored from __doc__ + """ x.__or__(y) <==> x|y """ + pass + + def __rand__(self, y): # real signature unknown; restored from __doc__ + """ x.__rand__(y) <==> y&x """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __ror__(self, y): # real signature unknown; restored from __doc__ + """ x.__ror__(y) <==> y|x """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __rxor__(self, y): # real signature unknown; restored from __doc__ + """ x.__rxor__(y) <==> y^x """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ S.__sizeof__() -> size of S in memory, in bytes """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + def __xor__(self, y): # real signature unknown; restored from __doc__ + """ x.__xor__(y) <==> x^y """ + pass + + __hash__ = None + + +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 __cmp__(self, y): # real signature unknown; restored from __doc__ + """ x.__cmp__(y) <==> cmp(x,y) """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, stop): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ Return state information for pickling. """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + start = property(lambda self: 0) + """:type: int""" + + step = property(lambda self: 0) + """:type: int""" + + stop = property(lambda self: 0) + """:type: int""" + + + +class staticmethod(object): + """ + staticmethod(function) -> 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 __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __get__(self, obj, type=None): # real signature unknown; restored from __doc__ + """ descr.__get__(obj[, type]) -> value """ + pass + + def __init__(self, function): # real signature unknown; restored from __doc__ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + __func__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +class super(object): + """ + super(type, obj) -> bound super object; requires isinstance(obj, type) + super(type) -> unbound super object + 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(C, self).meth(arg) + """ + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __get__(self, obj, type=None): # real signature unknown; restored from __doc__ + """ descr.__get__(obj[, type]) -> value """ + pass + + def __init__(self, type1, type2=None): # known special case of super.__init__ + """ + super(type, obj) -> bound super object; requires isinstance(obj, type) + super(type) -> unbound super object + 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(C, self).meth(arg) + # (copied from class doc) + """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 + """ + + + +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, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + 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): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + +class type(object): + """ + type(object) -> 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, *more): # real signature unknown; restored from __doc__ + """ x.__call__(...) <==> x(...) """ + pass + + def __delattr__(self, name): # real signature unknown; restored from __doc__ + """ x.__delattr__('name') <==> del x.name """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(cls, what, bases=None, dict=None): # known special case of type.__init__ + """ + 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 + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setattr__(self, name, value): # real signature unknown; restored from __doc__ + """ x.__setattr__('name', value) <==> x.name = value """ + pass + + 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__ = 872 + __dictoffset__ = 264 + __dict__ = None # (!) real value is '' + __flags__ = 2148423147 + __itemsize__ = 40 + __mro__ = ( + None, # (!) forward: type, real value is '' + object, + ) + __name__ = 'type' + __weakrefoffset__ = 368 + + +class unicode(basestring): + """ + unicode(object='') -> unicode object + unicode(string[, encoding[, errors]]) -> unicode object + + Create a new Unicode object from the given encoded string. + encoding defaults to the current default string encoding. + errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'. + """ + def capitalize(self): # real signature unknown; restored from __doc__ + """ + S.capitalize() -> unicode + + Return a capitalized version of S, i.e. make the first character + have upper case and the rest lower case. + """ + return u"" + + def center(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.center(width[, fillchar]) -> unicode + + Return S centered in a Unicode string of length width. Padding is + done using the specified fill character (default is a space) + """ + return u"" + + 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 + Unicode string S[start:end]. Optional arguments start and end are + interpreted as in slice notation. + """ + return 0 + + def decode(self, encoding=None, errors=None): # real signature unknown; restored from __doc__ + """ + S.decode([encoding[,errors]]) -> string or unicode + + Decodes S using the codec registered for encoding. encoding defaults + to the default encoding. 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 encode(self, encoding=None, errors=None): # real signature unknown; restored from __doc__ + """ + S.encode([encoding[,errors]]) -> string or unicode + + Encodes S using the codec registered for encoding. encoding defaults + to the default encoding. 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 "" + + 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=None): # real signature unknown; restored from __doc__ + """ + S.expandtabs([tabsize]) -> unicode + + 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 u"" + + 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(self, *args, **kwargs): # known special case of unicode.format + """ + S.format(*args, **kwargs) -> unicode + + Return a formatted version of S, using substitutions from args and kwargs. + The substitutions are identified by braces ('{' and '}'). + """ + pass + + 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 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 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) -> unicode + + Return a string which is the concatenation of the strings in the + iterable. The separator between elements is S. + """ + return u"" + + def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__ + """ + S.ljust(width[, fillchar]) -> int + + Return S left-justified in a Unicode string of length width. Padding is + done using the specified fill character (default is a space). + """ + return 0 + + def lower(self): # real signature unknown; restored from __doc__ + """ + S.lower() -> unicode + + Return a copy of the string S converted to lowercase. + """ + return u"" + + def lstrip(self, chars=None): # real signature unknown; restored from __doc__ + """ + S.lstrip([chars]) -> unicode + + Return a copy of the string S with leading whitespace removed. + If chars is given and not None, remove characters in chars instead. + If chars is a str, it will be converted to unicode before stripping + """ + return u"" + + 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]) -> unicode + + 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 u"" + + 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]) -> unicode + + Return S right-justified in a Unicode string of length width. Padding is + done using the specified fill character (default is a space). + """ + return u"" + + 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=None): # real signature unknown; restored from __doc__ + """ + S.rsplit([sep [,maxsplit]]) -> 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]) -> unicode + + Return a copy of the string S with trailing whitespace removed. + If chars is given and not None, remove characters in chars instead. + If chars is a str, it will be converted to unicode before stripping + """ + return u"" + + def split(self, sep=None, maxsplit=None): # real signature unknown; restored from __doc__ + """ + S.split([sep [,maxsplit]]) -> 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=False): # real signature unknown; restored from __doc__ + """ + S.splitlines(keepends=False) -> 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]) -> unicode + + 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. + If chars is a str, it will be converted to unicode before stripping + """ + return u"" + + def swapcase(self): # real signature unknown; restored from __doc__ + """ + S.swapcase() -> unicode + + Return a copy of S with uppercase characters converted to lowercase + and vice versa. + """ + return u"" + + def title(self): # real signature unknown; restored from __doc__ + """ + S.title() -> unicode + + Return a titlecased version of S, i.e. words start with title case + characters, all remaining cased characters have lower case. + """ + return u"" + + def translate(self, table): # real signature unknown; restored from __doc__ + """ + S.translate(table) -> unicode + + 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, Unicode strings or None. + Unmapped characters are left untouched. Characters mapped to None + are deleted. + """ + return u"" + + def upper(self): # real signature unknown; restored from __doc__ + """ + S.upper() -> unicode + + Return a copy of S converted to uppercase. + """ + return u"" + + def zfill(self, width): # real signature unknown; restored from __doc__ + """ + S.zfill(width) -> unicode + + 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 u"" + + def _formatter_field_name_split(self, *args, **kwargs): # real signature unknown + pass + + def _formatter_parser(self, *args, **kwargs): # real signature unknown + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __contains__(self, y): # real signature unknown; restored from __doc__ + """ x.__contains__(y) <==> y in x """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __format__(self, format_spec): # real signature unknown; restored from __doc__ + """ + S.__format__(format_spec) -> unicode + + Return a formatted version of S as described by format_spec. + """ + return u"" + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getnewargs__(self, *args, **kwargs): # real signature unknown + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, string=u'', encoding=None, errors='strict'): # known special case of unicode.__init__ + """ + unicode(object='') -> unicode object + unicode(string[, encoding[, errors]]) -> unicode object + + Create a new Unicode object from the given encoded string. + encoding defaults to the current default string encoding. + errors can be 'strict', 'replace' or 'ignore' and defaults to 'strict'. + # (copied from class doc) + """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x%y """ + pass + + def __mul__(self, n): # real signature unknown; restored from __doc__ + """ x.__mul__(n) <==> x*n """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rmod__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmod__(y) <==> y%x """ + pass + + def __rmul__(self, n): # real signature unknown; restored from __doc__ + """ x.__rmul__(n) <==> n*x """ + pass + + def __sizeof__(self): # real signature unknown; restored from __doc__ + """ S.__sizeof__() -> size of S in memory, in bytes """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + +class xrange(object): + """ + xrange(stop) -> xrange object + xrange(start, stop[, step]) -> xrange object + + Like range(), but instead of returning a list, returns an object that + generates the numbers in the range on demand. For looping, this is + slightly faster than range() and more memory efficient. + """ + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __init__(self, stop): # real signature unknown; restored from __doc__ + pass + + def __iter__(self): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + def __len__(self): # real signature unknown; restored from __doc__ + """ x.__len__() <==> len(x) """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __reversed__(self, *args, **kwargs): # real signature unknown + """ Returns a reverse iterator. """ + pass + + +# variables with complex values + +Ellipsis = None # (!) real value is '' + +NotImplemented = None # (!) real value is '' + diff --git a/python/testData/MockSdk2.7/python_stubs/_io.py b/python/testData/MockSdk2.7/python_stubs/_io.py new file mode 100644 index 000000000000..4d642d29fd9f --- /dev/null +++ b/python/testData/MockSdk2.7/python_stubs/_io.py @@ -0,0 +1,1347 @@ +# encoding: utf-8 +# module _io +# from /Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/lib-dynload/_io.so +# by generator 1.137 +""" +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 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), 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. (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 + '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 (for backwards compatibility; unneeded + for new code) + ========= =============================================================== + + 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. + + 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. + + 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 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 '', 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. + + 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 + +class BlockingIOError(IOError): + """ Exception raised when I/O would block on a non-blocking I/O stream """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + characters_written = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +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 a IOError 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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + pass + + def readable(self, *args, **kwargs): # real signature unknown + """ + Return whether object was opened for reading. + + If False, read() will raise IOError. + """ + 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 IOError. + 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, read() will raise IOError. + """ + 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 __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): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +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 + + +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. max_buffer_size isn't used anymore. + """ + 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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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 __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 + + + +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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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 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 __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 + + + +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 __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + closed = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +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. max_buffer_size isn't used anymore. + """ + 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 __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 + + + +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 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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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): # real signature unknown; restored from __doc__ + """ x.__iter__() <==> iter(x) """ + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + 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.""" + + + +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 + + +class FileIO(_RawIOBase): + """ + file(name: str[, mode: str]) -> file IO object + + Open a file. The mode can be 'r' (default), 'w' or 'a' for reading, + writing 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. Add a '+' to the mode to allow simultaneous + reading and writing. + """ + 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. + """ + pass + + def fileno(self): # real signature unknown; restored from __doc__ + """ fileno() -> int. Return the underlying file descriptor (an integer). """ + 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]) -> int. Move to new file position + and return the file position. + + Argument offset is a byte count. Optional argument whence defaults to + SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values + are SEEK_CUR or 1 (move relative to current position, positive or negative), + and SEEK_END or 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. + + Can raise OSError for non seekable files. + """ + pass + + def truncate(self, size=None): # real signature unknown; restored from __doc__ + """ + truncate([size: int]) -> int. Truncate the file to at most size bytes and + return the truncated size. + + 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. In non-blocking mode, + returns None if the write would block. + """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 by close().""" + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """String giving the file mode""" + + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + newlines = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + +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. +""" + + + +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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + 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 + + + +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. + + errors determines the strictness of encoding and decoding (see the + 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 '', 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 next(self): # real signature unknown; restored from __doc__ + """ x.next() -> the next value, or raise StopIteration """ + 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 __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + 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 + + + +class UnsupportedOperation(ValueError, IOError): + # 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)""" + + + diff --git a/python/testData/MockSdk2.7/python_stubs/datetime.py b/python/testData/MockSdk2.7/python_stubs/datetime.py new file mode 100644 index 000000000000..eece4e84d2d7 --- /dev/null +++ b/python/testData/MockSdk2.7/python_stubs/datetime.py @@ -0,0 +1,627 @@ +# encoding: utf-8 +# module datetime +# from /Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/lib-dynload/datetime.so +# by generator 1.137 +""" Fast implementation of the datetime type. """ +# no imports + +# Variables with simple values + +MAXYEAR = 9999 + +MINYEAR = 1 + +# no functions +# classes + +class date(object): + """ date(year, month, day) --> date object """ + def ctime(self): # real signature unknown; restored from __doc__ + """ Return ctime() style string. """ + pass + + @classmethod + def fromordinal(cls, ordinal): # known case of datetime.date.fromordinal + """ int -> date corresponding to a proleptic Gregorian ordinal. """ + return date(1,1,1) + + @classmethod + def fromtimestamp(cls, timestamp): # known case of datetime.date.fromtimestamp + """ timestamp -> local date from a POSIX timestamp (like time.time()). """ + return date(1,1,1) + + def isocalendar(self): # known case of datetime.date.isocalendar + """ Return a 3-tuple containing ISO year, week number, and weekday. """ + return (1, 1, 1) + + def isoformat(self): # known case of datetime.date.isoformat + """ Return string in ISO 8601 format, YYYY-MM-DD. """ + return "" + + def isoweekday(self): # known case of datetime.date.isoweekday + """ + Return the day of the week represented by the date. + Monday == 1 ... Sunday == 7 + """ + return 0 + + def replace(self, year=None, month=None, day=None): # known case of datetime.date.replace + """ Return date with new specified fields. """ + return date(1,1,1) + + def strftime(self, format): # known case of datetime.date.strftime + """ format -> strftime() style string. """ + return "" + + def timetuple(self): # known case of datetime.date.timetuple + """ Return time tuple, compatible with time.localtime(). """ + return (0, 0, 0, 0, 0, 0, 0, 0, 0) + + @classmethod + def today(self): # known case of datetime.date.today + """ Current date or datetime: same as self.__class__.fromtimestamp(time.time()). """ + return date(1, 1, 1) + + def toordinal(self): # known case of datetime.date.toordinal + """ Return proleptic Gregorian ordinal. January 1 of year 1 is day 1. """ + return 0 + + def weekday(self): # known case of datetime.date.weekday + """ + Return the day of the week represented by the date. + Monday == 0 ... Sunday == 6 + """ + return 0 + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + """ Formats self with strftime. """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, year, month, day): # real signature unknown; restored from __doc__ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __reduce__(self): # real signature unknown; restored from __doc__ + """ __reduce__() -> (cls, state) """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + day = property(lambda self: 0) + """:type: int""" + + month = property(lambda self: 0) + """:type: int""" + + year = property(lambda self: 0) + """:type: int""" + + + max = None # (!) real value is '' + min = None # (!) real value is '' + resolution = None # (!) real value is '' + + +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 or longs. + """ + def astimezone(self, tz): # known case of datetime.datetime.astimezone + """ tz -> convert to local time in new timezone tz """ + return datetime(1, 1, 1) + + @classmethod + def combine(cls, date, time): # known case of datetime.datetime.combine + """ date, time -> datetime with same date and time fields """ + return datetime(1, 1, 1) + + def ctime(self): # real signature unknown; restored from __doc__ + """ Return ctime() style string. """ + pass + + def date(self): # known case of datetime.datetime.date + """ Return date object with same year, month and day. """ + return datetime(1, 1, 1) + + def dst(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.dst(self). """ + pass + + @classmethod + def fromtimestamp(cls, timestamp, tz=None): # known case of datetime.datetime.fromtimestamp + """ timestamp[, tz] -> tz's local time from POSIX timestamp. """ + return datetime(1, 1, 1) + + def isoformat(self, sep='T'): # known case of datetime.datetime.isoformat + """ + [sep] -> string in ISO 8601 format, YYYY-MM-DDTHH:MM:SS[.mmmmmm][+HH:MM]. + + sep is used to separate the year from the time, and defaults to 'T'. + """ + return "" + + @classmethod + def now(cls, tz=None): # known case of datetime.datetime.now + """ [tz] -> new datetime with tz's local day and time. """ + return datetime(1, 1, 1) + + def replace(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=None): # known case of datetime.datetime.replace + """ Return datetime with new specified fields. """ + return datetime(1, 1, 1) + + @classmethod + def strptime(cls, date_string, format): # known case of datetime.datetime.strptime + """ string, format -> new datetime parsed from a string (like time.strptime()). """ + return "" + + def time(self): # known case of datetime.datetime.time + """ Return time object with same time but with tzinfo=None. """ + return time(0, 0) + + def timetuple(self): # known case of datetime.datetime.timetuple + """ Return time tuple, compatible with time.localtime(). """ + return (0, 0, 0, 0, 0, 0, 0, 0, 0) + + def timetz(self): # known case of datetime.datetime.timetz + """ Return time object with same time and tzinfo. """ + return time(0, 0) + + def tzname(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.tzname(self). """ + pass + + @classmethod + def utcfromtimestamp(self, timestamp): # known case of datetime.datetime.utcfromtimestamp + """ timestamp -> UTC datetime from a POSIX timestamp (like time.time()). """ + return datetime(1, 1, 1) + + @classmethod + def utcnow(cls): # known case of datetime.datetime.utcnow + """ Return a new datetime representing UTC day and time. """ + return datetime(1, 1, 1) + + def utcoffset(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.utcoffset(self). """ + pass + + def utctimetuple(self): # known case of datetime.datetime.utctimetuple + """ Return UTC time tuple, compatible with time.localtime(). """ + return (0, 0, 0, 0, 0, 0, 0, 0, 0) + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, year, month, day, hour=None, minute=None, second=None, microsecond=None, tzinfo=None): # real signature unknown; restored from __doc__ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __reduce__(self): # real signature unknown; restored from __doc__ + """ __reduce__() -> (cls, state) """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + hour = property(lambda self: 0) + """:type: int""" + + microsecond = property(lambda self: 0) + """:type: int""" + + minute = property(lambda self: 0) + """:type: int""" + + second = property(lambda self: 0) + """:type: int""" + + tzinfo = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + max = None # (!) real value is '' + min = None # (!) real value is '' + resolution = None # (!) real value is '' + + +class time(object): + """ + time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object + + All arguments are optional. tzinfo may be None, or an instance of + a tzinfo subclass. The remaining arguments may be ints or longs. + """ + def dst(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.dst(self). """ + pass + + def isoformat(self): # known case of datetime.time.isoformat + """ Return string in ISO 8601 format, HH:MM:SS[.mmmmmm][+HH:MM]. """ + return "" + + def replace(self, hour=None, minute=None, second=None, microsecond=None, tzinfo=None): # known case of datetime.time.replace + """ Return time with new specified fields. """ + return time(0, 0) + + def strftime(self, format): # known case of datetime.time.strftime + """ format -> strftime() style string. """ + return "" + + def tzname(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.tzname(self). """ + pass + + def utcoffset(self): # real signature unknown; restored from __doc__ + """ Return self.tzinfo.utcoffset(self). """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __format__(self, *args, **kwargs): # real signature unknown + """ Formats self with strftime. """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, hour=None, minute=None, second=None, microsecond=None, tzinfo=None): # real signature unknown; restored from __doc__ + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __reduce__(self): # real signature unknown; restored from __doc__ + """ __reduce__() -> (cls, state) """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + hour = property(lambda self: 0) + """:type: int""" + + microsecond = property(lambda self: 0) + """:type: int""" + + minute = property(lambda self: 0) + """:type: int""" + + second = property(lambda self: 0) + """:type: int""" + + tzinfo = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + max = None # (!) real value is '' + min = None # (!) real value is '' + resolution = None # (!) real value is '' + + +class timedelta(object): + """ Difference between two datetime values. """ + def total_seconds(self, *args, **kwargs): # real signature unknown + """ Total seconds in the duration. """ + pass + + def __abs__(self): # real signature unknown; restored from __doc__ + """ x.__abs__() <==> abs(x) """ + pass + + def __add__(self, y): # real signature unknown; restored from __doc__ + """ x.__add__(y) <==> x+y """ + pass + + def __div__(self, y): # real signature unknown; restored from __doc__ + """ x.__div__(y) <==> x/y """ + pass + + def __eq__(self, y): # real signature unknown; restored from __doc__ + """ x.__eq__(y) <==> x==y """ + pass + + def __floordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__floordiv__(y) <==> x//y """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __ge__(self, y): # real signature unknown; restored from __doc__ + """ x.__ge__(y) <==> x>=y """ + pass + + def __gt__(self, y): # real signature unknown; restored from __doc__ + """ x.__gt__(y) <==> x>y """ + pass + + def __hash__(self): # real signature unknown; restored from __doc__ + """ x.__hash__() <==> hash(x) """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + def __le__(self, y): # real signature unknown; restored from __doc__ + """ x.__le__(y) <==> x<=y """ + pass + + def __lt__(self, y): # real signature unknown; restored from __doc__ + """ x.__lt__(y) <==> x x*y """ + pass + + def __neg__(self): # real signature unknown; restored from __doc__ + """ x.__neg__() <==> -x """ + pass + + @staticmethod # known case of __new__ + def __new__(cls, days=None, seconds=None, microseconds=None, milliseconds=None, minutes=None, hours=None, weeks=None): # known case of datetime.timedelta.__new__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __ne__(self, y): # real signature unknown; restored from __doc__ + """ x.__ne__(y) <==> x!=y """ + pass + + def __nonzero__(self): # real signature unknown; restored from __doc__ + """ x.__nonzero__() <==> x != 0 """ + pass + + def __pos__(self): # real signature unknown; restored from __doc__ + """ x.__pos__() <==> +x """ + pass + + def __radd__(self, y): # real signature unknown; restored from __doc__ + """ x.__radd__(y) <==> y+x """ + pass + + def __rdiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rdiv__(y) <==> y/x """ + pass + + def __reduce__(self): # real signature unknown; restored from __doc__ + """ __reduce__() -> (cls, state) """ + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __rfloordiv__(self, y): # real signature unknown; restored from __doc__ + """ x.__rfloordiv__(y) <==> y//x """ + pass + + def __rmul__(self, y): # real signature unknown; restored from __doc__ + """ x.__rmul__(y) <==> y*x """ + pass + + def __rsub__(self, y): # real signature unknown; restored from __doc__ + """ x.__rsub__(y) <==> y-x """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __sub__(self, y): # real signature unknown; restored from __doc__ + """ x.__sub__(y) <==> x-y """ + pass + + days = property(lambda self: 0) + """Number of days. + + :type: int + """ + + microseconds = property(lambda self: 0) + """Number of microseconds (>= 0 and less than 1 second). + + :type: int + """ + + seconds = property(lambda self: 0) + """Number of seconds (>= 0 and less than 1 day). + + :type: int + """ + + + max = None # (!) real value is '' + min = None # (!) real value is '' + resolution = None # (!) real value is '' + + +class tzinfo(object): + """ Abstract base class for time zone info objects. """ + def dst(self, date_time): # known case of datetime.tzinfo.dst + """ datetime -> DST offset in minutes east of UTC. """ + return 0 + + def fromutc(self, date_time): # known case of datetime.tzinfo.fromutc + """ datetime in UTC -> datetime in local time. """ + return datetime(1, 1, 1) + + def tzname(self, date_time): # known case of datetime.tzinfo.tzname + """ datetime -> string name of time zone. """ + return "" + + def utcoffset(self, date_time): # known case of datetime.tzinfo.utcoffset + """ datetime -> minutes east of UTC (negative for west of UTC). """ + return 0 + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + """ -> (cls, state) """ + pass + + +# variables with complex values + +datetime_CAPI = None # (!) real value is '' + diff --git a/python/testData/MockSdk2.7/python_stubs/exceptions.py b/python/testData/MockSdk2.7/python_stubs/exceptions.py new file mode 100644 index 000000000000..e69ad0f05ea3 --- /dev/null +++ b/python/testData/MockSdk2.7/python_stubs/exceptions.py @@ -0,0 +1,769 @@ +# encoding: utf-8 +# module exceptions +# from (built-in) +# by generator 1.138 +""" +Python's standard exception class hierarchy. + +Exceptions found here are defined both in the exceptions module and the +built-in namespace. It is recommended that user-defined exceptions +inherit from Exception. See the documentation for the exception +inheritance hierarchy. +""" +# no imports + +# no functions +# classes + +class BaseException(object): + """ Common base class for all exceptions """ + def __delattr__(self, name): # real signature unknown; restored from __doc__ + """ x.__delattr__('name') <==> del x.name """ + pass + + def __getattribute__(self, name): # real signature unknown; restored from __doc__ + """ x.__getattribute__('name') <==> x.name """ + pass + + def __getitem__(self, y): # real signature unknown; restored from __doc__ + """ x.__getitem__(y) <==> x[y] """ + pass + + def __getslice__(self, i, j): # real signature unknown; restored from __doc__ + """ + x.__getslice__(i, j) <==> x[i:j] + + Use of negative indices is not supported. + """ + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + pass + + def __repr__(self): # real signature unknown; restored from __doc__ + """ x.__repr__() <==> repr(x) """ + pass + + def __setattr__(self, name, value): # real signature unknown; restored from __doc__ + """ x.__setattr__('name', value) <==> x.name = value """ + pass + + def __setstate__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + def __unicode__(self): # known case of exceptions.BaseException.__unicode__ + # no doc + return u"" + + args = property(lambda self: tuple()) + """:type: tuple""" + + message = property(lambda self: '', lambda self, v: None, lambda self: None) + """:type: string""" + + + __dict__ = None # (!) real value is '' + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class StandardError(Exception): + """ + Base class for all standard Python exceptions that do not represent + interpreter exiting. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class ArithmeticError(StandardError): + """ Base class for arithmetic errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class AssertionError(StandardError): + """ Assertion failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class AttributeError(StandardError): + """ Attribute not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class BufferError(StandardError): + """ Buffer error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class Warning(Exception): + """ Base class for warning categories. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class DeprecationWarning(Warning): + """ Base class for warnings about deprecated features. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class EnvironmentError(StandardError): + """ Base class for I/O related errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __reduce__(self, *args, **kwargs): # real signature unknown + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + errno = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception errno + + :type: int + """ + + filename = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception filename + + :type: string + """ + + strerror = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception strerror + + :type: int + """ + + + +class EOFError(StandardError): + """ Read beyond end of file. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class FloatingPointError(ArithmeticError): + """ Floating point operation failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class GeneratorExit(BaseException): + """ Request that a generator exit. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class ImportError(StandardError): + """ Import can't find module, or can't find name in module. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class SyntaxError(StandardError): + """ Invalid syntax. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + filename = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception filename + + :type: string + """ + + lineno = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception lineno + + :type: int + """ + + msg = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception msg + + :type: string + """ + + offset = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception offset + + :type: int + """ + + print_file_and_line = property(lambda self: True, lambda self, v: None, lambda self: None) + """exception print_file_and_line + + :type: bool + """ + + text = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception text + + :type: string + """ + + + +class IndentationError(SyntaxError): + """ Improper indentation. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class LookupError(StandardError): + """ Base class for lookup errors. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class IndexError(LookupError): + """ Sequence index out of range. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class IOError(EnvironmentError): + """ I/O operation failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class KeyboardInterrupt(BaseException): + """ Program interrupted by user. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class KeyError(LookupError): + """ Mapping key not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + +class MemoryError(StandardError): + """ Out of memory. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class NameError(StandardError): + """ Name not found globally. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class RuntimeError(StandardError): + """ Unspecified run-time error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class NotImplementedError(RuntimeError): + """ Method or function hasn't been implemented yet. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class OSError(EnvironmentError): + """ OS system call failed. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class OverflowError(ArithmeticError): + """ Result too large to be represented. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class PendingDeprecationWarning(Warning): + """ + Base class for warnings about features which will be deprecated + in the future. + """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class ReferenceError(StandardError): + """ Weak ref proxy used after referent went away. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class StopIteration(Exception): + """ Signal the end from iterator.next(). """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class SystemError(StandardError): + """ + 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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class SystemExit(BaseException): + """ Request to exit from the interpreter. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + code = property(lambda self: object(), lambda self, v: None, lambda self: None) + + +class TabError(IndentationError): + """ Improper mixture of spaces and tabs. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class TypeError(StandardError): + """ Inappropriate argument type. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class ValueError(StandardError): + """ Inappropriate argument value (of correct type). """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class UnicodeError(ValueError): + """ Unicode related error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +class UnicodeDecodeError(UnicodeError): + """ Unicode decoding error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + 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""" + + + +class UnicodeEncodeError(UnicodeError): + """ Unicode encoding error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + encoding = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception encoding + + :type: string + """ + + end = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception end + + :type: int + """ + + object = property(lambda self: object(), lambda self, v: None, lambda self: None) + reason = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception reason + + :type: string + """ + + start = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception start + + :type: int + """ + + + +class UnicodeTranslateError(UnicodeError): + """ Unicode translation error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + @staticmethod # known case of __new__ + def __new__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + def __str__(self): # real signature unknown; restored from __doc__ + """ x.__str__() <==> str(x) """ + pass + + encoding = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception encoding + + :type: string + """ + + end = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception end + + :type: int + """ + + object = property(lambda self: object(), lambda self, v: None, lambda self: None) + reason = property(lambda self: '', lambda self, v: None, lambda self: None) + """exception reason + + :type: string + """ + + start = property(lambda self: 0, lambda self, v: None, lambda self: None) + """exception start + + :type: int + """ + + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + +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__(S, *more): # real signature unknown; restored from __doc__ + """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ + pass + + diff --git a/python/testData/MockSdk2.7/python_stubs/sys.py b/python/testData/MockSdk2.7/python_stubs/sys.py new file mode 100644 index 000000000000..9016bec31633 --- /dev/null +++ b/python/testData/MockSdk2.7/python_stubs/sys.py @@ -0,0 +1,463 @@ +# encoding: utf-8 +# module sys +# from (built-in) +# by generator 1.138 +""" +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. + +exitfunc -- if sys.exitfunc exists, this routine is called when Python exits + Assigning to sys.exitfunc is deprecated; use the atexit module instead. + +stdin -- standard input file object; used by raw_input() and input() +stdout -- standard output file object; used by the print statement +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. + +exc_type -- type of exception currently being handled +exc_value -- value of exception currently being handled +exc_traceback -- traceback of exception currently being handled + The function exc_info() should be used instead of these three, + because it is thread-safe. + +Static objects: + +float_info -- a dict with information about the float inplementation. +long_info -- a struct sequence with information about the long implementation. +maxint -- the largest supported integer (the smallest is -maxint-1) +maxsize -- the largest supported length of containers. +maxunicode -- the largest supported character +builtin_module_names -- tuple of module names built into this interpreter +version -- the version of this interpreter as a string +version_info -- version information as a named tuple +hexversion -- version information encoded as a single integer +copyright -- copyright notice pertaining to this interpreter +platform -- platform identifier +executable -- absolute path of the executable binary of the Python interpreter +prefix -- prefix used to find the Python library +exec_prefix -- prefix used to find the machine-specific Python library +float_repr_style -- string indicating the style of repr() output for floats +__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 __builtin__._ +excepthook() -- print an exception and its traceback to sys.stderr +exc_info() -- return thread-safe information about the current exception +exc_clear() -- clear the exception state for the current thread +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 + +byteorder = 'little' + +copyright = 'Copyright (c) 2001-2015 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.' + +dont_write_bytecode = True + +exc_type = None + +executable = '/Users/vlan/.virtualenvs/obraz-py2.7/bin/python' + +exec_prefix = '/Users/vlan/.virtualenvs/obraz-py2.7' + +float_repr_style = 'short' + +hexversion = 34015984 + +maxint = 9223372036854775807 +maxsize = 9223372036854775807 +maxunicode = 65535 + +platform = 'darwin' + +prefix = '/Users/vlan/.virtualenvs/obraz-py2.7' + +py3kwarning = False + +real_prefix = '/System/Library/Frameworks/Python.framework/Versions/2.7' + +version = '2.7.10 (default, Oct 23 2015, 18:05:06) \n[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.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 __builtin__._ + """ + 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_clear(): # real signature unknown; restored from __doc__ + """ + exc_clear() -> None + + Clear global information on the current exception. Subsequent calls to + exc_info() will return (None,None,None) until another exception is raised + in the current thread or the execution stack returns to a frame where + another exception is being handled. + """ + 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 exitfunc(): # reliably restored by inspect + """ + run any registered exit functions + + _exithandlers is traversed in reverse order so functions are executed + last in, first out. + """ + pass + +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 getdlopenflags(): # real signature unknown; restored from __doc__ + """ + getdlopenflags() -> int + + Return the current value of the flags that are used for dlopen calls. + The flag constants are defined in the ctypes and DLFCN modules. + """ + return 0 + +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 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 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 setdlopenflags(n): # real signature unknown; restored from __doc__ + """ + setdlopenflags(n) -> None + + Set the flags used by the interpreter for dlopen calls, such as when the + interpreter loads extension modules. Among other things, this will enable + a lazy resolving of symbols when importing a module, if called as + sys.setdlopenflags(0). To share symbols across extension modules, call as + sys.setdlopenflags(ctypes.RTLD_GLOBAL). Symbolic names for the flag modules + can be either found in the ctypes module, or in the DLFCN module. If DLFCN + is not available, it can be generated from /usr/include/dlfcn.h using the + h2py script. + """ + 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 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 _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 __builtin__._ + """ + 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 + +# no classes +# variables with complex values + +argv = [] # real value of type skipped + +builtin_module_names = () # real value of type skipped + +flags = None # (!) real value is '' + +float_info = None # (!) real value is '' + +long_info = None # (!) real value is '' + +meta_path = [] + +modules = {} # real value of type skipped + +path = [ + '/Users/vlan/src/idea/out/classes/production/python-helpers', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python27.zip', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/plat-darwin', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/plat-mac', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/plat-mac/lib-scriptpackages', + '/Users/vlan/.virtualenvs/obraz-py2.7/Extras/lib/python', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/lib-tk', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/lib-old', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/lib-dynload', + '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', + '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', + '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', + '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', + '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', + '/Users/vlan/.virtualenvs/obraz-py2.7/lib/python2.7/site-packages', +] + +path_hooks = [ + None, # (!) real value is '' +] + +path_importer_cache = {} # real value of type skipped + +stderr = open('') # real value of type replaced + +stdin = open('') # real value of type replaced + +stdout = open('') # real value of type replaced + +subversion = ( + 'CPython', + '', + '', +) + +version_info = None # (!) real value is '' + +warnoptions = [] + +_mercurial = ( + 'CPython', + '', + '', +) + +__stderr__ = None # (!) real value is '' + +__stdin__ = None # (!) real value is '' + +__stdout__ = stdout + +# intermittent names +exc_value = Exception() +exc_traceback=None diff --git a/python/testData/MockSdk3.7/Lib/_collections_abc.py b/python/testData/MockSdk3.7/Lib/_collections_abc.py new file mode 100644 index 000000000000..dbe30dff1fe1 --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/_collections_abc.py @@ -0,0 +1,1011 @@ +# Copyright 2007 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Abstract Base Classes (ABCs) for collections, according to PEP 3119. + +Unit tests are in test_collections. +""" + +from abc import ABCMeta, abstractmethod +import sys + +__all__ = ["Awaitable", "Coroutine", + "AsyncIterable", "AsyncIterator", "AsyncGenerator", + "Hashable", "Iterable", "Iterator", "Generator", "Reversible", + "Sized", "Container", "Callable", "Collection", + "Set", "MutableSet", + "Mapping", "MutableMapping", + "MappingView", "KeysView", "ItemsView", "ValuesView", + "Sequence", "MutableSequence", + "ByteString", + ] + +# This module has been renamed from collections.abc to _collections_abc to +# speed up interpreter startup. Some of the types such as MutableMapping are +# required early but collections module imports a lot of other modules. +# See issue #19218 +__name__ = "collections.abc" + +# Private list of types that we want to register with the various ABCs +# so that they will pass tests like: +# it = iter(somebytearray) +# assert isinstance(it, Iterable) +# Note: in other implementations, these types might not be distinct +# and they may have their own implementation specific types that +# are not included on this list. +bytes_iterator = type(iter(b'')) +bytearray_iterator = type(iter(bytearray())) +#callable_iterator = ??? +dict_keyiterator = type(iter({}.keys())) +dict_valueiterator = type(iter({}.values())) +dict_itemiterator = type(iter({}.items())) +list_iterator = type(iter([])) +list_reverseiterator = type(iter(reversed([]))) +range_iterator = type(iter(range(0))) +longrange_iterator = type(iter(range(1 << 1000))) +set_iterator = type(iter(set())) +str_iterator = type(iter("")) +tuple_iterator = type(iter(())) +zip_iterator = type(iter(zip())) +## views ## +dict_keys = type({}.keys()) +dict_values = type({}.values()) +dict_items = type({}.items()) +## misc ## +mappingproxy = type(type.__dict__) +generator = type((lambda: (yield))()) +## coroutine ## +async def _coro(): pass +_coro = _coro() +coroutine = type(_coro) +_coro.close() # Prevent ResourceWarning +del _coro +## asynchronous generator ## +async def _ag(): yield +_ag = _ag() +async_generator = type(_ag) +del _ag + + +### ONE-TRICK PONIES ### + +def _check_methods(C, *methods): + mro = C.__mro__ + for method in methods: + for B in mro: + if method in B.__dict__: + if B.__dict__[method] is None: + return NotImplemented + break + else: + return NotImplemented + return True + +class Hashable(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __hash__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Hashable: + return _check_methods(C, "__hash__") + return NotImplemented + + +class Awaitable(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __await__(self): + yield + + @classmethod + def __subclasshook__(cls, C): + if cls is Awaitable: + return _check_methods(C, "__await__") + return NotImplemented + + +class Coroutine(Awaitable): + + __slots__ = () + + @abstractmethod + def send(self, value): + """Send a value into the coroutine. + Return next yielded value or raise StopIteration. + """ + raise StopIteration + + @abstractmethod + def throw(self, typ, val=None, tb=None): + """Raise an exception in the coroutine. + Return next yielded value or raise StopIteration. + """ + if val is None: + if tb is None: + raise typ + val = typ() + if tb is not None: + val = val.with_traceback(tb) + raise val + + def close(self): + """Raise GeneratorExit inside coroutine. + """ + try: + self.throw(GeneratorExit) + except (GeneratorExit, StopIteration): + pass + else: + raise RuntimeError("coroutine ignored GeneratorExit") + + @classmethod + def __subclasshook__(cls, C): + if cls is Coroutine: + return _check_methods(C, '__await__', 'send', 'throw', 'close') + return NotImplemented + + +Coroutine.register(coroutine) + + +class AsyncIterable(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __aiter__(self): + return AsyncIterator() + + @classmethod + def __subclasshook__(cls, C): + if cls is AsyncIterable: + return _check_methods(C, "__aiter__") + return NotImplemented + + +class AsyncIterator(AsyncIterable): + + __slots__ = () + + @abstractmethod + async def __anext__(self): + """Return the next item or raise StopAsyncIteration when exhausted.""" + raise StopAsyncIteration + + def __aiter__(self): + return self + + @classmethod + def __subclasshook__(cls, C): + if cls is AsyncIterator: + return _check_methods(C, "__anext__", "__aiter__") + return NotImplemented + + +class AsyncGenerator(AsyncIterator): + + __slots__ = () + + async def __anext__(self): + """Return the next item from the asynchronous generator. + When exhausted, raise StopAsyncIteration. + """ + return await self.asend(None) + + @abstractmethod + async def asend(self, value): + """Send a value into the asynchronous generator. + Return next yielded value or raise StopAsyncIteration. + """ + raise StopAsyncIteration + + @abstractmethod + async def athrow(self, typ, val=None, tb=None): + """Raise an exception in the asynchronous generator. + Return next yielded value or raise StopAsyncIteration. + """ + if val is None: + if tb is None: + raise typ + val = typ() + if tb is not None: + val = val.with_traceback(tb) + raise val + + async def aclose(self): + """Raise GeneratorExit inside coroutine. + """ + try: + await self.athrow(GeneratorExit) + except (GeneratorExit, StopAsyncIteration): + pass + else: + raise RuntimeError("asynchronous generator ignored GeneratorExit") + + @classmethod + def __subclasshook__(cls, C): + if cls is AsyncGenerator: + return _check_methods(C, '__aiter__', '__anext__', + 'asend', 'athrow', 'aclose') + return NotImplemented + + +AsyncGenerator.register(async_generator) + + +class Iterable(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __iter__(self): + while False: + yield None + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterable: + return _check_methods(C, "__iter__") + return NotImplemented + + +class Iterator(Iterable): + + __slots__ = () + + @abstractmethod + def __next__(self): + 'Return the next item from the iterator. When exhausted, raise StopIteration' + raise StopIteration + + def __iter__(self): + return self + + @classmethod + def __subclasshook__(cls, C): + if cls is Iterator: + return _check_methods(C, '__iter__', '__next__') + return NotImplemented + +Iterator.register(bytes_iterator) +Iterator.register(bytearray_iterator) +#Iterator.register(callable_iterator) +Iterator.register(dict_keyiterator) +Iterator.register(dict_valueiterator) +Iterator.register(dict_itemiterator) +Iterator.register(list_iterator) +Iterator.register(list_reverseiterator) +Iterator.register(range_iterator) +Iterator.register(longrange_iterator) +Iterator.register(set_iterator) +Iterator.register(str_iterator) +Iterator.register(tuple_iterator) +Iterator.register(zip_iterator) + + +class Reversible(Iterable): + + __slots__ = () + + @abstractmethod + def __reversed__(self): + while False: + yield None + + @classmethod + def __subclasshook__(cls, C): + if cls is Reversible: + return _check_methods(C, "__reversed__", "__iter__") + return NotImplemented + + +class Generator(Iterator): + + __slots__ = () + + def __next__(self): + """Return the next item from the generator. + When exhausted, raise StopIteration. + """ + return self.send(None) + + @abstractmethod + def send(self, value): + """Send a value into the generator. + Return next yielded value or raise StopIteration. + """ + raise StopIteration + + @abstractmethod + def throw(self, typ, val=None, tb=None): + """Raise an exception in the generator. + Return next yielded value or raise StopIteration. + """ + if val is None: + if tb is None: + raise typ + val = typ() + if tb is not None: + val = val.with_traceback(tb) + raise val + + def close(self): + """Raise GeneratorExit inside generator. + """ + try: + self.throw(GeneratorExit) + except (GeneratorExit, StopIteration): + pass + else: + raise RuntimeError("generator ignored GeneratorExit") + + @classmethod + def __subclasshook__(cls, C): + if cls is Generator: + return _check_methods(C, '__iter__', '__next__', + 'send', 'throw', 'close') + return NotImplemented + +Generator.register(generator) + + +class Sized(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __len__(self): + return 0 + + @classmethod + def __subclasshook__(cls, C): + if cls is Sized: + return _check_methods(C, "__len__") + return NotImplemented + + +class Container(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __contains__(self, x): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Container: + return _check_methods(C, "__contains__") + return NotImplemented + +class Collection(Sized, Iterable, Container): + + __slots__ = () + + @classmethod + def __subclasshook__(cls, C): + if cls is Collection: + return _check_methods(C, "__len__", "__iter__", "__contains__") + return NotImplemented + +class Callable(metaclass=ABCMeta): + + __slots__ = () + + @abstractmethod + def __call__(self, *args, **kwds): + return False + + @classmethod + def __subclasshook__(cls, C): + if cls is Callable: + return _check_methods(C, "__call__") + return NotImplemented + + +### SETS ### + + +class Set(Collection): + + """A set is a finite, iterable container. + + This class provides concrete generic implementations of all + methods except for __contains__, __iter__ and __len__. + + To override the comparisons (presumably for speed, as the + semantics are fixed), redefine __le__ and __ge__, + then the other operations will automatically follow suit. + """ + + __slots__ = () + + def __le__(self, other): + if not isinstance(other, Set): + return NotImplemented + if len(self) > len(other): + return False + for elem in self: + if elem not in other: + return False + return True + + def __lt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) < len(other) and self.__le__(other) + + def __gt__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) > len(other) and self.__ge__(other) + + def __ge__(self, other): + if not isinstance(other, Set): + return NotImplemented + if len(self) < len(other): + return False + for elem in other: + if elem not in self: + return False + return True + + def __eq__(self, other): + if not isinstance(other, Set): + return NotImplemented + return len(self) == len(other) and self.__le__(other) + + @classmethod + def _from_iterable(cls, it): + '''Construct an instance of the class from any iterable input. + + Must override this method if the class constructor signature + does not accept an iterable for an input. + ''' + return cls(it) + + def __and__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + return self._from_iterable(value for value in other if value in self) + + __rand__ = __and__ + + def isdisjoint(self, other): + 'Return True if two sets have a null intersection.' + for value in other: + if value in self: + return False + return True + + def __or__(self, other): + if not isinstance(other, Iterable): + return NotImplemented + chain = (e for s in (self, other) for e in s) + return self._from_iterable(chain) + + __ror__ = __or__ + + def __sub__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return self._from_iterable(value for value in self + if value not in other) + + def __rsub__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return self._from_iterable(value for value in other + if value not in self) + + def __xor__(self, other): + if not isinstance(other, Set): + if not isinstance(other, Iterable): + return NotImplemented + other = self._from_iterable(other) + return (self - other) | (other - self) + + __rxor__ = __xor__ + + def _hash(self): + """Compute the hash value of a set. + + Note that we don't define __hash__: not all sets are hashable. + But if you define a hashable set type, its __hash__ should + call this function. + + This must be compatible __eq__. + + All sets ought to compare equal if they contain the same + elements, regardless of how they are implemented, and + regardless of the order of the elements; so there's not much + freedom for __eq__ or __hash__. We match the algorithm used + by the built-in frozenset type. + """ + MAX = sys.maxsize + MASK = 2 * MAX + 1 + n = len(self) + h = 1927868237 * (n + 1) + h &= MASK + for x in self: + hx = hash(x) + h ^= (hx ^ (hx << 16) ^ 89869747) * 3644798167 + h &= MASK + h = h * 69069 + 907133923 + h &= MASK + if h > MAX: + h -= MASK + 1 + if h == -1: + h = 590923713 + return h + +Set.register(frozenset) + + +class MutableSet(Set): + """A mutable set is a finite, iterable container. + + This class provides concrete generic implementations of all + methods except for __contains__, __iter__, __len__, + add(), and discard(). + + To override the comparisons (presumably for speed, as the + semantics are fixed), all you have to do is redefine __le__ and + then the other operations will automatically follow suit. + """ + + __slots__ = () + + @abstractmethod + def add(self, value): + """Add an element.""" + raise NotImplementedError + + @abstractmethod + def discard(self, value): + """Remove an element. Do not raise an exception if absent.""" + raise NotImplementedError + + def remove(self, value): + """Remove an element. If not a member, raise a KeyError.""" + if value not in self: + raise KeyError(value) + self.discard(value) + + def pop(self): + """Return the popped value. Raise KeyError if empty.""" + it = iter(self) + try: + value = next(it) + except StopIteration: + raise KeyError from None + self.discard(value) + return value + + def clear(self): + """This is slow (creates N new iterators!) but effective.""" + try: + while True: + self.pop() + except KeyError: + pass + + def __ior__(self, it): + for value in it: + self.add(value) + return self + + def __iand__(self, it): + for value in (self - it): + self.discard(value) + return self + + def __ixor__(self, it): + if it is self: + self.clear() + else: + if not isinstance(it, Set): + it = self._from_iterable(it) + for value in it: + if value in self: + self.discard(value) + else: + self.add(value) + return self + + def __isub__(self, it): + if it is self: + self.clear() + else: + for value in it: + self.discard(value) + return self + +MutableSet.register(set) + + +### MAPPINGS ### + + +class Mapping(Collection): + + __slots__ = () + + """A Mapping is a generic container for associating key/value + pairs. + + This class provides concrete generic implementations of all + methods except for __getitem__, __iter__, and __len__. + + """ + + @abstractmethod + def __getitem__(self, key): + raise KeyError + + def get(self, key, default=None): + 'D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.' + try: + return self[key] + except KeyError: + return default + + def __contains__(self, key): + try: + self[key] + except KeyError: + return False + else: + return True + + def keys(self): + "D.keys() -> a set-like object providing a view on D's keys" + return KeysView(self) + + def items(self): + "D.items() -> a set-like object providing a view on D's items" + return ItemsView(self) + + def values(self): + "D.values() -> an object providing a view on D's values" + return ValuesView(self) + + def __eq__(self, other): + if not isinstance(other, Mapping): + return NotImplemented + return dict(self.items()) == dict(other.items()) + + __reversed__ = None + +Mapping.register(mappingproxy) + + +class MappingView(Sized): + + __slots__ = '_mapping', + + def __init__(self, mapping): + self._mapping = mapping + + def __len__(self): + return len(self._mapping) + + def __repr__(self): + return '{0.__class__.__name__}({0._mapping!r})'.format(self) + + +class KeysView(MappingView, Set): + + __slots__ = () + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, key): + return key in self._mapping + + def __iter__(self): + yield from self._mapping + +KeysView.register(dict_keys) + + +class ItemsView(MappingView, Set): + + __slots__ = () + + @classmethod + def _from_iterable(self, it): + return set(it) + + def __contains__(self, item): + key, value = item + try: + v = self._mapping[key] + except KeyError: + return False + else: + return v is value or v == value + + def __iter__(self): + for key in self._mapping: + yield (key, self._mapping[key]) + +ItemsView.register(dict_items) + + +class ValuesView(MappingView, Collection): + + __slots__ = () + + def __contains__(self, value): + for key in self._mapping: + v = self._mapping[key] + if v is value or v == value: + return True + return False + + def __iter__(self): + for key in self._mapping: + yield self._mapping[key] + +ValuesView.register(dict_values) + + +class MutableMapping(Mapping): + + __slots__ = () + + """A MutableMapping is a generic container for associating + key/value pairs. + + This class provides concrete generic implementations of all + methods except for __getitem__, __setitem__, __delitem__, + __iter__, and __len__. + + """ + + @abstractmethod + def __setitem__(self, key, value): + raise KeyError + + @abstractmethod + def __delitem__(self, key): + raise KeyError + + __marker = object() + + def pop(self, key, default=__marker): + '''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. + ''' + try: + value = self[key] + except KeyError: + if default is self.__marker: + raise + return default + else: + del self[key] + return value + + def popitem(self): + '''D.popitem() -> (k, v), remove and return some (key, value) pair + as a 2-tuple; but raise KeyError if D is empty. + ''' + try: + key = next(iter(self)) + except StopIteration: + raise KeyError from None + value = self[key] + del self[key] + return key, value + + def clear(self): + 'D.clear() -> None. Remove all items from D.' + try: + while True: + self.popitem() + except KeyError: + pass + + def update(*args, **kwds): + ''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + If E present and has a .keys() method, does: for k in E: D[k] = E[k] + If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v + In either case, this is followed by: for k, v in F.items(): D[k] = v + ''' + if not args: + raise TypeError("descriptor 'update' of 'MutableMapping' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('update expected at most 1 arguments, got %d' % + len(args)) + if args: + other = args[0] + if isinstance(other, Mapping): + for key in other: + self[key] = other[key] + elif hasattr(other, "keys"): + for key in other.keys(): + self[key] = other[key] + else: + for key, value in other: + self[key] = value + for key, value in kwds.items(): + self[key] = value + + def setdefault(self, key, default=None): + 'D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D' + try: + return self[key] + except KeyError: + self[key] = default + return default + +MutableMapping.register(dict) + + +### SEQUENCES ### + + +class Sequence(Reversible, Collection): + + """All the operations on a read-only sequence. + + Concrete subclasses must override __new__ or __init__, + __getitem__, and __len__. + """ + + __slots__ = () + + @abstractmethod + def __getitem__(self, index): + raise IndexError + + def __iter__(self): + i = 0 + try: + while True: + v = self[i] + yield v + i += 1 + except IndexError: + return + + def __contains__(self, value): + for v in self: + if v is value or v == value: + return True + return False + + def __reversed__(self): + for i in reversed(range(len(self))): + yield self[i] + + def index(self, value, start=0, stop=None): + '''S.index(value, [start, [stop]]) -> integer -- return first index of value. + Raises ValueError if the value is not present. + + Supporting start and stop arguments is optional, but + recommended. + ''' + if start is not None and start < 0: + start = max(len(self) + start, 0) + if stop is not None and stop < 0: + stop += len(self) + + i = start + while stop is None or i < stop: + try: + v = self[i] + if v is value or v == value: + return i + except IndexError: + break + i += 1 + raise ValueError + + def count(self, value): + 'S.count(value) -> integer -- return number of occurrences of value' + return sum(1 for v in self if v is value or v == value) + +Sequence.register(tuple) +Sequence.register(str) +Sequence.register(range) +Sequence.register(memoryview) + + +class ByteString(Sequence): + + """This unifies bytes and bytearray. + + XXX Should add all their methods. + """ + + __slots__ = () + +ByteString.register(bytes) +ByteString.register(bytearray) + + +class MutableSequence(Sequence): + + __slots__ = () + + """All the operations on a read-write sequence. + + Concrete subclasses must provide __new__ or __init__, + __getitem__, __setitem__, __delitem__, __len__, and insert(). + + """ + + @abstractmethod + def __setitem__(self, index, value): + raise IndexError + + @abstractmethod + def __delitem__(self, index): + raise IndexError + + @abstractmethod + def insert(self, index, value): + 'S.insert(index, value) -- insert value before index' + raise IndexError + + def append(self, value): + 'S.append(value) -- append value to the end of the sequence' + self.insert(len(self), value) + + def clear(self): + 'S.clear() -> None -- remove all items from S' + try: + while True: + self.pop() + except IndexError: + pass + + def reverse(self): + 'S.reverse() -- reverse *IN PLACE*' + n = len(self) + for i in range(n//2): + self[i], self[n-i-1] = self[n-i-1], self[i] + + def extend(self, values): + 'S.extend(iterable) -- extend sequence by appending elements from the iterable' + for v in values: + self.append(v) + + def pop(self, index=-1): + '''S.pop([index]) -> item -- remove and return item at index (default last). + Raise IndexError if list is empty or index is out of range. + ''' + v = self[index] + del self[index] + return v + + def remove(self, value): + '''S.remove(value) -- remove first occurrence of value. + Raise ValueError if the value is not present. + ''' + del self[self.index(value)] + + def __iadd__(self, values): + self.extend(values) + return self + +MutableSequence.register(list) +MutableSequence.register(bytearray) # Multiply inheriting, see ByteString diff --git a/python/testData/MockSdk3.7/Lib/collections/__init__.py b/python/testData/MockSdk3.7/Lib/collections/__init__.py new file mode 100644 index 000000000000..9a753db71cae --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/collections/__init__.py @@ -0,0 +1,1279 @@ +'''This module implements specialized container datatypes providing +alternatives to Python's general purpose built-in containers, dict, +list, set, and tuple. + +* namedtuple factory function for creating tuple subclasses with named fields +* deque list-like container with fast appends and pops on either end +* ChainMap dict-like class for creating a single view of multiple mappings +* Counter dict subclass for counting hashable objects +* OrderedDict dict subclass that remembers the order entries were added +* defaultdict dict subclass that calls a factory function to supply missing values +* UserDict wrapper around dictionary objects for easier dict subclassing +* UserList wrapper around list objects for easier list subclassing +* UserString wrapper around string objects for easier string subclassing + +''' + +__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList', + 'UserString', 'Counter', 'OrderedDict', 'ChainMap'] + +import _collections_abc +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 + +try: + from _collections import deque +except ImportError: + pass +else: + _collections_abc.MutableSequence.register(deque) + +try: + from _collections import defaultdict +except ImportError: + pass + + +def __getattr__(name): + # For backwards compatibility, continue to make the collections ABCs + # through Python 3.6 available through the collections module. + # Note, no new collections ABCs were added in Python 3.7 + if name in _collections_abc.__all__: + obj = getattr(_collections_abc, name) + import warnings + warnings.warn("Using or importing the ABCs from 'collections' instead " + "of from 'collections.abc' is deprecated, " + "and in 3.8 it will stop working", + DeprecationWarning, stacklevel=2) + globals()[name] = obj + return obj + raise AttributeError(f'module {__name__!r} has no attribute {name!r}') + +################################################################################ +### OrderedDict +################################################################################ + +class _OrderedDictKeysView(_collections_abc.KeysView): + + def __reversed__(self): + yield from reversed(self._mapping) + +class _OrderedDictItemsView(_collections_abc.ItemsView): + + def __reversed__(self): + for key in reversed(self._mapping): + yield (key, self._mapping[key]) + +class _OrderedDictValuesView(_collections_abc.ValuesView): + + def __reversed__(self): + for key in reversed(self._mapping): + yield self._mapping[key] + +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__(*args, **kwds): + '''Initialize an ordered dictionary. The signature is the same as + regular dictionaries. Keyword argument order is preserved. + ''' + if not args: + raise TypeError("descriptor '__init__' of 'OrderedDict' object " + "needs an argument") + self, *args = args + 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 + link.prev = None + link.next = None + + 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): + '''Remove and return a (key, value) pair from the dictionary. + + 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 is false). + + Raise KeyError if the element does not exist. + ''' + link = self.__map[key] + link_prev = link.prev + link_next = link.next + soft_link = link_next.prev + link_prev.next = link_next + link_next.prev = link_prev + root = self.__root + if last: + last = root.prev + link.prev = last + link.next = root + root.prev = soft_link + last.next = link + else: + first = root.next + link.prev = root + link.next = first + first.prev = soft_link + root.next = 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 = _collections_abc.MutableMapping.update + + def keys(self): + "D.keys() -> a set-like object providing a view on D's keys" + return _OrderedDictKeysView(self) + + def items(self): + "D.items() -> a set-like object providing a view on D's items" + return _OrderedDictItemsView(self) + + def values(self): + "D.values() -> an object providing a view on D's values" + return _OrderedDictValuesView(self) + + __ne__ = _collections_abc.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): + '''Insert key with a value of default if key is not in the dictionary. + + Return the value for key if key is in the dictionary, else default. + ''' + 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): + '''Create a new ordered dictionary with keys from iterable and values set to value. + ''' + 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) + + +try: + from _collections import OrderedDict +except ImportError: + # Leave the pure Python version in place. + pass + + +################################################################################ +### namedtuple +################################################################################ + +_nt_itemgetters = {} + +def namedtuple(typename, field_names, *, rename=False, defaults=None, module=None): + """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 accessible 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)) + typename = _sys.intern(str(typename)) + + 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] = f'_{index}' + seen.add(name) + + for name in [typename] + field_names: + if type(name) is not str: + raise TypeError('Type names and field names must be strings') + if not name.isidentifier(): + raise ValueError('Type names and field names must be valid ' + f'identifiers: {name!r}') + if _iskeyword(name): + raise ValueError('Type names and field names cannot be a ' + f'keyword: {name!r}') + + seen = set() + for name in field_names: + if name.startswith('_') and not rename: + raise ValueError('Field names cannot start with an underscore: ' + f'{name!r}') + if name in seen: + raise ValueError(f'Encountered duplicate field name: {name!r}') + seen.add(name) + + field_defaults = {} + if defaults is not None: + defaults = tuple(defaults) + if len(defaults) > len(field_names): + raise TypeError('Got more default values than field names') + field_defaults = dict(reversed(list(zip(reversed(field_names), + reversed(defaults))))) + + # Variables used in the methods and docstrings + field_names = tuple(map(_sys.intern, field_names)) + num_fields = len(field_names) + arg_list = repr(field_names).replace("'", "")[1:-1] + repr_fmt = '(' + ', '.join(f'{name}=%r' for name in field_names) + ')' + tuple_new = tuple.__new__ + _len = len + + # Create all the named tuple methods to be added to the class namespace + + s = f'def __new__(_cls, {arg_list}): return _tuple_new(_cls, ({arg_list}))' + namespace = {'_tuple_new': tuple_new, '__name__': f'namedtuple_{typename}'} + # Note: exec() has the side-effect of interning the field names + exec(s, namespace) + __new__ = namespace['__new__'] + __new__.__doc__ = f'Create new instance of {typename}({arg_list})' + if defaults is not None: + __new__.__defaults__ = defaults + + @classmethod + def _make(cls, iterable): + result = tuple_new(cls, iterable) + if _len(result) != num_fields: + raise TypeError(f'Expected {num_fields} arguments, got {len(result)}') + return result + + _make.__func__.__doc__ = (f'Make a new {typename} object from a sequence ' + 'or iterable') + + def _replace(_self, **kwds): + result = _self._make(map(kwds.pop, field_names, _self)) + if kwds: + raise ValueError(f'Got unexpected field names: {list(kwds)!r}') + return result + + _replace.__doc__ = (f'Return a new {typename} object replacing specified ' + 'fields with new values') + + def __repr__(self): + 'Return a nicely formatted representation string' + return self.__class__.__name__ + repr_fmt % self + + def _asdict(self): + 'Return a new OrderedDict which maps field names to their values.' + return OrderedDict(zip(self._fields, self)) + + def __getnewargs__(self): + 'Return self as a plain tuple. Used by copy and pickle.' + return tuple(self) + + # Modify function metadata to help with introspection and debugging + + for method in (__new__, _make.__func__, _replace, + __repr__, _asdict, __getnewargs__): + method.__qualname__ = f'{typename}.{method.__name__}' + + # Build-up the class namespace dictionary + # and use type() to build the result class + class_namespace = { + '__doc__': f'{typename}({arg_list})', + '__slots__': (), + '_fields': field_names, + '_fields_defaults': field_defaults, + '__new__': __new__, + '_make': _make, + '_replace': _replace, + '__repr__': __repr__, + '_asdict': _asdict, + '__getnewargs__': __getnewargs__, + } + cache = _nt_itemgetters + for index, name in enumerate(field_names): + try: + itemgetter_object, doc = cache[index] + except KeyError: + itemgetter_object = _itemgetter(index) + doc = f'Alias for field number {index}' + cache[index] = itemgetter_object, doc + class_namespace[name] = property(itemgetter_object, doc=doc) + + result = type(typename, (tuple,), class_namespace) + + # 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), or where the user has + # specified a particular module. + if module is None: + try: + module = _sys._getframe(1).f_globals.get('__name__', '__main__') + except (AttributeError, ValueError): + pass + if module is not None: + result.__module__ = module + + 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__(*args, **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 + + ''' + if not args: + raise TypeError("descriptor '__init__' of 'Counter' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('expected at most 1 arguments, got %d' % len(args)) + super(Counter, self).__init__() + self.update(*args, **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(*args, **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 not args: + raise TypeError("descriptor 'update' of 'Counter' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('expected at most 1 arguments, got %d' % len(args)) + iterable = args[0] if args else None + if iterable is not None: + if isinstance(iterable, _collections_abc.Mapping): + if self: + self_get = self.get + for elem, count in iterable.items(): + self[elem] = count + self_get(elem, 0) + else: + super(Counter, self).update(iterable) # fast path when counter is empty + else: + _count_elements(self, iterable) + if kwds: + self.update(kwds) + + def subtract(*args, **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 not args: + raise TypeError("descriptor 'subtract' of 'Counter' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('expected at most 1 arguments, got %d' % len(args)) + iterable = args[0] if args else None + if iterable is not None: + self_get = self.get + if isinstance(iterable, _collections_abc.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' + result = Counter() + for elem, count in self.items(): + if count > 0: + result[elem] = count + return result + + def __neg__(self): + '''Subtracts from an empty counter. Strips positive and zero counts, + and flips the sign on negative counts. + + ''' + result = Counter() + for elem, count in self.items(): + if count < 0: + result[elem] = 0 - count + return result + + 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 +######################################################################## + +class ChainMap(_collections_abc.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 + be 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): + d = {} + for mapping in reversed(self.maps): + d.update(mapping) # reuses stored hash values if possible + return iter(d) + + 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(_collections_abc.MutableMapping): + + # Start by filling-out the abstract methods + def __init__(*args, **kwargs): + if not args: + raise TypeError("descriptor '__init__' of 'UserDict' object " + "needs an argument") + self, *args = args + if len(args) > 1: + raise TypeError('expected at most 1 arguments, got %d' % len(args)) + if args: + dict = args[0] + elif 'dict' in kwargs: + dict = kwargs.pop('dict') + import warnings + warnings.warn("Passing 'dict' as keyword argument is deprecated", + DeprecationWarning, stacklevel=2) + else: + dict = None + 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(_collections_abc.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 __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(_collections_abc.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 __getnewargs__(self): + return (self.data[:],) + + def __eq__(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) + def __rmod__(self, format): + return self.__class__(format % args) + + # the following methods are defined in alphabetical order: + def capitalize(self): return self.__class__(self.data.capitalize()) + def casefold(self): + return self.__class__(self.data.casefold()) + 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 format_map(self, mapping): + return self.data.format_map(mapping) + 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 isascii(self): return self.data.isascii() + 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 isprintable(self): return self.data.isprintable() + 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)) + maketrans = str.maketrans + 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.7/Lib/collections/abc.py b/python/testData/MockSdk3.7/Lib/collections/abc.py new file mode 100644 index 000000000000..891600d16bee --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/collections/abc.py @@ -0,0 +1,2 @@ +from _collections_abc import * +from _collections_abc import __all__ diff --git a/python/testData/MockSdk3.7/Lib/datetime.py b/python/testData/MockSdk3.7/Lib/datetime.py new file mode 100644 index 000000000000..12a0f1489feb --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/datetime.py @@ -0,0 +1,2442 @@ +"""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 +import sys + +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, timespec='auto'): + specs = { + 'hours': '{:02d}', + 'minutes': '{:02d}:{:02d}', + 'seconds': '{:02d}:{:02d}:{:02d}', + 'milliseconds': '{:02d}:{:02d}:{:02d}.{:03d}', + 'microseconds': '{:02d}:{:02d}:{:02d}.{:06d}' + } + + if timespec == 'auto': + # Skip trailing microseconds when us==0. + timespec = 'microseconds' if us else 'seconds' + elif timespec == 'milliseconds': + us //= 1000 + try: + fmt = specs[timespec] + except KeyError: + raise ValueError('Unknown timespec value') + else: + return fmt.format(hh, mm, ss, us) + +def _format_offset(off): + s = '' + if off is not None: + if off.days < 0: + sign = "-" + off = -off + else: + sign = "+" + hh, mm = divmod(off, timedelta(hours=1)) + mm, ss = divmod(mm, timedelta(minutes=1)) + s += "%s%02d:%02d" % (sign, hh, mm) + if ss or ss.microseconds: + s += ":%02d" % ss.seconds + + if ss.microseconds: + s += '.%06d' % ss.microseconds + return s + +# 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, rest = divmod(offset, timedelta(hours=1)) + m, rest = divmod(rest, timedelta(minutes=1)) + s = rest.seconds + u = offset.microseconds + if u: + zreplace = '%c%02d%02d%02d.%06d' % (sign, h, m, s, u) + elif s: + zreplace = '%c%02d%02d%02d' % (sign, h, m, s) + else: + 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) + +# Helpers for parsing the result of isoformat() +def _parse_isoformat_date(dtstr): + # It is assumed that this function will only be called with a + # string of length exactly 10, and (though this is not used) ASCII-only + year = int(dtstr[0:4]) + if dtstr[4] != '-': + raise ValueError('Invalid date separator: %s' % dtstr[4]) + + month = int(dtstr[5:7]) + + if dtstr[7] != '-': + raise ValueError('Invalid date separator') + + day = int(dtstr[8:10]) + + return [year, month, day] + +def _parse_hh_mm_ss_ff(tstr): + # Parses things of the form HH[:MM[:SS[.fff[fff]]]] + len_str = len(tstr) + + time_comps = [0, 0, 0, 0] + pos = 0 + for comp in range(0, 3): + if (len_str - pos) < 2: + raise ValueError('Incomplete time component') + + time_comps[comp] = int(tstr[pos:pos+2]) + + pos += 2 + next_char = tstr[pos:pos+1] + + if not next_char or comp >= 2: + break + + if next_char != ':': + raise ValueError('Invalid time separator: %c' % next_char) + + pos += 1 + + if pos < len_str: + if tstr[pos] != '.': + raise ValueError('Invalid microsecond component') + else: + pos += 1 + + len_remainder = len_str - pos + if len_remainder not in (3, 6): + raise ValueError('Invalid microsecond component') + + time_comps[3] = int(tstr[pos:]) + if len_remainder == 3: + time_comps[3] *= 1000 + + return time_comps + +def _parse_isoformat_time(tstr): + # Format supported is HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]] + len_str = len(tstr) + if len_str < 2: + raise ValueError('Isoformat time too short') + + # This is equivalent to re.search('[+-]', tstr), but faster + tz_pos = (tstr.find('-') + 1 or tstr.find('+') + 1) + timestr = tstr[:tz_pos-1] if tz_pos > 0 else tstr + + time_comps = _parse_hh_mm_ss_ff(timestr) + + tzi = None + if tz_pos > 0: + tzstr = tstr[tz_pos:] + + # Valid time zone strings are: + # HH:MM len: 5 + # HH:MM:SS len: 8 + # HH:MM:SS.ffffff len: 15 + + if len(tzstr) not in (5, 8, 15): + raise ValueError('Malformed time zone string') + + tz_comps = _parse_hh_mm_ss_ff(tzstr) + if all(x == 0 for x in tz_comps): + tzi = timezone.utc + else: + tzsign = -1 if tstr[tz_pos - 1] == '-' else 1 + + td = timedelta(hours=tz_comps[0], minutes=tz_comps[1], + seconds=tz_comps[2], microseconds=tz_comps[3]) + + tzi = timezone(tzsign * td) + + time_comps.append(tzi) + + return time_comps + + +# 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. +# 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 not -timedelta(1) < offset < timedelta(1): + raise ValueError("%s()=%s, must be strictly between " + "-timedelta(hours=24) and timedelta(hours=24)" % + (name, offset)) + +def _check_int_field(value): + if isinstance(value, int): + return value + if not isinstance(value, float): + try: + value = value.__int__() + except AttributeError: + pass + else: + if isinstance(value, int): + return value + raise TypeError('__int__ returned non-int (type %s)' % + type(value).__name__) + raise TypeError('an integer is required (got type %s)' % + type(value).__name__) + raise TypeError('integer argument expected, got float') + +def _check_date_fields(year, month, day): + year = _check_int_field(year) + month = _check_int_field(month) + day = _check_int_field(day) + 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) + return year, month, day + +def _check_time_fields(hour, minute, second, microsecond, fold): + hour = _check_int_field(hour) + minute = _check_int_field(minute) + second = _check_int_field(second) + microsecond = _check_int_field(microsecond) + 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) + if fold not in (0, 1): + raise ValueError('fold must be either 0 or 1', fold) + return hour, minute, second, microsecond, fold + +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__)) + +def _divide_and_round(a, b): + """divide a by b and round result to the nearest integer + + When the ratio is exactly half-way between two integers, + the even integer is returned. + """ + # Based on the reference implementation for divmod_near + # in Objects/longobject.c. + q, r = divmod(a, b) + # round up if either r / b > 0.5, or r / b == 0.5 and q is odd. + # The expression r / b > 0.5 is equivalent to 2 * r > b if b is + # positive, 2 * r < b if b negative. + r *= 2 + greater_than_half = r > b if b > 0 else r < b + if greater_than_half or r == b and q % 2 == 1: + q += 1 + + return q + + +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', '_hashcode' + + 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 = round(microseconds + usdouble) + seconds, microseconds = divmod(microseconds, 1000000) + days, seconds = divmod(seconds, 24*3600) + d += days + s += seconds + else: + microseconds = int(microseconds) + seconds, microseconds = divmod(microseconds, 1000000) + days, seconds = divmod(seconds, 24*3600) + d += days + s += seconds + microseconds = round(microseconds + usdouble) + assert isinstance(s, int) + assert isinstance(microseconds, int) + assert abs(s) <= 3 * 24 * 3600 + assert abs(microseconds) < 3.1e6 + + # Just a little bit of carrying possible for microseconds and seconds. + seconds, us = divmod(microseconds, 1000000) + s += seconds + 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 + + if abs(d) > 999999999: + raise OverflowError("timedelta # of days is too large: %d" % d) + + self = object.__new__(cls) + self._days = d + self._seconds = s + self._microseconds = us + self._hashcode = -1 + return self + + def __repr__(self): + args = [] + if self._days: + args.append("days=%d" % self._days) + if self._seconds: + args.append("seconds=%d" % self._seconds) + if self._microseconds: + args.append("microseconds=%d" % self._microseconds) + if not args: + args.append('0') + return "%s.%s(%s)" % (self.__class__.__module__, + self.__class__.__qualname__, + ', '.join(args)) + + 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): + usec = self._to_microseconds() + a, b = other.as_integer_ratio() + return timedelta(0, 0, _divide_and_round(usec * 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, _divide_and_round(usec, other)) + if isinstance(other, float): + a, b = other.as_integer_ratio() + return timedelta(0, 0, _divide_and_round(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 __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): + if self._hashcode == -1: + self._hashcode = hash(self._getstate()) + return self._hashcode + + 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__ + __eq__, __le__, __lt__, __ge__, __gt__, __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', '_hashcode' + + def __new__(cls, year, month=None, day=None): + """Constructor. + + Arguments: + + year, month, day (required, base 1) + """ + if month is None and isinstance(year, bytes) and len(year) == 4 and \ + 1 <= year[2] <= 12: + # Pickle support + self = object.__new__(cls) + self.__setstate(year) + self._hashcode = -1 + return self + year, month, day = _check_date_fields(year, month, day) + self = object.__new__(cls) + self._year = year + self._month = month + self._day = day + self._hashcode = -1 + 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): + """Construct 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) + + @classmethod + def fromisoformat(cls, date_string): + """Construct a date from the output of date.isoformat().""" + if not isinstance(date_string, str): + raise TypeError('fromisoformat: argument must be str') + + try: + assert len(date_string) == 10 + return cls(*_parse_isoformat_date(date_string)) + except Exception: + raise ValueError('Invalid isoformat string: %s' % date_string) + + + # 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.%s(%d, %d, %d)" % (self.__class__.__module__, + self.__class__.__qualname__, + 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 not isinstance(fmt, str): + raise TypeError("must be str, not %s" % type(fmt).__name__) + 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, __eq__, __le__, __lt__, __ge__, __gt__, + # __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 + return type(self)(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 __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." + if self._hashcode == -1: + self._hashcode = hash(self._getstate()) + return self._hashcode + + # 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 + (used with permission) + """ + 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): + 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 -> timedelta, positive for east of UTC, negative for west of UTC" + raise NotImplementedError("tzinfo subclass must override utcoffset()") + + def dst(self, dt): + """datetime -> DST offset as timedelta, positive for 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__ + __eq__, __le__, __lt__, __ge__, __gt__, __hash__ + + Methods: + + strftime() + isoformat() + utcoffset() + tzname() + dst() + + Properties (readonly): + hour, minute, second, microsecond, tzinfo, fold + """ + __slots__ = '_hour', '_minute', '_second', '_microsecond', '_tzinfo', '_hashcode', '_fold' + + def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0): + """Constructor. + + Arguments: + + hour, minute (required) + second, microsecond (default to zero) + tzinfo (default to None) + fold (keyword only, default to zero) + """ + if isinstance(hour, bytes) and len(hour) == 6 and hour[0]&0x7F < 24: + # Pickle support + self = object.__new__(cls) + self.__setstate(hour, minute or None) + self._hashcode = -1 + return self + hour, minute, second, microsecond, fold = _check_time_fields( + hour, minute, second, microsecond, fold) + _check_tzinfo_arg(tzinfo) + self = object.__new__(cls) + self._hour = hour + self._minute = minute + self._second = second + self._microsecond = microsecond + self._tzinfo = tzinfo + self._hashcode = -1 + self._fold = fold + 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 + + @property + def fold(self): + return self._fold + + # 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 __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.""" + if self._hashcode == -1: + if self.fold: + t = self.replace(fold=0) + else: + t = self + tzoff = t.utcoffset() + if not tzoff: # zero or None + self._hashcode = hash(t._getstate()[0]) + else: + 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: + self._hashcode = hash(time(h, m, self.second, self.microsecond)) + else: + self._hashcode = hash((h, m, self.second, self.microsecond)) + return self._hashcode + + # Conversion to string + + def _tzstr(self): + """Return formatted timezone offset (+xx:xx) or an empty string.""" + off = self.utcoffset() + return _format_offset(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.%s(%d, %d%s)" % (self.__class__.__module__, + self.__class__.__qualname__, + self._hour, self._minute, s) + if self._tzinfo is not None: + assert s[-1:] == ")" + s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" + if self._fold: + assert s[-1:] == ")" + s = s[:-1] + ", fold=1)" + return s + + def isoformat(self, timespec='auto'): + """Return the time formatted according to ISO. + + The full format is 'HH:MM:SS.mmmmmm+zz:zz'. By default, the fractional + part is omitted if self.microsecond == 0. + + The optional argument timespec specifies the number of additional + terms of the time to include. + """ + s = _format_time(self._hour, self._minute, self._second, + self._microsecond, timespec) + tz = self._tzstr() + if tz: + s += tz + return s + + __str__ = isoformat + + @classmethod + def fromisoformat(cls, time_string): + """Construct a time from the output of isoformat().""" + if not isinstance(time_string, str): + raise TypeError('fromisoformat: argument must be str') + + try: + return cls(*_parse_isoformat_time(time_string)) + except Exception: + raise ValueError('Invalid isoformat string: %s' % time_string) + + + 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 not isinstance(fmt, str): + raise TypeError("must be str, not %s" % type(fmt).__name__) + if len(fmt) != 0: + return self.strftime(fmt) + return str(self) + + # Timezone functions + + def utcoffset(self): + """Return the timezone offset as timedelta, positive 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 (as timedelta + positive 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, *, fold=None): + """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 + if fold is None: + fold = self._fold + return type(self)(hour, minute, second, microsecond, tzinfo, fold=fold) + + # Pickle support. + + def _getstate(self, protocol=3): + us2, us3 = divmod(self._microsecond, 256) + us1, us2 = divmod(us2, 256) + h = self._hour + if self._fold and protocol > 3: + h += 128 + basestate = bytes([h, 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 tzinfo is not None and not isinstance(tzinfo, _tzinfo_class): + raise TypeError("bad tzinfo state arg") + h, self._minute, self._second, us1, us2, us3 = string + if h > 127: + self._fold = 1 + self._hour = h - 128 + else: + self._fold = 0 + self._hour = h + self._microsecond = (((us1 << 8) | us2) << 8) | us3 + self._tzinfo = tzinfo + + def __reduce_ex__(self, protocol): + return (time, self._getstate(protocol)) + + def __reduce__(self): + return self.__reduce_ex__(2) + +_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__ + time.__slots__ + + def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0, + microsecond=0, tzinfo=None, *, fold=0): + if isinstance(year, bytes) and len(year) == 10 and 1 <= year[2]&0x7F <= 12: + # Pickle support + self = object.__new__(cls) + self.__setstate(year, month) + self._hashcode = -1 + return self + year, month, day = _check_date_fields(year, month, day) + hour, minute, second, microsecond, fold = _check_time_fields( + hour, minute, second, microsecond, fold) + _check_tzinfo_arg(tzinfo) + self = object.__new__(cls) + self._year = year + self._month = month + self._day = day + self._hour = hour + self._minute = minute + self._second = second + self._microsecond = microsecond + self._tzinfo = tzinfo + self._hashcode = -1 + self._fold = fold + 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 + + @property + def fold(self): + return self._fold + + @classmethod + def _fromtimestamp(cls, t, utc, tz): + """Construct a datetime from a POSIX timestamp (like time.time()). + + A timezone info object may be passed in as well. + """ + frac, t = _math.modf(t) + us = round(frac * 1e6) + if us >= 1000000: + t += 1 + us -= 1000000 + elif us < 0: + t -= 1 + us += 1000000 + + converter = _time.gmtime if utc else _time.localtime + 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 None: + # As of version 2015f max fold in IANA database is + # 23 hours at 1969-09-30 13:00:00 in Kwajalein. + # Let's probe 24 hours in the past to detect a transition: + max_fold_seconds = 24 * 3600 + + # On Windows localtime_s throws an OSError for negative values, + # thus we can't perform fold detection for values of time less + # than the max time fold. See comments in _datetimemodule's + # version of this method for more details. + if t < max_fold_seconds and sys.platform.startswith("win"): + return result + + y, m, d, hh, mm, ss = converter(t - max_fold_seconds)[:6] + probe1 = cls(y, m, d, hh, mm, ss, us, tz) + trans = result - probe1 - timedelta(0, max_fold_seconds) + if trans.days < 0: + y, m, d, hh, mm, ss = converter(t + trans // timedelta(0, 1))[:6] + probe2 = cls(y, m, d, hh, mm, ss, us, tz) + if probe2 == result: + result._fold = 1 + else: + result = tz.fromutc(result) + return result + + @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) + + return cls._fromtimestamp(t, tz is not None, tz) + + @classmethod + def utcfromtimestamp(cls, t): + """Construct a naive UTC datetime from a POSIX timestamp.""" + return cls._fromtimestamp(t, True, None) + + @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, tzinfo=True): + "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") + if tzinfo is True: + tzinfo = time.tzinfo + return cls(date.year, date.month, date.day, + time.hour, time.minute, time.second, time.microsecond, + tzinfo, fold=time.fold) + + @classmethod + def fromisoformat(cls, date_string): + """Construct a datetime from the output of datetime.isoformat().""" + if not isinstance(date_string, str): + raise TypeError('fromisoformat: argument must be str') + + # Split this at the separator + dstr = date_string[0:10] + tstr = date_string[11:] + + try: + date_components = _parse_isoformat_date(dstr) + except ValueError: + raise ValueError('Invalid isoformat string: %s' % date_string) + + if tstr: + try: + time_components = _parse_isoformat_time(tstr) + except ValueError: + raise ValueError('Invalid isoformat string: %s' % date_string) + else: + time_components = [0, 0, 0, 0, None] + + return cls(*(date_components + time_components)) + + 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 _mktime(self): + """Return integer POSIX timestamp.""" + epoch = datetime(1970, 1, 1) + max_fold_seconds = 24 * 3600 + t = (self - epoch) // timedelta(0, 1) + def local(u): + y, m, d, hh, mm, ss = _time.localtime(u)[:6] + return (datetime(y, m, d, hh, mm, ss) - epoch) // timedelta(0, 1) + + # Our goal is to solve t = local(u) for u. + a = local(t) - t + u1 = t - a + t1 = local(u1) + if t1 == t: + # We found one solution, but it may not be the one we need. + # Look for an earlier solution (if `fold` is 0), or a + # later one (if `fold` is 1). + u2 = u1 + (-max_fold_seconds, max_fold_seconds)[self.fold] + b = local(u2) - u2 + if a == b: + return u1 + else: + b = t1 - u1 + assert a != b + u2 = t - b + t2 = local(u2) + if t2 == t: + return u2 + if t1 == t: + return u1 + # We have found both offsets a and b, but neither t - a nor t - b is + # a solution. This means t is in the gap. + return (max, min)[self.fold](u1, u2) + + + def timestamp(self): + "Return POSIX timestamp as float" + if self._tzinfo is None: + s = self._mktime() + return s + 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, fold=self.fold) + + def timetz(self): + "Return the time part, with same tzinfo." + return time(self.hour, self.minute, self.second, self.microsecond, + self._tzinfo, fold=self.fold) + + def replace(self, year=None, month=None, day=None, hour=None, + minute=None, second=None, microsecond=None, tzinfo=True, + *, fold=None): + """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 + if fold is None: + fold = self.fold + return type(self)(year, month, day, hour, minute, second, + microsecond, tzinfo, fold=fold) + + def _local_timezone(self): + if self.tzinfo is None: + ts = self._mktime() + else: + 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: + delta = local - datetime(*_time.gmtime(ts)[:6]) + zone = _time.strftime('%Z', localtm) + tz = timezone(delta, zone) + else: + tz = timezone(timedelta(seconds=gmtoff), zone) + return tz + + def astimezone(self, tz=None): + if tz is None: + tz = self._local_timezone() + elif not isinstance(tz, tzinfo): + raise TypeError("tz argument must be an instance of tzinfo") + + mytz = self.tzinfo + if mytz is None: + mytz = self._local_timezone() + myoffset = mytz.utcoffset(self) + else: + myoffset = mytz.utcoffset(self) + if myoffset is None: + mytz = self.replace(tzinfo=None)._local_timezone() + myoffset = mytz.utcoffset(self) + + if tz is mytz: + return self + + # Convert self to UTC, and attach the new time zone object. + 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', timespec='auto'): + """Return the time formatted according to ISO. + + The full format looks like 'YYYY-MM-DD HH:MM:SS.mmmmmm'. + By default, the fractional part is omitted if self.microsecond == 0. + + If self.tzinfo is not None, the UTC offset is also attached, giving + giving a full format of 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM'. + + Optional argument sep specifies the separator between date and + time, default 'T'. + + The optional argument timespec specifies the number of additional + terms of the time to include. + """ + s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) + + _format_time(self._hour, self._minute, self._second, + self._microsecond, timespec)) + + off = self.utcoffset() + tz = _format_offset(off) + if tz: + s += tz + + 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 = "%s.%s(%s)" % (self.__class__.__module__, + self.__class__.__qualname__, + ", ".join(map(str, L))) + if self._tzinfo is not None: + assert s[-1:] == ")" + s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" + if self._fold: + assert s[-1:] == ")" + s = s[:-1] + ", fold=1)" + 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 as timedelta positive 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. + """ + if self._tzinfo is None: + return None + name = self._tzinfo.tzname(self) + _check_tzname(name) + return name + + def dst(self): + """Return 0 if DST is not in effect, or the DST offset (as timedelta + positive 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 __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() + # Assume that allow_mixed means that we are called from __eq__ + if allow_mixed: + if myoff != self.replace(fold=not self.fold).utcoffset(): + return 2 + if otoff != other.replace(fold=not other.fold).utcoffset(): + return 2 + 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): + if self._hashcode == -1: + if self.fold: + t = self.replace(fold=0) + else: + t = self + tzoff = t.utcoffset() + if tzoff is None: + self._hashcode = hash(t._getstate()[0]) + else: + days = _ymd2ord(self.year, self.month, self.day) + seconds = self.hour * 3600 + self.minute * 60 + self.second + self._hashcode = hash(timedelta(days, seconds, self.microsecond) - tzoff) + return self._hashcode + + # Pickle support. + + def _getstate(self, protocol=3): + yhi, ylo = divmod(self._year, 256) + us2, us3 = divmod(self._microsecond, 256) + us1, us2 = divmod(us2, 256) + m = self._month + if self._fold and protocol > 3: + m += 128 + basestate = bytes([yhi, ylo, m, 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): + if tzinfo is not None and not isinstance(tzinfo, _tzinfo_class): + raise TypeError("bad tzinfo state arg") + (yhi, ylo, m, self._day, self._hour, + self._minute, self._second, us1, us2, us3) = string + if m > 127: + self._fold = 1 + self._month = m - 128 + else: + self._fold = 0 + self._month = m + self._year = yhi * 256 + ylo + self._microsecond = (((us1 << 8) | us2) << 8) | us3 + self._tzinfo = tzinfo + + def __reduce_ex__(self, protocol): + return (self.__class__, self._getstate(protocol)) + + def __reduce__(self): + return self.__reduce_ex__(2) + + +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).") + 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.%s(%r)" % (self.__class__.__module__, + self.__class__.__qualname__, + self._offset) + return "%s.%s(%r, %r)" % (self.__class__.__module__, + self.__class__.__qualname__, + 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 not delta: + return 'UTC' + if delta < timedelta(0): + sign = '-' + delta = -delta + else: + sign = '+' + hours, rest = divmod(delta, timedelta(hours=1)) + minutes, rest = divmod(rest, timedelta(minutes=1)) + seconds = rest.seconds + microseconds = rest.microseconds + if microseconds: + return (f'UTC{sign}{hours:02d}:{minutes:02d}:{seconds:02d}' + f'.{microseconds:06d}') + if seconds: + return f'UTC{sign}{hours:02d}:{minutes:02d}:{seconds:02d}' + return f'UTC{sign}{hours:02d}:{minutes:02d}' + +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, _EPOCH, _MAXORDINAL, _MONTHNAMES, _build_struct_time, + _check_date_fields, _check_int_field, _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, _format_offset, _is_leap, _isoweek1monday, _math, + _ord2ymd, _time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord, + _divide_and_round, _parse_isoformat_date, _parse_isoformat_time, + _parse_hh_mm_ss_ff) + # 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.7/Lib/io.py b/python/testData/MockSdk3.7/Lib/io.py new file mode 100644 index 000000000000..968ee5073df1 --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/io.py @@ -0,0 +1,99 @@ +"""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 an 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 + +try: + from _io import _WindowsConsoleIO +except ImportError: + pass +else: + RawIOBase.register(_WindowsConsoleIO) diff --git a/python/testData/MockSdk3.7/Lib/re.py b/python/testData/MockSdk3.7/Lib/re.py new file mode 100644 index 000000000000..94d486579e08 --- /dev/null +++ b/python/testData/MockSdk3.7/Lib/re.py @@ -0,0 +1,366 @@ +# +# 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). + (?= _MAXCACHE: + # Drop the oldest item + try: + del _cache[next(iter(_cache))] + except (StopIteration, RuntimeError, KeyError): + pass + _cache[type(pattern), pattern, flags] = p + return p + +@functools.lru_cache(_MAXCACHE) +def _compile_repl(repl, pattern): + # internal: compile replacement pattern + return sre_parse.parse_template(repl, pattern) + +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, _pickle, _compile) + +# -------------------------------------------------------------------- +# experimental stuff (see python-dev discussions for details) + +class Scanner: + def __init__(self, lexicon, flags=0): + from sre_constants import BRANCH, SUBPATTERN + if isinstance(flags, RegexFlag): + flags = flags.value + self.lexicon = lexicon + # combine phrases into a compound pattern + p = [] + s = sre_parse.Pattern() + s.flags = flags + for phrase, action in lexicon: + gid = s.opengroup() + p.append(sre_parse.SubPattern(s, [ + (SUBPATTERN, (gid, 0, 0, sre_parse.parse(phrase, flags))), + ])) + s.closegroup(gid, 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 True: + 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.7/python_stubs/_io.py b/python/testData/MockSdk3.7/python_stubs/_io.py new file mode 100644 index 000000000000..dc877209e8d4 --- /dev/null +++ b/python/testData/MockSdk3.7/python_stubs/_io.py @@ -0,0 +1,1613 @@ +# encoding: utf-8 +# module _io calls itself io +# from (built-in) +# by generator 1.145 +""" +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 an 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 and return a stream. Raise OSError 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 + +class BlockingIOError(OSError): + """ I/O operation would block. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +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. Other bytes-like objects are accepted as method arguments too. + In some cases (such as readinto), a writable object is required. 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. + + OSError 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 OSError. + """ + pass + + def readline(self, *args, **kwargs): # real signature unknown + """ + Read and return a line from the stream. + + If size is specified, at most size 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 OSError. + 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 OSError. + """ + 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 '' + + +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 readinto1(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 always the length of b + in bytes. + + 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 + + +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 readinto1(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 + + + +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 readinto1(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 _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 + + + +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 readinto1(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 + + + +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 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 + + + +class BytesIO(_BufferedIOBase): + """ Buffered I/O implementation using an in-memory bytes buffer. """ + def close(self, *args, **kwargs): # real signature unknown + """ Disable all I/O operations. """ + pass + + def flush(self, *args, **kwargs): # real signature unknown + """ Does nothing. """ + pass + + def getbuffer(self, *args, **kwargs): # real signature unknown + """ Get a read-write view over the contents of the BytesIO object. """ + pass + + def getvalue(self, *args, **kwargs): # real signature unknown + """ Retrieve the entire contents of the BytesIO object. """ + pass + + def isatty(self, *args, **kwargs): # real signature unknown + """ + Always returns False. + + BytesIO objects are not connected to a TTY-like device. + """ + pass + + def read(self, *args, **kwargs): # real signature unknown + """ + Read at most size bytes, returned as a bytes object. + + If the size argument is negative, read until EOF is reached. + Return an empty bytes object at EOF. + """ + pass + + def read1(self, *args, **kwargs): # real signature unknown + """ + Read at most size bytes, returned as a bytes object. + + If the size argument is negative or omitted, read until EOF is reached. + Return an empty bytes object at EOF. + """ + pass + + def readable(self, *args, **kwargs): # real signature unknown + """ Returns True if the IO object can be read. """ + pass + + def readinto(self, *args, **kwargs): # real signature unknown + """ + Read bytes into buffer. + + Returns number of bytes read (0 for EOF), or None if the object + is set not to block and has no data to read. + """ + pass + + def readline(self, *args, **kwargs): # real signature unknown + """ + Next line from the file, as a bytes object. + + 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 bytes object at EOF. + """ + pass + + def readlines(self, *args, **kwargs): # real signature unknown + """ + List of bytes objects, 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. + """ + pass + + def seek(self, *args, **kwargs): # real signature unknown + """ + 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, *args, **kwargs): # real signature unknown + """ Returns True if the IO object can be seeked. """ + pass + + def tell(self, *args, **kwargs): # real signature unknown + """ Current file position, an integer. """ + pass + + def truncate(self, *args, **kwargs): # real signature unknown + """ + 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, *args, **kwargs): # real signature unknown + """ Returns True if the IO object can be written. """ + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write bytes to file. + + Return the number of bytes written. + """ + pass + + def writelines(self, *args, **kwargs): # real signature unknown + """ + Write lines to the file. + + Note that newlines are not added. lines can be any iterable object + producing bytes-like objects. This is equivalent to calling write() for + each element. + """ + pass + + def __getstate__(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 + + 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.""" + + + +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 readinto(self, *args, **kwargs): # real signature unknown + pass + + def write(self, *args, **kwargs): # real signature unknown + pass + + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class FileIO(_RawIOBase): + """ + Open a file. + + The mode can be 'r' (default), 'w', 'x' or 'a' for reading, + 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 the file. + + A closed file cannot be used for further I/O operations. close() may be + called more than once without error. + """ + pass + + def fileno(self, *args, **kwargs): # real signature unknown + """ Return the underlying file descriptor (an integer). """ + pass + + def isatty(self, *args, **kwargs): # real signature unknown + """ True if the file is connected to a TTY device. """ + pass + + def read(self, size=-1): # known case of _io.FileIO.read + """ + 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. + Return an empty bytes object at EOF. + """ + return "" + + def readable(self, *args, **kwargs): # real signature unknown + """ True if file was opened in a read mode. """ + pass + + def readall(self, *args, **kwargs): # real signature unknown + """ + 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. Return an empty bytes object at EOF. + """ + pass + + def readinto(self): # real signature unknown; restored from __doc__ + """ Same as RawIOBase.readinto(). """ + pass + + def seek(self, *args, **kwargs): # real signature unknown + """ + Move to new file position and return the file position. + + Argument offset is a byte count. Optional argument whence defaults to + SEEK_SET or 0 (offset from start of file, offset should be >= 0); other values + are SEEK_CUR or 1 (move relative to current position, positive or negative), + and SEEK_END or 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, *args, **kwargs): # real signature unknown + """ True if file supports random-access. """ + pass + + def tell(self, *args, **kwargs): # real signature unknown + """ + Current file position. + + Can raise OSError for non seekable files. + """ + pass + + def truncate(self, *args, **kwargs): # real signature unknown + """ + Truncate the file to at most size bytes and return the truncated size. + + 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, *args, **kwargs): # real signature unknown + """ True if file was opened in a write mode. """ + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write buffer b to file, return number of bytes written. + + Only makes one system call, so not all of the data may be written. + The number of bytes actually written is returned. In non-blocking mode, + returns None if the write would block. + """ + 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 by close().""" + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """String giving the file mode""" + + _blksize = 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 + + + +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 + + + +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. +""" + + + +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 size 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, *args, **kwargs): # real signature unknown + """ 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, *args, **kwargs): # real signature unknown + """ 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, *args, **kwargs): # real signature unknown + """ 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 + + + +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 reconfigure(self, *args, **kwargs): # real signature unknown + """ + Reconfigure the text stream with new parameters. + + This also does an implicit stream flush. + """ + 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 + + write_through = 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 + + + +class UnsupportedOperation(OSError, ValueError): + # 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)""" + + + +class _WindowsConsoleIO(_RawIOBase): + """ + Open a console buffer by file descriptor. + + The mode can be 'rb' (default), or 'wb' for reading or writing bytes. All + other mode characters will be ignored. Mode 'b' will be assumed if it is + omitted. The *opener* parameter is always ignored. + """ + def close(self): # real signature unknown; restored from __doc__ + """ + Close the handle. + + A closed handle cannot be used for further I/O operations. close() may be + called more than once without error. + """ + pass + + def fileno(self, *args, **kwargs): # real signature unknown + """ + Return the underlying file descriptor (an integer). + + fileno is only set when a file descriptor is used to open + one of the standard streams. + """ + pass + + def isatty(self, *args, **kwargs): # real signature unknown + """ Always True. """ + pass + + def read(self, *args, **kwargs): # real signature unknown + """ + Read at most size bytes, returned as bytes. + + Only makes one system call when size is a positive integer, + so less data may be returned than requested. + Return an empty bytes object at EOF. + """ + pass + + def readable(self, *args, **kwargs): # real signature unknown + """ True if console is an input buffer. """ + pass + + def readall(self, *args, **kwargs): # real signature unknown + """ + Read all data from the console, returned as bytes. + + Return an empty bytes object at EOF. + """ + pass + + def readinto(self): # real signature unknown; restored from __doc__ + """ Same as RawIOBase.readinto(). """ + pass + + def writable(self, *args, **kwargs): # real signature unknown + """ True if console is an output buffer. """ + pass + + def write(self, *args, **kwargs): # real signature unknown + """ + Write buffer b to file, return number of bytes 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 __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 by close().""" + + mode = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + """String giving the file mode""" + + _blksize = 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 + + + +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 create_module(cls, *args, **kwargs): # real signature unknown + """ Create a built-in module """ + pass + + @classmethod + def exec_module(cls, *args, **kwargs): # real signature unknown + """ Exec a built-in module """ + pass + + @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 the specified module into sys.modules and return it. + + This method is deprecated. Use loader.exec_module instead. + """ + 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.7/python_stubs/builtins.py b/python/testData/MockSdk3.7/python_stubs/builtins.py new file mode 100644 index 000000000000..e4517191ca09 --- /dev/null +++ b/python/testData/MockSdk3.7/python_stubs/builtins.py @@ -0,0 +1,5858 @@ +# encoding: utf-8 +# module builtins +# from (built-in) +# by generator 1.145 +""" +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 + +def abs(*args, **kwargs): # real signature unknown + """ Return the absolute value of the argument. """ + pass + +def all(*args, **kwargs): # real signature unknown + """ + Return True if bool(x) is True for all values x in the iterable. + + If the iterable is empty, return True. + """ + pass + +def any(*args, **kwargs): # real signature unknown + """ + Return True if bool(x) is True for any x in the iterable. + + If the iterable is empty, return False. + """ + pass + +def ascii(*args, **kwargs): # real signature unknown + """ + Return an ASCII-only representation of an object. + + 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. + """ + pass + +def bin(*args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + Return the binary representation of an integer. + + >>> bin(2796202) + '0b1010101010101010101010' + """ + pass + +def breakpoint(*args, **kws): # real signature unknown; restored from __doc__ + """ + breakpoint(*args, **kws) + + Call sys.breakpointhook(*args, **kws). sys.breakpointhook() must accept + whatever arguments are passed. + + By default, this drops you into the pdb debugger. + """ + pass + +def callable(i_e_, some_kind_of_function): # real signature unknown; restored from __doc__ + """ + 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. + """ + pass + +def chr(*args, **kwargs): # real signature unknown + """ Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff. """ + pass + +def compile(*args, **kwargs): # real signature unknown + """ + Compile source into a code object that can be executed by exec() or eval(). + + The source code may represent a Python module, statement or expression. + 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 true, stops the compilation inheriting + the effects of any future statements in effect in the code calling + compile; if absent or false 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(x, y): # real signature unknown; restored from __doc__ + """ + Deletes the named attribute from the given 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 + """ Return the tuple (x//y, x%y). Invariant: div*y + mod == x. """ + return (0, 0) + +def eval(*args, **kwargs): # real signature unknown + """ + Evaluate the given 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(*args, **kwargs): # real signature unknown + """ + Execute the given source in the context of globals and locals. + + The source may be a string representing one or more Python statements + 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 exit(*args, **kwargs): # real signature unknown + pass + +def format(*args, **kwargs): # real signature unknown + """ + Return value.__format__(format_spec) + + format_spec defaults to the empty string. + See the Format Specification Mini-Language section of help('FORMATTING') for + details. + """ + pass + +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(*args, **kwargs): # real signature unknown + """ + Return the dictionary containing the current scope's global variables. + + NOTE: Updates to this dictionary *will* affect name lookups in the current + global scope and vice-versa. + """ + pass + +def hasattr(*args, **kwargs): # real signature unknown + """ + Return whether the object has an attribute with the given name. + + This is done by calling getattr(obj, name) and catching AttributeError. + """ + pass + +def hash(*args, **kwargs): # real signature unknown + """ + Return the hash value for the given object. + + Two objects that compare equal must also have the same hash value, but the + reverse is not necessarily true. + """ + pass + +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(*args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + Return the hexadecimal representation of an integer. + + >>> hex(12648430) + '0xc0ffee' + """ + pass + +def id(*args, **kwargs): # real signature unknown + """ + Return the identity of an object. + + This is guaranteed to be unique among simultaneously existing objects. + (CPython uses the object's memory address.) + """ + pass + +def input(*args, **kwargs): # real signature unknown + """ + Read a string from standard input. The trailing newline is stripped. + + The prompt string, if given, is printed to standard output without a + trailing newline before reading input. + + If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError. + On *nix systems, readline is used if available. + """ + pass + +def isinstance(x, A_tuple): # real signature unknown; restored from __doc__ + """ + Return whether an object is an instance of a class or of a subclass thereof. + + A tuple, as in ``isinstance(x, (A, B, ...))``, may be given as the target to + check against. This is equivalent to ``isinstance(x, A) or isinstance(x, B) + or ...`` etc. + """ + pass + +def issubclass(x, A_tuple): # real signature unknown; restored from __doc__ + """ + Return whether 'cls' is a derived from another class or is the same class. + + A tuple, as in ``issubclass(x, (A, B, ...))``, may be given as the target to + check against. This is equivalent to ``issubclass(x, A) or issubclass(x, B) + or ...`` etc. + """ + pass + +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(*args, **kwargs): # real signature unknown + """ Return the number of items in a container. """ + 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(*args, **kwargs): # real signature unknown + """ + Return a dictionary containing the current scope's local variables. + + NOTE: Whether or not updates to this dictionary will affect name lookups in + the local scope and vice-versa is *implementation dependent* and not + covered by any backwards compatibility guarantees. + """ + pass + +def max(*args, key=None): # known special case of max + """ + max(iterable, *[, default=obj, key=func]) -> value + max(arg1, arg2, *args, *[, key=func]) -> value + + With a single iterable argument, return its biggest item. The + default keyword-only argument specifies an object to return if + the provided iterable is empty. + With two or more arguments, return the largest argument. + """ + pass + +def min(*args, key=None): # known special case of min + """ + min(iterable, *[, default=obj, key=func]) -> value + min(arg1, arg2, *args, *[, key=func]) -> value + + With a single iterable argument, return its smallest item. The + default keyword-only argument specifies an object to return if + the provided iterable is empty. + 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(*args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + Return the octal representation of an integer. + + >>> oct(342391) + '0o1234567' + """ + pass + +def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True): # known special case of open + """ + Open file and return a stream. Raise OSError 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(*args, **kwargs): # real signature unknown + """ Return the Unicode code point for a one-character string. """ + pass + +def pow(*args, **kwargs): # real signature unknown + """ + Equivalent to x**y (with two arguments) or x**y % z (with three arguments) + + Some types, such as ints, are able to use a more efficient algorithm when + invoked using the three argument form. + """ + pass + +def print(self, *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(obj): # real signature unknown; restored from __doc__ + """ + Return the canonical string representation of the object. + + For many object types, including most builtins, eval(repr(obj)) == obj. + """ + pass + +def round(*args, **kwargs): # real signature unknown + """ + Round a number to a given precision in decimal digits. + + The return value is an integer if ndigits is omitted or None. Otherwise + the return value has the same type as the number. ndigits may be negative. + """ + pass + +def setattr(x, y, v): # real signature unknown; restored from __doc__ + """ + Sets the named attribute on the given object to the specified value. + + setattr(x, 'y', v) is equivalent to ``x.y = v'' + """ + pass + +def sorted(*args, **kwargs): # real signature unknown + """ + Return a new list containing all items from the iterable in ascending order. + + A custom key function can be supplied to customize the sort order, and the + reverse flag can be set to request the result in descending order. + """ + pass + +def sum(*args, **kwargs): # real signature unknown + """ + Return the sum of a 'start' value (default: 0) plus an iterable of numbers + + When the iterable is empty, return the start value. + This function is intended specifically for use with numeric values and may + reject non-numeric types. + """ + 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. The level argument 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 __asyncgenerator(object): + '''A mock class representing the async generator function type.''' + def __init__(self): + '''Create an async generator object.''' + self.__name__ = '' + self.__qualname__ = '' + self.ag_await = None + self.ag_frame = None + self.ag_running = False + self.ag_code = None + + def __aiter__(self): + '''Defined to support iteration over container.''' + pass + + def __anext__(self): + '''Returns an awaitable, that performs one asynchronous generator iteration when awaited.''' + pass + + def aclose(self): + '''Returns an awaitable, that throws a GeneratorExit exception into generator.''' + pass + + def asend(self, value): + '''Returns an awaitable, that pushes the value object in generator.''' + pass + + def athrow(self, type, value=None, traceback=None): + '''Returns an awaitable, that throws an exception into 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 __coroutine(object): + '''A mock class representing coroutine type.''' + + def __init__(self): + self.__name__ = '' + self.__qualname__ = '' + self.cr_await = None + self.cr_frame = None + self.cr_running = False + self.cr_code = None + + def __await__(self): + return [] + + def close(self): + pass + + def send(self, value): + pass + + def throw(self, type, value=None, traceback=None): + pass + + +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, *args, **kwargs): # real signature unknown + """ Default dir() implementation. """ + pass + + 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_subclass__(self, *args, **kwargs): # real signature unknown + """ + This method is called when a class is subclassed. + + The default implementation does nothing. It may be + overridden to extend subclasses. + """ + 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 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__ + """ + Number of bits necessary to represent self in binary. + + >>> bin(37) + '0b100101' + >>> (37).bit_length() + 6 + """ + pass + + def conjugate(self, *args, **kwargs): # real signature unknown + """ Returns self, the complex conjugate of any int. """ + pass + + @classmethod # known case + def from_bytes(cls, *args, **kwargs): # real signature unknown + """ + Return the integer represented by the given array of bytes. + + bytes + Holds the array of bytes to convert. The 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. + byteorder + 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. + signed + Indicates whether two's complement is used to represent the integer. + """ + pass + + def to_bytes(self, *args, **kwargs): # real signature unknown + """ + Return an array of bytes representing an integer. + + length + Length of bytes object to use. An OverflowError is raised if the + integer is not representable with the given number of bytes. + byteorder + 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. + signed + 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]) -> 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""" + + + +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 + + +class ConnectionError(OSError): + """ Connection error. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class BrokenPipeError(ConnectionError): + """ Broken pipe. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +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 + + +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 a 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, *args, **kwargs): # real signature unknown + """ + Append a single item to the end of the bytearray. + + item + The item to be appended. + """ + 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, *args, **kwargs): # real signature unknown + """ Remove all items from the bytearray. """ + pass + + def copy(self, *args, **kwargs): # real signature unknown + """ Return a copy of B. """ + 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 subsection sub in + bytes B[start:end]. Optional arguments start and end are interpreted + as in slice notation. + """ + return 0 + + def decode(self, *args, **kwargs): # real signature unknown + """ + Decode the bytearray using the codec registered for encoding. + + encoding + The encoding with which to decode the bytearray. + errors + The error handling scheme to use for the handling of decoding errors. + The default is 'strict' meaning that decoding errors raise a + UnicodeDecodeError. Other possible values are 'ignore' and 'replace' + as well as any other name registered with codecs.register_error that + can handle UnicodeDecodeErrors. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Append all the items from the iterator or sequence to the end of the bytearray. + + iterable_of_ints + The iterable of items to append. + """ + 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, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + 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') + """ + pass + + def hex(self): # real signature unknown; restored from __doc__ + """ + B.hex() -> string + + Create a string of hexadecimal numbers from a bytearray object. + Example: bytearray([0xb9, 0x01, 0xef]).hex() -> 'b901ef'. + """ + return "" + + def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.index(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. + + Raises ValueError when the subsection is not found. + """ + return 0 + + def insert(self, *args, **kwargs): # real signature unknown + """ + Insert a single item into the bytearray before the given index. + + index + The index where the value is to be inserted. + item + The item to be inserted. + """ + 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 isascii(self): # real signature unknown; restored from __doc__ + """ + B.isascii() -> bool + + Return True if B is empty or all characters in B are ASCII, + 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, *args, **kwargs): # real signature unknown + """ + Concatenate any number of bytes/bytearray objects. + + The bytearray whose method is called is inserted in between each pair. + + The result is returned as a new bytearray object. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Strip leading bytes contained in the argument. + + If the argument is omitted or None, strip leading ASCII whitespace. + """ + pass + + @staticmethod # known case + def maketrans(*args, **kwargs): # real signature unknown + """ + Return a translation table useable for the bytes or bytearray translate method. + + The returned table will be one 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, *args, **kwargs): # real signature unknown + """ + Partition the bytearray into three parts using the given separator. + + This will search for the separator sep in the bytearray. If the separator is + found, returns a 3-tuple containing the part before the separator, the + separator itself, and the part after it as new bytearray objects. + + If the separator is not found, returns a 3-tuple containing the copy of the + original bytearray object and two empty bytearray objects. + """ + pass + + def pop(self, *args, **kwargs): # real signature unknown + """ + Remove and return a single item from B. + + index + The index from where to remove the item. + -1 (the default value) means remove the last item. + + If no index argument is given, will pop the last item. + """ + pass + + def remove(self, *args, **kwargs): # real signature unknown + """ + Remove the first occurrence of a value in the bytearray. + + value + The value to remove. + """ + pass + + def replace(self, *args, **kwargs): # real signature unknown + """ + Return a copy with all occurrences of substring old replaced by new. + + count + Maximum number of occurrences to replace. + -1 (the default value) means replace all occurrences. + + If the optional argument count is given, only the first count occurrences are + replaced. + """ + pass + + def reverse(self, *args, **kwargs): # real signature unknown + """ 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 + + 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. + + 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, *args, **kwargs): # real signature unknown + """ + Partition the bytearray into three parts using the given separator. + + This will search for the separator sep in the bytearray, starting at the end. + If the separator is found, returns a 3-tuple containing the part before the + separator, the separator itself, and the part after it as new bytearray + objects. + + If the separator is not found, returns a 3-tuple containing two empty bytearray + objects and the copy of the original bytearray object. + """ + pass + + def rsplit(self, *args, **kwargs): # real signature unknown + """ + Return a list of the sections in the bytearray, using sep as the delimiter. + + sep + The delimiter according which to split the bytearray. + None (the default value) means split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + + Splitting is done starting at the end of the bytearray and working to the front. + """ + pass + + def rstrip(self, *args, **kwargs): # real signature unknown + """ + Strip trailing bytes contained in the argument. + + If the argument is omitted or None, strip trailing ASCII whitespace. + """ + pass + + def split(self, *args, **kwargs): # real signature unknown + """ + Return a list of the sections in the bytearray, using sep as the delimiter. + + sep + The delimiter according which to split the bytearray. + None (the default value) means split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + """ + pass + + def splitlines(self, *args, **kwargs): # real signature unknown + """ + Return a list of the lines in the bytearray, breaking at line boundaries. + + Line breaks are not included in the resulting list unless keepends is given and + true. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Strip leading and trailing bytes contained in the argument. + + If the argument is omitted or None, strip leading and trailing ASCII whitespace. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Return a copy with each character mapped by the given translation table. + + table + Translation table, which must be a bytes object of length 256. + + All characters occurring in the optional argument delete are removed. + The remaining characters are mapped through the given translation table. + """ + pass + + 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 a 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 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 subsection sub in + bytes B[start:end]. Optional arguments start and end are interpreted + as in slice notation. + """ + return 0 + + def decode(self, *args, **kwargs): # real signature unknown + """ + Decode the bytes using the codec registered for encoding. + + encoding + The encoding with which to decode the bytes. + errors + The error handling scheme to use for the handling of decoding errors. + The default is 'strict' meaning that decoding errors raise a + UnicodeDecodeError. Other possible values are 'ignore' and 'replace' + as well as any other name registered with codecs.register_error that + can handle UnicodeDecodeErrors. + """ + pass + + 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 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, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + 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'. + """ + pass + + def hex(self): # real signature unknown; restored from __doc__ + """ + B.hex() -> string + + Create a string of hexadecimal numbers from a bytes object. + Example: b'\xb9\x01\xef'.hex() -> 'b901ef'. + """ + return "" + + def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__ + """ + B.index(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. + + Raises ValueError when the subsection 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 isascii(self): # real signature unknown; restored from __doc__ + """ + B.isascii() -> bool + + Return True if B is empty or all characters in B are ASCII, + 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, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + Concatenate any number of bytes objects. + + The bytes whose method is called is inserted in between each pair. + + The result is returned as a new bytes object. + + Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Strip leading bytes contained in the argument. + + If the argument is omitted or None, strip leading ASCII whitespace. + """ + pass + + @staticmethod # known case + def maketrans(*args, **kwargs): # real signature unknown + """ + Return a translation table useable for the bytes or bytearray translate method. + + The returned table will be one 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, *args, **kwargs): # real signature unknown + """ + Partition the bytes into three parts using the given separator. + + This will search for the separator sep in the bytes. If the separator is found, + returns a 3-tuple containing the part before the separator, the separator + itself, and the part after it. + + If the separator is not found, returns a 3-tuple containing the original bytes + object and two empty bytes objects. + """ + pass + + def replace(self, *args, **kwargs): # real signature unknown + """ + Return a copy with all occurrences of substring old replaced by new. + + count + Maximum number of occurrences to replace. + -1 (the default value) means replace all occurrences. + + If the optional argument count is given, only the first count occurrences are + replaced. + """ + 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 + + 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. + + 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, *args, **kwargs): # real signature unknown + """ + Partition the bytes into three parts using the given separator. + + This will search for the separator sep in the bytes, starting at the end. If + the separator is found, returns a 3-tuple containing the part before the + separator, the separator itself, and the part after it. + + If the separator is not found, returns a 3-tuple containing two empty bytes + objects and the original bytes object. + """ + pass + + def rsplit(self, *args, **kwargs): # real signature unknown + """ + Return a list of the sections in the bytes, using sep as the delimiter. + + sep + The delimiter according which to split the bytes. + None (the default value) means split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + + Splitting is done starting at the end of the bytes and working to the front. + """ + pass + + def rstrip(self, *args, **kwargs): # real signature unknown + """ + Strip trailing bytes contained in the argument. + + If the argument is omitted or None, strip trailing ASCII whitespace. + """ + pass + + def split(self, *args, **kwargs): # real signature unknown + """ + Return a list of the sections in the bytes, using sep as the delimiter. + + sep + The delimiter according which to split the bytes. + None (the default value) means split on ASCII whitespace characters + (space, tab, return, newline, formfeed, vertical tab). + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + """ + pass + + def splitlines(self, *args, **kwargs): # real signature unknown + """ + Return a list of the lines in the bytes, breaking at line boundaries. + + Line breaks are not included in the resulting list unless keepends is given and + true. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Strip leading and trailing bytes contained in the argument. + + If the argument is omitted or None, strip leading and trailing ASCII whitespace. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Return a copy with each character mapped by the given translation table. + + table + Translation table, which must be a bytes object of length 256. + + All characters occurring in the optional argument delete are removed. + The remaining characters are mapped through the given translation table. + """ + pass + + 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 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: + @classmethod + def f(cls, arg1, arg2, ...): + ... + + 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 '' + + +class complex(object): + """ + 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, *args, **kwargs): # real signature unknown + 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 + """ Create a new dictionary with keys from iterable and values set to value. """ + pass + + def get(self, *args, **kwargs): # real signature unknown + """ Return the value for key if key is in the dictionary, else default. """ + 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, *args, **kwargs): # real signature unknown + """ + Insert key with a value of default if key is not in the dictionary. + + Return the value for key if key is in the dictionary, else default. + """ + 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 the dictionary has the specified key, 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 + + +class enumerate(object): + """ + Return an enumerate object. + + iterable + an object supporting 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 + + +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 + + +class FileExistsError(OSError): + """ File already exists. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class FileNotFoundError(OSError): + """ File not found. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +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 + + +class float(object): + """ Convert a string or number to a floating point number, if possible. """ + def as_integer_ratio(self): # real signature unknown; restored from __doc__ + """ + Return integer ratio. + + 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 + + @staticmethod # known case + def fromhex(*args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + Create a floating-point number from a hexadecimal string. + + >>> float.fromhex('0x1.ffffp10') + 2047.984375 + >>> float.fromhex('-0x1p-1074') + -5e-324 + """ + pass + + def hex(self): # real signature unknown; restored from __doc__ + """ + Return a hexadecimal representation of a floating-point number. + + >>> (-0.1).hex() + '-0x1.999999999999ap-4' + >>> 3.14159.hex() + '0x1.921f9f01b866ep+1' + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ Formats the float according to format_spec. """ + pass + + def __getattribute__(self, *args, **kwargs): # real signature unknown + """ Return getattr(self, name). """ + pass + + def __getformat__(self, *args, **kwargs): # real signature unknown + """ + You probably don't want to use this function. + + typestr + Must be 'double' or 'float'. + + It exists mainly to be used in Python's test suite. + + 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. + """ + 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, *args, **kwargs): # real signature unknown + 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 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 + + +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 + + +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 + + +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 __reduce__(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""" + + + +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 + + +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""" + + + +class IndentationError(SyntaxError): + """ Improper indentation. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +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 + + +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 + + +class InterruptedError(OSError): + """ Interrupted by signal. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class IsADirectoryError(OSError): + """ Operation doesn't work on directories. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +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 + + +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 + + +class list(object): + """ + Built-in mutable sequence. + + If no argument is given, the constructor creates a new empty list. + The argument must be an iterable if specified. + """ + def append(self, *args, **kwargs): # real signature unknown + """ Append object to the end of the list. """ + pass + + def clear(self, *args, **kwargs): # real signature unknown + """ Remove all items from list. """ + pass + + def copy(self, *args, **kwargs): # real signature unknown + """ Return a shallow copy of the list. """ + pass + + def count(self, *args, **kwargs): # real signature unknown + """ Return number of occurrences of value. """ + pass + + def extend(self, *args, **kwargs): # real signature unknown + """ Extend list by appending elements from the iterable. """ + pass + + def index(self, *args, **kwargs): # real signature unknown + """ + Return first index of value. + + Raises ValueError if the value is not present. + """ + pass + + def insert(self, *args, **kwargs): # real signature unknown + """ Insert object before index. """ + pass + + def pop(self, *args, **kwargs): # real signature unknown + """ + Remove and return item at index (default last). + + Raises IndexError if list is empty or index is out of range. + """ + pass + + def remove(self, *args, **kwargs): # real signature unknown + """ + Remove first occurrence of value. + + Raises ValueError if the value is not present. + """ + pass + + def reverse(self, *args, **kwargs): # real signature unknown + """ Reverse *IN PLACE*. """ + pass + + def sort(self, *args, **kwargs): # real signature unknown + """ 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__ + """ + Built-in mutable sequence. + + If no argument is given, the constructor creates a new empty list. + The argument must be an iterable if specified. + # (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 + + +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 + + +class memoryview(object): + """ Create a new memoryview object which references the given object. """ + def cast(self, *args, **kwargs): # real signature unknown + """ Cast a memoryview to a new format or shape. """ + pass + + def hex(self, *args, **kwargs): # real signature unknown + """ Return the data in the buffer as a string of hexadecimal numbers. """ + pass + + def release(self, *args, **kwargs): # real signature unknown + """ Release the underlying buffer exposed by the memoryview object. """ + pass + + def tobytes(self, *args, **kwargs): # real signature unknown + """ Return the data in the buffer as a byte string. """ + pass + + def tolist(self, *args, **kwargs): # real signature unknown + """ Return the data in the buffer as a list of elements. """ + pass + + 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, *args, **kwargs): # real signature unknown + 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 range object + range(start, stop[, step]) -> range object + + Return an object that produces a sequence of integers from start (inclusive) + to stop (exclusive) by step. range(i, j) produces i, i+1, i+2, ..., j-1. + start defaults to 0, and stop is omitted! range(4) produces 0, 1, 2, 3. + These are exactly the valid indices for a list of 4 elements. + When step is given, it specifies the increment (or decrement). + """ + 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 __bool__(self, *args, **kwargs): # real signature unknown + """ self != 0 """ + 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 __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 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 + + +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: + @staticmethod + def f(arg1, arg2, ...): + ... + + 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 '' + + +class StopAsyncIteration(Exception): + """ Signal the end from iterator.__anext__(). """ + 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 + + +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""" + + + +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, *args, **kwargs): # real signature unknown + """ + Return a capitalized version of the string. + + More specifically, make the first character have upper case and the rest lower + case. + """ + pass + + def casefold(self, *args, **kwargs): # real signature unknown + """ Return a version of the string suitable for caseless comparisons. """ + pass + + def center(self, *args, **kwargs): # real signature unknown + """ + Return a centered 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__ + """ + 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, *args, **kwargs): # real signature unknown + """ + Encode the string using the codec registered for encoding. + + encoding + The encoding in which to encode the string. + errors + The error handling scheme to use for encoding errors. + The 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. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Return a copy 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__ + """ + 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(self, *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 + + 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. + + Raises ValueError when the substring is not found. + """ + return 0 + + def isalnum(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is an alpha-numeric string, False otherwise. + + A string is alpha-numeric if all characters in the string are alpha-numeric and + there is at least one character in the string. + """ + pass + + def isalpha(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is an alphabetic string, False otherwise. + + A string is alphabetic if all characters in the string are alphabetic and there + is at least one character in the string. + """ + pass + + def isascii(self, *args, **kwargs): # real signature unknown + """ + Return True if all characters in the string are ASCII, False otherwise. + + ASCII characters have code points in the range U+0000-U+007F. + Empty string is ASCII too. + """ + pass + + def isdecimal(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a decimal string, False otherwise. + + A string is a decimal string if all characters in the string are decimal and + there is at least one character in the string. + """ + pass + + def isdigit(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a digit string, False otherwise. + + A string is a digit string if all characters in the string are digits and there + is at least one character in the string. + """ + pass + + def isidentifier(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a valid Python identifier, False otherwise. + + Use keyword.iskeyword() to test for reserved identifiers such as "def" and + "class". + """ + pass + + def islower(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a lowercase string, False otherwise. + + A string is lowercase if all cased characters in the string are lowercase and + there is at least one cased character in the string. + """ + pass + + def isnumeric(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a numeric string, False otherwise. + + A string is numeric if all characters in the string are numeric and there is at + least one character in the string. + """ + pass + + def isprintable(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is printable, False otherwise. + + A string is printable if all of its characters are considered printable in + repr() or if it is empty. + """ + pass + + def isspace(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a whitespace string, False otherwise. + + A string is whitespace if all characters in the string are whitespace and there + is at least one character in the string. + """ + pass + + def istitle(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is a title-cased string, False otherwise. + + In a title-cased string, upper- and title-case characters may only + follow uncased characters and lowercase characters only cased ones. + """ + pass + + def isupper(self, *args, **kwargs): # real signature unknown + """ + Return True if the string is an uppercase string, False otherwise. + + A string is uppercase if all cased characters in the string are uppercase and + there is at least one cased character in the string. + """ + pass + + def join(self, ab=None, pq=None, rs=None): # real signature unknown; restored from __doc__ + """ + Concatenate any number of strings. + + The string whose method is called is inserted in between each given string. + The result is returned as a new string. + + Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs' + """ + pass + + def ljust(self, *args, **kwargs): # real signature unknown + """ + Return a left-justified string of length width. + + Padding is done using the specified fill character (default is a space). + """ + pass + + def lower(self, *args, **kwargs): # real signature unknown + """ Return a copy of the string converted to lowercase. """ + pass + + def lstrip(self, *args, **kwargs): # real signature unknown + """ + Return a copy of the string with leading whitespace removed. + + If chars is given and not None, remove characters in chars instead. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Partition the string into three parts using the given separator. + + This will search for the separator in the string. If the separator is found, + returns a 3-tuple containing the part before the separator, the separator + itself, and the part after it. + + If the separator is not found, returns a 3-tuple containing the original string + and two empty strings. + """ + pass + + def replace(self, *args, **kwargs): # real signature unknown + """ + Return a copy with all occurrences of substring old replaced by new. + + count + Maximum number of occurrences to replace. + -1 (the default value) means replace all occurrences. + + If the optional argument count is given, only the first count occurrences are + replaced. + """ + pass + + 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 + + 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. + + Raises ValueError when the substring is not found. + """ + return 0 + + def rjust(self, *args, **kwargs): # real signature unknown + """ + Return a right-justified string of length width. + + Padding is done using the specified fill character (default is a space). + """ + pass + + def rpartition(self, *args, **kwargs): # real signature unknown + """ + Partition the string into three parts using the given separator. + + This will search for the separator in the string, starting at the end. If + the separator is found, returns a 3-tuple containing the part before the + separator, the separator itself, and the part after it. + + If the separator is not found, returns a 3-tuple containing two empty strings + and the original string. + """ + pass + + def rsplit(self, *args, **kwargs): # real signature unknown + """ + Return a list of the words in the string, using sep as the delimiter string. + + sep + The delimiter according which to split the string. + None (the default value) means split according to any whitespace, + and discard empty strings from the result. + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + + Splits are done starting at the end of the string and working to the front. + """ + pass + + def rstrip(self, *args, **kwargs): # real signature unknown + """ + Return a copy of the string with trailing whitespace removed. + + If chars is given and not None, remove characters in chars instead. + """ + pass + + def split(self, *args, **kwargs): # real signature unknown + """ + Return a list of the words in the string, using sep as the delimiter string. + + sep + The delimiter according which to split the string. + None (the default value) means split according to any whitespace, + and discard empty strings from the result. + maxsplit + Maximum number of splits to do. + -1 (the default value) means no limit. + """ + pass + + def splitlines(self, *args, **kwargs): # real signature unknown + """ + Return a list of the lines in the string, breaking at line boundaries. + + Line breaks are not included in the resulting list unless keepends is given and + true. + """ + pass + + 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, *args, **kwargs): # real signature unknown + """ + Return a copy of the string with leading and trailing whitespace remove. + + If chars is given and not None, remove characters in chars instead. + """ + pass + + def swapcase(self, *args, **kwargs): # real signature unknown + """ Convert uppercase characters to lowercase and lowercase characters to uppercase. """ + pass + + def title(self, *args, **kwargs): # real signature unknown + """ + Return a version of the string where each word is titlecased. + + More specifically, words start with uppercased characters and all remaining + cased characters have lower case. + """ + pass + + def translate(self, *args, **kwargs): # real signature unknown + """ + Replace each character in the string using the given translation table. + + table + Translation table, which must be a mapping of Unicode ordinals to + Unicode ordinals, strings, or None. + + The table must implement lookup/indexing via __getitem__, for instance a + dictionary or list. If this operation raises LookupError, the character is + left untouched. Characters mapped to None are deleted. + """ + pass + + def upper(self, *args, **kwargs): # real signature unknown + """ Return a copy of the string converted to uppercase. """ + pass + + def zfill(self, *args, **kwargs): # real signature unknown + """ + Pad a numeric string with zeros on the left, to fill a field of the given width. + + The string 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 __format__(self, *args, **kwargs): # real signature unknown + """ Return a formatted version of the string as described by format_spec. """ + 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='', 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 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 + """ + + + +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 + + +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 + + +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""" + + + +class TabError(IndentationError): + """ Improper mixture of spaces and tabs. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class TimeoutError(OSError): + """ Timeout expired. """ + def __init__(self, *args, **kwargs): # real signature unknown + pass + + +class tuple(object): + """ + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. + If iterable is specified the tuple is initialized from iterable's items. + + If the argument is a tuple, the return value is the same object. + """ + def count(self, *args, **kwargs): # real signature unknown + """ Return number of occurrences of value. """ + pass + + def index(self, *args, **kwargs): # real signature unknown + """ + Return first index of value. + + Raises ValueError if the value is not present. + """ + 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, seq=()): # known special case of tuple.__init__ + """ + Built-in immutable sequence. + + If no argument is given, the constructor returns an empty tuple. + If iterable is specified the tuple is 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, *args, **kwargs): # real signature unknown + """ Return a type's method resolution order. """ + pass + + 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, *args, **kwargs): # real signature unknown + """ Specialized __dir__ implementation for types. """ + pass + + 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, *args, **kwargs): # real signature unknown + """ Check if an object is an instance. """ + 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 __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, *args, **kwargs): # real signature unknown + """ Return memory consumption of the type object. """ + pass + + def __subclasscheck__(self, *args, **kwargs): # real signature unknown + """ Check if a class is a subclass. """ + pass + + def __subclasses__(self, *args, **kwargs): # real signature unknown + """ Return a list of immediate subclasses. """ + pass + + __abstractmethods__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default + + + __bases__ = ( + object, + ) + __base__ = object + __basicsize__ = 864 + __dictoffset__ = 264 + __dict__ = None # (!) real value is '' + __flags__ = -2146675712 + __itemsize__ = 40 + __mro__ = ( + None, # (!) forward: type, real value is '' + object, + ) + __name__ = 'type' + __qualname__ = 'type' + __text_signature__ = None + __weakrefoffset__ = 368 + + +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 + + +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 + + +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 + + +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 + + +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""" + + + +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""" + + + +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""" + + + +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 + + +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 + + +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 + + +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 + + +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 create_module(self, *args, **kwargs): # real signature unknown + """ Create a built-in module """ + pass + + def exec_module(self, *args, **kwargs): # real signature unknown + """ Exec a built-in module """ + pass + + 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 the specified module into sys.modules and return it. + + This method is deprecated. Use loader.exec_module instead. + """ + 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.7/python_stubs/sys.py b/python/testData/MockSdk3.7/python_stubs/sys.py new file mode 100644 index 000000000000..bd1637f014a2 --- /dev/null +++ b/python/testData/MockSdk3.7/python_stubs/sys.py @@ -0,0 +1,704 @@ +# encoding: utf-8 +# module sys +# from (built-in) +# by generator 1.145 +""" +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 code point +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 +_enablelegacywindowsfsencoding -- [Windows only] +__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:\\Python37' + +base_prefix = 'C:\\Python37' + +byteorder = 'little' + +copyright = 'Copyright (c) 2001-2018 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 = 140705079492608 + +dont_write_bytecode = True + +executable = 'C:\\Python37\\python.exe' + +exec_prefix = 'C:\\Python37' + +float_repr_style = 'short' + +hexversion = 50790896 + +maxsize = 9223372036854775807 +maxunicode = 1114111 + +platform = 'win32' + +prefix = 'C:\\Python37' + +version = '3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]' + +winver = '3.7' + +_framework = '' + +_home = None + +# functions + +def breakpointhook(*args, **kws): # real signature unknown; restored from __doc__ + """ + breakpointhook(*args, **kws) + + This hook function is called by built-in breakpoint(). + """ + pass + +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 getfilesystemencodeerrors(): # real signature unknown; restored from __doc__ + """ + getfilesystemencodeerrors() -> string + + Return the error mode used to convert Unicode filenames in + operating system filenames. + """ + 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 and platform_type which are + strings, and platform_version which is a 3-tuple. Platform is always 2. + Product_type may be 1 for a workstation, 2 for a domain controller, 3 for a + server. Platform_version is a 3-tuple containing a version number that is + intended for identifying the OS rather than feature detection. + """ + pass + +def get_asyncgen_hooks(): # real signature unknown; restored from __doc__ + """ + get_asyncgen_hooks() + + Return a namedtuple of installed asynchronous generators hooks (firstiter, finalizer). + """ + pass + +def get_coroutine_origin_tracking_depth(*args, **kwargs): # real signature unknown + """ Check status of origin tracking for coroutine objects in this thread. """ + pass + +def get_coroutine_wrapper(): # real signature unknown; restored from __doc__ + """ + get_coroutine_wrapper() + + Return the wrapper for coroutine objects set by sys.set_coroutine_wrapper. + """ + 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 is_finalizing(): # real signature unknown; restored from __doc__ + """ + is_finalizing() + Return True if Python is exiting. + """ + pass + +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 set_asyncgen_hooks(*args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ + """ + set_asyncgen_hooks(*, firstiter=None, finalizer=None) + + Set a finalizer for async generators objects. + """ + pass + +def set_coroutine_origin_tracking_depth(*args, **kwargs): # real signature unknown + """ + Enable or disable origin tracking for coroutine objects in this thread. + + Coroutine objects will track 'depth' frames of traceback information about + where they came from, available in their cr_origin attribute. Set depth of 0 + to disable. + """ + pass + +def set_coroutine_wrapper(wrapper): # real signature unknown; restored from __doc__ + """ + set_coroutine_wrapper(wrapper) + + Set a wrapper for coroutine objects. + """ + 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 _enablelegacywindowsfsencoding(): # real signature unknown; restored from __doc__ + """ + _enablelegacywindowsfsencoding() + + Changes the default filesystem encoding to mbcs:replace for consistency + with earlier versions of Python. See PEP 529 for more information. + + This is equivalent to defining the PYTHONLEGACYWINDOWSFSENCODING + environment variable before launching Python. + """ + 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 __breakpointhook__(*args, **kwargs): # real signature unknown + """ + breakpointhook(*args, **kws) + + This hook function is called by built-in breakpoint(). + """ + 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 + +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 create_module(cls, *args, **kwargs): # real signature unknown + """ Create a built-in module """ + pass + + @classmethod + def exec_module(cls, *args, **kwargs): # real signature unknown + """ Exec a built-in module """ + pass + + @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 the specified module into sys.modules and return it. + + This method is deprecated. Use loader.exec_module instead. + """ + 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, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + False, + 0, +) + +float_info = ( + 1.7976931348623157e+308, + 1024, + 308, + 2.2250738585072014e-308, + -1021, + -307, + 15, + 53, + 2.220446049250313e-16, + 2, + 1, +) + +hash_info = ( + 64, + 2305843009213693951, + 314159, + 0, + 1000003, + 'siphash24', + 64, + 128, + 0, +) + +implementation = None # (!) real value is '' + +int_info = ( + 30, + 4, +) + +meta_path = [ + __loader__, + None, # (!) real value is '' + None, # (!) real value is '' +] + +modules = {} # real value of type skipped + +path = [ + 'C:\\Projects\\IDEA\\out\\classes\\production\\intellij.python.helpers', + 'C:\\Python37\\python37.zip', + 'C:\\Python37\\DLLs', + 'C:\\Python37\\lib', + 'C:\\Python37', + 'C:\\Python37\\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 # (!) forward: __stdin__, real value is '' + +stdout = None # (!) forward: __stdout__, real value is '' + +thread_info = ( + 'nt', + None, + None, +) + +version_info = ( + 3, + 7, + 1, + 'final', + 0, +) + +warnoptions = [] + +_git = ( + 'CPython', + 'v3.7.1', + '260ec2c36a', +) + +_xoptions = {} + +__spec__ = None # (!) real value is '' + +__stderr__ = stderr + +__stdin__ = None # (!) real value is '' + +__stdout__ = None # (!) real value is '' + +# intermittent names +exc_value = Exception() +exc_traceback=None diff --git a/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py b/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py index 154cf1dd98b8..b79665a044db 100644 --- a/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py +++ b/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py @@ -88,7 +88,7 @@ def f: pass # PY-30335 -with open('file', 'r') as file: +with open('file', None) as file: pass # PY-29731 diff --git a/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/b.py b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/b.py new file mode 100644 index 000000000000..80adb1ad2032 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/b.py @@ -0,0 +1,5 @@ +import logging + +logger = logging.getLogger() +logger.exception() +logging.exception() \ No newline at end of file diff --git a/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py new file mode 100644 index 000000000000..205bc4ce65fc --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MethodsForLoggingExceptions/logging.py @@ -0,0 +1,9 @@ +def getLogger(): + pass + +def exception(msg): + pass + +class Logger(object): + def exception(self, msg): + pass \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py new file mode 100644 index 000000000000..b4f337fe5995 --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/a.py @@ -0,0 +1,4 @@ +import logging + +logger = logging.getLogger() +logger.foobar() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py new file mode 100644 index 000000000000..9e6ae8ae6d2d --- /dev/null +++ b/python/testData/inspections/PyUnresolvedReferencesInspection/NonexistentLoggerMethod/logging.py @@ -0,0 +1,6 @@ +def getLogger(): + pass + +class Logger(object): + def exception(self, msg): + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyAddImportTest.java b/python/testSrc/com/jetbrains/python/PyAddImportTest.java index 84cc3e313d35..a11c6f6e70d9 100644 --- a/python/testSrc/com/jetbrains/python/PyAddImportTest.java +++ b/python/testSrc/com/jetbrains/python/PyAddImportTest.java @@ -32,16 +32,7 @@ import static com.jetbrains.python.codeInsight.imports.AddImportHelper.ImportPri */ public class PyAddImportTest extends PyTestCase { public void testAddBuiltin() { - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doAddImport("re", BUILTIN) - ) - ); + doAddImport("re", BUILTIN); } // PY-7400 @@ -61,16 +52,7 @@ public class PyAddImportTest extends PyTestCase { // PY-14765 public void testNewLastImportInBuiltinGroup() { - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doAddImportWithResolveInProject("sys", BUILTIN) - ) - ); + doAddImportWithResolveInProject("sys", BUILTIN); } // PY-14765 @@ -125,15 +107,9 @@ public class PyAddImportTest extends PyTestCase { // PY-16373 public void testLocalImportQuickFixAvailable() { - runWithAdditionalFileInLibDir( - "sys.py", - "path = 10", - (__) -> { - myFixture.configureByFile(getTestName(true) + ".py"); - myFixture.enableInspections(PyUnresolvedReferencesInspection.class); - assertNotNull(myFixture.findSingleIntention("Import 'sys' locally")); - } - ); + myFixture.configureByFile(getTestName(true) + ".py"); + myFixture.enableInspections(PyUnresolvedReferencesInspection.class); + assertNotNull(myFixture.findSingleIntention("Import 'sys' locally")); } // PY-23475 diff --git a/python/testSrc/com/jetbrains/python/PyClassNameCompletionTest.java b/python/testSrc/com/jetbrains/python/PyClassNameCompletionTest.java index 5ad2c894854c..49cafbc11499 100644 --- a/python/testSrc/com/jetbrains/python/PyClassNameCompletionTest.java +++ b/python/testSrc/com/jetbrains/python/PyClassNameCompletionTest.java @@ -41,11 +41,11 @@ public class PyClassNameCompletionTest extends PyTestCase { } public void testModule() { - runWithAdditionalFileInLibDir("collections.py", "", (__) -> doTest()); + doTest(); } public void testVariable() { - runWithAdditionalFileInLibDir("datetime.py", "MAXYEAR = 10", (__) -> doTest()); + doTest(); } public void testSubmodule() { // PY-7887 @@ -108,11 +108,7 @@ public class PyClassNameCompletionTest extends PyTestCase { // PY-20976 public void testOrderingLocalBeforeStdlib() { - runWithAdditionalFileInLibDir( - "sys.py", - "path = 10", - (__) -> doTestCompletionOrder("local_pkg.path", "local_pkg.local_module.path", "sys.path") - ); + doTestCompletionOrder("local_pkg.path", "local_pkg.local_module.path", "sys.path"); } // PY-20976 @@ -142,11 +138,7 @@ public class PyClassNameCompletionTest extends PyTestCase { // PY-20976 public void testCombinedOrdering() { - runWithAdditionalFileInLibDir( - "sys.py", - "path = 10", - (__) -> doTestCompletionOrder("main.path", "first.foo.path", "sys.path", "_second.bar.path") - ); + doTestCompletionOrder("main.path", "first.foo.path", "sys.path", "_second.bar.path"); } // PY-20976 diff --git a/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt b/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt index b30955f4ca01..5f155d1a5c55 100644 --- a/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt +++ b/python/testSrc/com/jetbrains/python/PyLineBreakpointTypeTest.kt @@ -7,6 +7,8 @@ import com.jetbrains.python.codeInsight.typing.PyTypeShed import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil.getUserSkeletonsDirectory import com.jetbrains.python.debugger.PyLineBreakpointType import com.jetbrains.python.fixtures.PyTestCase +import com.jetbrains.python.sdk.PythonSdkUtil +import com.jetbrains.python.sdk.PythonSdkUtil.findSkeletonsDir class PyLineBreakpointTypeTest : PyTestCase() { @@ -25,15 +27,16 @@ class PyLineBreakpointTypeTest : PyTestCase() { // PY-16932 fun testPutAtSkeleton() { - runWithAdditionalFileInSkeletonDir("my_mod.py", "class A:\n def method(self):\n print(\"ok\")") { pythonFile -> - val line = 2 + val sdk = PythonSdkUtil.findPythonSdk(myFixture.module) + val skeletonsDir = findSkeletonsDir(sdk!!) + val pythonFile = skeletonsDir!!.findFileByRelativePath("datetime.py") + val line = 20 - val document = FileDocumentManager.getInstance().getDocument(pythonFile) - val range = TextRange.create(document!!.getLineStartOffset(line), document.getLineEndOffset(line)) - assertEquals(" print(\"ok\")", document.getText(range)) + val document = FileDocumentManager.getInstance().getDocument(pythonFile!!) + val range = TextRange.create(document!!.getLineStartOffset(line), document.getLineEndOffset(line)) + assertEquals(" pass", document.getText(range)) - assertFalse(PyLineBreakpointType().canPutAt(pythonFile, line, myFixture.project)) - } + assertFalse(PyLineBreakpointType().canPutAt(pythonFile, line, myFixture.project)) } // PY-16932 diff --git a/python/testSrc/com/jetbrains/python/PyNavigationTest.kt b/python/testSrc/com/jetbrains/python/PyNavigationTest.kt index 52b8ba9a0907..30e08e85a816 100644 --- a/python/testSrc/com/jetbrains/python/PyNavigationTest.kt +++ b/python/testSrc/com/jetbrains/python/PyNavigationTest.kt @@ -28,11 +28,9 @@ class PyNavigationTest : PyTestCase() { // PY-35129 fun testGoToDeclarationForDirectory() { - runWithAdditionalFileInLibDir("collections/__init__.py", "") { - configureByDir(getTestName(true)) - val target = PyGotoDeclarationHandler().getGotoDeclarationTarget(elementAtCaret, myFixture.editor) - checkPyNotPyi(target) - } + configureByDir(getTestName(true)) + val target = PyGotoDeclarationHandler().getGotoDeclarationTarget(elementAtCaret, myFixture.editor) + checkPyNotPyi(target) } private fun configureByDir(dirName: String) { diff --git a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java index b25d0eecba5c..9dcf7754a838 100644 --- a/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java +++ b/python/testSrc/com/jetbrains/python/PyOptimizeImportsTest.java @@ -68,43 +68,16 @@ public class PyOptimizeImportsTest extends PyTestCase { } public void testOrderByType() { - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doTest() - ) - ); + doTest(); } // PY-12018 public void testAlphabeticalOrder() { - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doTest() - ) - ); + doTest(); } public void testInsertBlankLines() { // PY-8355 - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doTest() - ) - ); + doTest(); } // PY-16351 @@ -148,16 +121,7 @@ public class PyOptimizeImportsTest extends PyTestCase { // PY-18792 public void testDisableAlphabeticalOrder() { getPythonCodeStyleSettings().OPTIMIZE_IMPORTS_SORT_IMPORTS = false; - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doTest() - ) - ); + doTest(); } // PY-18792, PY-19292 @@ -263,20 +227,7 @@ public class PyOptimizeImportsTest extends PyTestCase { // PY-18972 public void testReferencesInFStringLiterals() { - runWithLanguageLevel( - LanguageLevel.PYTHON36, - () -> - runWithAdditionalFileInLibDir( - "sys.py", - "", - (__) -> - runWithAdditionalFileInLibDir( - "datetime.py", - "", - (___) -> doTest() - ) - ) - ); + runWithLanguageLevel(LanguageLevel.PYTHON36, this::doTest); } // PY-22355 diff --git a/python/testSrc/com/jetbrains/python/PyQuickDocTest.java b/python/testSrc/com/jetbrains/python/PyQuickDocTest.java index 8698c67da439..2ea9e15cb1ab 100644 --- a/python/testSrc/com/jetbrains/python/PyQuickDocTest.java +++ b/python/testSrc/com/jetbrains/python/PyQuickDocTest.java @@ -10,9 +10,6 @@ import com.jetbrains.python.documentation.PythonDocumentationProvider; import com.jetbrains.python.documentation.docstrings.DocStringFormat; import com.jetbrains.python.fixtures.LightMarkedTestCase; import com.jetbrains.python.psi.*; -import com.jetbrains.python.psi.impl.PyBuiltinCache; -import com.jetbrains.python.sdk.PythonSdkType; -import com.jetbrains.python.sdk.PythonSdkUtil; import org.jetbrains.annotations.NotNull; import java.util.Map; @@ -329,19 +326,7 @@ public class PyQuickDocTest extends LightMarkedTestCase { // PY-22685 public void testBuiltinLen() { - final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(PythonSdkUtil.findPythonSdk(myFixture.getModule())); - - runWithAdditionalFileInLibDir( - PyBuiltinCache.getBuiltinsFileName(languageLevel), - "def len(p_object): # real signature unknown; restored from __doc__\n" + - " \"\"\"\n" + - " len(object) -> integer\n" + - " \n" + - " Return the number of items of a sequence or collection.\n" + - " \"\"\"\n" + - " return 0", - (__) -> checkHTMLOnly() - ); + checkHTMLOnly(); } public void testArgumentList() { @@ -369,16 +354,7 @@ public class PyQuickDocTest extends LightMarkedTestCase { } public void testReferenceToMethodQualifiedWithInstance() { - final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(PythonSdkUtil.findPythonSdk(myFixture.getModule())); - - runWithAdditionalFileInLibDir( - PyBuiltinCache.getBuiltinsFileName(languageLevel), - "class list(object):\n" + - " def count(self, value): # real signature unknown; restored from __doc__\n" + - " \"\"\" L.count(value) -> integer -- return number of occurrences of value \"\"\"\n" + - " return 0", - (__) -> checkHTMLOnly() - ); + checkHTMLOnly(); } public void testOneDecoratorFunction() { diff --git a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java index f51ba84cd45b..47ffa4857604 100644 --- a/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java +++ b/python/testSrc/com/jetbrains/python/PythonInspectionsTest.java @@ -8,9 +8,6 @@ import com.jetbrains.python.documentation.docstrings.DocStringFormat; import com.jetbrains.python.fixtures.PyTestCase; import com.jetbrains.python.inspections.*; import com.jetbrains.python.psi.LanguageLevel; -import com.jetbrains.python.psi.impl.PyBuiltinCache; -import com.jetbrains.python.sdk.PythonSdkType; -import com.jetbrains.python.sdk.PythonSdkUtil; /** * @author yole @@ -228,17 +225,7 @@ public class PythonInspectionsTest extends PyTestCase { } public void testPyArgumentEqualDefaultInspection() { //PY-3125 - final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(PythonSdkUtil.findPythonSdk(myFixture.getModule())); - - runWithAdditionalFileInLibDir( - PyBuiltinCache.getBuiltinsFileName(languageLevel), - "class property(object):\n" + - " def __init__(self, fget=None, fset=None, fdel=None, doc=None):\n" + - " pass\n" + - "def open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=True):\n" + - " pass", - (__) -> doHighlightingTest(PyArgumentEqualDefaultInspection.class) - ); + doHighlightingTest(PyArgumentEqualDefaultInspection.class); } public void testPyArgumentEqualDefaultInspectionPy3() { diff --git a/python/testSrc/com/jetbrains/python/PythonMockSdk.java b/python/testSrc/com/jetbrains/python/PythonMockSdk.java index 1a943394ab21..56157d57ac91 100644 --- a/python/testSrc/com/jetbrains/python/PythonMockSdk.java +++ b/python/testSrc/com/jetbrains/python/PythonMockSdk.java @@ -21,7 +21,6 @@ import com.intellij.openapi.projectRoots.impl.MockSdk; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.MultiMap; import com.jetbrains.python.codeInsight.typing.PyTypeShed; import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil; @@ -32,7 +31,6 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import java.io.File; -import java.util.Arrays; /** * @author yole @@ -50,22 +48,30 @@ public class PythonMockSdk { SdkType sdkType = PythonSdkType.getInstance(); MultiMap roots = MultiMap.create(); - OrderRootType classes = OrderRootType.CLASSES; - ContainerUtil.putIfNotNull(classes, LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(mock_path, "Lib")), roots); + File libPath = new File(mock_path, "Lib"); + if (libPath.exists()) { + roots.putValue(OrderRootType.CLASSES, LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath)); + } - ContainerUtil.putIfNotNull(classes, PyUserSkeletonsUtil.getUserSkeletonsDirectory(), roots); + roots.putValue(OrderRootType.CLASSES, PyUserSkeletonsUtil.getUserSkeletonsDirectory()); final LanguageLevel level = LanguageLevel.fromPythonVersion(version); final VirtualFile typeShedDir = PyTypeShed.INSTANCE.getDirectory(); - PyTypeShed.INSTANCE - .findRootsForLanguageLevel(level) - .forEach(path -> ContainerUtil.putIfNotNull(classes, typeShedDir.findFileByRelativePath(path), roots)); + assert typeShedDir != null; + PyTypeShed.INSTANCE.findRootsForLanguageLevel(level).forEach(path -> { + final VirtualFile file = typeShedDir.findFileByRelativePath(path); + if (file != null) { + roots.putValue(OrderRootType.CLASSES, file); + } + }); String mock_stubs_path = mock_path + PythonSdkUtil.SKELETON_DIR_NAME; - ContainerUtil.putIfNotNull(classes, LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), roots); + roots.putValue(PythonSdkUtil.BUILTIN_ROOT_TYPE, LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path)); - roots.putValues(classes, Arrays.asList(additionalRoots)); + for (final VirtualFile root : additionalRoots) { + roots.putValue(OrderRootType.CLASSES, root); + } MockSdk sdk = new MockSdk(MOCK_SDK_NAME + " " + version, sdkHome, "Python " + version + " Mock SDK", roots, sdkType); diff --git a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java index a7bde1144d44..2e5177148e0c 100644 --- a/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java +++ b/python/testSrc/com/jetbrains/python/fixtures/PyTestCase.java @@ -40,7 +40,10 @@ import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.refactoring.RefactoringActionHandler; -import com.intellij.testFramework.*; +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.PsiTestUtil; +import com.intellij.testFramework.TestDataPath; +import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.*; import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl; import com.intellij.usageView.UsageInfo; @@ -59,7 +62,6 @@ import com.jetbrains.python.formatter.PyCodeStyleSettings; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.impl.PyFileImpl; import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher; -import com.jetbrains.python.psi.search.PySearchUtilBase; import com.jetbrains.python.psi.types.PyType; import com.jetbrains.python.psi.types.TypeEvalContext; import com.jetbrains.python.sdk.PythonSdkUtil; @@ -70,7 +72,6 @@ import org.junit.Assert; import javax.swing.*; import java.io.File; import java.util.*; -import java.util.function.Consumer; /** * @author yole @@ -170,33 +171,6 @@ public abstract class PyTestCase extends UsefulTestCase { return new LightTempDirTestFixtureImpl(true); // "tmp://" dir by default } - protected void runWithAdditionalFileInLibDir(@NotNull String relativePath, - @NotNull String text, - @NotNull Consumer consumer) { - final Sdk sdk = PythonSdkUtil.findPythonSdk(myFixture.getModule()); - runWithAdditionalFileIn(relativePath, text, PySearchUtilBase.findLibDir(sdk), consumer); - } - - protected void runWithAdditionalFileInSkeletonDir(@NotNull String relativePath, - @NotNull String text, - @NotNull Consumer consumer) { - final Sdk sdk = PythonSdkUtil.findPythonSdk(myFixture.getModule()); - runWithAdditionalFileIn(relativePath, text, PythonSdkUtil.findSkeletonsDir(sdk), consumer); - } - - private void runWithAdditionalFileIn(@NotNull String relativePath, - @NotNull String text, - @NotNull VirtualFile dir, - @NotNull Consumer consumer) { - final VirtualFile file = VfsTestUtil.createFile(dir, relativePath, text); - try { - consumer.accept(file); - } - finally { - VfsTestUtil.deleteFile(file); - } - } - protected void runWithAdditionalClassEntryInSdkRoots(@NotNull VirtualFile directory, @NotNull Runnable runnable) { final Sdk sdk = PythonSdkUtil.findPythonSdk(myFixture.getModule()); assertNotNull(sdk); diff --git a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java index ea8cfb34e33f..744121a1e7c5 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyArgumentListInspectionTest.java @@ -190,6 +190,11 @@ public class PyArgumentListInspectionTest extends PyInspectionTestCase { doTest(); } + // PY-19716 + public void testMethodsForLoggingExceptions() { + doMultiFileTest("b.py"); + } + // PY-19522 public void testCsvRegisterDialect() { doMultiFileTest("b.py"); diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java index e2a2857904fa..41a36e5f6d23 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -540,6 +540,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { doTest(); } + // PY-20071 + public void testNonexistentLoggerMethod() { + doMultiFileTest(); + } + // PY-21224 public void testSixWithMetaclass() { doTest(); diff --git a/python/testSrc/com/jetbrains/python/quickFixes/PyAddImportQuickFixTest.java b/python/testSrc/com/jetbrains/python/quickFixes/PyAddImportQuickFixTest.java index ea5cba9c5ef5..8715a4fbd360 100644 --- a/python/testSrc/com/jetbrains/python/quickFixes/PyAddImportQuickFixTest.java +++ b/python/testSrc/com/jetbrains/python/quickFixes/PyAddImportQuickFixTest.java @@ -74,25 +74,12 @@ public class PyAddImportQuickFixTest extends PyQuickFixTestCase { // PY-21563 public void testCombineFromImportsForReferencesInTypeComment() { - doMultiFileAutoImportTest("Import 'typing.Set'"); + doMultiFileAutoImportTest("Import this name"); } // PY-25234 public void testBinarySkeletonStdlibModule() { - runWithAdditionalFileInLibDir( - "re.py", - "", - (__) -> - runWithAdditionalFileInSkeletonDir( - "sys.py", - "# encoding: utf-8\n" + - "# module sys\n" + - "# from (built-in)\n" + - "# by generator 1.138\n" + - "path = 10", - (___) -> doMultiFileAutoImportTest("Import 'sys'") - ) - ); + doMultiFileAutoImportTest("Import 'sys'"); } // PY-25234 @@ -155,20 +142,12 @@ public class PyAddImportQuickFixTest extends PyQuickFixTestCase { // PY-20976 public void testOrderingLocalBeforeStdlib() { - runWithAdditionalFileInLibDir( - "sys.py", - "path = 10", - (__) -> doTestProposedImportsOrdering("path", "pkg.path", "sys.path", "os.path") - ); + doTestProposedImportsOrdering("path", "pkg.path", "sys.path", "os.path"); } // PY-20976 public void testOrderingUnderscoreInPath() { - runWithAdditionalFileInLibDir( - "sys.py", - "path = 10", - (__) -> doTestProposedImportsOrdering("path", "first.second.path", "sys.path", "os.path", "_private.path") - ); + doTestProposedImportsOrdering("path", "first.second.path", "sys.path", "os.path", "_private.path"); } // PY-20976 diff --git a/python/testSrc/com/jetbrains/python/refactoring/PyInlineFunctionTest.kt b/python/testSrc/com/jetbrains/python/refactoring/PyInlineFunctionTest.kt index a8c0b82d5abf..a962b004c794 100644 --- a/python/testSrc/com/jetbrains/python/refactoring/PyInlineFunctionTest.kt +++ b/python/testSrc/com/jetbrains/python/refactoring/PyInlineFunctionTest.kt @@ -122,11 +122,7 @@ class PyInlineFunctionTest : PyTestCase() { fun testOverridden() = doTestError("Cannot inline overridden methods") fun testNested() = doTestError("Cannot inline functions with another function declaration") fun testInterruptedFlow() = doTestError("Cannot inline functions that interrupt control flow") - fun testFunctionFromBinaryStub() { - runWithAdditionalFileInSkeletonDir("sys.py", "def exit():\n pass") { - doTestError("Cannot inline function from binary module") - } - } + fun testFunctionFromBinaryStub() = doTestError("Cannot inline function from binary module") fun testUsedAsDecorator() = doTestError("Function foo is used as a decorator and cannot be inlined. Function definition will not be removed", isReferenceError = true) fun testUsedAsReference() = doTestError("Function foo is used as a reference and cannot be inlined. Function definition will not be removed", isReferenceError = true) fun testUsesArgumentUnpacking() = doTestError("Function foo uses argument unpacking and cannot be inlined. Function definition will not be removed", isReferenceError = true)