Skip to content

Commit

Permalink
Fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
smarttommyau committed Dec 28, 2023
1 parent b2c6cb5 commit 4558815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ def Update(self) -> bool:
for index,result in enumerate(results):
pageid = result.get("id")
if result.get("object") == "database" :
print("Items:",index+1,"/",len(results)) # print only if it is processed
if self.databases.get(pageid) is None:
print("Items:",index+1,"/",len(results)) # print only if it is processed

database = notion_database(self.notion,result.get("id"),self.exchange_rate_getter)
if database.success:
self.databases[pageid] = database
database.UpdateAllPages()
updated_db.append(pageid)
self.cursor = pageid
else:
if self.databases[pageid].PullPropertyStruct() & self.databases[pageid].PropertyUpdate():
if self.databases[pageid].PullPropertyStruct() and self.databases[pageid].PropertyUpdate():
print("Items:",index+1,"/",len(results)) # print only if it is processed
self.databases[pageid].UpdateAllPages()
updated_db.append(pageid)
self.cursor = pageid
Expand Down
8 changes: 6 additions & 2 deletions notion/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ def __init__(self,notion,ID,exchange_rate_getter) -> None:
self.propTf = list()
self.filter_props = list()
self.exchange_rate_getter = exchange_rate_getter
self.struct = None
self.success = self.PullPropertyStruct() & (self.PropertyUpdate() in (None,True))

def PullPropertyStruct(self) -> bool:
temp = RetrieveDatabaseStructure(self.notion,self.ID)
if temp is None:
return False
if self.struct == temp:
return None

self.struct = temp
return True

Expand All @@ -40,10 +44,10 @@ def PropertyUpdate(self) -> bool:
elif prop.startswith("ExRTV"):
if str(v.get("type")) == "number":
print("'",prop[5:],"'")
propV[prop[5:]] = v.copy()
# Delete name field if exist
if v.get("name"):
del v["name"]
propV[prop[5:]] = v
del propV[prop[5:]]["name"]
elif str(v.get("type")) == "formula":
cur = prop.split() # split to get the second part of prop name
if len(cur)<2:
Expand Down

0 comments on commit 4558815

Please sign in to comment.