Skip to main content

This is a PigLatin Translator served with cute pigs

Project description

example workflow

Open in Visual Studio Code

Python Package Exercise

A little exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.

Group members

Functions in our package

Our Pig Latin Translation Rules:

Our rules for pig latin are as follows: take away the first letter of a word, then add a new word that uses the first letter of the word with "ay" added to it e.g., hello becomes ello-hay. For words that start with a vowel, you add "ay" to the end of the word e.g., enter becomes enter-ay, for words that start with a consonant, all letters are removed until a vowel is reached and then all removed consonants are used to create a second word, with "ay" added to the end of it e.g., happy becomes appy-hay

toEnglish(string s):

This function takes pig Latin words as input. These words must be hyphenated at the end with their pig latin translation/addition in order for our system to be able to process them properly. As a result it returns the english translation to the user.

toPl(string s, boolean intermediate_output_flag = True):

This function takes an english word as input and returns this word in our pig latin translation of it. In the case of an intermediate flag set to True (as is default) it will return the word in its hyphenated format. Otherwise it will return the word without hyphenation.

process_input(string s, boolean translation_flag):

Function that takes in a an input string and a flag corresponding to the type of translation and returns a parsed usable list, depending on the type of translation needed. Also prints useful output for debugging / running.

When we call this function, we can make sure that it returns a non-empty list by checking the len().

speech_bubble(string message):

arguments: one argument, message returns: a string that is essentially ASCII art, with the message enclosed in a speech bubble

arrow_to_bubble():

no arguments returns: a string that represents ASCII art, pointing to the speech bubble

print_pig():

no_arguments returns: a string that represents ASCII art of a pig

print_everything(message):

arguments: one argument, message returns: a string that represents ASCII art, with a speech bubble enclosing the message, a pig and an arrow pointing from the pig to the speech bubble


We believe that the functions most useful to potential users are (with their use shown in the example file)

  • toEnglish
  • toPL
  • speech_bubble
  • print_pig
  • print_everything

PYPI

How to install and use our package

  • Create a pipenv-managed virtual environment and install the latest version of your package installed:https://test.pypi.org/project/piglatin/1.0.3/ (Note that if you've previously created a pipenv virtual environment in the same directory, you may have to delete the old one first. Find out where it is located with the pipenv --venv command.)
  • Activate the virtual environment: pipenv shell.
  • Create a Python program file that imports your package and uses it, e.g. from piglatin import pig and then print(pig.toPL("Hello World")).
  • Run the program: python3 my_program_filename.py.
  • Exit the virtual environment: exit.

How to contribute in this package

  • Clone the repo
  • Install pipenv, build, and twine if not already installed.
  • Add settings in pyproject.toml suitable for a setuptools-based build and add metadata fields to this file (our package do not requires any additional package apart from pytest for testing)
  • Include your code in src/piglatin/pig.py
  • Build the project by running python -m build from the same directory where the pyproject.toml file is located.
  • Verify that the built .tar archive has the files you expect your package to have (including any important non-code files) by running the command: tar --list -f dist/piglatin-1.0.1.tar.gz, where piglatin-1.0.1 is replaced the new version.
  • Create an account on TestPyPI where one can upload to a test repository instead of the production PyPI repo.
  • Create a new API token on TestPyPI with the "Scope" set to “Entire account”. Save a copy of the token somewhere safe.
  • Upload your package to the TestPyPI repository using twine, e.g. twine upload -r testpypi dist/*
  • twine will output the URL of your package on the PyPI website - load that URL in your web browser to see your packaged published

Every time you change the code in your package, you will need to rebuild and reupload it to PyPI. You will need to build from a clean slate and update the version number to achieve this:

  • delete the autogenerated dist directory
  • delete the autogenerated src/*.egg-info directory
  • update the version number in pyproject.toml and anywhere else it is mentioned (do a find/replace)
  • build the package again with python -m build
  • upload the package again with twine upload -r testpypi dist/*

Repeat as many times as necessary until the package works as expected. Once complete, upload to the real PyPI instead of the TestPyPI repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piglatinTeam7-1.0.3.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piglatinTeam7-1.0.3-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file piglatinTeam7-1.0.3.tar.gz.

File metadata

  • Download URL: piglatinTeam7-1.0.3.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for piglatinTeam7-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f347a493bb971cb5c7706153e1faabce3c5be307b32d4591f3769291885b412b
MD5 9e0ab2a9f022e987cf0f97f50c1437e5
BLAKE2b-256 6480a6fee84e582962ec558a33211df5187a0b314e097a2612a5afc55348b513

See more details on using hashes here.

File details

Details for the file piglatinTeam7-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: piglatinTeam7-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for piglatinTeam7-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d6a3f8f35ba58793163ef81eb73305ec2855920a2904ea412fa14aae0a4e6441
MD5 bab996e7492edb42789d40f10ddfab15
BLAKE2b-256 f2e8ecb8baecf3310fdea54c41c607f5e71a5c96b9102a768394a726a97a3f40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page