Косметические изменения в коде
This commit is contained in:
@@ -315,5 +315,6 @@ class UserApi(object):
|
|||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
try:
|
try:
|
||||||
return response.json()
|
return response.json()
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return response.content
|
return response.content
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ from user import User
|
|||||||
|
|
||||||
def print_lists(lists):
|
def print_lists(lists):
|
||||||
for item in lists:
|
for item in lists:
|
||||||
print(f"List: '{item.title}'", f"Id: {item.id}", "|", "|".join([str(x) for x in item.items_]))
|
print(
|
||||||
|
f"List: '{item.title}'", f"Id: {item.id}", "|", "|".join([str(x) for x in item.items_])
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_URL = "http://127.0.0.1:8000"
|
DEFAULT_URL = "http://127.0.0.1:8000"
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from types import SimpleNamespace
|
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -14,12 +12,13 @@ UPDATE_ERROR = "Failed to update property: {0}"
|
|||||||
|
|
||||||
DATETIME_STR = "%Y-%m-%dT%H:%M:%S.%fZ"
|
DATETIME_STR = "%Y-%m-%dT%H:%M:%S.%fZ"
|
||||||
|
|
||||||
|
|
||||||
def bad_arguments(x, d):
|
def bad_arguments(x, d):
|
||||||
return list((set(x) - set(d)))
|
return list((set(x) - set(d)))
|
||||||
|
|
||||||
|
|
||||||
class ToDoList(object):
|
class ToDoList(object):
|
||||||
def __init__(self, id, title, created_at=None, items=None,
|
def __init__(self, id, title, created_at=None, items=None, parent=None, user=None):
|
||||||
parent=None, user=None):
|
|
||||||
self.id = id
|
self.id = id
|
||||||
self.title = title
|
self.title = title
|
||||||
self.items_ = [] if items is None else items
|
self.items_ = [] if items is None else items
|
||||||
@@ -88,10 +87,8 @@ class ToDoList(object):
|
|||||||
self.user.lists_update(title=self.title, id=self.id)
|
self.user.lists_update(title=self.title, id=self.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ToDoItem(object):
|
class ToDoItem(object):
|
||||||
def __init__(self, id, text, finished=False, created_at=None,
|
def __init__(self, id, text, finished=False, created_at=None, parent=None, user=None):
|
||||||
parent=None, user=None):
|
|
||||||
self.id = id
|
self.id = id
|
||||||
self.text = text
|
self.text = text
|
||||||
self.finished = finished
|
self.finished = finished
|
||||||
@@ -125,7 +122,9 @@ class ToDoItem(object):
|
|||||||
print(f"Item '{self}' is being synchronized...")
|
print(f"Item '{self}' is being synchronized...")
|
||||||
if "DEBUG" in os.environ:
|
if "DEBUG" in os.environ:
|
||||||
return
|
return
|
||||||
self.user.todo_items_update(id=self.id, text=self.text, finished=self.finished, parent=self.parent)
|
self.user.todo_items_update(
|
||||||
|
id=self.id, text=self.text, finished=self.finished, parent=self.parent
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def make_debug_lists():
|
def make_debug_lists():
|
||||||
@@ -142,8 +141,8 @@ def make_debug_lists():
|
|||||||
for i in range(10)
|
for i in range(10)
|
||||||
]
|
]
|
||||||
|
|
||||||
class User(UserApi):
|
|
||||||
|
|
||||||
|
class User(UserApi):
|
||||||
def auth(self, user, passwd):
|
def auth(self, user, passwd):
|
||||||
"""
|
"""
|
||||||
Basic authentification
|
Basic authentification
|
||||||
@@ -188,7 +187,6 @@ class User(UserApi):
|
|||||||
to_remove.dispose()
|
to_remove.dispose()
|
||||||
return self.lists_
|
return self.lists_
|
||||||
|
|
||||||
|
|
||||||
def appendUserList(self, title):
|
def appendUserList(self, title):
|
||||||
"""
|
"""
|
||||||
Create a new user list
|
Create a new user list
|
||||||
|
|||||||
@@ -162,14 +162,13 @@ class WorkSpaceFrame(tk.Frame):
|
|||||||
self.lists = self.user.fetchUserLists()
|
self.lists = self.user.fetchUserLists()
|
||||||
|
|
||||||
# fill list box
|
# fill list box
|
||||||
self.listBox.delete(0,'end')
|
self.listBox.delete(0, "end")
|
||||||
for item in self.lists:
|
for item in self.lists:
|
||||||
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
s = f"{str(item)}: {item.created_at.strftime('%Y-%m-%d %H:%M:%S')}"
|
||||||
self.listBox.insert(tk.END, s)
|
self.listBox.insert(tk.END, s)
|
||||||
self.listBox.pack()
|
self.listBox.pack()
|
||||||
len(self.lists) > 0 and self.listBox.selection_set(first=0)
|
len(self.lists) > 0 and self.listBox.selection_set(first=0)
|
||||||
|
|
||||||
|
|
||||||
def listBox_selected(self, *args):
|
def listBox_selected(self, *args):
|
||||||
|
|
||||||
self.toToList.clear()
|
self.toToList.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user