Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
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.

Empty file added examples/demo.py
Empty file.
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'
]

41 changes: 41 additions & 0 deletions src/morseify/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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}'")

# Uncomment for interactive mode
# print("\nInteractive mode:")
# text = input("Enter text to encode: ")
# encoded = encode(text)
# print(f"Encoded: {encoded}")
# decoded = decode(encoded)
# print(f"Decoded: {decoded}")

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
Loading