Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
218b341
create initial folder setup
Xuan4781 Oct 31, 2025
f751319
Add initial pyproject.toml for morse_code package
Xuan4781 Oct 31, 2025
761c634
Add Pipfile with Python version and dependencies
Xuan4781 Oct 31, 2025
6dbc027
add Github build.yml for CI/CD
Xuan4781 Oct 31, 2025
bc0d10f
Add placeholder tests
Xuan4781 Oct 31, 2025
52f4c49
Merge pull request #2 from swe-students-fall2025/angela-dev
yiminliu2004 Oct 31, 2025
5f7494f
add main file
yiminliu2004 Oct 31, 2025
ae4f737
add mapping morse code data
yiminliu2004 Oct 31, 2025
6df246c
add function TODOs
yiminliu2004 Oct 31, 2025
20619d2
add encode function
yiminliu2004 Oct 31, 2025
fd1215a
change project name to morseify
yiminliu2004 Oct 31, 2025
47d1e03
add decode function
yiminliu2004 Oct 31, 2025
27da830
Merge pull request #3 from swe-students-fall2025/encode/decode
gkbichara Oct 31, 2025
e3411b4
add is_valid function & test file setup
Xuan4781 Oct 31, 2025
aeb9641
Merge pull request #4 from swe-students-fall2025/isvalid
phoebelh Oct 31, 2025
53ed5f8
add: normalize_text and normalize_code function
phoebelh Oct 31, 2025
022d60e
add: normalize_text and normalize_code test file setup
phoebelh Oct 31, 2025
640d168
Merge pull request #5 from swe-students-fall2025/normalize
Xuan4781 Nov 1, 2025
77018f8
add is_valid and normalize funcs to decode/encode
yiminliu2004 Nov 1, 2025
f5847a6
add cli
yiminliu2004 Nov 1, 2025
510885f
Merge pull request #6 from swe-students-fall2025/cli
Xuan4781 Nov 1, 2025
0515325
Started quiz functionality
gkbichara Nov 2, 2025
513d173
Added write function, and prettified output
gkbichara Nov 2, 2025
300d411
Finished quiz functionality
gkbichara Nov 2, 2025
2aa5e5b
Merge pull request #7 from swe-students-fall2025/galal-createTest
Xuan4781 Nov 2, 2025
6f0a20e
update: readme file for overview and installation instruction template
phoebelh Nov 2, 2025
9d1b790
Merge pull request #8 from swe-students-fall2025/readme
yiminliu2004 Nov 2, 2025
56cf1b2
add tests for decode function
yiminliu2004 Nov 2, 2025
1a47d21
add more tests for decode
yiminliu2004 Nov 2, 2025
1367bc0
add decode alphabet letter test
yiminliu2004 Nov 2, 2025
b4f46a4
add tests for encode function
yiminliu2004 Nov 2, 2025
9eb91e7
add test for encode+decode roundtrip
yiminliu2004 Nov 2, 2025
b058503
Merge pull request #9 from swe-students-fall2025/test-encode
Xuan4781 Nov 2, 2025
76d9696
Start explain.py from step 0 to step 2
Leo-codingMaster Nov 3, 2025
930ed57
Merge pull request #14 from swe-students-fall2025/explain
Leo-codingMaster Nov 3, 2025
6b10302
finish basic function for explain.py
Leo-codingMaster Nov 3, 2025
321c4f1
add explain feature to main
yiminliu2004 Nov 3, 2025
5dbac5b
Merge pull request #15 from swe-students-fall2025/explain
yiminliu2004 Nov 3, 2025
2bf86e6
Add test_explain.py function and some bug fix
Leo-codingMaster Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI / CD - Morse Code

on:
pull_request:
branches: [pipfile-experiment]
push:
tags: ["v*"]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Install Python and Pipenv
uses: kojoru/prepare-pipenv@v1
with:
python-version: ${{ matrix.python-version }}


- name: Turn on 'editable' mode
run: |
pipenv install -e .

- name: Run pytest
run: |
pipenv install pytest
pipenv --venv
pipenv run python -m pytest

deliver:
if: github.event_name != 'pull_request'
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- uses: actions/checkout@v4

- name: Install Python, pipenv and Pipfile packages
uses: kojoru/prepare-pipenv@v1
with:
python-version: "3.10"

- name: Build package
run: |
pipenv install build
pipenv run python -m build .

