PEP8 compatibility
This commit is contained in:
parent
9982477759
commit
420c9a783c
1 changed files with 129 additions and 129 deletions
|
@ -1,17 +1,17 @@
|
|||
from __future__ import absolute_import
|
||||
from datetime import datetime, timedelta
|
||||
from calendar import monthrange
|
||||
import time
|
||||
import uuid
|
||||
import pytz
|
||||
import json
|
||||
|
||||
|
||||
class RemindersService(object):
|
||||
def __init__(self, service_root, session, params):
|
||||
self.session = session
|
||||
self.params = params
|
||||
self._service_root = service_root
|
||||
self.lists={}
|
||||
self.lists = {}
|
||||
self.collections = {}
|
||||
|
||||
self.refresh()
|
||||
|
@ -41,8 +41,6 @@ class RemindersService(object):
|
|||
local_names.append(name)
|
||||
return local_names
|
||||
|
||||
|
||||
|
||||
def get_system_tz(self):
|
||||
"""
|
||||
Retrieves the system's timezone from a list of possible options.
|
||||
|
@ -50,17 +48,15 @@ class RemindersService(object):
|
|||
"""
|
||||
return self.get_all_possible_timezones_of_local_machine()[0]
|
||||
|
||||
|
||||
|
||||
def refresh(self):
|
||||
host = self._service_root.split('//')[1].split(':')[0]
|
||||
self.session.headers.update({'host': host})
|
||||
|
||||
params_reminders=dict(self.params)
|
||||
params_reminders = dict(self.params)
|
||||
params_reminders.update({
|
||||
'clientVersion': '4.0',
|
||||
'lang': 'en-us',
|
||||
'usertz':self.get_system_tz()
|
||||
'usertz': self.get_system_tz()
|
||||
})
|
||||
|
||||
# Open reminders
|
||||
|
@ -71,7 +67,7 @@ class RemindersService(object):
|
|||
|
||||
startup = req.json()
|
||||
|
||||
self.lists={}
|
||||
self.lists = {}
|
||||
self.collections = {}
|
||||
for collection in startup['Collections']:
|
||||
temp = []
|
||||
|
@ -83,18 +79,21 @@ class RemindersService(object):
|
|||
|
||||
if reminder['pGuid'] != collection['guid']:
|
||||
continue
|
||||
if reminder.has_key("dueDate"):
|
||||
if 'dueDate' in reminder:
|
||||
if reminder['dueDate']:
|
||||
due = datetime(
|
||||
reminder['dueDate'][1],
|
||||
reminder['dueDate'][2],reminder['dueDate'][3],
|
||||
reminder['dueDate'][4],reminder['dueDate'][5]
|
||||
reminder['dueDate'][2], reminder['dueDate'][3],
|
||||
reminder['dueDate'][4], reminder['dueDate'][5]
|
||||
)
|
||||
else:
|
||||
due = None
|
||||
else:
|
||||
due = None
|
||||
desc=reminder['description'] if reminder['description'] else ""
|
||||
if reminder['description']:
|
||||
desc = reminder['description']
|
||||
else:
|
||||
desc = ""
|
||||
temp.append({
|
||||
"title": reminder['title'],
|
||||
"desc": desc,
|
||||
|
@ -102,46 +101,47 @@ class RemindersService(object):
|
|||
})
|
||||
self.lists[collection['title']] = temp
|
||||
|
||||
def post(self, title, description = "", collection=None):
|
||||
def post(self, title, description="", collection=None):
|
||||
pguid = 'tasks'
|
||||
if collection:
|
||||
if self.collections.has_key(collection):
|
||||
if collection in self.collections:
|
||||
pguid = self.collections[collection]['guid']
|
||||
|
||||
host = self._service_root.split('//')[1].split(':')[0]
|
||||
self.session.headers.update({'host': host})
|
||||
|
||||
params_reminders=dict(self.params)
|
||||
params_reminders = dict(self.params)
|
||||
params_reminders.update({
|
||||
'clientVersion': '4.0',
|
||||
'lang': 'en-us',
|
||||
'usertz':self.get_system_tz()
|
||||
'usertz': self.get_system_tz()
|
||||
})
|
||||
|
||||
req = self.session.post(
|
||||
self._service_root + '/rd/reminders/tasks',
|
||||
data=json.dumps({
|
||||
"Reminders":{
|
||||
"Reminders": {
|
||||
'title': title,
|
||||
"description":description,
|
||||
"pGuid":pguid,
|
||||
"etag":None,
|
||||
"order":None,
|
||||
"priority":0,
|
||||
"recurrence":None,
|
||||
"alarms":[],
|
||||
"startDate":None,
|
||||
"startDateTz":None,
|
||||
"startDateIsAllDay":False,
|
||||
"completedDate":None,
|
||||
"dueDate":None,
|
||||
"dueDateIsAllDay":False,
|
||||
"lastModifiedDate":None,
|
||||
"createdDate":None,
|
||||
"isFamily":None,
|
||||
"createdDateExtended":int(time.time()*1000),
|
||||
"guid":str(uuid.uuid4())
|
||||
"description": description,
|
||||
"pGuid": pguid,
|
||||
"etag": None,
|
||||
"order": None,
|
||||
"priority": 0,
|
||||
"recurrence": None,
|
||||
"alarms": [],
|
||||
"startDate": None,
|
||||
"startDateTz": None,
|
||||
"startDateIsAllDay": False,
|
||||
"completedDate": None,
|
||||
"dueDate": None,
|
||||
"dueDateIsAllDay": False,
|
||||
"lastModifiedDate": None,
|
||||
"createdDate": None,
|
||||
"isFamily": None,
|
||||
"createdDateExtended": int(time.time()*1000),
|
||||
"guid": str(uuid.uuid4())
|
||||
},
|
||||
"ClientState": {"Collections": self.collections.values() }
|
||||
"ClientState": {"Collections": self.collections.values()}
|
||||
}),
|
||||
params=params_reminders)
|
||||
return req.ok
|
||||
|
|
Loading…
Reference in a new issue