47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
import argparse
|
||
|
import asyncio
|
||
|
import sys
|
||
|
|
||
|
import uvloop
|
||
|
|
||
|
__version__ = "0.0.1"
|
||
|
|
||
|
|
||
|
async def main(args: argparse.Namespace) -> None:
|
||
|
"""
|
||
|
Main function of the program (stub).
|
||
|
|
||
|
This function serves as ${REPO_NAME_SNAKE}'s critical path for primary logic.
|
||
|
It receives an `argparse.Namespace` object as input from invoke_maiun, which includes
|
||
|
the command-line arguments that were defined and parsed in the `run` function.
|
||
|
|
||
|
Args:
|
||
|
args (argparse.Namespace): The command-line arguments object.
|
||
|
|
||
|
Returns:
|
||
|
None
|
||
|
"""
|
||
|
pass
|
||
|
|
||
|
|
||
|
def invoke_main(args: argparse.Namespace) -> None:
|
||
|
"""
|
||
|
Function to invoke the main function using asyncio and uvloop (stub).
|
||
|
|
||
|
This function serves as a bridge to run the async main function in
|
||
|
a uvloop event loop. It handles the differences in asyncio API across
|
||
|
different Python versions.
|
||
|
|
||
|
Args:
|
||
|
args (argparse.Namespace): The command-line arguments object.
|
||
|
|
||
|
Returns:
|
||
|
None
|
||
|
"""
|
||
|
if sys.version_info >= (3, 11):
|
||
|
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
|
||
|
runner.run(main(args))
|
||
|
else:
|
||
|
uvloop.install()
|
||
|
asyncio.run(main(args))
|