A Python command-line application for converting text ↔ Morse code.
Includes ASCII art banners, a looping interactive prompt, unit tests, and GitHub Actions CI.
-
Text → Morse
- Prompts the user for a string and converts it to Morse code.
- Uses
"/"
as a word separator and replaces unknown characters with"???"
.
-
Morse → Text
- Converts user-input Morse code (split by spaces) back into readable text.
-
ASCII Art
- Displays a welcome banner at startup and a goodbye banner on exit.
-
Looping Prompt
- Perform multiple conversions in one session.
-
Unit Tests
- A small suite covering both text-to-Morse and Morse-to-text.
-
GitHub Actions CI
- Automatically runs tests on every push or pull request to
main
ordev
.
- Automatically runs tests on every push or pull request to
We use Pipenv for environment management, even though there are no external dependencies. This simply creates a clean virtual environment.
-
Clone the repository:
git clone https://github.com/<your-username>/portfolio-morse-code.git cd portfolio-morse-code
-
Install using Pipenv:
pip install pipenv pipenv install --dev
-
Activate the virtual environment:
pipenv shell
Once you're in the enviroment:
python main.py
Select a mode: [T] (Text → Morse) or [M] (Morse → Text). Enter your text (if [T]) or Morse code (if [M]). See the result. Repeat until you choose to exit. You’ll see ASCII art at startup and a goodbye ASCII art message when you choose to exit.
This project uses Python's built-in unittest module for testing, enhanced with the parameterized library to avoid repetitive code and improve readability.
python -m unittest discover tests
This project uses flake8 to ensure the code adheres to PEP 8 style guidelines.
GitHub Actions automatically runs flake8 whenever you push or open a pull request against main
or dev
.
If you want to check your code style locally before committing:
pip install flake8
flake8 .
portfolio-morse-code/
├── .github/
│ └── workflows/
│ └── python-tests.yml # GitHub Actions for automated tests
├── gui/ # Python package
│ ├── __init__.py
│ ├── ascii_art.py # ASCII art functionality
├── morse_code_converter/ # Python package
│ ├── __init__.py
│ └── morse_code.py # Morse conversion logic
├── tests/
│ ├── __init__.py
│ └── morse_code_test.py # Unit tests
├── main.py # Entry point (CLI)
├── .gitignore
├── LICENSE
├── Pipfile
├── Pipfile.lock
└── README.md
- morse_code_converter/: Contains the core modules (ASCII art and Morse logic).
- tests/: Holds unit tests for the converter logic.
- main.py: CLI script to run the app.
- .github/workflows/: GitHub Actions workflow for CI.
- Pipfile & Pipfile.lock: Manage the Pipenv virtual environment.
- LICENSE: GNU General Public License v3.0.