Added ability to filter list of workspaces

This commit is contained in:
Aaron Gutierrez
2015-07-19 16:15:46 -07:00
parent b134ac23c0
commit dfdadb5a96
2 changed files with 43 additions and 13 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.swp
.pyc
.config

View File

@@ -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()