diff --git a/README.md b/README.md index 8aea519..c8689a6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,34 @@ # pycw -Python Morse Code Generator \ No newline at end of file +Python Morse Code Generator + +Generate Morse Code (CW) audio files in Python. + +## Usage + +``` +optional arguments: + -h, --help show this help message and exit + -i INPUT, --input INPUT + Input text file (defaults to stdin) + -t TEXT, --text TEXT Input text. Overrides --input. + -s SPEED, --speed SPEED + Speed, in words per minute (default: 12) + -n TONE, --tone TONE Tone frequency, in Hz (default: 800) + -v VOLUME, --volume VOLUME + Volume (default: 1.0) + -r SAMPLE_RATE, --sample_rate SAMPLE_RATE + Sample rate (default: 44100) + -o OUTPUT, --output OUTPUT + Name of the output file +``` + +Or `import pycw` and then use functions in your code, for example: + +``` +import pycw + +pycw.output_wave("Intro.wav", "CQ CQ CQ DE BG5AWO BG5AWO BG5AWO PSE K", 20) +``` + +Then you can get a output file called `Intro.wav` in your working directory. diff --git a/pycw/__init__.py b/pycw/__init__.py index b7c2876..ff496b0 100644 --- a/pycw/__init__.py +++ b/pycw/__init__.py @@ -6,8 +6,6 @@ from .morse import stream_wave from .morse import output_wave from .morse import normalize_text -__version__ = '0.0.1' - __all__ = [ "synth", "DIT", diff --git a/pycw/__main__.py b/pycw/__main__.py index d5cd88e..0e122fe 100644 --- a/pycw/__main__.py +++ b/pycw/__main__.py @@ -1,3 +1,5 @@ +import os + from argparse import ArgumentParser from . import output_wave @@ -28,8 +30,8 @@ def main(): else: input_text = args.text - if input_text == "-": - print('usage: -h to learn more') + if input_text == "-" or input_text is None: + os.system("pycw -h") else: output_wave( args.output, input_text, diff --git a/pycw/__version__.py b/pycw/__version__.py new file mode 100644 index 0000000..0f7278d --- /dev/null +++ b/pycw/__version__.py @@ -0,0 +1,8 @@ +__title__ = "pycw" +__description__ = "Generate Morse Code (CW) audio files in Python." +__url__ = "https://github.com/bigsk05/pycw" +__version__ = '0.0.2' +__author__ = "Ian Xia" +__author_email__ = "i@ianxia.com" +__license__ = "Apache 2.0" +__copyright__ = "Copyright Ian Xia" \ No newline at end of file diff --git a/setup.py b/setup.py index 1ace65b..2b934b7 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,32 @@ +import os +import sys + from setuptools import setup, find_packages -version = '0.0.1' +about = {} +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, "pycw", "__version__.py"), "r") as f: + exec(f.read(), about) -longdesc = """\ -PyCW -####### - -Generate Morse Code (CW) audio files in Python. - -Repository and documentation: https://github.com/bigsk05/pycw -""" +with open("README.md", "r") as f: + readme = f.read() +if sys.argv[-1] == "publish": + os.system("python setup.py sdist bdist_wheel") + os.system("twine upload dist/*") + sys.exit() setup( - name='pycw', - version=version, + name=about["__title__"], + version=about["__version__"], + description=about["__description__"], packages=find_packages(), - url='https://github.com/bigsk05/pycw', - license='Apache Software License', - author='Ian Xia', - author_email='i@ianxia.com', - description='Generate Morse Code (CW) audio files in Python', - long_description=longdesc, + url=about["__url__"], + license=about["__license__"], + author=about["__author__"], + author_email=about["__author_email__"], + long_description_content_type="text/markdown", + long_description=readme, install_requires=[ 'numpy', ], @@ -32,16 +37,16 @@ setup( # 'Programming Language :: Python :: 3.1', # 'Programming Language :: Python :: 3.2', # 'Programming Language :: Python :: 3.3', - # 'Programming Language :: Python :: 3.4', - # 'Programming Language :: Python :: 3.5', - # 'Programming Language :: Python :: 3.6', - # 'Programming Language :: Python :: 3.7', - # 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', - # 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3 :: Only', ], entry_points={ - 'console_scripts': ['pycw=pycw:main'], + 'console_scripts': ['pycw=pycw.__main__:main'], }, package_data={'': ['README.md']}, include_package_data=True,