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