# publish to PyPI Test server
# - name: Publish to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
13 changes: 13 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pytest = "*"
morse-code = {file = ".", editable = true}

[dev-packages]

[requires]
python_version = "3.10"
66 changes: 66 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Python Package Exercise

An exercise to create a Python package, build it, test it, distribute it, and use it. See [instructions](./instructions.md) for details.

## morseify - Overview
morseify is a lightweight Python package that brings the world of Morse code to anyone curious about how digital communication began. It offers intuitive encode and decode functionality to translate between English text and Morse code, along with built-in tools for text normalization and message validation.

For a more interactive experience, morseify also includes a quiz mode that generates random Morse code challenges for users to decode, making it both an educational and entertaining way to explore the fundamentals of encoded communication.

## Features
- Encode English text to Morse code
- Decode Morse code to English text
- Normalize text and Morse sequences
- Validate Morse message formats
- Explain message steps
- Quiz mode to test Morse knowledge

## Installation / Setup

<!-- TODO: Update once package is published to PyPI or ready for local install.
Include both PyPI and local development setup -->
1 change: 1 addition & 0 deletions examples/demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "morse_code"
version = "0.1.0"
description = "A Python package for encoding and decoding Morse code."
readme = "README.md"
requires-python = ">=3.10"
license = { file = "LICENSE" }
authors = [{ name = "Team Lumen" }]
keywords = ["python", "morse code", "encoder", "decoder"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]

[project.urls]
Homepage = "https://github.com/swe-students-fall2025/3-python-package-team_lumen"
Issues = "https://github.com/swe-students-fall2025/3-python-package-team_lumen/issues"

[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.packages.find]
where = ["src"]

[project.scripts]
morseify = "morseify.cli:cli"
27 changes: 27 additions & 0 deletions src/morseify/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Morse Code Package
A Python package for encoding and decoding Morse code with additional utilities.
"""

from morseify.core import (
encode,
decode,
is_valid
)
from morseify.normalize import (
normalize_text,
normalize_code
)
from morseify.explain import explain
from morseify.quiz import quiz

__all__ = [
'encode',
'decode',
'is_valid',
'normalize_text',
'normalize_code',
'explain',
'quiz'
]

46 changes: 46 additions & 0 deletions src/morseify/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from .core import encode, decode, is_valid
from .explain import explain
from .quiz import quiz


def main():
print("Morse Code Encode/Decode Test")
# Test cases
test_cases = [
"HELLO",
"HELLO WORLD",
"SOS",
"PYTHON",
"123",
"A1B2C3"
]

for text in test_cases:
encoded = encode(text)
decoded = decode(encoded)

print(f"\nOriginal: '{text}'")
print(f"Encoded : '{encoded}'")
print(f"Decoded : '{decoded}'")

# Check if round-trip works
if decoded == text:
print("✓ Round-trip successful!")
else:
print(f"✗ Round-trip failed! Expected: '{text}'")

# Example of explain feature with user input
print("Explain Feature")
user_morse = input("Enter morse code to explain: ").strip()
if user_morse:
explanation = explain(user_morse)
print(explanation)
else:
print("No input provided. Using example:")
example_morse = ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."
explanation = explain(example_morse)
print(explanation)


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions src/morseify/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Command-line interface for morseify.
"""

import sys
from morseify.core import encode, decode, is_valid


def cli():
"""
Command-line interface for morseify.
Auto-detects whether input is text (encode) or morse code (decode).

Usage:
morseify "HELLO" # Encodes text to morse code
morseify ".... . .-.. .-.. ---" # Decodes morse code to text
"""
if len(sys.argv) < 2:
print("Usage: morseify <text or morse code>")
print("Examples:")
print(' morseify "HELLO"')
print(' morseify ".... . .-.. .-.. ---"')
sys.exit(1)

# Join all arguments in case user passes multiple words
input_text = ' '.join(sys.argv[1:])

# Auto-detect: if input contains only morse characters (., -, /, space), decode it
# Otherwise, encode it
valid_morse_chars = {'.', '-', '/', ' '}
is_morse = all(char in valid_morse_chars for char in input_text) and input_text.strip()

if is_morse and is_valid(input_text):
# It's valid morse code, decode it
result = decode(input_text)
print(result)
else:
# It's text, encode it
result = encode(input_text)
print(result)

Loading