diff --git a/asyncio_slow/asyncio_slow.py b/asyncio_slow/asyncio_slow.py deleted file mode 100644 index 89245ce0..00000000 --- a/asyncio_slow/asyncio_slow.py +++ /dev/null @@ -1,151 +0,0 @@ -import time -import logging - - -log = logging.getLogger("asyncio") - - -# Workaround for not being able to subclass builtin types -class LoopStop(Exception): - pass - -class InvalidStateError(Exception): - pass - -# Object not matching any other object -_sentinel = [] - - -class EventLoop: - - def __init__(self): - self.q = [] - - def call_soon(self, c, *args): - self.q.append((c, args)) - - def call_later(self, delay, c, *args): - def _delayed(c, args, delay): - yield from sleep(delay) - self.call_soon(c, *args) - Task(_delayed(c, args, delay)) - - def run_forever(self): - while self.q: - c = self.q.pop(0) - try: - c[0](*c[1]) - except LoopStop: - return - # I mean, forever - while True: - time.sleep(1) - - def stop(self): - def _cb(): - raise LoopStop - self.call_soon(_cb) - - def run_until_complete(self, coro): - t = ensure_future(coro) - t.add_done_callback(lambda a: self.stop()) - self.run_forever() - - def close(self): - pass - - -_def_event_loop = EventLoop() - - -class Future: - - def __init__(self, loop=_def_event_loop): - self.loop = loop - self.res = _sentinel - self.cbs = [] - - def result(self): - if self.res is _sentinel: - raise InvalidStateError - return self.res - - def add_done_callback(self, fn): - if self.res is _sentinel: - self.cbs.append(fn) - else: - self.loop.call_soon(fn, self) - - def set_result(self, val): - self.res = val - for f in self.cbs: - f(self) - - -class Task(Future): - - def __init__(self, coro, loop=_def_event_loop): - super().__init__() - self.loop = loop - self.c = coro - # upstream asyncio forces task to be scheduled on instantiation - self.loop.call_soon(self) - - def __call__(self): - try: - next(self.c) - self.loop.call_soon(self) - except StopIteration as e: - log.debug("Coro finished: %s", self.c) - self.set_result(None) - - -def get_event_loop(): - return _def_event_loop - - -# Decorator -def coroutine(f): - return f - - -def ensure_future(coro): - if isinstance(coro, Future): - return coro - return Task(coro) - - -class _Wait(Future): - - def __init__(self, n): - Future.__init__(self) - self.n = n - - def _done(self): - self.n -= 1 - log.debug("Wait: remaining tasks: %d", self.n) - if not self.n: - self.set_result(None) - - def __call__(self): - pass - - -def wait(coro_list, loop=_def_event_loop): - - w = _Wait(len(coro_list)) - - for c in coro_list: - t = ensure_future(c) - t.add_done_callback(lambda val: w._done()) - - return w - - -def sleep(secs): - t = time.time() - log.debug("Started sleep at: %s, targetting: %s", t, t + secs) - while time.time() < t + secs: - time.sleep(0.01) - yield - log.debug("Finished sleeping %ss", secs) diff --git a/asyncio_slow/example_chain.py b/asyncio_slow/example_chain.py deleted file mode 100644 index 8d6b9a61..00000000 --- a/asyncio_slow/example_chain.py +++ /dev/null @@ -1,18 +0,0 @@ -#https://docs.python.org/3.4/library/asyncio-task.html#example-chain-coroutines -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def compute(x, y): - print("Compute %s + %s ..." % (x, y)) - yield from asyncio.sleep(1.0) - return x + y - -@asyncio.coroutine -def print_sum(x, y): - result = yield from compute(x, y) - print("%s + %s = %s" % (x, y, result)) - -loop = asyncio.get_event_loop() -loop.run_until_complete(print_sum(1, 2)) -loop.close() diff --git a/asyncio_slow/example_future.py b/asyncio_slow/example_future.py deleted file mode 100644 index 53026c8d..00000000 --- a/asyncio_slow/example_future.py +++ /dev/null @@ -1,15 +0,0 @@ -#https://docs.python.org/3.4/library/asyncio-task.html#example-chain-coroutines -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def slow_operation(future): - yield from asyncio.sleep(1) - future.set_result('Future is done!') - -loop = asyncio.get_event_loop() -future = asyncio.Future() -asyncio.Task(slow_operation(future)) -loop.run_until_complete(future) -print(future.result()) -loop.close() diff --git a/asyncio_slow/example_future2.py b/asyncio_slow/example_future2.py deleted file mode 100644 index 8ba03ef8..00000000 --- a/asyncio_slow/example_future2.py +++ /dev/null @@ -1,21 +0,0 @@ -#https://docs.python.org/3.4/library/asyncio-task.html#example-future-with-run-forever -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def slow_operation(future): - yield from asyncio.sleep(1) - future.set_result('Future is done!') - -def got_result(future): - print(future.result()) - loop.stop() - -loop = asyncio.get_event_loop() -future = asyncio.Future() -asyncio.Task(slow_operation(future)) -future.add_done_callback(got_result) -try: - loop.run_forever() -finally: - loop.close() \ No newline at end of file diff --git a/asyncio_slow/example_hello_world.py b/asyncio_slow/example_hello_world.py deleted file mode 100644 index fab55813..00000000 --- a/asyncio_slow/example_hello_world.py +++ /dev/null @@ -1,12 +0,0 @@ -#https://docs.python.org/3.4/library/asyncio-task.html#example-hello-world-coroutine -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def greet_every_two_seconds(): - while True: - print('Hello World') - yield from asyncio.sleep(2) - -loop = asyncio.get_event_loop() -loop.run_until_complete(greet_every_two_seconds()) diff --git a/asyncio_slow/example_hello_world_bare.py b/asyncio_slow/example_hello_world_bare.py deleted file mode 100644 index 1f8d9702..00000000 --- a/asyncio_slow/example_hello_world_bare.py +++ /dev/null @@ -1,12 +0,0 @@ -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def greet_every_two_seconds(): - while True: - print('Hello World') - yield from asyncio.sleep(2) - -loop = asyncio.get_event_loop() -asyncio.Task(greet_every_two_seconds()) -loop.run_forever() diff --git a/asyncio_slow/example_hello_world_callback.py b/asyncio_slow/example_hello_world_callback.py deleted file mode 100644 index 9836ffd7..00000000 --- a/asyncio_slow/example_hello_world_callback.py +++ /dev/null @@ -1,11 +0,0 @@ -# https://docs.python.org/3.4/library/asyncio-eventloop.html#example-hello-world-callback -#import asyncio -import asyncio_slow as asyncio - -def print_and_repeat(loop): - print('Hello World') - loop.call_later(2, print_and_repeat, loop) - -loop = asyncio.get_event_loop() -loop.call_soon(print_and_repeat, loop) -loop.run_forever() diff --git a/asyncio_slow/example_parallel.py b/asyncio_slow/example_parallel.py deleted file mode 100644 index 48a187b8..00000000 --- a/asyncio_slow/example_parallel.py +++ /dev/null @@ -1,21 +0,0 @@ -#https://docs.python.org/3.4/library/asyncio-task.html#example-parallel-execution-of-tasks -#import asyncio -import asyncio_slow as asyncio - -@asyncio.coroutine -def factorial(name, number): - f = 1 - for i in range(2, number+1): - print("Task %s: Compute factorial(%s)..." % (name, i)) - yield from asyncio.sleep(1) - f *= i - print("Task %s: factorial(%s) = %s" % (name, number, f)) - -tasks = [ - asyncio.Task(factorial("A", 2)), - asyncio.Task(factorial("B", 3)), - asyncio.Task(factorial("C", 4))] - -loop = asyncio.get_event_loop() -loop.run_until_complete(asyncio.wait(tasks)) -loop.close() diff --git a/linecache/linecache.py b/linecache/linecache.py deleted file mode 100644 index 039e6af9..00000000 --- a/linecache/linecache.py +++ /dev/null @@ -1 +0,0 @@ -cache = {} diff --git a/linecache/metadata.txt b/linecache/metadata.txt deleted file mode 100644 index dc5f60a6..00000000 --- a/linecache/metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -srctype = dummy -type = module -version = 0.0.1 diff --git a/linecache/setup.py b/linecache/setup.py deleted file mode 100644 index c1a9ba10..00000000 --- a/linecache/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -# Remove current dir from sys.path, otherwise setuptools will peek up our -# module instead of system's. -sys.path.pop(0) -from setuptools import setup -sys.path.append("..") -import sdist_upip - -setup(name='micropython-linecache', - version='0.0.1', - description='Dummy linecache module for MicroPython', - long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.', - url='https://github.com/micropython/micropython-lib', - author='micropython-lib Developers', - author_email='micro-python@googlegroups.com', - maintainer='micropython-lib Developers', - maintainer_email='micro-python@googlegroups.com', - license='MIT', - cmdclass={'sdist': sdist_upip.sdist}, - py_modules=['linecache']) diff --git a/unicodedata/metadata.txt b/unicodedata/metadata.txt deleted file mode 100644 index 849688fb..00000000 --- a/unicodedata/metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -srctype = dummy -type = module -version = 0.0.3 diff --git a/unicodedata/setup.py b/unicodedata/setup.py deleted file mode 100644 index 4635da4d..00000000 --- a/unicodedata/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -# Remove current dir from sys.path, otherwise setuptools will peek up our -# module instead of system's. -sys.path.pop(0) -from setuptools import setup -sys.path.append("..") -import sdist_upip - -setup(name='micropython-unicodedata', - version='0.0.3', - description='Dummy unicodedata module for MicroPython', - long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.', - url='https://github.com/micropython/micropython-lib', - author='micropython-lib Developers', - author_email='micro-python@googlegroups.com', - maintainer='micropython-lib Developers', - maintainer_email='micro-python@googlegroups.com', - license='MIT', - cmdclass={'sdist': sdist_upip.sdist}, - py_modules=['unicodedata']) diff --git a/unicodedata/unicodedata.py b/unicodedata/unicodedata.py deleted file mode 100644 index 2b6cfd7e..00000000 --- a/unicodedata/unicodedata.py +++ /dev/null @@ -1,6 +0,0 @@ -def east_asian_width(c): - return 1 - - -def normalize(form, unistr): - return unistr diff --git a/weakref/metadata.txt b/weakref/metadata.txt deleted file mode 100644 index fda992a9..00000000 --- a/weakref/metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -srctype=dummy -type=module -version = 0.0.2 diff --git a/weakref/setup.py b/weakref/setup.py deleted file mode 100644 index 822d4787..00000000 --- a/weakref/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -# Remove current dir from sys.path, otherwise setuptools will peek up our -# module instead of system's. -sys.path.pop(0) -from setuptools import setup -sys.path.append("..") -import sdist_upip - -setup(name='micropython-weakref', - version='0.0.2', - description='Dummy weakref module for MicroPython', - long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.', - url='https://github.com/micropython/micropython-lib', - author='micropython-lib Developers', - author_email='micro-python@googlegroups.com', - maintainer='micropython-lib Developers', - maintainer_email='micro-python@googlegroups.com', - license='MIT', - cmdclass={'sdist': sdist_upip.sdist}, - py_modules=['weakref']) diff --git a/weakref/weakref.py b/weakref/weakref.py deleted file mode 100644 index 76aabfa3..00000000 --- a/weakref/weakref.py +++ /dev/null @@ -1,7 +0,0 @@ -# -# This is completely dummy implementation, which does not -# provide real weak references, and thus will hoard memory! -# - -def proxy(obj, cb=None): - return obj diff --git a/zlib/metadata.txt b/zlib/metadata.txt deleted file mode 100644 index dc5f60a6..00000000 --- a/zlib/metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -srctype = dummy -type = module -version = 0.0.1 diff --git a/zlib/setup.py b/zlib/setup.py deleted file mode 100644 index a5584b1f..00000000 --- a/zlib/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -import sys -# Remove current dir from sys.path, otherwise setuptools will peek up our -# module instead of system's. -sys.path.pop(0) -from setuptools import setup -sys.path.append("..") -import sdist_upip - -setup(name='micropython-zlib', - version='0.0.1', - description='Dummy zlib module for MicroPython', - long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.', - url='https://github.com/micropython/micropython-lib', - author='micropython-lib Developers', - author_email='micro-python@googlegroups.com', - maintainer='micropython-lib Developers', - maintainer_email='micro-python@googlegroups.com', - license='MIT', - cmdclass={'sdist': sdist_upip.sdist}, - py_modules=['zlib']) diff --git a/zlib/zlib.py b/zlib/zlib.py deleted file mode 100644 index e803341c..00000000 --- a/zlib/zlib.py +++ /dev/null @@ -1 +0,0 @@ -from uzlib import *