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 os
|
||||||
import asana
|
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)
|
def __init__(self):
|
||||||
me = client.users.me()
|
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():
|
def shouldShowWorkspace(self, workspace_id):
|
||||||
for workspace in me['workspaces']:
|
try:
|
||||||
tasks = client.tasks.find_all(params={
|
return not (workspace_id in self.config['excluded_domains'])
|
||||||
'assignee': me['id'],
|
except KeyError:
|
||||||
'workspace': workspace['id'],
|
return True
|
||||||
'completed_since': 'now'
|
|
||||||
})
|
|
||||||
|
|
||||||
for task in tasks:
|
def allMyTasks(self):
|
||||||
print task['name']
|
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