Skip to content

Commit

Permalink
make pip installable, closes #1
Browse files Browse the repository at this point in the history
mypy doesn't like kwargs python/mypy#8772
  • Loading branch information
ConorSheehan1 committed Mar 20, 2022
1 parent 9839edc commit 040b8b8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
9 changes: 7 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## Installing dependencies
#### Dev Install
```bash
pip install poetry
poetry install

# install uhabits_converter as symlink to avoid reinstall whenever code changes
# instead of pip install /path/to/uhabits_converter
# https://github.com/python-poetry/poetry/issues/1135
# workaround using __name__ == '__main__' and fire
poetry run task dev
```

### Tests
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,29 @@ It has been tested with version [2.0.3](https://github.com/iSoron/uhabits/releas

## Installation
```bash
# option 1 github release
pip install https://github.com/ConorSheehan1/uhabits_converter/releases/latest/download/uhabits_converter.tar.gz

# option 2 from source
# install python (>=3.8 check pyproject.toml)
# https://github.com/ConorSheehan1/uhabits_converter/blob/main/pyproject.toml#L9
pip install poetry
git clone git@github.com:ConorSheehan1/uhabits_converter.git
cd uhabits_converter
poetry install
# if you want the uhabits_converter command available run the lines below.
# otherwise you can use: PYTHONPATH=$(pwd) poetry run task dev
poetry build
pip install .
```

### Steps to convert habits
1. Follow the instructions for **How can I export a full backup of my data?**
1. https://github.com/iSoron/uhabits/discussions/689
> Select the option "Export full backup" on the settings screen.
2. Copy the `.db` file to your computer
3. `poetry run task cli`
3. `uhabits_converter --help`
1. You can specify arguments up front or interactively. e.g.
`poetry run task cli --db=Loop_Habits_Backup_2022-02-28_220305.db --habits=Gym,Coffee`
`uhabits_converter --db=Loop_Habits_Backup_2022-02-28_220305.db --habits=Gym,Coffee`
this will convert the habits Gym and Coffee from boolean to numeric habits.
now you can track hours in the gym and cups of coffee, rather than just the days you went to the Gym or drank coffee.
4. copy the `output.db` file back to your android device.
Expand Down
19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ version = "0.2.0"
description = "convert types of habit from uhabits"
authors = ["Conor Sheehan <conor.sheehan.dev@gmail.com>"]
license = "MIT"
homepage = "https://github.com/ConorSheehan1/uhabits_converter"
readme = "README.md"
classifiers = [
"Intended Audience :: End Users/Desktop ",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Utilities",
]
packages = [
# { include = "*.py", from = "src"}
{ include = "src" }
]

[tool.poetry.dependencies]
python = ">=3.8"
Expand All @@ -26,6 +38,7 @@ cli = "python src/cli.py"
bumpversion = "bumpversion"
ci_lint = "black --check ."
ci_isort = "isort --check --diff ."
dev = "python src/cli.py"
isort = 'isort .'
lint = "black ."
mypy = "mypy --ignore-missing-imports src/*.py"
Expand All @@ -45,6 +58,10 @@ line_length = 100
[tool.black]
line_length = 100

# cli entrypoint
[tool.poetry.scripts]
uhabits_converter = "src.cli:main"

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=0.12"]
build-backend = "poetry.core.masonry.api"
15 changes: 9 additions & 6 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from rich.progress import track
from rich.prompt import Prompt

from convert import Converter
from version import __version__
from src.convert import Converter
from src.version import __version__

console = Console(color_system="auto")

Expand Down Expand Up @@ -58,7 +58,7 @@ def select_outputdb(outputdb, overwrite: bool = False) -> str:
return proposed_db


def main(
def cli(
db: str = "",
outputdb: str = "",
habits: List = [],
Expand Down Expand Up @@ -99,9 +99,8 @@ def main(
outputdb = outputdb or "output.db"
outputdb = select_outputdb(outputdb, overwrite=yes)

kwargs = {"inputdb": db, "outputdb": outputdb}
console.print(f"Reading from {db}, writing to {outputdb}", style="green")
c = Converter(**kwargs)
c = Converter(inputdb=db, outputdb=outputdb)

if not habits:
console.print(f"Selecting habits interactively")
Expand All @@ -127,5 +126,9 @@ def main(
console.print(errors, style="red")


def main():
fire.Fire(cli)


if __name__ == "__main__":
fire.Fire(main)
main()

0 comments on commit 040b8b8

Please sign in to comment.