Guest User

Untitled

a guest
Dec 11th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. """
  2. Installation:
  3. $ pipenv install click maya togglwrapper
  4.  
  5. Configuration:
  6. $ export TOGGL_API_KEY="PASTE_YOUR_KEY_HERE"
  7.  
  8. Usage:
  9. $ python standup.py yesterday
  10.  
  11. """
  12.  
  13. import click
  14. import os
  15. import maya
  16.  
  17. from togglwrapper import Toggl
  18.  
  19.  
  20. @click.command()
  21. @click.argument('slang_date')
  22. def main(slang_date):
  23. toggl = Toggl(os.environ.get('TOGGL_API_KEY'))
  24.  
  25. now = maya.when(slang_date, timezone='US/Central')
  26. now = now.datetime().replace(hour=6, minute=0, second=0, microsecond=0)
  27.  
  28. now = maya.MayaDT.from_datetime(now)
  29. click.echo('## {0}'.format(now.slang_date()))
  30.  
  31. time_entries = toggl.TimeEntries.get(start_date=now.iso8601())
  32.  
  33. for time_entry in time_entries:
  34. project_id = time_entry['pid']
  35. project = toggl.Projects.get(project_id)
  36. click.echo(
  37. '- [{0}] {1}{2}'.format(
  38. project['data']['name'],
  39. time_entry['description'],
  40. ' :moneybag:' if time_entry['billable'] else ''
  41. )
  42. )
  43.  
  44.  
  45. if __name__ == '__main__':
  46. main()
Add Comment
Please, Sign In to add comment