Added ability to filter list of workspaces
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.swp
|
||||
.pyc
|
||||
|
||||
.config
|
||||
52
cmdasana.py
52
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()
|
||||
|
||||
Reference in New Issue
Block a user