Skip to content

Commit

Permalink
Merge pull request #18 from ryancheley/v0.6.0
Browse files Browse the repository at this point in the history
V0.6.0
  • Loading branch information
ryancheley authored Jan 11, 2022
2 parents 7dbc978 + c131b85 commit 4941309
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 399 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
omit=
*/venv/*
*/htmlcov/*

[report]
fail_under = 100
show_missing = True
skip_covered = False
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
143 changes: 11 additions & 132 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,139 +1,18 @@
# Byte-compiled / optimized / DLL files
.venv
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

.vscode
venv
.eggs
.pytest_cache
*.egg-info
.DS_Store
.coverage
auth.json
.coveragerc
dist
*.db
tests/test_hidden.py
.mutmut-cache

# Jupyter Notebooks
*.ipynb
# ignore the output files generated
output.html
output.txt
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.isort]
profile = "black"
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ci:
autoupdate_commit_msg: "chore: [pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: monthly

repos:
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--profile", "black"]
name: isort (python)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ You will need to first obtain a valid API token for your toggl account. You can

https://track.toggl.com/profile

Once you have your API Token enter it at the command line.
Once you have your API Token enter it at the command line.

Authentication tokens written to auth.json

Now you can fetch all of your items from toggl like this:
Expand All @@ -33,7 +33,7 @@ Now you can fetch all of your items from toggl like this:

$ toggl-to-sqlite fetch -s 2021-03-13

You can choose to get only `time_entries`, `projects`, or `workspaces` by speciying a type in the argument like this.
You can choose to get only `time_entries`, `projects`, or `workspaces` by speciying a type in the argument like this.

To get ONLY your workspaces:

Expand All @@ -45,7 +45,35 @@ To get your workspaces and projects:

The default is to get all three of `time_entries`, `projects`, and `workspaces`

## toggl-to-sqlite --help

<!-- [[[cog
import cog
from toggl_to_sqlite import cli
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli.cli, ["--help"])
help = result.output.replace("Usage: cli", "Usage: toggl-to-sqlite")
cog.out(
"```\n{}\n```".format(help)
)
]]] -->
```
Usage: toggl-to-sqlite [OPTIONS] COMMAND [ARGS]...
Save Toggl data to a SQLite database
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
auth Save authentication credentials to a JSON file
fetch Save Toggl data to a SQLite database
```
<!-- [[[end]]] -->

## Using with Datasette

The SQLite database produced by this tool is designed to be browsed using [Datasette](https://datasette.readthedocs.io/). Use the [datasette-render-timestamps](https://github.com/simonw/datasette-render-timestamps) plugin to improve the display of the timestamp values.

2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ To run the tests:

## Code style

This library uses [Black](https://github.com/psf/black) for code formatting. The correct version of Black will be installed by `pip install -e '.[test]'` - you can run `black .` in the root directory to apply those formatting rules.
This library uses [Black](https://github.com/psf/black) for code formatting. The correct version of Black will be installed by `pip install -e '.[test]'` - you can run `black .` in the root directory to apply those formatting rules.
30 changes: 28 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# run tests via pytest, creates coverage report, and then opens it up
test:
coverage run -m pytest
coverage html
open htmlcov/index.html
coverage html --omit=src/toggl_to_sqlite/cli.py--omit=src/toggl_to_sqlite/cli.py
open htmlcov/index.html

# runs the pre-commit check command
check: mypy
pre-commit run --all-files

# opens the coverage index
coverage:
open htmlcov/index.html

# prunes remote branches from github
prune:
git remote prune origin

# removes all but main and dev local branch
gitclean:
git branch | grep -v "main" | grep -v "dev"| xargs git branch -D


# run mypy on the files
mypy:
mypy src/toggl_to_sqlite/*.py --no-strict-optional --ignore-missing-imports


# generates the README.md file --help section
cog:
cog -r README.md
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.black]
line-length = 130
target-version = ['py39']
include = '\.pyi?$'
exclude = '(venv)'
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude = .git,*migrations*,*venv*
max-line-length = 130
ignore = E203,W503
31 changes: 22 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from setuptools import setup
import os

VERSION = "0.5"
from setuptools import setup

VERSION = "0.6.0"


def get_long_description():
Expand All @@ -18,20 +19,32 @@ def get_long_description():
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Ryan Cheley",
project_urls={
"Issues": "https://github.com/ryancheley/toggl-to-sqlite/issues",
"CI": "https://github.com/ryancheley/toggl-to-sqlite/actions",
"Changelog": "https://github.com/ryancheley/toggl-to-sqlite/releases",
"Documentation": "https://github.com/ryancheley/toggl-to-sqlite/blob/main/README.md",
},
url="https://github.com/ryancheley/toggle-to-sqlite",
license="Apache License, Version 2.0",
version=VERSION,
packages=["toggl_to_sqlite"],
package_dir={"": "src"},
entry_points="""
[console_scripts]
toggl-to-sqlite=toggl_to_sqlite.cli:cli
""",
install_requires=["sqlite-utils>=2.4.4", "click", "requests", "requests_mock"],
extras_require={
"test": [
"pytest",
"black==21.5b2",
]
},
install_requires=["sqlite-utils>=2.4.4", "click", "requests", "requests_mock", "toml"],
extras_require={"test": ["pytest", "black", "isort", "coverage", "mypy", "cogapp", "pre-commit"]},
tests_require=["toggl-to-sqlite[test]"],
python_requires=">=3.6",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Utilities",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
)
File renamed without changes.
8 changes: 4 additions & 4 deletions toggl_to_sqlite/cli.py → src/toggl_to_sqlite/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import click
import json

import click
import sqlite_utils

from . import utils


Expand Down Expand Up @@ -68,9 +70,7 @@ def fetch(db_path, auth, days, since, type):
days = days
since = since
if "time_entries" in type:
time_entries = utils.get_time_entries(
api_token=auth["api_token"], days=days, since=since
)
time_entries = utils.get_time_entries(api_token=auth["api_token"], days=days, since=since)
utils.save_items(time_entries, "time_entries", db)
if "workspaces" in type:
workspaces = utils.get_workspaces(api_token=auth["api_token"])
Expand Down
Loading

0 comments on commit 4941309

Please sign in to comment.