@@ -448,7 +448,6 @@ def create_page_package(self, param: CreatePagePackageParam):
448448 added_titles .append (title )
449449 page = self .get_page (WtSite .GetPageParam (titles = [title ])).pages [0 ]
450450
451- page = self .get_WtPage (title )
452451 bundle .packages [config .name ].pages .append (page .dump (dump_config ))
453452 if config .include_files :
454453 for file in page ._page .images ():
@@ -463,11 +462,11 @@ def create_page_package(self, param: CreatePagePackageParam):
463462 file_page .dump (dump_config )
464463 )
465464
466- content = bundle .json (exclude_none = True , indent = 4 )
465+ content = bundle .json (exclude_none = True , indent = 4 , ensure_ascii = False )
467466 # This will create the JSON (e.g., package.json) with the PagePackageConfig,
468467 # which contains the PagePackageBundle
469468 file_name = f"{ config .config_path } "
470- with open (file_name , "w" ) as f :
469+ with open (file_name , "w" , encoding = "utf-8" ) as f :
471470 f .write (content )
472471
473472 class ReadPagePackageParam (model .OswBaseModel ):
@@ -552,7 +551,7 @@ def read_page_package(self, param: ReadPagePackageParam) -> ReadPagePackageResul
552551 f"Error: No JSON files found in '{ storage_path } '."
553552 )
554553 # Read packages info file
555- with open (pi_fp , "r" ) as f :
554+ with open (pi_fp , "r" , encoding = "utf-8" ) as f :
556555 packages_json = json .load (f )
557556 # Assume that the pages files are located in the subdir
558557 storage_path_content = ut .list_files_and_directories (
@@ -572,12 +571,12 @@ def get_slot_content(
572571 for pdir in parent_dir :
573572 slot_path = storage_path / pdir / url_path
574573 if slot_path in files_in_storage_path :
575- with open (slot_path , "r" ) as f :
574+ with open (slot_path , "r" , encoding = "utf-8" ) as f :
576575 file_content = f .read ()
577576 # Makes sure not to open an empty file with json
578577 if len (file_content ) > 0 :
579578 if url_path .endswith (".json" ):
580- with open (slot_path , "r" ) as f :
579+ with open (slot_path , "r" , encoding = "utf-8" ) as f :
581580 slot_data = json .load (f )
582581 return slot_data
583582 elif url_path .endswith (".wikitext" ):
@@ -746,7 +745,7 @@ def __init__(self, wtSite: WtSite = None, title: str = None):
746745 # revision["slots"][slot_key]["*"]
747746 if self ._content_model [slot_key ] == "json" :
748747 self ._slots [slot_key ] = json .loads (
749- self ._slots [slot_key ]
748+ self ._slots [slot_key ],
750749 )
751750 # todo: set content for slots not in revision["slots"] (use
752751 # SLOTS) --> create empty slots
@@ -889,7 +888,7 @@ def _edit(self, comment: str = None, mode="action-multislot"):
889888 content = self ._slots [slot_key ]
890889 if self ._content_model [slot_key ] == "json" :
891890 if not isinstance (content , str ):
892- content = json .dumps (content )
891+ content = json .dumps (content , ensure_ascii = False )
893892 params ["slot_" + slot_key ] = content
894893 if changed :
895894 self .wtSite ._site .api (
@@ -906,7 +905,7 @@ def _edit(self, comment: str = None, mode="action-multislot"):
906905 if self ._slots_changed [slot_key ]:
907906 content = self ._slots [slot_key ]
908907 if self ._content_model [slot_key ] == "json" :
909- content = json .dumps (content )
908+ content = json .dumps (content , ensure_ascii = False )
910909 self .wtSite ._site .api (
911910 "editslot" ,
912911 token = self .wtSite ._site .get_token ("csrf" ),
@@ -1008,7 +1007,7 @@ def save_to_file(file_path__, content__):
10081007
10091008 def dump_slot_content (slot_key_ , content_type_ , content_ ):
10101009 if isinstance (content_ , dict ):
1011- content_ = json .dumps (content_ , indent = 4 )
1010+ content_ = json .dumps (content_ , indent = 4 , ensure_ascii = False )
10121011 if content_type_ == "Scribunto" :
10131012 content_type_ = "lua"
10141013 if slot_key_ == "main" and config .skip_slot_suffix_for_main :
0 commit comments