An example of a package developed with pyenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.
Project description
Python Package Exercise
A little exercise to create a Python package, build it, test it, distribute it, and use it. See instructions for details.
Teammates
- Jonason Wu (jw5911): Github Profile
- Alejandro Olazabal (ajo351): Github Profile
- Junyi Dong (jd4634): Github Profile
- Fatema Nassar (fan6236) : Github Profile
Import the Project
Package Name:
- metricconverterteam10
Package content(functions):
- age_converter, number_converter, time_zone_converter, distance_converter
How to Install:
Activate a
pipenvshell:
$ pipenv shell
Install our package:
$ pipenv install metricconverterteam10
Possible imports
You can test out these imports either on a python file or test the on the python shell with the following command:
$ python
- You can now run:
from metricconverterteam10 import age_converterage_converter.calc_age(dob: str, unit: str)- dob: Date Of Birth (e.g., Jan 10 2000 12:00AM)
- unit: The unit to convert into. Choices: 'actual', 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'.
age_converter.help()
from metricconverterteam10 import number_converternumber_converter.convert_number(toUnit: str, value: Any)- toUnit: The unit to convert value into. Choices: 'binary', 'decimal', 'hexadecimal', 'octal'
- value: The value to convert. It could be in binary, octal, decimal, or hexadecimal form.
from metricconverterteam10 import time_zone_convertertime_zone_converter.convert_timezone(code: str)- code: the ISO Alpha 2 code of the country.
from metricconverterteam10 import distance_converterdistance_converter.allowed_distance_conversions()distance_converter.convert_distance(num: float | int | str, unit1: str, unit2: str)- num: A number that is convertible to a float value.
- unit1: The unit to convert from
- unit2: The unit to convert to
Link to project:
- Link to the Test PyPi project: link
- Link to the actual PyPi project: link
- Link to the documentation of the functions: Code Examples
- Link to an example python program: __main__.py
Contribute to this Project
- Open bash terminal
- Clone this repository
$ git clone https://github.com/software-students-fall2022/python-package-exercise-project-3-team-10.git - Get into the project directory
$ cd python-package-exercise-project-3-team-10 - Create python virtual environment
python -m venv .venv - Activate python virtual environment:
- On Mac:
source .venv/bin/activate - On Windows:
.venv/Scripts/activate.bat
- On Mac:
- Install pipenv
$ pip install pipenv - Activate virtual enviroment
$ pipenv shell - Install all dependencies
$ pipenv install -e . - Build
If this doesnt work try$ python -m build$ python3 -m build - Test
$ pipenv run pytest
Code Examples
Age Converter
-
The following line will give the options for the age conversions that are available:
>> age_converter.help() calc_age(dob, unit): Input dob in the following format: MTH DAY YEAR TIME These are the available units to convert into: ['actual', 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'] Example: >> calc_age('Jan 1 2000 1:33PM', 'years') 22 years old -
The following line will give a converted description given the date of birth (at 11/8/2022):
>> print(age_converter.calc_age('Jan 1 2000 1:33PM', 'actual')) 22 years 10 months and 7 days old -
The following line will give the number of days someone with that birthday has lived (at 11/8/2022):
>> print(age_converter.calc_age('Jan 1 2000 1:33PM', 'days')) 8347 days old
Distance Converter
- The following line will print and give all the conversions for distances that are available:
>> li = distance_converter.allowed_distance_conversions() These are the allowed unit inputs for the convert_distance method: inches --> in feet --> ft mile --> mi milimeter --> mm centimeter --> cm meter --> m kilometer --> km >> print(li) ['mm', 'm', 'mi', 'cm', 'in', 'km', 'ft'] - The following line will convert 10 feet into inches:
>> print(distance_converter.convert_distance(10, 'ft', 'in')) 120.0 - The following line will convert 100 centimeters into meters:
>> print(distance_converter.convert_distance(100, 'cm', 'm')) 1.0
Number Converter
- The following line will convert a decimal value of 1000 into binary:
>> print(number_converter.convert_number("binary", 1000)) 0b1111101000 - The following line will convert a decimal value of 1000 into octal:
>> print(number_converter.convert_number("octal", 1000)) 0o1750 - The following line will convert a hexadecimal value of 0x1111 into decimal:
>> print(number_converter.convert_number("decimal", 0x1111)) 4369
Time Zone Converter
- The following line will print out all the possible times of the United States at the current time of 8:16PM:
>> print(time_zone_converter.convert_timezone("US")) {'08:16PM': ['America/New_York', 'America/Detroit', 'America/Kentucky/Louisville', 'America/Kentucky/Monticello', 'America/Indiana/Indianapolis', 'America/Indiana/Vincennes', 'America/Indiana/Winamac', 'America/Indiana/Marengo', 'America/Indiana/Petersburg', 'America/Indiana/Vevay'], '07:16PM': ['America/Chicago', 'America/Indiana/Tell_City', 'America/Indiana/Knox', 'America/Menominee', 'America/North_Dakota/Center', 'America/North_Dakota/New_Salem', 'America/North_Dakota/Beulah'], '06:16PM': ['America/Denver', 'America/Boise', 'America/Phoenix'], '05:16PM': ['America/Los_Angeles'], '04:16PM': ['America/Anchorage', 'America/Juneau', 'America/Sitka', 'America/Metlakatla', 'America/Yakutat', 'America/Nome'], '03:16PM': ['America/Adak', 'Pacific/Honolulu']}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metricconverterteam10-1.1.0.tar.gz.
File metadata
- Download URL: metricconverterteam10-1.1.0.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6b6bd5c3cd886888bb67787588de63ef6e161961f2c5ba16d7bd94af699a5c2
|
|
| MD5 |
59e002eab81505d135cae79630e4be38
|
|
| BLAKE2b-256 |
4147f2efb9b18f5cd90d9b187ee17a67bcc3000ac6bc9c1d85148ce7421c28b3
|
File details
Details for the file metricconverterteam10-1.1.0-py3-none-any.whl.
File metadata
- Download URL: metricconverterteam10-1.1.0-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da798f2e27c5df218897c581e094e833dd2654773fb14593ab9f11c450333072
|
|
| MD5 |
3b2a81410ebb3da77a22d96e7165505d
|
|
| BLAKE2b-256 |
efbc9d1a7cdca1811456d9bc75acb399a7148c1dd8cdf9c6544ba1a23e2e375d
|