Skip to content

Commit

Permalink
refactor: re-formats code according to black rules
Browse files Browse the repository at this point in the history
Also removed extra comments in the file headers.
Should make merging of existing PRs messy.
  • Loading branch information
joamag committed Apr 22, 2024
1 parent d16093a commit dea137c
Show file tree
Hide file tree
Showing 173 changed files with 8,472 additions and 8,453 deletions.
28 changes: 10 additions & 18 deletions examples/basic/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -41,24 +32,25 @@

import netius

def set(future, raise_e = True):
if raise_e: future.set_exception(Exception("Awaiting error"))
else: future.set_result(42)

def set(future, raise_e=True):
if raise_e:
future.set_exception(Exception("Awaiting error"))
else:
future.set_result(42)


@netius.coroutine
def await_forever():
print("Awaiting forever")
future = netius.build_future()
thread = threading.Thread(
target = set,
args = (future,),
kwargs = dict(raise_e = True)
)
thread = threading.Thread(target=set, args=(future,), kwargs=dict(raise_e=True))
thread.start()
result = yield from future
return result

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
result = loop.run_until_complete(await_forever())
loop.close()

Expand Down
28 changes: 10 additions & 18 deletions examples/basic/future_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -41,22 +32,23 @@

import netius

def set(future, raise_e = True):
if raise_e: future.set_exception(Exception("Awaiting error"))
else: future.set_result(42)

def set(future, raise_e=True):
if raise_e:
future.set_exception(Exception("Awaiting error"))
else:
future.set_result(42)


async def await_forever():
print("Awaiting forever")
future = netius.build_future()
thread = threading.Thread(
target = set,
args = (future,),
kwargs = dict(raise_e = True)
)
thread = threading.Thread(target=set, args=(future,), kwargs=dict(raise_e=True))
thread.start()
return await future

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
result = loop.run_until_complete(await_forever())
loop.close()

Expand Down
31 changes: 12 additions & 19 deletions examples/basic/future_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -41,23 +32,25 @@

import netius

def set(future, raise_e = True):
if raise_e: future.set_exception(Exception("Awaiting error"))
else: future.set_result(42)

def set(future, raise_e=True):
if raise_e:
future.set_exception(Exception("Awaiting error"))
else:
future.set_result(42)


@netius.coroutine
def await_forever():
print("Awaiting forever")
future = netius.build_future()
thread = threading.Thread(
target = set,
args = (future,),
kwargs = dict(raise_e = True)
)
thread = threading.Thread(target=set, args=(future,), kwargs=dict(raise_e=True))
thread.start()
for value in future: yield value
for value in future:
yield value


loop = netius.get_loop(_compat = True)
loop = netius.get_loop(_compat=True)
result = loop.run_until_complete(await_forever())
loop.close()

Expand Down
14 changes: 4 additions & 10 deletions examples/basic/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -39,17 +30,20 @@

import netius


@netius.coroutine
def compute(x, y):
print("Compute %s + %s ..." % (x, y))
yield from netius.sleep(1.0)
return x + y


@netius.coroutine
def print_sum(x, y):
result = yield from compute(x, y)
print("%s + %s = %s" % (x, y, result))

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
loop.run_until_complete(print_sum(1, 2))
loop.close()
14 changes: 4 additions & 10 deletions examples/basic/loop_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -41,17 +32,20 @@

import netius


@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 = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
loop.run_until_complete(print_sum(1, 2))
loop.close()
14 changes: 4 additions & 10 deletions examples/basic/loop_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -39,15 +30,18 @@

import netius


async def compute(x, y):
print("Compute %s + %s ..." % (x, y))
await netius.sleep(1.0)
return x + y


async def print_sum(x, y):
result = await compute(x, y)
print("%s + %s = %s" % (x, y, result))

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
loop.run_until_complete(print_sum(1, 2))
loop.close()
20 changes: 8 additions & 12 deletions examples/basic/loop_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -39,19 +30,24 @@

import netius


@netius.coroutine
def compute(future, x, y):
print("Compute %s + %s ..." % (x, y))
for value in netius.sleep(1.0): yield value
for value in netius.sleep(1.0):
yield value
future.set_result(x + y)


@netius.coroutine
def print_sum(x, y):
future = netius.build_future()
for value in compute(future, x, y): yield value
for value in compute(future, x, y):
yield value
result = future.result()
print("%s + %s = %s" % (x, y, result))

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
loop.run_until_complete(print_sum(1, 2))
loop.close()
13 changes: 3 additions & 10 deletions examples/basic/sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -39,13 +30,15 @@

import netius


@netius.coroutine
def compute(x, y):
print("Compute %s + %s ..." % (x, y))
yield from netius.sleep(1.0)
return x + y

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
result = loop.run_until_complete(compute(1, 2))
loop.close()

Expand Down
14 changes: 4 additions & 10 deletions examples/basic/sum_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@
__author__ = "João Magalhães <[email protected]>"
""" The author(s) of the module """

__version__ = "1.0.0"
""" The version of the module """

__revision__ = "$LastChangedRevision$"
""" The revision number of the module """

__date__ = "$LastChangedDate$"
""" The last change date of the module """

__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
""" The copyright for the module """

Expand All @@ -39,18 +30,21 @@

import netius


async def compute(x, y):
result = None
async for value in _compute(x, y):
result = value
return result


async def _compute(x, y):
print("Compute %s + %s ..." % (x, y))
await netius.sleep(1.0)
yield x + y

loop = netius.get_loop(_compat = True)

loop = netius.get_loop(_compat=True)
result = loop.run_until_complete(compute(1, 2))
loop.close()

Expand Down
Loading

0 comments on commit dea137c

Please sign in to comment.