top: Remove unhelpful packages.

pull/376/head
Jim Mussared 2020-03-20 10:10:57 +11:00
rodzic 444b45e431
commit b4eeaae105
20 zmienionych plików z 0 dodań i 368 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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()

Wyświetl plik

@ -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()

Wyświetl plik

@ -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()

Wyświetl plik

@ -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())

Wyświetl plik

@ -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()

Wyświetl plik

@ -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()

Wyświetl plik

@ -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()

Wyświetl plik

@ -1 +0,0 @@
cache = {}

Wyświetl plik

@ -1,3 +0,0 @@
srctype = dummy
type = module
version = 0.0.1

Wyświetl plik

@ -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'])

Wyświetl plik

@ -1,3 +0,0 @@
srctype = dummy
type = module
version = 0.0.3

Wyświetl plik

@ -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'])

Wyświetl plik

@ -1,6 +0,0 @@
def east_asian_width(c):
return 1
def normalize(form, unistr):
return unistr

Wyświetl plik

@ -1,3 +0,0 @@
srctype=dummy
type=module
version = 0.0.2

Wyświetl plik

@ -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'])

Wyświetl plik

@ -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

Wyświetl plik

@ -1,3 +0,0 @@
srctype = dummy
type = module
version = 0.0.1

Wyświetl plik

@ -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'])

Wyświetl plik

@ -1 +0,0 @@
from uzlib import *