Skip to content

Commit 3678d81

Browse files
committed
refactor: replace all references to _content with get_slot_content('main')
1 parent 5d492db commit 3678d81

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

src/osw/wtsite.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ def modify_search_results(
481481
modify_page(wtpage)
482482
if log:
483483
print(f"\n======= {title} =======")
484-
print(wtpage._content)
485484
for slot in wtpage._slots:
486485
content = wtpage.get_slot_content(slot)
487486
# if isinstance(content, dict): content = json.dumps(content)
@@ -1219,7 +1218,6 @@ def __init__(self, wtSite: WtSite = None, title: str = None, do_init: bool = Tru
12191218
self.title = title
12201219

12211220
self._original_content = ""
1222-
self._content = ""
12231221
self.changed: bool = False
12241222
self._dict = [] # todo: named dict but is of type list
12251223
self._slots: Dict[str, Union[str, dict]] = {"main": ""}
@@ -1239,7 +1237,6 @@ def init(self):
12391237

12401238
if self.exists:
12411239
self._original_content = self._page.text()
1242-
self._content = self._original_content
12431240
# multi content revisions
12441241
# second API call - ToDo: combine / replace with first call
12451242
rev = self.wtSite.mw_site.api(
@@ -1283,7 +1280,7 @@ def parse_main_slot(self):
12831280
Requires wikitext dependencies installed with 'pip install osw[wikitext]'
12841281
"""
12851282
self._dict = wt.create_flat_content_structure_from_wikitext(
1286-
self._content, array_mode="only_multiple"
1283+
self.get_slot_content("main"), array_mode="only_multiple"
12871284
)
12881285

12891286
def create_slot(self, slot_key, content_model):
@@ -1314,7 +1311,7 @@ def get_content(self):
13141311
-------
13151312
_description_
13161313
"""
1317-
return self._content
1314+
return self.get_slot_content("main")
13181315

13191316
def get_slot_content(self, slot_key, clone: bool = True):
13201317
"""Get the content of a slot
@@ -1380,8 +1377,7 @@ def set_content(self, content):
13801377
content
13811378
The new content of the page
13821379
"""
1383-
self._content = content
1384-
self.changed = True
1380+
self.set_slot_content("main", content)
13851381

13861382
def set_slot_content(self, slot_key, content):
13871383
"""Sets the content of a slot
@@ -1571,8 +1567,9 @@ def update_content(self):
15711567
-------
15721568
the WtPage object
15731569
"""
1574-
self._content = wt.get_wikitext_from_flat_content_structure(self._dict)
1575-
self.changed = self._original_content != self._content
1570+
self.set_slot_content(
1571+
"main", wt.get_wikitext_from_flat_content_structure(self._dict)
1572+
)
15761573
return self
15771574

15781575
def edit(self, comment: str = None, mode="action-multislot"):
@@ -1602,8 +1599,6 @@ def edit(self, comment: str = None, mode="action-multislot"):
16021599
def _edit(self, comment: str = None, mode="action-multislot"):
16031600
if not comment:
16041601
comment = "[bot] update of page content"
1605-
if self.changed:
1606-
self._page.edit(self._content, comment) # legacy mode
16071602
if mode == "action-multislot":
16081603
params = {}
16091604
changed = False

0 commit comments

Comments
 (0)