added initial
This commit is contained in:
parent
1d70071d75
commit
bc925ef767
5 changed files with 257 additions and 0 deletions
158
.gitignore
vendored
Normal file
158
.gitignore
vendored
Normal file
|
@ -0,0 +1,158 @@
|
|||
|
||||
### Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__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/
|
||||
cover/
|
||||
|
||||
# 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
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .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/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
### Vim
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
33
.style.yapf
Normal file
33
.style.yapf
Normal file
|
@ -0,0 +1,33 @@
|
|||
[style]
|
||||
|
||||
# Insert a blank line before a module docstring.
|
||||
blank_line_before_module_docstring=True
|
||||
|
||||
# The column limit.
|
||||
column_limit=120
|
||||
|
||||
# Split before the '.' if we need to split a longer expression:
|
||||
#
|
||||
# foo = ('This is a really long string: {}, {}, {}, {}'.format(a, b, c, d))
|
||||
#
|
||||
# would reformat to something like:
|
||||
#
|
||||
# foo = ('This is a really long string: {}, {}, {}, {}'
|
||||
# .format(a, b, c, d))
|
||||
split_before_dot=True
|
||||
|
||||
# Set to True to split list comprehensions and generators that have
|
||||
# non-trivial expressions and multiple clauses before each of these
|
||||
# clauses. For example:
|
||||
#
|
||||
# result = [
|
||||
# a_long_var + 100 for a_long_var in xrange(1000)
|
||||
# if a_long_var % 10]
|
||||
#
|
||||
# would reformat to something like:
|
||||
#
|
||||
# result = [
|
||||
# a_long_var + 100
|
||||
# for a_long_var in xrange(1000)
|
||||
# if a_long_var % 10]
|
||||
split_complex_comprehension=True
|
14
pylama.ini
Normal file
14
pylama.ini
Normal file
|
@ -0,0 +1,14 @@
|
|||
[pylama]
|
||||
format = pylint
|
||||
linters = mccabe,pep257,pydocstyle,pep8,pycodestyle,pyflakes,pylint,isort
|
||||
ignore = D203
|
||||
skip=.env/*
|
||||
|
||||
[pylama:pycodestyle]
|
||||
max_line_length = 120
|
||||
|
||||
[pylama:pep8]
|
||||
max_line_length = 120
|
||||
|
||||
[pylama:pylint]
|
||||
max_line_length = 120
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
pylama>=7.7.0
|
||||
pylint>=2.3.0
|
||||
yapf>=0.27.0
|
||||
timew>=0.0.22
|
48
timewarrior.py
Executable file
48
timewarrior.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#! /usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Timewarrior adapter for `argos <https://github.com/p-e-w/argos>`."""
|
||||
# <bitbar.title>timewarrior</bitbar.title>
|
||||
# <bitbar.version>v1.0</bitbar.version>
|
||||
# <bitbar.author>Tobias Schmidl</bitbar.author>
|
||||
# <bitbar.author.github>schtobia</bitbar.author.github>
|
||||
# <bitbar.desc>Greps and formats data from timewarrior.</bitbar.desc>
|
||||
# <bitbar.image></bitbar.image>
|
||||
# <bitbar.dependencies>python,timew</bitbar.dependencies>
|
||||
# <bitbar.abouturl>https://github.com/schtobia/argos-timewarrior/blob/master/timewarrior.py</bitbar.abouturl>
|
||||
|
||||
|
||||
import functools
|
||||
import locale
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from timew import TimeWarrior
|
||||
|
||||
TW = TimeWarrior()
|
||||
TIMEFORMATTER = '%Y%m%dT%H%M%S%z'
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
RESULTS = sorted(map(
|
||||
lambda x: {
|
||||
'start':
|
||||
datetime.strptime(x['start'], TIMEFORMATTER).astimezone(tz=None),
|
||||
'end':
|
||||
datetime.strptime(x['end'], TIMEFORMATTER).astimezone(tz=None)
|
||||
if 'end' in x else datetime.now().astimezone(tz=None),
|
||||
'id':
|
||||
x['id'],
|
||||
'tags':
|
||||
x['tags']
|
||||
}, TW.summary()),
|
||||
key=lambda x: x['start'])
|
||||
|
||||
print("TW: {}\n-----".format(
|
||||
str(functools.reduce(lambda total, x: total + x['end'] - x['start'], RESULTS, timedelta())).split(sep='.', maxsplit=1)[0]
|
||||
))
|
||||
print(
|
||||
" | font=monospace | size=8\n".join(
|
||||
map(
|
||||
lambda x: str({
|
||||
'start': datetime.strftime(x['start'], "%x %X"),
|
||||
'end': datetime.strftime(x['end'], "%x %X"),
|
||||
'tags': x['tags']
|
||||
}), RESULTS)), "| font=monospace | size=8")
|
Loading…
Reference in a new issue