diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a15fb57 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.swp +.pyc + +.config diff --git a/cmdasana.py b/cmdasana.py index c5b7ea5..c242424 100644 --- a/cmdasana.py +++ b/cmdasana.py @@ -1,20 +1,46 @@ import os import asana +import json -ASANA_API_KEY = os.environ['ASANA_API_KEY'] +class CmdAsana: + ASANA_API_KEY = os.environ['ASANA_API_KEY'] -client = asana.Client.basic_auth(ASANA_API_KEY) -me = client.users.me() + def __init__(self): + self.client = asana.Client.basic_auth(self.ASANA_API_KEY) + self.me = self.client.users.me() + + f = open('.config', 'r') + config = f.read() + self.config = json.loads(config) + f.close() -def allMyTasks(): - for workspace in me['workspaces']: - tasks = client.tasks.find_all(params={ - 'assignee': me['id'], - 'workspace': workspace['id'], - 'completed_since': 'now' - }) + def shouldShowWorkspace(self, workspace_id): + try: + return not (workspace_id in self.config['excluded_domains']) + except KeyError: + return True - for task in tasks: - print task['name'] + def allMyTasks(self): + for workspace in self.me['workspaces']: + if not self.shouldShowWorkspace(workspace['id']): + continue -allMyTasks() + print "*" * 80 + print workspace['id'], ': ', workspace['name'], " Tasks" + print "*" * 80, "\n" + + tasks = self.client.tasks.find_all(params={ + 'assignee': self.me['id'], + 'workspace': workspace['id'], + 'completed_since': 'now' + }) + + for task in tasks: + print task['name'] + +def main(): + cmdasana = CmdAsana() + + cmdasana.allMyTasks() + +if __name__ == "__main__": main()