mirror of
https://github.com/romanz/amodem.git
synced 2026-04-19 04:36:02 +08:00
Use contextlib.nullcontext (Python 3.7+)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# PYTHON_ARGCOMPLETE_OK
|
# PYTHON_ARGCOMPLETE_OK
|
||||||
import argparse
|
import argparse
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@@ -183,14 +184,6 @@ def create_parser(description, interface_factory):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
class _Dummy:
|
|
||||||
def __enter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __exit__(self, *args):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _version():
|
def _version():
|
||||||
return pkg_resources.require('amodem')[0].version
|
return pkg_resources.require('amodem')[0].version
|
||||||
|
|
||||||
@@ -240,11 +233,11 @@ def _main():
|
|||||||
from . import alsa # pylint: disable=import-outside-toplevel
|
from . import alsa # pylint: disable=import-outside-toplevel
|
||||||
interface = alsa.Interface(config)
|
interface = alsa.Interface(config)
|
||||||
elif args.audio_library == '-':
|
elif args.audio_library == '-':
|
||||||
interface = _Dummy() # manually disable PortAudio
|
interface = contextlib.nullcontext() # manually disable PortAudio
|
||||||
elif args.command == 'send' and args.output is not None:
|
elif args.command == 'send' and args.output is not None:
|
||||||
interface = _Dummy() # redirected output
|
interface = contextlib.nullcontext() # redirected output
|
||||||
elif args.command == 'recv' and args.input is not None:
|
elif args.command == 'recv' and args.input is not None:
|
||||||
interface = _Dummy() # redirected input
|
interface = contextlib.nullcontext() # redirected input
|
||||||
else:
|
else:
|
||||||
interface = audio.Interface(config)
|
interface = audio.Interface(config)
|
||||||
interface.load(args.audio_library)
|
interface.load(args.audio_library)
|
||||||
|
|||||||
Reference in New Issue
Block a user