diff --git a/.gitignore b/.gitignore index 5d2af0d..4e7d8d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +venv/ .idea/ diff --git a/README.md b/README.md index 2d187f4..049492f 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,9 @@ Units are converted to one another by asking one unit to convert to the other. The `Unit.to_unit` function takes a number and a target `Unit`. ```python -import oxrse_unit_conv +from oxrse_unit_conv import km, mile n = 42 -km = oxrse_unit_conv.km -mile = oxrse_unit_conv.mile print(f"{n}{km.abbr} in {mile} = {km.to_unit(n, mile)}") ``` diff --git a/src/oxrse_unit_conv/__init__.py b/src/oxrse_unit_conv/__init__.py index 0cbac0b..37f9361 100644 --- a/src/oxrse_unit_conv/__init__.py +++ b/src/oxrse_unit_conv/__init__.py @@ -1,2 +1,2 @@ -from .units import * -from .main import convert, click_convert +from oxrse_unit_conv.units import * +from oxrse_unit_conv.main import convert, click_convert diff --git a/src/oxrse_unit_conv/main.py b/src/oxrse_unit_conv/main.py index 072527d..a2340dd 100644 --- a/src/oxrse_unit_conv/main.py +++ b/src/oxrse_unit_conv/main.py @@ -1,6 +1,6 @@ # Click interface to allow running from command line -import units -import meta.classes +from oxrse_unit_conv import units +from oxrse_unit_conv.meta import classes import click import logging @@ -25,15 +25,15 @@ def click_convert(number, unit, to): click.echo(convert(number, unit, to)) -def convert(number: meta.classes.Number, unit: str, to: str): +def convert(number: classes.Number, unit: str, to: str): logging.debug(f"Call: {number}: {unit} -> {to}") my_unit: units.Unit = getattr(units, unit) - if not isinstance(my_unit, meta.classes.BaseUnit): + if not isinstance(my_unit, classes.BaseUnit): raise TypeError(f"{unit} does not correspond to a known unit.") if to: target_unit = getattr(units, to) - if not isinstance(target_unit, meta.classes.BaseUnit): + if not isinstance(target_unit, classes.BaseUnit): raise TypeError(f"{to} does not correspond to a known unit.") else: target_unit = my_unit.si_unit diff --git a/src/oxrse_unit_conv/si.py b/src/oxrse_unit_conv/si.py index f51fc89..7cf0306 100644 --- a/src/oxrse_unit_conv/si.py +++ b/src/oxrse_unit_conv/si.py @@ -5,7 +5,7 @@ # the first unit is converted to the SI unit, # and then the SI unit is converted to the second unit. -from meta import classes +from oxrse_unit_conv.meta import classes second = classes.SIUnit("second", "s") s = second diff --git a/src/oxrse_unit_conv/units.py b/src/oxrse_unit_conv/units.py index 881af78..ad09e02 100644 --- a/src/oxrse_unit_conv/units.py +++ b/src/oxrse_unit_conv/units.py @@ -1,5 +1,5 @@ -from si import * -from meta.classes import Unit +from oxrse_unit_conv.si import * +from oxrse_unit_conv.meta.classes import Unit # second minute = Unit(name='minute', abbr='min', si=second, to_si_fun=lambda n: n * 60) diff --git a/src/tests/test_conversion_core.py b/src/tests/test_conversion_core.py index fba2518..70acff2 100644 --- a/src/tests/test_conversion_core.py +++ b/src/tests/test_conversion_core.py @@ -1,6 +1,6 @@ import unittest from oxrse_unit_conv.meta import classes -from oxrse_unit_conv import kilometer, m, m2, m3, s, hour +from oxrse_unit_conv.units import kilometer, m, m2, m3, s, hour class TestConversionCore(unittest.TestCase):