From f78a094aaa5cca232e98625018bb28082e3f8259 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Fri, 12 Jun 2026 04:49:51 +0300 Subject: [PATCH 01/11] . --- src/WDYe/ali.py | 6 ++-- src/WDYe/alias.py | 6 ++-- src/WDYe/category.py | 2 +- src/WDYe/catwithoutp31.py | 6 ++-- src/WDYe/common.py | 4 +-- src/WDYe/d1.py | 4 +-- src/WDYe/disam2.py | 6 ++-- src/WDYe/indy.py | 6 ++-- src/WDYe/label.py | 8 ++--- src/WDYe/labelnumber.py | 4 +-- src/WDYe/med.py | 6 ++-- src/WDYe/month.py | 2 +- src/alabel/labels.py | 2 +- src/bots_subs/hi_api/__init__.py | 2 +- .../hi_api/h_wd_newapi/wd_newapi_bot.py | 6 ++-- .../hi_api/req_bots_new/claims_wd.py | 12 ++++---- .../hi_api/req_bots_new/descriptions_wd.py | 14 ++++----- .../hi_api/req_bots_new/labels_wd.py | 18 +++++------ .../hi_api/utils/handle_wd_errors.py | 2 +- src/bots_subs/hi_api/utils/lag_bot.py | 6 ++-- src/bots_subs/hi_api/utils/out_json.py | 2 +- src/bots_subs/open_url.py | 2 +- src/bots_subs/qs_bot.py | 2 +- src/bots_subs/wd_api/newdesc.py | 12 ++++---- src/bots_subs/wd_api/wd_bot.py | 3 +- src/bots_subs/wd_api/wd_desc.py | 2 +- src/bots_subs/wd_api/wd_sparql_bot.py | 14 ++++----- src/bots_subs/wiki_sql.py | 12 ++++---- src/cy/cy6.py | 2 +- src/cy/cy_bot/cy_api.py | 2 +- src/cy/cy_bot/cy_helps.py | 12 ++++---- src/cy/cy_bot/cy_regs.py | 4 +-- src/cy/cy_bot/do_text.py | 10 +++---- src/cy/jsub.py | 4 +-- src/cy/mv.py | 14 ++++----- src/des/book.py | 6 ++-- src/des/desc.py | 10 +++---- src/des/fam.py | 4 +-- src/des/film.py | 6 ++-- src/des/na.py | 4 +-- src/des/p155.py | 8 ++--- src/des/point.py | 4 +-- src/des/railway.py | 2 +- src/des/ru_st_2_latin.py | 9 +++--- src/nep/bots/helps.py | 4 +-- src/nep/bots/its.py | 8 ++--- src/nep/bots/scientific_article.py | 4 +-- src/nep/bots/tax_desc.py | 4 +-- src/nep/nldesc.py | 4 +-- src/nep/others/read_json.py | 2 +- src/nep/others/read_np.py | 2 +- src/nep/si3.py | 14 ++++----- src/nep/si3g.py | 2 +- src/nep/si3g_qua.py | 4 +-- src/nep/tables/str_descs.py | 6 ++-- src/nep/tests/test_si3.py | 2 +- src/nep/work_new.py | 2 +- src/nep/wr_people.py | 6 ++-- src/neq/nldes3.py | 6 ++-- src/people/new3.py | 8 ++--- src/people/people_get_topic.py | 2 +- src/prop_labs/chutes.py | 4 +-- src/prop_labs/fill_ar_props.py | 6 ++-- src/prop_labs/gemini_bot.py | 4 +-- src/prop_labs/openrouter.py | 4 +-- src/prop_labs/translate_bot.py | 2 +- src/prop_labs/wd_Session.py | 2 +- src/wd_gent.py | 4 +-- src/wd_utils/utils.py | 4 +-- src1/lex-examples/gemini.py | 6 ++-- src1/lex-examples/gemini_new.py | 4 +-- src1/lex-examples/gemini_new2.py | 6 ++-- tests/conftest.py | 2 +- tests/desc_dicts/test_utils.py | 30 +++++++++---------- 74 files changed, 216 insertions(+), 214 deletions(-) diff --git a/src/WDYe/ali.py b/src/WDYe/ali.py index 796ed9f..014fb65 100644 --- a/src/WDYe/ali.py +++ b/src/WDYe/ali.py @@ -152,7 +152,7 @@ } -def action_one(q, ar): +def action_one(q, ar) -> None: logger.info(f"<>> {q}:{ar} ") ar2 = ar if ar.find("عبد ") != -1: @@ -161,7 +161,7 @@ def action_one(q, ar): WD_API_Bot.Alias_API(q, [ar2], "ar", False) -def workqua(qua): +def workqua(qua) -> None: # --- qua = qua + Limit[1] logger.info(qua) @@ -174,7 +174,7 @@ def workqua(qua): action_one(pa["item"], pa["label"]) -def mains(): +def mains() -> None: logger.info("start with query") # --- FFF = True diff --git a/src/WDYe/alias.py b/src/WDYe/alias.py index ed36887..819ca9b 100644 --- a/src/WDYe/alias.py +++ b/src/WDYe/alias.py @@ -43,7 +43,7 @@ qid_table[labe] = qid -def WORK(item, table, type): +def WORK(item, table, type) -> None: # logger.info( item ) logger.info(table) # logger.info( '<> item:"%s" ' % item ) @@ -85,7 +85,7 @@ def WORK(item, table, type): LIMIT """ -def WORK_table(qid, tables): +def WORK_table(qid, tables) -> None: # qid = qid_table.get( peo , "" ) for peo in tables: qua = Quaa % (qid, peo) @@ -111,7 +111,7 @@ def WORK_table(qid, tables): WORK(item, value, peo) -def main(): +def main() -> None: # python pwb.py wd/med mainkey subcats # python pwb.py wd/med short subcats # python pwb.py wd/med subcats ta:horror diff --git a/src/WDYe/category.py b/src/WDYe/category.py index 178fdc1..18781a0 100644 --- a/src/WDYe/category.py +++ b/src/WDYe/category.py @@ -22,7 +22,7 @@ Limit = {1: "500"} -def main(): +def main() -> None: # python pwb.py wd/category # --- for arg in sys.argv: diff --git a/src/WDYe/catwithoutp31.py b/src/WDYe/catwithoutp31.py index d848bb4..8838c05 100644 --- a/src/WDYe/catwithoutp31.py +++ b/src/WDYe/catwithoutp31.py @@ -47,7 +47,7 @@ } -def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_props=None, return_main_table=False): +def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_props=None, return_main_table: bool=False): # --- sitewiki = site if site.find("wiki") == -1: @@ -98,7 +98,7 @@ def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_pro return table -def work_one_item(q): +def work_one_item(q) -> None: # --- # claims P31 = wd_bot.Get_Property_API(q=q, p="P31") @@ -149,7 +149,7 @@ def work_one_item(q): logger.info(f"<>* work 2 :{q} no descriptions to add.") -def main(): +def main() -> None: # --- for qua_a in quaries: qua = quaries[qua_a] diff --git a/src/WDYe/common.py b/src/WDYe/common.py index 5e43916..fba1b46 100644 --- a/src/WDYe/common.py +++ b/src/WDYe/common.py @@ -118,7 +118,7 @@ limiTa = ["Wikimedia category", "Wikimedia disambiguation page"] -def main(): +def main() -> None: logger.info("*<> main:") queries_list = sorted(list(queries.keys())) lenth = len(queries_list) @@ -141,7 +141,7 @@ def main(): logger.info("Finished successfully") -def Main_Test(): +def Main_Test() -> None: wikidatasite = pywikibot.Site("wikidata", "wikidata") repo = wikidatasite.data_repository() # --- diff --git a/src/WDYe/d1.py b/src/WDYe/d1.py index 8c7a96e..d0b118a 100644 --- a/src/WDYe/d1.py +++ b/src/WDYe/d1.py @@ -74,7 +74,7 @@ } -def work2(q, topic): +def work2(q, topic) -> None: # --- ItemDescriptions = wd_bot.Get_item_descriptions_or_labels(q, "descriptions") # --- @@ -103,7 +103,7 @@ def work2(q, topic): wd_desc.wwdesc(NewDesc, q, 1, fixlang, ask=False) -def mam(): +def mam() -> None: topic = "species of insect" logger.info("*<> mainfromQuarry:") Quarry = quuu[topic] diff --git a/src/WDYe/disam2.py b/src/WDYe/disam2.py index 5709915..850939c 100644 --- a/src/WDYe/disam2.py +++ b/src/WDYe/disam2.py @@ -30,7 +30,7 @@ } -def work2(q, topic): +def work2(q, topic) -> None: # --- # logger.info( '<> **newdesc: work2:' + q) # ItemDescriptions = {} @@ -64,7 +64,7 @@ def work2(q, topic): work_api_desc(NewDesc, q) -def mainfromQuarry(): +def mainfromQuarry() -> None: logger.info("*<> mainfromQuarry:") Quarry = """SELECT DISTINCT ?item WHERE { @@ -89,7 +89,7 @@ def mainfromQuarry(): repo = wikidatasite.data_repository() -def mainfromQuarry2(): +def mainfromQuarry2() -> None: logger.info("*<> mainfromQuarry:") # --- # quarrr = '207388' diff --git a/src/WDYe/indy.py b/src/WDYe/indy.py index ea2a486..38443f1 100644 --- a/src/WDYe/indy.py +++ b/src/WDYe/indy.py @@ -9,12 +9,12 @@ missing_dict = {} -def fixlabel(oldlabel): +def fixlabel(oldlabel: str): new = oldlabel.replace("٠", "0").replace("١", "1").replace("٢", "2").replace("٣", "3").replace("٤", "4") return new.replace("٥", "5").replace("٦", "6").replace("٧", "7").replace("٨", "8").replace("٩", "9") -def one_item(wditem): +def one_item(wditem) -> int: global items2do items2do -= 1 if wditem.labels: # تسميات موجودة @@ -35,7 +35,7 @@ def wd_sparql_generator(query): yield wd -def main(): +def main() -> None: global itemsdone itemsdone = 0 max = 10 diff --git a/src/WDYe/label.py b/src/WDYe/label.py index 792d9f6..03a97f7 100644 --- a/src/WDYe/label.py +++ b/src/WDYe/label.py @@ -30,11 +30,11 @@ missing_dict = {} -def preee(wditem, data, site): +def preee(wditem, data, site) -> None: wditem.editEntity(data, summary=f"Bot: Add Arabic label: {site}") -def one_q_item(wditem): +def one_q_item(wditem) -> int: global items2do items2do -= 1 if "arwiki" in wditem.sitelinks: @@ -55,7 +55,7 @@ def one_q_item(wditem): return 1 -def action_item2(wditem): +def action_item2(wditem) -> int: global items2do items2do -= 1 if "arwiki" in wditem.sitelinks: @@ -113,7 +113,7 @@ def wd_sparql_generator(query): yield wd -def main(): +def main() -> None: global itemsdone itemsdone = 0 print("- بدء المهمة") diff --git a/src/WDYe/labelnumber.py b/src/WDYe/labelnumber.py index 4a975de..41e0499 100644 --- a/src/WDYe/labelnumber.py +++ b/src/WDYe/labelnumber.py @@ -9,7 +9,7 @@ missing_dict = {} -def onee_item(wditem): +def onee_item(wditem) -> int: global items2do items2do -= 1 if wditem.labels: # تسميات موجودة @@ -29,7 +29,7 @@ def wd_sparql_generator(query): yield wd -def main(): +def main() -> None: global itemsdone itemsdone = 0 max = 10 diff --git a/src/WDYe/med.py b/src/WDYe/med.py index 62e10ab..c7ad167 100644 --- a/src/WDYe/med.py +++ b/src/WDYe/med.py @@ -261,7 +261,7 @@ def Get_item_table2(enlab): Looogs = {} -def looog(): +def looog() -> None: log2 = {x: Looogs[x] for x in Looogs if Looogs[x] != []} # --- text2 = "" @@ -290,7 +290,7 @@ def looog(): EngPage.save(newtext=newtext, summary="update.", nocreate=1) -def WORK(item, table): +def WORK(item, table) -> None: # logger.info( item ) logger.info(table) # --- @@ -369,7 +369,7 @@ def WORK(item, table): Limit = {1: "500"} -def main(): +def main() -> None: # python3 core8/pwb.py WDYe/med # python3 core8/pwb.py WDYe/med short # python3 core8/pwb.py WDYe/med ta:horror diff --git a/src/WDYe/month.py b/src/WDYe/month.py index 54a4daf..8753fb2 100644 --- a/src/WDYe/month.py +++ b/src/WDYe/month.py @@ -31,7 +31,7 @@ } -def main_from_quarry(topic): +def main_from_quarry(topic) -> None: logger.info("*<> main_from_quarry:") Quarry = quuu["month"] % topic if sys.argv and "OFFSET" in sys.argv: diff --git a/src/alabel/labels.py b/src/alabel/labels.py index 4eb6e56..f5f22d3 100644 --- a/src/alabel/labels.py +++ b/src/alabel/labels.py @@ -60,7 +60,7 @@ Quaa += f"limit {Limit[1]}" -def main(): +def main() -> None: # python3 core8/pwb.py alabel/labels -limit:20 # --- logger.info(Quaa) diff --git a/src/bots_subs/hi_api/__init__.py b/src/bots_subs/hi_api/__init__.py index 5418a94..f0b2fc0 100644 --- a/src/bots_subs/hi_api/__init__.py +++ b/src/bots_subs/hi_api/__init__.py @@ -8,7 +8,7 @@ class HimoAPIBot: - def __init__(self, mr_or_bot="bot", www="www"): + def __init__(self, mr_or_bot="bot", www="www") -> None: # --- self.login_bot: WikiLoginClient = log_in_wikidata(mr_or_bot=mr_or_bot, www=www) # --- diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py index 2f4ba05..68db03f 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py @@ -13,7 +13,7 @@ class WdAPI(WdErrorsHandler): - def __init__(self, login_bot, mr_or_bot="bot"): + def __init__(self, login_bot, mr_or_bot="bot") -> None: # --- self.login_bot: WikiLoginClient = login_bot # --- @@ -26,7 +26,7 @@ def __init__(self, login_bot, mr_or_bot="bot"): # --- logger.info(f"<> WdAPI: {mr_or_bot}, {self.usernamex=} \n") - def post_to_newapi(self, params={}, data={}, tage="", editgroups="", max_retry=0, **kwargs): + def post_to_newapi(self, params={}, data={}, tage="", editgroups="", max_retry: int=0, **kwargs): # --- if not params and data: params = data @@ -96,7 +96,7 @@ def filter_data(self, data, editgroups, tage): # --- return data - def lag_work(self, err): + def lag_work(self, err) -> str: # --- _ixix = { "error": { diff --git a/src/bots_subs/hi_api/req_bots_new/claims_wd.py b/src/bots_subs/hi_api/req_bots_new/claims_wd.py index 26d6c2d..aef85fc 100644 --- a/src/bots_subs/hi_api/req_bots_new/claims_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/claims_wd.py @@ -16,12 +16,12 @@ class WD_Claims: - def __init__(self, wdapi_new): + def __init__(self, wdapi_new) -> None: self.wdapi_new = wdapi_new self.session_post = self.wdapi_new.post_to_newapi # pass - def add_quall(self, Claimid, quall_prop, valueline, hashx="", nowait=False): + def add_quall(self, Claimid, quall_prop, valueline, hashx="", nowait: bool=False): """Add a qualifier to a claim. This function adds a specified qualifier to a given claim identified by @@ -86,7 +86,7 @@ def add_quall(self, Claimid, quall_prop, valueline, hashx="", nowait=False): # --- return d - def _Set_Quall(self, js, quall_prop, quall_id, nowait=False): + def _Set_Quall(self, js, quall_prop, quall_id, nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" @@ -131,7 +131,7 @@ def _Set_Quall(self, js, quall_prop, quall_id, nowait=False): # --- return Claimid - def _Set_Quall2(self, js, qualifiers, nowait=False): + def _Set_Quall2(self, js, qualifiers, nowait: bool=False) -> str: # --- if lag_bot.bad_lag(nowait): return "" @@ -186,7 +186,7 @@ def _Set_Quall2(self, js, qualifiers, nowait=False): # --- self.add_quall(Claimid, quall_prop, valueline) - def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait=False): + def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" @@ -233,7 +233,7 @@ def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait=False): if qualifiers != []: self._Set_Quall2(r4, qualifiers) - def Claim_API_time(self, q, proprty, precision=9, year="", strtime="", nowait=False): + def Claim_API_time(self, q, proprty, precision: int=9, year="", strtime="", nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py index ec9ccef..d08e570 100644 --- a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py @@ -31,12 +31,12 @@ def ask_put(s): class WD_Descriptions: - def __init__(self, wdapi_new): + def __init__(self, wdapi_new) -> None: self.wdapi_new = wdapi_new self.session_post = self.wdapi_new.post_to_newapi # pass - def Des_API(self, Qid, desc, lang, ask="", rea=True, nowait=False): + def Des_API(self, Qid, desc: str, lang, ask="", rea: bool=True, nowait: bool=False): """Set the description for a given item in a specified language. This function updates the description of an item identified by its Qid @@ -109,7 +109,7 @@ def Des_API(self, Qid, desc, lang, ask="", rea=True, nowait=False): qsline = f'{Qid}|D{lang}|"{desc}"' QS_line(qsline, user="Mr.Ibrahembot") - def New_Mult_Des(self, q, data2, summary, ret, nowait=False): + def New_Mult_Des(self, q, data2, summary, ret, nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" @@ -144,11 +144,11 @@ def New_Mult_Des_2( data2, summary, ret, - ask=False, - rea=True, - nowait=False, + ask: bool=False, + rea: bool=True, + nowait: bool=False, tage="", - return_result=False, + return_result: bool=False, ): # --- if lag_bot.bad_lag(nowait): diff --git a/src/bots_subs/hi_api/req_bots_new/labels_wd.py b/src/bots_subs/hi_api/req_bots_new/labels_wd.py index b44d5d2..089140f 100644 --- a/src/bots_subs/hi_api/req_bots_new/labels_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/labels_wd.py @@ -30,13 +30,13 @@ def ask_put(s): class WD_Labels: - def __init__(self, wdapi_new, Des_API): + def __init__(self, wdapi_new, Des_API) -> None: self.wdapi_new = wdapi_new self.session_post = self.wdapi_new.post_to_newapi self.Des_API_funcs = Des_API # pass - def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait=False): + def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" @@ -74,15 +74,15 @@ def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait=False): def Labels_API( self, Qid, - label, + label: str, lang, ret, - Or_Alii=False, - change_des=False, - number=0, - nowait=False, + Or_Alii: bool=False, + change_des: bool=False, + number: int=0, + nowait: bool=False, tage="", - remove=False, + remove: bool=False, ): # --- if lag_bot.bad_lag(nowait): @@ -130,7 +130,7 @@ def Labels_API( if d == "warn": logger.exception("Exception:", exc_info=True) - def Add_Labels_if_not_there(self, Qid, label, lang, ask="", Or_Alii=False, nowait=False): + def Add_Labels_if_not_there(self, Qid, label: str, lang, ask="", Or_Alii: bool=False, nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/utils/handle_wd_errors.py b/src/bots_subs/hi_api/utils/handle_wd_errors.py index 1d56b54..8d069d6 100644 --- a/src/bots_subs/hi_api/utils/handle_wd_errors.py +++ b/src/bots_subs/hi_api/utils/handle_wd_errors.py @@ -7,7 +7,7 @@ class WdErrorsHandler: - def __init__(self): + def __init__(self) -> None: logger.info("class WdErrorsHandler:") def handle_err_wd( diff --git a/src/bots_subs/hi_api/utils/lag_bot.py b/src/bots_subs/hi_api/utils/lag_bot.py index 8b3778a..5321f17 100644 --- a/src/bots_subs/hi_api/utils/lag_bot.py +++ b/src/bots_subs/hi_api/utils/lag_bot.py @@ -50,7 +50,7 @@ def find_lag(err) -> None: time.sleep(FFa_lag[1] + 1) -def make_sleep_def(): +def make_sleep_def() -> None: # --- frr = int(time.time() - Find_Lag[2]) # --- @@ -119,7 +119,7 @@ def make_sleep_def(): newsleep[1] = fain -def do_lag(): +def do_lag() -> None: GG = False # --- numb = 0 @@ -149,7 +149,7 @@ def do_lag(): GG = False -def bad_lag(nowait): +def bad_lag(nowait) -> bool: # --- if "testwikidata" in sys.argv: return False diff --git a/src/bots_subs/hi_api/utils/out_json.py b/src/bots_subs/hi_api/utils/out_json.py index e449733..7716323 100644 --- a/src/bots_subs/hi_api/utils/out_json.py +++ b/src/bots_subs/hi_api/utils/out_json.py @@ -188,7 +188,7 @@ def outbot_json_bot(err): return err_code -def outbot_json(js_text, fi="", line="", timesleeps=0, NoWait=False): +def outbot_json(js_text, fi="", line="", timesleeps: int=0, NoWait: bool=False): # --- success = js_text.get("success", 0) # --- diff --git a/src/bots_subs/open_url.py b/src/bots_subs/open_url.py index 72c9c63..720562c 100644 --- a/src/bots_subs/open_url.py +++ b/src/bots_subs/open_url.py @@ -10,7 +10,7 @@ class ClassGetURL: - def __init__(self, url): + def __init__(self, url) -> None: self.start = time.time() self.url = url self.html = "" diff --git a/src/bots_subs/qs_bot.py b/src/bots_subs/qs_bot.py index 5f3d7c6..fc94fa5 100644 --- a/src/bots_subs/qs_bot.py +++ b/src/bots_subs/qs_bot.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) -def QS_line(line, user="Mr. Ibrahem"): +def QS_line(line, user="Mr. Ibrahem") -> bool: # --- # https://quickstatements.toolforge.org/api.php?format=v1&action=import&compress=1&submit=1&batchname=df&username=Mr.Ibrahembot&token=$2&data=Q24173161|Dar|"جين في متفطرة خراجية" # --- diff --git a/src/bots_subs/wd_api/newdesc.py b/src/bots_subs/wd_api/newdesc.py index c5b1070..75ecddf 100644 --- a/src/bots_subs/wd_api/newdesc.py +++ b/src/bots_subs/wd_api/newdesc.py @@ -25,7 +25,7 @@ # newdesc.Quarry_with_item_langs( p31, Quarry, translations) -def work2_with_replacement(item, topic, translations, replacement_ke): +def work2_with_replacement(item, topic, translations, replacement_ke) -> None: item.get() # logger.info( '<> **newdesc: work2:' + item.title(as_link=False)) # ItemDescriptions = {} @@ -61,7 +61,7 @@ def work2_with_replacement(item, topic, translations, replacement_ke): wd_desc.work_api_desc(NewDesc, q) -def work22(q, topic, translations): +def work22(q, topic, translations) -> None: # --- keys = sorted([x for x in translations[topic].keys()]) if "en" in keys: @@ -89,7 +89,7 @@ def work22(q, topic, translations): wd_desc.work_api_desc(NewDesc, q) -def mainfromQuarry(topic, Quarry, translations): +def mainfromQuarry(topic, Quarry, translations) -> None: # logger.info( '*<> mainfromQuarry:' ) # Quarry = 'SELECT ?item WHERE { ?item wdt:P31 wd:Q17633526.}' json = wd_sparql_bot.sparql_generator_url(Quarry) @@ -103,7 +103,7 @@ def mainfromQuarry(topic, Quarry, translations): work22(q, topic, translations) -def Quarry_with_item_langs(p31, Quarry, translations): +def Quarry_with_item_langs(p31, Quarry, translations) -> None: json = wd_sparql_bot.sparql_generator_url(Quarry) lenth = len(json) num = 0 @@ -123,11 +123,11 @@ def Quarry_with_item_langs(p31, Quarry, translations): work22(q, p31, translations) -def mainfromQuarry2(topic, Quarry, translations): +def mainfromQuarry2(topic, Quarry, translations) -> None: mainfromQuarry(topic, Quarry, translations) -def work2(item, topic, translations): +def work2(item, topic, translations) -> None: # --- keys = sorted([x for x in translations[topic].keys()]) if "en" in keys: diff --git a/src/bots_subs/wd_api/wd_bot.py b/src/bots_subs/wd_api/wd_bot.py index c74f65c..301d36e 100644 --- a/src/bots_subs/wd_api/wd_bot.py +++ b/src/bots_subs/wd_api/wd_bot.py @@ -3,6 +3,7 @@ import logging from .submit_bot import submitAPI +from typing import Sequence logger = logging.getLogger(__name__) @@ -11,7 +12,7 @@ def format_sitelinks(sitelinks): return {x["site"]: x["title"] for d, x in sitelinks.items()} -def format_labels_descriptions(labels): +def format_labels_descriptions(labels: Sequence[str]): return {x["language"]: x["value"] for _, x in labels.items()} diff --git a/src/bots_subs/wd_api/wd_desc.py b/src/bots_subs/wd_api/wd_desc.py index 6709a15..d6f6a98 100644 --- a/src/bots_subs/wd_api/wd_desc.py +++ b/src/bots_subs/wd_api/wd_desc.py @@ -180,7 +180,7 @@ def wwdesc(newdesc, qid, i, fixlang, ask="", tage=""): logger.info(skipp) -def work_api_desc(newdesc, qid, fixlang=[]): +def work_api_desc(newdesc, qid, fixlang=[]) -> None: # --- newdesc = del_keys(newdesc) # --- diff --git a/src/bots_subs/wd_api/wd_sparql_bot.py b/src/bots_subs/wd_api/wd_sparql_bot.py index fca5cd7..bd03915 100644 --- a/src/bots_subs/wd_api/wd_sparql_bot.py +++ b/src/bots_subs/wd_api/wd_sparql_bot.py @@ -52,7 +52,7 @@ def get_query_data(query): return data -def wd_sparql_generator_url(quary, returnq=False): +def wd_sparql_generator_url(quary, returnq: bool=False): """Generate a list of unique item identifiers from a SPARQL query. This function takes a SPARQL query as input, executes it to retrieve @@ -107,12 +107,12 @@ def wd_sparql_generator_url(quary, returnq=False): def sparql_generator_url( quary, - printq=False, - add_date=True, + printq: bool=False, + add_date: bool=True, key="", - geterror=False, - returndict=False, - returnq=False, + geterror: bool=False, + returndict: bool=False, + returnq: bool=False, ): # --- if add_date: @@ -174,7 +174,7 @@ def sparql_generator_url( return qlist -def sparql_generator_big_results(spq, offset=0, limit=5000, alllimit=0): +def sparql_generator_big_results(spq, offset: int=0, limit: int=5000, alllimit: int=0): """Generate a list of results from a SPARQL query with pagination support. This function executes a SPARQL query and retrieves results in batches, diff --git a/src/bots_subs/wiki_sql.py b/src/bots_subs/wiki_sql.py index c95f463..392cad3 100644 --- a/src/bots_subs/wiki_sql.py +++ b/src/bots_subs/wiki_sql.py @@ -135,10 +135,10 @@ def make_labsdb_dbs_p(wiki): def sql_connect_pymysql( query, db="", - host="", - update=False, + host: str="", + update: bool=False, default_return=None, - return_dict=False, + return_dict: bool=False, values=None, ): # --- @@ -196,10 +196,10 @@ def sql_connect_pymysql( def make_sql_connect( query, db="", - host="", - update=False, + host: str="", + update: bool=False, default_return=None, - return_dict=False, + return_dict: bool=False, values=None, ): # --- diff --git a/src/cy/cy6.py b/src/cy/cy6.py index d1aa7a0..5f1286a 100644 --- a/src/cy/cy6.py +++ b/src/cy/cy6.py @@ -51,7 +51,7 @@ def StartOnePage(title) -> None: return page_put(NewText, title) -def main(): +def main() -> None: # --- title = "" # --- diff --git a/src/cy/cy_bot/cy_api.py b/src/cy/cy_bot/cy_api.py index a691932..2d386b8 100644 --- a/src/cy/cy_bot/cy_api.py +++ b/src/cy/cy_bot/cy_api.py @@ -90,7 +90,7 @@ def login(): login() -def page_put(newtext, maintitle): +def page_put(newtext, maintitle) -> None: printt(" page_put:
") # try: title = ec_de_code(maintitle, "decode") diff --git a/src/cy/cy_bot/cy_helps.py b/src/cy/cy_bot/cy_helps.py index 85eca43..2f2e785 100644 --- a/src/cy/cy_bot/cy_helps.py +++ b/src/cy/cy_bot/cy_helps.py @@ -119,20 +119,20 @@ def make_dada(newtext, maintitle): return t -def print_test2(s): +def print_test2(s) -> None: if TEST[2]: # logger.info(s) print(s) -def printt(s): +def printt(s) -> None: SS = False if SS or "test" in sys.argv or "test2" in sys.argv: # logger.info(s) print(s) -def printo(s): +def printo(s) -> None: # --- if "test" in sys.argv or "test2" in sys.argv or "ask" in sys.argv: print(s) @@ -144,7 +144,7 @@ def printo(s): print("") -def CheckTempalteInPageText(text): +def CheckTempalteInPageText(text: str): printt("**CheckTempalteInPageText:
") if not text: printt(" * no text.
") @@ -186,7 +186,7 @@ def CheckTempalteInPageText(text): return True -def find_cy_temp(text): +def find_cy_temp(text: str): start = "{{نتيجة سباق الدراجات/بداية" end = "{{نتيجة سباق الدراجات/نهاية}}" # --- @@ -206,7 +206,7 @@ def find_cy_temp(text): return text[start_pos:end_pos] -def get_temps_str(text, temp_name): +def get_temps_str(text: str, temp_name: str): # --- parser = wtp.parse(text) # --- diff --git a/src/cy/cy_bot/cy_regs.py b/src/cy/cy_bot/cy_regs.py index 1ec631c..3167240 100644 --- a/src/cy/cy_bot/cy_regs.py +++ b/src/cy/cy_bot/cy_regs.py @@ -11,7 +11,7 @@ from .cy_helps import get_temp_arg -def make_data_new(text): +def make_data_new(text: str): # --- tab = {} # --- @@ -49,7 +49,7 @@ def make_data_new(text): return tab -def test(): +def test() -> None: text = """{{نتيجة سباق الدراجات/سطر4 |qid = Q110775370 |السباق = 2022 Tour de Romandie Féminin diff --git a/src/cy/cy_bot/do_text.py b/src/cy/cy_bot/do_text.py index 29f4717..a9e0626 100644 --- a/src/cy/cy_bot/do_text.py +++ b/src/cy/cy_bot/do_text.py @@ -49,7 +49,7 @@ Work_with_Stage = {} -def template_params(text, title): +def template_params(text: str, title): # --- parser = wtp.parse(text) # --- @@ -119,7 +119,7 @@ def findflag(race, flag): return flag -def fix_label(label): +def fix_label(label: str): label = label.strip() label = re.sub( @@ -566,7 +566,7 @@ def make_new_section(qid, title): return texxt -def work_tano(text, maintitle): +def work_tano(text: str, maintitle): # --- lines[maintitle] = make_data_new(text) # --- @@ -620,7 +620,7 @@ def work_tano(text, maintitle): return liner -def make_new_text(item, title, text): +def make_new_text(item, title, text: str): # --- Newsect = make_new_section(item, title) # --- @@ -662,7 +662,7 @@ def make_new_text(item, title, text): return text -def do_One_Page(title, text, item=""): +def do_One_Page(title, text: str, item=""): # --- Check = CheckTempalteInPageText(text) # --- diff --git a/src/cy/jsub.py b/src/cy/jsub.py index 97a459e..13e1f02 100644 --- a/src/cy/jsub.py +++ b/src/cy/jsub.py @@ -33,7 +33,7 @@ ] -def onep(title): +def onep(title) -> None: # --- if title in skip_titles: return @@ -72,7 +72,7 @@ def onep(title): page.save(newtext=new_text, summary="بوت:تجربة تحديث بيانات اللاعب") -def main2(): +def main2() -> None: generator = wd_gent.get_gent_list() # --- for numb, pagetitle in enumerate(generator, start=1): diff --git a/src/cy/mv.py b/src/cy/mv.py index 0ef1409..27eaee0 100644 --- a/src/cy/mv.py +++ b/src/cy/mv.py @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) -def add_id_to_text(item, text): +def add_id_to_text(item, text: str): parser = wtp.parse(text) # --- for template in parser.templates: @@ -48,7 +48,7 @@ def add_id_to_text(item, text): return text -def move_it_to_temp(title, item, text): +def move_it_to_temp(title, item, text: str): # --- if not text: return None @@ -70,7 +70,7 @@ def move_it_to_temp(title, item, text): return do -def find_cy_temp(text): +def find_cy_temp(text: str): start = "{{نتيجة سباق الدراجات/بداية" end = "{{نتيجة سباق الدراجات/نهاية}}" # --- @@ -90,7 +90,7 @@ def find_cy_temp(text): return text[start_pos:end_pos] -def one_page_work(title, text, item): +def one_page_work(title, text: str, item): # --- cy_temp = find_cy_temp(text) # --- @@ -111,7 +111,7 @@ def one_page_work(title, text, item): return text -def onep(title): +def onep(title) -> None: # --- ar_api = load_main_api("ar", "wikipedia") page = ar_api.MainPage(title) @@ -157,7 +157,7 @@ def onep(title): page.save(newtext=new_text, summary="بوت:تجربة تحديث بيانات اللاعب") -def split_pages(pages, parts=4): +def split_pages(pages, parts: int=4): length = len(pages) part_size = length // parts remaining = length % parts @@ -179,7 +179,7 @@ def split_pages(pages, parts=4): return pages -def main2(): +def main2() -> None: generator = wd_gent.get_gent_list() # --- list_of_pages = list(tqdm.tqdm(generator)) diff --git a/src/des/book.py b/src/des/book.py index 16ff1ab..88469a4 100644 --- a/src/des/book.py +++ b/src/des/book.py @@ -66,7 +66,7 @@ } -def one_book_item(Qid, pa, lang, keys): +def one_book_item(Qid, pa, lang, keys) -> None: item = wd_bot.Get_Item_API_From_Qid(pa["item"]) if not item: return @@ -200,7 +200,7 @@ def Gquery2(json1): Off[1] = int(value) -def WorkWithOneLang(Qid, lang, keys): +def WorkWithOneLang(Qid, lang, keys) -> None: logger.info("*<> WorkWithOneLang: ") # --- query = GetQuery(Qid, lang, keys) @@ -275,7 +275,7 @@ def MakeDesc(Qid, pa, lang): return description -def main(): +def main() -> None: # --- for arg in sys.argv: # --- diff --git a/src/des/desc.py b/src/des/desc.py index e19c753..5347a51 100644 --- a/src/des/desc.py +++ b/src/des/desc.py @@ -185,7 +185,7 @@ def get_property_label_for_qids(properties, List): return newtabe -def descqs(q, value, lang): +def descqs(q, value, lang) -> None: if len(New_QS[1]) < QSlimit[1]: qsline = f'{q}|D{lang}|"{value}"' New_QS[1].append(qsline) @@ -196,7 +196,7 @@ def descqs(q, value, lang): New_QS[1] = [] -def Add_desc(q, value, lang): +def Add_desc(q, value, lang) -> str: # --- if q in q_list_done: logger.info("q in q_list_done") @@ -210,7 +210,7 @@ def Add_desc(q, value, lang): WD_API_Bot.Des_API(q, value, lang, ask="") -def work_one_item(start, lang, tab, c, total, findlab=False): +def work_one_item(start, lang, tab, c, total: int, findlab: bool=False) -> str: # --- """work_one_item used in np/si3.py""" # --- @@ -292,7 +292,7 @@ def work_one_item(start, lang, tab, c, total, findlab=False): Add_desc(q, arlabel2, lang) -def work_one_place(place): +def work_one_place(place) -> str: lang = "ar" # --- start = placestable2[place].get(lang, "") @@ -323,7 +323,7 @@ def work_one_place(place): work_one_item(start, lang, tab, c, total) -def mainoo(): +def mainoo() -> None: # --- kee = sorted(placestable2.keys()) # --- diff --git a/src/des/fam.py b/src/des/fam.py index 69fc4d5..8deb0cf 100644 --- a/src/des/fam.py +++ b/src/des/fam.py @@ -127,7 +127,7 @@ qlist_done = [] -def work_one_json(json1, topic_ar, p31, p31_langs): +def work_one_json(json1, topic_ar, p31, p31_langs) -> None: # --- json_lenth = len(json1) # --- @@ -170,7 +170,7 @@ def work_one_quarry(quarry, p31, p31_desc): return quarry_result_lenth -def main(): +def main() -> None: # lenth of desc_table and quarry_list all_lenth = len(quarry_list) * len(desc_table) # --- diff --git a/src/des/film.py b/src/des/film.py index 720a844..96db0aa 100644 --- a/src/des/film.py +++ b/src/des/film.py @@ -25,7 +25,7 @@ # def AddDes( item , pa , lang , Qid , keys): -def one_film_item(Qid, pa, lang, keys): +def one_film_item(Qid, pa, lang, keys) -> None: item = getwditem(pa["item"]) if not item: return @@ -202,7 +202,7 @@ def Gquery2(json1): """ -def WorkWithOneLang(Qid, lang, keys): +def WorkWithOneLang(Qid, lang, keys) -> None: logger.info("*<> WorkWithOneLang: ") limit = 200 # limit = '10000' @@ -294,7 +294,7 @@ def MakeDesc(Qid, pa, lang): return description -def films(): +def films() -> None: logger.info("films: ") Q = "film" # for lang in language: diff --git a/src/des/na.py b/src/des/na.py index c311b15..6e18f45 100644 --- a/src/des/na.py +++ b/src/des/na.py @@ -26,7 +26,7 @@ items_done = [] -def action(json1): +def action(json1) -> None: try: total = len(json1) except BaseException: @@ -222,7 +222,7 @@ def make_quarry(ar_suff="", item_p31_cat="", en_suff="", en_priff=""): } -def main(): +def main() -> None: # --- # python pwb.py des/na # python pwb.py des/na Deaths diff --git a/src/des/p155.py b/src/des/p155.py index 07e1c4c..60bb62a 100644 --- a/src/des/p155.py +++ b/src/des/p155.py @@ -42,7 +42,7 @@ tests_ar = r"[ابتثجحخدذرزسشصضطظعغفقكلمنهويأآإىءئؤة1234567890\–\-\.]" -def make_newlabel(label, ar, en): +def make_newlabel(label: str, ar, en): # --- logger.info(f'<>make_newlabel label:"{label}",ar:"{ar}",en:"{en}" ') newlabel = "" @@ -306,7 +306,7 @@ def make_newlabel(label, ar, en): return newlabel.strip() -def Item(item): +def Item(item) -> str: # --- q = item["item"] # ---# @@ -543,7 +543,7 @@ def Item(item): Quarry["use"] = Quarry[2] -def main(): +def main() -> None: # --- # python pwb.py des/p155 qua0 P17:Q145 # python pwb.py des/p155 qua0 @@ -635,7 +635,7 @@ def main(): Item(tabj) -def test(): +def test() -> None: # cc = "2010 World Figure Skating Championships - ladies' singles free skating" # ar = make_newlabel( cc , '' , '' ) # ar = make_newlabel( "2020 Volleyball at the Summer olympics" , 'الألعاب الأولمبية الصيفية 2020' , '2020 Summer Olympics' ) diff --git a/src/des/point.py b/src/des/point.py index ef78623..f7f8a4a 100644 --- a/src/des/point.py +++ b/src/des/point.py @@ -25,7 +25,7 @@ items_done = [] -def action(json1): +def action(json1) -> None: try: total = len(json1) except BaseException: @@ -85,7 +85,7 @@ def action(json1): } -def main(): +def main() -> None: # --- # python pwb.py des/point -limit:2 # --- diff --git a/src/des/railway.py b/src/des/railway.py index d16ee27..c576985 100644 --- a/src/des/railway.py +++ b/src/des/railway.py @@ -26,7 +26,7 @@ } -def Get_P_API_id(claims, P, onlyone=False): +def Get_P_API_id(claims, P, onlyone: bool=False): # --- lista = [] # --- diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index b36126d..373aa47 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -12,6 +12,7 @@ import pywikibot from bots_subs.hi_api import HimoAPIBot from pywikibot.pagegenerators import WikidataSPARQLPageGenerator +from typing import Sequence WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") @@ -290,7 +291,7 @@ } -def add_new_label(q, enlabel): +def add_new_label(q, enlabel: str) -> None: # --- if not enlabel: return @@ -311,7 +312,7 @@ def add_new_label(q, enlabel): } -def change_one_lab(text, lang): +def change_one_lab(text: str, lang): table = letters_to_latin[lang] # --- new_lab = "".join([table.get(i, i) for i in text]) @@ -331,7 +332,7 @@ def change_one_lab(text, lang): return new_lab -def make_en_label(labels, q, Add=False): +def make_en_label(labels: Sequence[str], q, Add: bool=False): org_lab = "" new_lab = "" # --- @@ -351,7 +352,7 @@ def make_en_label(labels, q, Add=False): return new_lab -def main(): +def main() -> None: # --- query = """SELECT ?item WHERE { ?item wdt:P495 wd:Q403. diff --git a/src/nep/bots/helps.py b/src/nep/bots/helps.py index 3f8a75d..db9ed5b 100644 --- a/src/nep/bots/helps.py +++ b/src/nep/bots/helps.py @@ -56,7 +56,7 @@ def Get_P_API_time(item, P): return qlist[0] if len(Faso.keys()) == 1 else False -def log_new_types(lists): +def log_new_types(lists) -> str: # --- if "nolog" in sys.argv: return "" @@ -132,7 +132,7 @@ def get_female_for_p17(contry_lab, tyy): return lab -def get_label_txt(lng, wdi, property, array=0, fallback=False): +def get_label_txt(lng, wdi, property, array: int=0, fallback: bool=False): if property in wdi.get("claims", {}): if len(wdi.get("claims", {}).get(property, "")) > array: lnkProperty = wdi.get("claims", {}).get(property)[array].getTarget() diff --git a/src/nep/bots/its.py b/src/nep/bots/its.py index e635c75..b49b429 100644 --- a/src/nep/bots/its.py +++ b/src/nep/bots/its.py @@ -37,7 +37,7 @@ def its_a_generalthing(wditem, shortstr, longdescrstr, myclaim, claimstr=""): return laste -def its_something_in_an_entity(wdi, something): +def its_something_in_an_entity(wdi, something) -> str: # 'P131' #P131 # 'P17' #P17 # --- @@ -148,7 +148,7 @@ def its_an_episode(lng, wditem): return "" -def its_a_computergame(lng, wditem): +def its_a_computergame(lng, wditem) -> str: logger.info(" its_a_computergame ") if "P178" in wditem.get("claims", {}): # المطور LNKdeveloper = get_mainsnak(wditem.get("claims", {}).get("P178")[0]) # .getTarget() @@ -301,7 +301,7 @@ def its_a_p50(type_of_item, wditem, shortstr, claimstr=""): return laste -def its_a_thing_located_in_country(wditem, countryname, thing): +def its_a_thing_located_in_country(wditem, countryname: str, thing) -> str: if "P131" in wditem.get("claims", {}): LNKcommunity = get_mainsnak(wditem.get("claims", {}).get("P131")[0]) # .getTarget() label = Get_label(LNKcommunity) @@ -312,7 +312,7 @@ def its_a_thing_located_in_country(wditem, countryname, thing): return f"{thing} في {countryname}" -def its_a_film(wditem): +def its_a_film(wditem) -> str: # --- directorname = "" # --- diff --git a/src/nep/bots/scientific_article.py b/src/nep/bots/scientific_article.py index bbf9404..e6dca92 100644 --- a/src/nep/bots/scientific_article.py +++ b/src/nep/bots/scientific_article.py @@ -179,7 +179,7 @@ def Monthname(lang, month): return False -def Make_uk_desc(desc): +def Make_uk_desc(desc: str): return desc @@ -287,7 +287,7 @@ def make_scientific_desc(lang, date, precision): return desc -def make_scientific_article(item, p31, num, TestTable=False): +def make_scientific_article(item, p31, num: int, TestTable: bool=False): # --- tablem = {"descriptions": {}, "qid": "", "fixlang": []} # --- diff --git a/src/nep/bots/tax_desc.py b/src/nep/bots/tax_desc.py index ea170ef..cc973ef 100644 --- a/src/nep/bots/tax_desc.py +++ b/src/nep/bots/tax_desc.py @@ -25,7 +25,7 @@ tax_translations_lower[kkey.lower()] = tax_lab.replace("~", natar) -def make_tax_des_new(item): +def make_tax_des_new(item) -> str: q = item["q"] # --- P171 = Get_P_API_id(item, "P171") @@ -80,7 +80,7 @@ def make_tax_des_new(item): WD_API_Bot.Des_API(q, ar_lab, "ar") -def work_taxon_desc(item, endesc): +def work_taxon_desc(item, endesc) -> None: # --- ardesc = tax_translations_lower.get(endesc.lower(), "") # .get("ar", '') q = item["q"] diff --git a/src/nep/nldesc.py b/src/nep/nldesc.py index 83ae95e..e2c1397 100644 --- a/src/nep/nldesc.py +++ b/src/nep/nldesc.py @@ -72,7 +72,7 @@ def Make_railway_desc(wditem, p31): return work_railway(wditem, p31) -def action_one_P131_item(lng, oneitem): +def action_one_P131_item(lng, oneitem) -> int: global totaledits if lng in oneitem.get("descriptions", {}): nld = oneitem.get("descriptions", {}).get(lng, "") @@ -133,7 +133,7 @@ def action_one_P131_item(lng, oneitem): return 0 -def Add_desc(q, value, lang): +def Add_desc(q, value, lang) -> None: WD_API_Bot.Des_API(q, value, lang, ask="") diff --git a/src/nep/others/read_json.py b/src/nep/others/read_json.py index 2f2c025..2886d3d 100644 --- a/src/nep/others/read_json.py +++ b/src/nep/others/read_json.py @@ -9,7 +9,7 @@ logger = logging.getLogger(__name__) -def printo(s): +def printo(s) -> None: logger.info(s) diff --git a/src/nep/others/read_np.py b/src/nep/others/read_np.py index c068aa4..0d1f3d7 100644 --- a/src/nep/others/read_np.py +++ b/src/nep/others/read_np.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) -def read_new_types_file(): +def read_new_types_file() -> None: # --- # python3 core8/pwb.py nep/si3 read # python3 core8/pwb.py nep/si3 read -file:nep/new_types11.json diff --git a/src/nep/si3.py b/src/nep/si3.py index 6648c29..40c120e 100644 --- a/src/nep/si3.py +++ b/src/nep/si3.py @@ -33,7 +33,7 @@ logger = logging.getLogger(__name__) -def work_a_desc(NewDesc, qid, fixlang): +def work_a_desc(NewDesc, qid, fixlang) -> str: # --- if MainTestTable[1] or "dd" in sys.argv: logger.info("<> Without save:") @@ -44,7 +44,7 @@ def work_a_desc(NewDesc, qid, fixlang): work_api_desc(NewDesc, qid, fixlang=fixlang) -def make_scientific_art(item, P31, num): +def make_scientific_art(item, P31, num: int) -> None: # --- table = make_scientific_article(item, P31, num, TestTable=MainTestTable[1]) # --- @@ -55,7 +55,7 @@ def make_scientific_art(item, P31, num): work_a_desc(NewDesc, qid, rep_langs) -def do_P1433_new_list(item, p31): +def do_P1433_new_list(item, p31) -> None: # --- logger.info(" do_P1433_new_list: ") # --- @@ -74,7 +74,7 @@ def do_P1433_new_list(item, p31): print("do_P1433_new_list nothing to add. ") -def work_new_list(item, p31, ardes): +def work_new_list(item, p31, ardes) -> None: # --- logger.info(f" work_new_list: {ardes=}") # --- @@ -119,7 +119,7 @@ def work_new_list(item, p31, ardes): print("work_new_list nothing to add. ") -def work_qid_desc(item, topic, num): +def work_qid_desc(item, topic, num: int) -> None: logger.info("<> work_qid_desc: ") q = item["q"] descriptions = item.get("descriptions", {}) @@ -152,7 +152,7 @@ def work_qid_desc(item, topic, num): work_a_desc(NewDesc, q, []) -def ISRE(qitem, num, lenth, no_donelist=True, P31_list=False, get_nl_des=True): +def ISRE(qitem, num: int, lenth, no_donelist: bool=True, P31_list: bool=False, get_nl_des: bool=True): # --- logger.info(f"--- *<> >{num}/{lenth}: q:{qitem}") # --- @@ -251,7 +251,7 @@ def ISRE(qitem, num, lenth, no_donelist=True, P31_list=False, get_nl_des=True): new_types[P31] += 1 -def print_new_types(): +def print_new_types() -> None: lists = [[y, x] for x, y in new_types.items()] lists.sort(reverse=True) # --- diff --git a/src/nep/si3g.py b/src/nep/si3g.py index aea585f..e932058 100644 --- a/src/nep/si3g.py +++ b/src/nep/si3g.py @@ -69,7 +69,7 @@ logger.info(f"<> main_dir1 = {main_dir1}") -def mainwithcat2(): +def mainwithcat2() -> None: logger.info("*<> > mainwithcat2:") # --- # python3 core8/pwb.py nep/si3g -newpages:10 diff --git a/src/nep/si3g_qua.py b/src/nep/si3g_qua.py index 770bfaf..5d77bba 100644 --- a/src/nep/si3g_qua.py +++ b/src/nep/si3g_qua.py @@ -98,7 +98,7 @@ def get_qua(): return qua -def one_item(qid, num): +def one_item(qid, num: int) -> None: # {'item': 'http://www.wikidata.org/entity/Q21457154', 'qid': 'Q21457154'} item = wd_bot.Get_Item_API_From_Qid(qid, props="claims|descriptions|labels") # --- @@ -114,7 +114,7 @@ def one_item(qid, num): work_people(item, "", num, ardes) -def main(): +def main() -> None: logger.info("*<> > main:") # --- base_qua = get_qua() diff --git a/src/nep/tables/str_descs.py b/src/nep/tables/str_descs.py index 7411120..daa9aad 100644 --- a/src/nep/tables/str_descs.py +++ b/src/nep/tables/str_descs.py @@ -321,7 +321,7 @@ def its_a_tabon_in_thailand(lng, wditem): return "" -def its_a_publication(wditem): +def its_a_publication(wditem) -> str: if "P921" in wditem.get("claims", {}): its_a_generalthing(wditem, "", "over", "P921") if "P123" in wditem.get("claims", {}): @@ -345,7 +345,7 @@ def its_a_fictional_character(wditem): return "" -def its_a_discography(lng, wditem): +def its_a_discography(lng, wditem) -> str: if "P175" in wditem.get("claims", {}): artistLNK = get_mainsnak(wditem.get("claims", {}).get("P175")[0]) # .getTarget() if artistLNK is not None: @@ -359,7 +359,7 @@ def its_a_discography(lng, wditem): return "" -def its_a_composition(lng, wditem): +def its_a_composition(lng, wditem) -> str: """ find composer P86 """ diff --git a/src/nep/tests/test_si3.py b/src/nep/tests/test_si3.py index da1de72..0a54e03 100644 --- a/src/nep/tests/test_si3.py +++ b/src/nep/tests/test_si3.py @@ -7,7 +7,7 @@ si3.MainTestTable[1] = True -def Main_Test(): +def Main_Test() -> None: # python core8/pwb.py nep/test_si3 -page:Q122652815 # python core8/pwb.py nep/test_si3 print("<> Main_Test :") diff --git a/src/nep/work_new.py b/src/nep/work_new.py index 91e794c..97aebd9 100644 --- a/src/nep/work_new.py +++ b/src/nep/work_new.py @@ -11,7 +11,7 @@ # 32897048 متبقي حتى -def WorkNew(): +def WorkNew() -> None: start = 32700000 ATend = 32500000 # --- diff --git a/src/nep/wr_people.py b/src/nep/wr_people.py index d5072d1..b73150e 100644 --- a/src/nep/wr_people.py +++ b/src/nep/wr_people.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) -def add_only_ar(q, ara): +def add_only_ar(q, ara) -> None: # --- tab = {"ar": {"language": "ar", "value": ara}} work_api_desc(tab, q, fixlang=[]) @@ -36,7 +36,7 @@ def get_claim_id(item, prop): ) -def work_people2(item, topic, num=0, years=""): +def work_people2(item, topic, num: int=0, years=""): # --- q = item["q"] # --- @@ -83,7 +83,7 @@ def work_people2(item, topic, num=0, years=""): work_api_desc(NewDesc, q, fixlang=[]) -def work_people(item, topic, num, ardes): +def work_people(item, topic, num: int, ardes): q = item["q"] # --- topic = topic.lower().strip() or get_topic(item).lower() diff --git a/src/neq/nldes3.py b/src/neq/nldes3.py index a8e4769..8184379 100644 --- a/src/neq/nldes3.py +++ b/src/neq/nldes3.py @@ -55,7 +55,7 @@ logger.info(f'sparqler[1] = "{sparqler[1]}"') -def just_get_ar(label): +def just_get_ar(label: str): parts = label.split("@@") arabic_parts = [part for part in parts if part.lower() == re.sub(r"[a-z@]", "", part.lower()) and part] @@ -89,7 +89,7 @@ def get_sparql_queries(): return quaries -def process_item(wd, n, total_reads): +def process_item(wd, n, total_reads) -> None: q = wd["item"].split("/entity/")[1] # --- logger.info(f"p{n}/{total_reads} q:{q}") @@ -99,7 +99,7 @@ def process_item(wd, n, total_reads): action_one_item("ar", q, claimstr=claim_str) -def main(): +def main() -> None: sparql_queries = get_sparql_queries() # --- random.shuffle(sparql_queries) diff --git a/src/people/new3.py b/src/people/new3.py index 767b0fb..ffb6796 100644 --- a/src/people/new3.py +++ b/src/people/new3.py @@ -192,7 +192,7 @@ def check_quarry_new(tab): translations_for_nat = {1: {}} -def make_Tabs(tabs): +def make_Tabs(tabs) -> None: # من هذا البوت # TraOc = translationsOccupations TraNat = tabs["Nationalities"] @@ -297,7 +297,7 @@ def make_Tabs(tabs): q_dones = [] -def start_one_nat(nat_tab): +def start_one_nat(nat_tab) -> None: # --- check = check_quarry_new(nat_tab) # --- @@ -337,7 +337,7 @@ def start_one_nat(nat_tab): work_api_desc(NewDesc, q) -def mainnat(Tabs): # translations_for_nat +def mainnat(Tabs) -> None: # translations_for_nat # --- # python pwb.py people/new3 mainnat -nat:American # @@ -371,7 +371,7 @@ def mainnat(Tabs): # translations_for_nat logger.info("انتهت بنجاح") -def Main_Test(): +def Main_Test() -> None: qua = ( "SELECT ?item WHERE { ?item wdt:P31 wd:Q5 . ?item wdt:P21 wd:Q6581097" + ' . ?item schema:description "Argentinian actor"@en. ' diff --git a/src/people/people_get_topic.py b/src/people/people_get_topic.py index 6a8dce6..a38c9c7 100644 --- a/src/people/people_get_topic.py +++ b/src/people/people_get_topic.py @@ -448,7 +448,7 @@ def get_topic(item): return "" -def print_new_jobs(): +def print_new_jobs() -> None: lists = [[y, x] for x, y in new_jobs.items()] lists.sort(reverse=True) # --- diff --git a/src/prop_labs/chutes.py b/src/prop_labs/chutes.py index f6b6357..a9ccafa 100644 --- a/src/prop_labs/chutes.py +++ b/src/prop_labs/chutes.py @@ -10,7 +10,7 @@ api_token = f.read().strip() -async def invoke_chute(): +async def invoke_chute() -> None: headers = { "Authorization": "Bearer " + api_token, @@ -41,7 +41,7 @@ async def invoke_chute(): print(f"Error parsing chunk: {e}") -async def invoke_chute2(): +async def invoke_chute2() -> None: headers = { "Authorization": "Bearer " + api_token, diff --git a/src/prop_labs/fill_ar_props.py b/src/prop_labs/fill_ar_props.py index 682e66c..a661459 100644 --- a/src/prop_labs/fill_ar_props.py +++ b/src/prop_labs/fill_ar_props.py @@ -138,13 +138,13 @@ def fetch_props_missing_ar(limit: int, offset: int = 0) -> List[dict]: already_translated[pid_data["description"]["en"]] = pid_data["description"]["ar"] -def translate_en_to_ar_wrap(text): +def translate_en_to_ar_wrap(text: str): if already_translated.get(text): return already_translated[text] return translate_en_to_ar(text) -def dump_all(): +def dump_all() -> None: logger.info("<> dump_all():") with cache_file.open("w", encoding="utf-8") as f: @@ -287,7 +287,7 @@ def start(args): print(f"[*] finished. labels added: {done_labels}, descriptions added: {done_descs}") -def main(): +def main() -> None: ap = argparse.ArgumentParser(description="Fill Arabic labels/descriptions for Wikidata properties.") ap.add_argument("--limit", type=int, default=200, help="عدد الخصائص المطلوب جلبها من WDQS") ap.add_argument("--offset", type=int, default=0, help="إزاحة في نتائج WDQS") diff --git a/src/prop_labs/gemini_bot.py b/src/prop_labs/gemini_bot.py index cfab318..32e1e02 100644 --- a/src/prop_labs/gemini_bot.py +++ b/src/prop_labs/gemini_bot.py @@ -76,7 +76,7 @@ contents = [] -def send_ai(text, sleep_time=3): +def send_ai(text: str, sleep_time: int=3): time_start = time.time() model = genai.GenerativeModel( @@ -131,7 +131,7 @@ def send_ai(text, sleep_time=3): return result -def start(): +def start() -> None: file = Dir / "old.txt" file2 = Dir / "new.txt" # --- diff --git a/src/prop_labs/openrouter.py b/src/prop_labs/openrouter.py index 12da735..17ecfc6 100644 --- a/src/prop_labs/openrouter.py +++ b/src/prop_labs/openrouter.py @@ -19,7 +19,7 @@ MODEL = "z-ai/glm-4.5-air:free" # يمكنك تغيير النموذج حسب الحاجة -def dump_all(cache_file, data): +def dump_all(cache_file, data) -> None: print("<> dump_all():") # حفظ ملف JSON المحدث @@ -29,7 +29,7 @@ def dump_all(cache_file, data): print(" Dump saved to: data_translated.json") -def translate_text(text): +def translate_text(text: str): """ترجمة النص من الإنجليزية إلى العربية باستخدام OpenRouter API""" headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"} diff --git a/src/prop_labs/translate_bot.py b/src/prop_labs/translate_bot.py index 5921f7a..a8458e2 100644 --- a/src/prop_labs/translate_bot.py +++ b/src/prop_labs/translate_bot.py @@ -21,7 +21,7 @@ cache_data[obj["en"]] = obj["ar"] -def save_cache(en, ar): +def save_cache(en, ar) -> None: with jsonlines.open(dump_file, mode="a") as writer: writer.write({"en": en, "ar": ar}) cache_data[en] = ar diff --git a/src/prop_labs/wd_Session.py b/src/prop_labs/wd_Session.py index 2382698..79e0da1 100644 --- a/src/prop_labs/wd_Session.py +++ b/src/prop_labs/wd_Session.py @@ -29,7 +29,7 @@ class WikidataSession: - def __init__(self, username: str, password: str): + def __init__(self, username: str, password: str) -> None: self.s = requests.session() self.s.headers.update(HEADERS_API) self.username = username diff --git a/src/wd_gent.py b/src/wd_gent.py index b2f9a59..f0787ee 100644 --- a/src/wd_gent.py +++ b/src/wd_gent.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) -def fetch_user_new_pages(limit="max", namespace="0", user=""): +def fetch_user_new_pages(limit: int="max", namespace="0", user=""): api = load_main_api("www", "wikidata") new_api = api.NewApi() generator = new_api.Get_Newpages(limit=limit, namespace=namespace, user=user) @@ -64,7 +64,7 @@ def fetch_new_pages(value): return generator -def get_gent(listonly=True, *args): +def get_gent(listonly: bool=True, *args): # --- options = {} # --- diff --git a/src/wd_utils/utils.py b/src/wd_utils/utils.py index 4a256f8..13f5353 100644 --- a/src/wd_utils/utils.py +++ b/src/wd_utils/utils.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) -def load_data_from_url(page_name="descraptions.json"): +def load_data_from_url(page_name: str="descraptions.json"): if not page_name.endswith(".json"): page_name = f"{page_name}.json" @@ -75,7 +75,7 @@ def open_file_json_check_time(file_path: Path): return data -def save_json_data(file_path, data): +def save_json_data(file_path, data) -> None: try: with open(file_path, "w", encoding="utf-8") as f: json.dump(data, f, ensure_ascii=False, indent=4) diff --git a/src1/lex-examples/gemini.py b/src1/lex-examples/gemini.py index bff45c8..d6a8222 100644 --- a/src1/lex-examples/gemini.py +++ b/src1/lex-examples/gemini.py @@ -48,7 +48,7 @@ ) -def search_in_quran_new(word): +def search_in_quran_new(word: str): results = words_to_add.get(word, []) return results @@ -128,7 +128,7 @@ def get_arabic_lexemes(): return lexemes -def start(): +def start() -> None: lexemes = get_arabic_lexemes() for lexeme_id in tqdm(lexemes): extracted = get_forms_from_lexeme(lexeme_id) @@ -137,7 +137,7 @@ def start(): json.dump(extracted, f, ensure_ascii=False, indent=2) -def test(): +def test() -> None: lexeme_id = "L1478647" extracted = get_forms_from_lexeme(lexeme_id) diff --git a/src1/lex-examples/gemini_new.py b/src1/lex-examples/gemini_new.py index 129f0ad..c136c90 100644 --- a/src1/lex-examples/gemini_new.py +++ b/src1/lex-examples/gemini_new.py @@ -46,7 +46,7 @@ ) -def search_in_quran_new(word): +def search_in_quran_new(word: str): results = words_to_add.get(word, []) return results @@ -155,7 +155,7 @@ def get_arabic_lexemes_new(): time_parts = time.time() -def print_status(): +def print_status() -> None: global time_parts # --- in_time = time.time() - time_parts diff --git a/src1/lex-examples/gemini_new2.py b/src1/lex-examples/gemini_new2.py index 8fe055e..174492a 100644 --- a/src1/lex-examples/gemini_new2.py +++ b/src1/lex-examples/gemini_new2.py @@ -41,7 +41,7 @@ ) -def search_in_quran_new(word): +def search_in_quran_new(word: str): results = words_to_add.get(word, []) return results @@ -100,7 +100,7 @@ def get_results(query): return result -def get_arabic_lexemes_new(limit, offset): +def get_arabic_lexemes_new(limit: int, offset: int): # --- sparql_query = """ SELECT ?item ?category (CONCAT( @@ -134,7 +134,7 @@ def get_arabic_lexemes_new(limit, offset): return result -def start(): +def start() -> None: # --- limit = 50 offset = 0 diff --git a/tests/conftest.py b/tests/conftest.py index 7f303e7..d9aaf16 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,5 +11,5 @@ @pytest.fixture(autouse=True) -def stop_nets(): +def stop_nets() -> None: disable_socket(allow_unix_socket=True) diff --git a/tests/desc_dicts/test_utils.py b/tests/desc_dicts/test_utils.py index 2b9864f..7167e32 100644 --- a/tests/desc_dicts/test_utils.py +++ b/tests/desc_dicts/test_utils.py @@ -11,21 +11,21 @@ ) -def test_load_data_from_url(): +def test_load_data_from_url() -> None: """ no need to test requests """ class TestCheckDate: - def test_check_date(self): + def test_check_date(self) -> None: # Test with a valid date string today = "2023-01-01" assert are_dates_same(today, "2023-01-01") is True class TestGetFileDate: - def test_get_file_date_existing_file(self, tmp_path): + def test_get_file_date_existing_file(self, tmp_path) -> None: """Test get_file_date with an existing file.""" test_file = tmp_path / "test.json" test_file.write_text('{"key": "value"}') @@ -39,7 +39,7 @@ def test_get_file_date_existing_file(self, tmp_path): # Verify it's a reasonable year assert int(result[:4]) >= 2020 - def test_get_file_date_nonexistent_file(self, tmp_path): + def test_get_file_date_nonexistent_file(self, tmp_path) -> None: """Test get_file_date with a non-existent file.""" nonexistent_file = tmp_path / "nonexistent.json" @@ -47,7 +47,7 @@ def test_get_file_date_nonexistent_file(self, tmp_path): assert result == "" - def test_get_file_date_directory(self, tmp_path): + def test_get_file_date_directory(self, tmp_path) -> None: """Test get_file_date with a directory (edge case).""" test_dir = tmp_path / "test_dir" test_dir.mkdir() @@ -59,7 +59,7 @@ def test_get_file_date_directory(self, tmp_path): class TestOpenFileJson: - def test_open_file_json_existing_valid_file(self, tmp_path): + def test_open_file_json_existing_valid_file(self, tmp_path) -> None: """Test open_file_json with an existing valid JSON file.""" test_file = tmp_path / "test.json" expected_data = {"key": "value", "number": 42} @@ -69,7 +69,7 @@ def test_open_file_json_existing_valid_file(self, tmp_path): assert result == expected_data - def test_open_file_json_nonexistent_file(self, tmp_path): + def test_open_file_json_nonexistent_file(self, tmp_path) -> None: """Test open_file_json with a non-existent file.""" nonexistent_file = tmp_path / "nonexistent.json" @@ -77,7 +77,7 @@ def test_open_file_json_nonexistent_file(self, tmp_path): assert result == {} - def test_open_file_json_invalid_json(self, tmp_path): + def test_open_file_json_invalid_json(self, tmp_path) -> None: """Test open_file_json with an invalid JSON file.""" test_file = tmp_path / "invalid.json" test_file.write_text("not valid json {") @@ -86,7 +86,7 @@ def test_open_file_json_invalid_json(self, tmp_path): assert result == {} - def test_open_file_json_empty_file(self, tmp_path): + def test_open_file_json_empty_file(self, tmp_path) -> None: """Test open_file_json with an empty file.""" test_file = tmp_path / "empty.json" test_file.write_text("") @@ -95,7 +95,7 @@ def test_open_file_json_empty_file(self, tmp_path): assert result == {} - def test_open_file_json_empty_json_object(self, tmp_path): + def test_open_file_json_empty_json_object(self, tmp_path) -> None: """Test open_file_json with an empty JSON object.""" test_file = tmp_path / "empty_obj.json" test_file.write_text("{}") @@ -104,7 +104,7 @@ def test_open_file_json_empty_json_object(self, tmp_path): assert result == {} - def test_open_file_json_array(self, tmp_path): + def test_open_file_json_array(self, tmp_path) -> None: """Test open_file_json with a JSON array.""" test_file = tmp_path / "array.json" expected_data = [1, 2, 3] @@ -116,7 +116,7 @@ def test_open_file_json_array(self, tmp_path): class TestOpenFileJsonCheckTime: - def test_open_file_json_check_time_same_day(self, tmp_path): + def test_open_file_json_check_time_same_day(self, tmp_path) -> None: """Test open_file_json_check_time when file was modified today.""" import time @@ -132,7 +132,7 @@ def test_open_file_json_check_time_same_day(self, tmp_path): assert result == expected_data - def test_open_file_json_check_time_nonexistent_file(self, tmp_path): + def test_open_file_json_check_time_nonexistent_file(self, tmp_path) -> None: """Test open_file_json_check_time with a non-existent file.""" nonexistent_file = tmp_path / "nonexistent.json" @@ -140,7 +140,7 @@ def test_open_file_json_check_time_nonexistent_file(self, tmp_path): assert result == {} - def test_open_file_json_check_time_old_file(self, tmp_path, mocker): + def test_open_file_json_check_time_old_file(self, tmp_path, mocker) -> None: """Test open_file_json_check_time when file has an old modification date.""" test_file = tmp_path / "old.json" test_file.write_text(json.dumps({"key": "value"})) @@ -154,7 +154,7 @@ def test_open_file_json_check_time_old_file(self, tmp_path, mocker): # Should return empty dict because file date doesn't match today assert result == {} - def test_open_file_json_check_time_invalid_json(self, tmp_path): + def test_open_file_json_check_time_invalid_json(self, tmp_path) -> None: """Test open_file_json_check_time with invalid JSON content.""" import time From 258f31b3289d6617335bc4991d61c3bff0cc05f7 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Fri, 12 Jun 2026 04:51:17 +0300 Subject: [PATCH 02/11] . --- src/WDYe/catwithoutp31.py | 2 +- src/bots_subs/hi_api/__init__.py | 2 +- src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py | 2 +- src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py | 4 ++-- src/bots_subs/hi_api/req_bots_new/claims_wd.py | 4 ++-- src/bots_subs/hi_api/req_bots_new/descriptions_wd.py | 4 ++-- src/bots_subs/hi_api/req_bots_new/labels_wd.py | 4 ++-- src/bots_subs/hi_api/utils/out_json.py | 2 +- src/bots_subs/qs_bot.py | 2 +- src/bots_subs/wd_api/wd_bot.py | 6 +++--- src/bots_subs/wd_api/wd_desc.py | 2 +- src/bots_subs/wd_api/wd_sparql_bot.py | 2 +- src/bots_subs/wiki_sql.py | 6 +++--- src/cy/cy_bot/do_text.py | 2 +- src/des/na.py | 2 +- src/des/railway.py | 2 +- src/nep/bots/its.py | 8 ++++---- src/nep/nldesc.py | 2 +- src/nep/space_others.py | 4 ++-- src/nep/wr_people.py | 2 +- src/neq/quarries.py | 2 +- src/wd_gent.py | 2 +- 22 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/WDYe/catwithoutp31.py b/src/WDYe/catwithoutp31.py index 8838c05..13e0eac 100644 --- a/src/WDYe/catwithoutp31.py +++ b/src/WDYe/catwithoutp31.py @@ -47,7 +47,7 @@ } -def Get_Sitelinks_From_wikidata(site, title, ssite="", ids="", props="", add_props=None, return_main_table: bool=False): +def Get_Sitelinks_From_wikidata(site, title, ssite: str="", ids: str="", props: str="", add_props=None, return_main_table: bool=False): # --- sitewiki = site if site.find("wiki") == -1: diff --git a/src/bots_subs/hi_api/__init__.py b/src/bots_subs/hi_api/__init__.py index f0b2fc0..a4b1e11 100644 --- a/src/bots_subs/hi_api/__init__.py +++ b/src/bots_subs/hi_api/__init__.py @@ -8,7 +8,7 @@ class HimoAPIBot: - def __init__(self, mr_or_bot="bot", www="www") -> None: + def __init__(self, mr_or_bot: str="bot", www: str="www") -> None: # --- self.login_bot: WikiLoginClient = log_in_wikidata(mr_or_bot=mr_or_bot, www=www) # --- diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py b/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py index b656e1e..76d3184 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py @@ -31,7 +31,7 @@ def _load_credentials(mr_or_bot) -> dict[str, str]: return User_tables_bot if mr_or_bot == "bot" else User_tables_ibrahem -def log_in_wikidata(mr_or_bot="bot", www="www") -> WikiLoginClient: +def log_in_wikidata(mr_or_bot: str="bot", www: str="www") -> WikiLoginClient: # --- users_data = _load_credentials(mr_or_bot) # --- diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py index 68db03f..79b6e78 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py @@ -13,7 +13,7 @@ class WdAPI(WdErrorsHandler): - def __init__(self, login_bot, mr_or_bot="bot") -> None: + def __init__(self, login_bot, mr_or_bot: str="bot") -> None: # --- self.login_bot: WikiLoginClient = login_bot # --- @@ -26,7 +26,7 @@ def __init__(self, login_bot, mr_or_bot="bot") -> None: # --- logger.info(f"<> WdAPI: {mr_or_bot}, {self.usernamex=} \n") - def post_to_newapi(self, params={}, data={}, tage="", editgroups="", max_retry: int=0, **kwargs): + def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", max_retry: int=0, **kwargs): # --- if not params and data: params = data diff --git a/src/bots_subs/hi_api/req_bots_new/claims_wd.py b/src/bots_subs/hi_api/req_bots_new/claims_wd.py index aef85fc..ed314b5 100644 --- a/src/bots_subs/hi_api/req_bots_new/claims_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/claims_wd.py @@ -21,7 +21,7 @@ def __init__(self, wdapi_new) -> None: self.session_post = self.wdapi_new.post_to_newapi # pass - def add_quall(self, Claimid, quall_prop, valueline, hashx="", nowait: bool=False): + def add_quall(self, Claimid, quall_prop, valueline, hashx: str="", nowait: bool=False): """Add a qualifier to a claim. This function adds a specified qualifier to a given claim identified by @@ -233,7 +233,7 @@ def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool=False): if qualifiers != []: self._Set_Quall2(r4, qualifiers) - def Claim_API_time(self, q, proprty, precision: int=9, year="", strtime="", nowait: bool=False): + def Claim_API_time(self, q, proprty, precision: int=9, year: str="", strtime: str="", nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py index d08e570..1728b5d 100644 --- a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py @@ -36,7 +36,7 @@ def __init__(self, wdapi_new) -> None: self.session_post = self.wdapi_new.post_to_newapi # pass - def Des_API(self, Qid, desc: str, lang, ask="", rea: bool=True, nowait: bool=False): + def Des_API(self, Qid, desc: str, lang, ask: str="", rea: bool=True, nowait: bool=False): """Set the description for a given item in a specified language. This function updates the description of an item identified by its Qid @@ -147,7 +147,7 @@ def New_Mult_Des_2( ask: bool=False, rea: bool=True, nowait: bool=False, - tage="", + tage: str="", return_result: bool=False, ): # --- diff --git a/src/bots_subs/hi_api/req_bots_new/labels_wd.py b/src/bots_subs/hi_api/req_bots_new/labels_wd.py index 089140f..30dd160 100644 --- a/src/bots_subs/hi_api/req_bots_new/labels_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/labels_wd.py @@ -81,7 +81,7 @@ def Labels_API( change_des: bool=False, number: int=0, nowait: bool=False, - tage="", + tage: str="", remove: bool=False, ): # --- @@ -130,7 +130,7 @@ def Labels_API( if d == "warn": logger.exception("Exception:", exc_info=True) - def Add_Labels_if_not_there(self, Qid, label: str, lang, ask="", Or_Alii: bool=False, nowait: bool=False): + def Add_Labels_if_not_there(self, Qid, label: str, lang, ask: str="", Or_Alii: bool=False, nowait: bool=False): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/utils/out_json.py b/src/bots_subs/hi_api/utils/out_json.py index 7716323..ab91c29 100644 --- a/src/bots_subs/hi_api/utils/out_json.py +++ b/src/bots_subs/hi_api/utils/out_json.py @@ -188,7 +188,7 @@ def outbot_json_bot(err): return err_code -def outbot_json(js_text, fi="", line="", timesleeps: int=0, NoWait: bool=False): +def outbot_json(js_text, fi: str="", line: str="", timesleeps: int=0, NoWait: bool=False): # --- success = js_text.get("success", 0) # --- diff --git a/src/bots_subs/qs_bot.py b/src/bots_subs/qs_bot.py index fc94fa5..9ba6b9a 100644 --- a/src/bots_subs/qs_bot.py +++ b/src/bots_subs/qs_bot.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) -def QS_line(line, user="Mr. Ibrahem") -> bool: +def QS_line(line, user: str="Mr. Ibrahem") -> bool: # --- # https://quickstatements.toolforge.org/api.php?format=v1&action=import&compress=1&submit=1&batchname=df&username=Mr.Ibrahembot&token=$2&data=Q24173161|Dar|"جين في متفطرة خراجية" # --- diff --git a/src/bots_subs/wd_api/wd_bot.py b/src/bots_subs/wd_api/wd_bot.py index 301d36e..a17ed21 100644 --- a/src/bots_subs/wd_api/wd_bot.py +++ b/src/bots_subs/wd_api/wd_bot.py @@ -50,7 +50,7 @@ def Get_infos_wikidata(params): return table -def Get_item_descriptions_or_labels(q, ty="descriptions or labels"): +def Get_item_descriptions_or_labels(q, ty: str="descriptions or labels"): """Retrieve item descriptions or labels from a given entity ID. This function queries an API to obtain either descriptions or labels for @@ -104,7 +104,7 @@ def Get_item_descriptions_or_labels(q, ty="descriptions or labels"): return table -def Get_Item_API_From_Qid(q, sites="", titles="", props=""): +def Get_Item_API_From_Qid(q, sites: str="", titles: str="", props: str=""): # "sites": "arwiki", # "titles": "ويكيبيديا:مشروع_ويكي_بيانات", # url = 'wikidata.org/w/api.php?action=wbgetentities&ids=' + q + '&format=json' @@ -160,7 +160,7 @@ def Get_Item_API_From_Qid(q, sites="", titles="", props=""): return table -def Get_Property_API(q="", p="", titles="", sites=""): +def Get_Property_API(q: str="", p: str="", titles: str="", sites: str=""): # url = 'https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=' + q + '&property=' + p + '&format=json' # json1 = tools.loads_json( html) # --- diff --git a/src/bots_subs/wd_api/wd_desc.py b/src/bots_subs/wd_api/wd_desc.py index d6f6a98..5ddf2ed 100644 --- a/src/bots_subs/wd_api/wd_desc.py +++ b/src/bots_subs/wd_api/wd_desc.py @@ -47,7 +47,7 @@ def del_keys(d): return d -def wwdesc(newdesc, qid, i, fixlang, ask="", tage=""): +def wwdesc(newdesc, qid, i, fixlang, ask: str="", tage: str=""): """Process and update descriptions for a given query ID. This function takes a dictionary of new descriptions and processes it to diff --git a/src/bots_subs/wd_api/wd_sparql_bot.py b/src/bots_subs/wd_api/wd_sparql_bot.py index bd03915..79e2918 100644 --- a/src/bots_subs/wd_api/wd_sparql_bot.py +++ b/src/bots_subs/wd_api/wd_sparql_bot.py @@ -109,7 +109,7 @@ def sparql_generator_url( quary, printq: bool=False, add_date: bool=True, - key="", + key: str="", geterror: bool=False, returndict: bool=False, returnq: bool=False, diff --git a/src/bots_subs/wiki_sql.py b/src/bots_subs/wiki_sql.py index 392cad3..195ecf4 100644 --- a/src/bots_subs/wiki_sql.py +++ b/src/bots_subs/wiki_sql.py @@ -134,7 +134,7 @@ def make_labsdb_dbs_p(wiki): def sql_connect_pymysql( query, - db="", + db: str="", host: str="", update: bool=False, default_return=None, @@ -195,7 +195,7 @@ def sql_connect_pymysql( def make_sql_connect( query, - db="", + db: str="", host: str="", update: bool=False, default_return=None, @@ -230,7 +230,7 @@ def make_sql_connect( def sql_new( queries, - wiki="", + wiki: str="", values=None, ): # --- diff --git a/src/cy/cy_bot/do_text.py b/src/cy/cy_bot/do_text.py index a9e0626..92fb452 100644 --- a/src/cy/cy_bot/do_text.py +++ b/src/cy/cy_bot/do_text.py @@ -662,7 +662,7 @@ def make_new_text(item, title, text: str): return text -def do_One_Page(title, text: str, item=""): +def do_One_Page(title, text: str, item: str=""): # --- Check = CheckTempalteInPageText(text) # --- diff --git a/src/des/na.py b/src/des/na.py index 6e18f45..f9854b3 100644 --- a/src/des/na.py +++ b/src/des/na.py @@ -50,7 +50,7 @@ def action(json1) -> None: logger.info(f" <> * q in items_done. {q}") -def make_quarry(ar_suff="", item_p31_cat="", en_suff="", en_priff=""): +def make_quarry(ar_suff: str="", item_p31_cat: str="", en_suff: str="", en_priff: str=""): quaaa = """ #تسمية تصانيف مواليد في SELECT DISTINCT #?item ?label ?item_ar diff --git a/src/des/railway.py b/src/des/railway.py index c576985..38b9612 100644 --- a/src/des/railway.py +++ b/src/des/railway.py @@ -40,7 +40,7 @@ def Get_P_API_id(claims, P, onlyone: bool=False): return "" if onlyone else lista -def work_railway(wditem, p31, q=""): +def work_railway(wditem, p31, q: str=""): # --- if "railway" not in sys.argv: return diff --git a/src/nep/bots/its.py b/src/nep/bots/its.py index b49b429..5ada7ad 100644 --- a/src/nep/bots/its.py +++ b/src/nep/bots/its.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) -def its_a_generalthing(wditem, shortstr, longdescrstr, myclaim, claimstr=""): +def its_a_generalthing(wditem, shortstr, longdescrstr, myclaim, claimstr: str=""): # --- pp = wditem.get("claims", {}).get(myclaim, []) # --- @@ -168,7 +168,7 @@ def its_a_computergame(lng, wditem) -> str: return "" -def its_a_sports_season(wditem, claimstr=""): +def its_a_sports_season(wditem, claimstr: str=""): # --- # LNKsport=wditem.get('claims',{}).get('P3450')[0].get('mainsnak',{}).get('datavalue',{}).get('value',{}).get('id','')#.getTarget() # --- @@ -199,7 +199,7 @@ def its_a_sports_season(wditem, claimstr=""): return laste -def its_songs(type_of_item, wditem, shortstr, claimstr=""): +def its_songs(type_of_item, wditem, shortstr, claimstr: str=""): # my_description = its_a_generalthing( wditem , da , '%s من أداء ' % da ,'P175') myclaim = "P175" # --- @@ -253,7 +253,7 @@ def its_songs(type_of_item, wditem, shortstr, claimstr=""): return laste -def its_a_p50(type_of_item, wditem, shortstr, claimstr=""): +def its_a_p50(type_of_item, wditem, shortstr, claimstr: str=""): myclaim = "P50" # --- P136 = get_mainsnak(wditem.get("claims", {}).get("P136", [{}])[0]) diff --git a/src/nep/nldesc.py b/src/nep/nldesc.py index e2c1397..6134d04 100644 --- a/src/nep/nldesc.py +++ b/src/nep/nldesc.py @@ -137,7 +137,7 @@ def Add_desc(q, value, lang) -> None: WD_API_Bot.Des_API(q, value, lang, ask="") -def action_one_item(lngr, q, item={}, claimstr=""): +def action_one_item(lngr, q, item={}, claimstr: str=""): global items2do global totaledits # --- diff --git a/src/nep/space_others.py b/src/nep/space_others.py index cd70c78..8b79acb 100644 --- a/src/nep/space_others.py +++ b/src/nep/space_others.py @@ -31,7 +31,7 @@ logger = logging.getLogger(__name__) -def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr=""): +def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str=""): my_description = "" # --- if type_of_item == "Q2467461": @@ -125,7 +125,7 @@ def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr=""): return my_description -def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr=""): +def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr: str=""): my_description = "" # --- # logger.info( "Make others desc:P31:%s" % type_of_item ) diff --git a/src/nep/wr_people.py b/src/nep/wr_people.py index b73150e..aaa7079 100644 --- a/src/nep/wr_people.py +++ b/src/nep/wr_people.py @@ -36,7 +36,7 @@ def get_claim_id(item, prop): ) -def work_people2(item, topic, num: int=0, years=""): +def work_people2(item, topic, num: int=0, years: str=""): # --- q = item["q"] # --- diff --git a/src/neq/quarries.py b/src/neq/quarries.py index 4623034..489404e 100644 --- a/src/neq/quarries.py +++ b/src/neq/quarries.py @@ -37,7 +37,7 @@ """ -def do_qua(qid, prop="", ad="", ar_values=""): +def do_qua(qid, prop: str="", ad: str="", ar_values: str=""): qua = "SELECT ?item WHERE {\n" # --- if ar_values: diff --git a/src/wd_gent.py b/src/wd_gent.py index f0787ee..efd6fd1 100644 --- a/src/wd_gent.py +++ b/src/wd_gent.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) -def fetch_user_new_pages(limit: int="max", namespace="0", user=""): +def fetch_user_new_pages(limit: int="max", namespace: str="0", user: str=""): api = load_main_api("www", "wikidata") new_api = api.NewApi() generator = new_api.Get_Newpages(limit=limit, namespace=namespace, user=user) From d65b4773dd121bf1301d7bf37cbbf9c50dfd4711 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Fri, 12 Jun 2026 04:52:01 +0300 Subject: [PATCH 03/11] . --- src/WDYe/catwithoutp31.py | 4 +++- src/bots_subs/hi_api/__init__.py | 2 +- .../hi_api/h_wd_newapi/wd_login_wrap.py | 2 +- .../hi_api/h_wd_newapi/wd_newapi_bot.py | 20 ++++++++++--------- .../hi_api/req_bots_new/claims_wd.py | 10 +++++----- .../hi_api/req_bots_new/descriptions_wd.py | 14 ++++++------- .../hi_api/req_bots_new/labels_wd.py | 18 +++++++++-------- .../hi_api/utils/handle_wd_errors.py | 10 +++++----- src/bots_subs/hi_api/utils/out_json.py | 2 +- src/bots_subs/qs_bot.py | 2 +- src/bots_subs/wd_api/wd_bot.py | 8 ++++---- src/bots_subs/wd_api/wd_desc.py | 2 +- src/bots_subs/wd_api/wd_sparql_bot.py | 16 +++++++-------- src/bots_subs/wiki_sql.py | 18 ++++++++--------- src/cy/cy_bot/do_text.py | 2 +- src/cy/mv.py | 2 +- src/des/desc.py | 2 +- src/des/na.py | 2 +- src/des/railway.py | 4 ++-- src/des/ru_st_2_latin.py | 4 ++-- src/nep/bots/helps.py | 2 +- src/nep/bots/its.py | 8 ++++---- src/nep/bots/scientific_article.py | 2 +- src/nep/nldesc.py | 2 +- src/nep/si3.py | 2 +- src/nep/space_others.py | 4 ++-- src/nep/wr_people.py | 2 +- src/neq/quarries.py | 2 +- src/prop_labs/gemini_bot.py | 2 +- src/wd_gent.py | 4 ++-- src/wd_utils/utils.py | 2 +- 31 files changed, 91 insertions(+), 85 deletions(-) diff --git a/src/WDYe/catwithoutp31.py b/src/WDYe/catwithoutp31.py index 13e0eac..f37f010 100644 --- a/src/WDYe/catwithoutp31.py +++ b/src/WDYe/catwithoutp31.py @@ -47,7 +47,9 @@ } -def Get_Sitelinks_From_wikidata(site, title, ssite: str="", ids: str="", props: str="", add_props=None, return_main_table: bool=False): +def Get_Sitelinks_From_wikidata( + site, title, ssite: str = "", ids: str = "", props: str = "", add_props=None, return_main_table: bool = False +): # --- sitewiki = site if site.find("wiki") == -1: diff --git a/src/bots_subs/hi_api/__init__.py b/src/bots_subs/hi_api/__init__.py index a4b1e11..003dd97 100644 --- a/src/bots_subs/hi_api/__init__.py +++ b/src/bots_subs/hi_api/__init__.py @@ -8,7 +8,7 @@ class HimoAPIBot: - def __init__(self, mr_or_bot: str="bot", www: str="www") -> None: + def __init__(self, mr_or_bot: str = "bot", www: str = "www") -> None: # --- self.login_bot: WikiLoginClient = log_in_wikidata(mr_or_bot=mr_or_bot, www=www) # --- diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py b/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py index 76d3184..43fdee5 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_login_wrap.py @@ -31,7 +31,7 @@ def _load_credentials(mr_or_bot) -> dict[str, str]: return User_tables_bot if mr_or_bot == "bot" else User_tables_ibrahem -def log_in_wikidata(mr_or_bot: str="bot", www: str="www") -> WikiLoginClient: +def log_in_wikidata(mr_or_bot: str = "bot", www: str = "www") -> WikiLoginClient: # --- users_data = _load_credentials(mr_or_bot) # --- diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py index 79b6e78..440c343 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py @@ -13,7 +13,7 @@ class WdAPI(WdErrorsHandler): - def __init__(self, login_bot, mr_or_bot: str="bot") -> None: + def __init__(self, login_bot, mr_or_bot: str = "bot") -> None: # --- self.login_bot: WikiLoginClient = login_bot # --- @@ -26,7 +26,7 @@ def __init__(self, login_bot, mr_or_bot: str="bot") -> None: # --- logger.info(f"<> WdAPI: {mr_or_bot}, {self.usernamex=} \n") - def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", max_retry: int=0, **kwargs): + def post_to_newapi(self, params={}, data={}, tage: str = "", editgroups: str = "", max_retry: int = 0, **kwargs): # --- if not params and data: params = data @@ -35,7 +35,12 @@ def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", m # --- try: results = self.login_bot.client_request( - params, method="get", get_csrf=True, do_error=False, max_retry=max_retry,) + params, + method="get", + get_csrf=True, + do_error=False, + max_retry=max_retry, + ) except Exception as e: logger.error(f"<>post_to_newapi: <> {e}") results = {} @@ -49,8 +54,7 @@ def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", m if error_code == "maxlag" and max_retry < 4: self.lag_work(error) # --- - logger.info( - f"<>post_to_newapi: <> lag_work: {max_retry=}") + logger.info(f"<>post_to_newapi: <> lag_work: {max_retry=}") # --- return self.post_to_newapi(params=params, tage=tage, editgroups=editgroups, max_retry=max_retry + 1) # --- @@ -58,8 +62,7 @@ def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", m # --- er = self.handle_err_wd(error, function="", params=params) # --- - logger.info( - f"<>post_to_newapi: <> handle_err_wd: {er}") + logger.info(f"<>post_to_newapi: <> handle_err_wd: {er}") # return er # --- success = results.get("success", 0) @@ -69,8 +72,7 @@ def post_to_newapi(self, params={}, data={}, tage: str="", editgroups: str="", m # {"entity":{"sitelinks":{"arwiki":{}},"id":"Q97928551","type":"item","lastrevid":1242627521,"nochange":""},"success":1} # --- if lag_bot.newsleep[1] != 0: - logger.info( - f"<> ** true. sleep({lag_bot.newsleep[1]})") + logger.info(f"<> ** true. sleep({lag_bot.newsleep[1]})") time.sleep(lag_bot.newsleep[1]) else: logger.info("<> ** true.") diff --git a/src/bots_subs/hi_api/req_bots_new/claims_wd.py b/src/bots_subs/hi_api/req_bots_new/claims_wd.py index ed314b5..be1b113 100644 --- a/src/bots_subs/hi_api/req_bots_new/claims_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/claims_wd.py @@ -21,7 +21,7 @@ def __init__(self, wdapi_new) -> None: self.session_post = self.wdapi_new.post_to_newapi # pass - def add_quall(self, Claimid, quall_prop, valueline, hashx: str="", nowait: bool=False): + def add_quall(self, Claimid, quall_prop, valueline, hashx: str = "", nowait: bool = False): """Add a qualifier to a claim. This function adds a specified qualifier to a given claim identified by @@ -86,7 +86,7 @@ def add_quall(self, Claimid, quall_prop, valueline, hashx: str="", nowait: bool= # --- return d - def _Set_Quall(self, js, quall_prop, quall_id, nowait: bool=False): + def _Set_Quall(self, js, quall_prop, quall_id, nowait: bool = False): # --- if lag_bot.bad_lag(nowait): return "" @@ -131,7 +131,7 @@ def _Set_Quall(self, js, quall_prop, quall_id, nowait: bool=False): # --- return Claimid - def _Set_Quall2(self, js, qualifiers, nowait: bool=False) -> str: + def _Set_Quall2(self, js, qualifiers, nowait: bool = False) -> str: # --- if lag_bot.bad_lag(nowait): return "" @@ -186,7 +186,7 @@ def _Set_Quall2(self, js, qualifiers, nowait: bool=False) -> str: # --- self.add_quall(Claimid, quall_prop, valueline) - def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool=False): + def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool = False): # --- if lag_bot.bad_lag(nowait): return "" @@ -233,7 +233,7 @@ def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool=False): if qualifiers != []: self._Set_Quall2(r4, qualifiers) - def Claim_API_time(self, q, proprty, precision: int=9, year: str="", strtime: str="", nowait: bool=False): + def Claim_API_time(self, q, proprty, precision: int = 9, year: str = "", strtime: str = "", nowait: bool = False): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py index 1728b5d..c1caa2c 100644 --- a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py @@ -36,7 +36,7 @@ def __init__(self, wdapi_new) -> None: self.session_post = self.wdapi_new.post_to_newapi # pass - def Des_API(self, Qid, desc: str, lang, ask: str="", rea: bool=True, nowait: bool=False): + def Des_API(self, Qid, desc: str, lang, ask: str = "", rea: bool = True, nowait: bool = False): """Set the description for a given item in a specified language. This function updates the description of an item identified by its Qid @@ -109,7 +109,7 @@ def Des_API(self, Qid, desc: str, lang, ask: str="", rea: bool=True, nowait: boo qsline = f'{Qid}|D{lang}|"{desc}"' QS_line(qsline, user="Mr.Ibrahembot") - def New_Mult_Des(self, q, data2, summary, ret, nowait: bool=False): + def New_Mult_Des(self, q, data2, summary, ret, nowait: bool = False): # --- if lag_bot.bad_lag(nowait): return "" @@ -144,11 +144,11 @@ def New_Mult_Des_2( data2, summary, ret, - ask: bool=False, - rea: bool=True, - nowait: bool=False, - tage: str="", - return_result: bool=False, + ask: bool = False, + rea: bool = True, + nowait: bool = False, + tage: str = "", + return_result: bool = False, ): # --- if lag_bot.bad_lag(nowait): diff --git a/src/bots_subs/hi_api/req_bots_new/labels_wd.py b/src/bots_subs/hi_api/req_bots_new/labels_wd.py index 30dd160..9c1c13c 100644 --- a/src/bots_subs/hi_api/req_bots_new/labels_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/labels_wd.py @@ -36,7 +36,7 @@ def __init__(self, wdapi_new, Des_API) -> None: self.Des_API_funcs = Des_API # pass - def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait: bool=False): + def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait: bool = False): # --- if lag_bot.bad_lag(nowait): return "" @@ -77,12 +77,12 @@ def Labels_API( label: str, lang, ret, - Or_Alii: bool=False, - change_des: bool=False, - number: int=0, - nowait: bool=False, - tage: str="", - remove: bool=False, + Or_Alii: bool = False, + change_des: bool = False, + number: int = 0, + nowait: bool = False, + tage: str = "", + remove: bool = False, ): # --- if lag_bot.bad_lag(nowait): @@ -130,7 +130,9 @@ def Labels_API( if d == "warn": logger.exception("Exception:", exc_info=True) - def Add_Labels_if_not_there(self, Qid, label: str, lang, ask: str="", Or_Alii: bool=False, nowait: bool=False): + def Add_Labels_if_not_there( + self, Qid, label: str, lang, ask: str = "", Or_Alii: bool = False, nowait: bool = False + ): # --- if lag_bot.bad_lag(nowait): return "" diff --git a/src/bots_subs/hi_api/utils/handle_wd_errors.py b/src/bots_subs/hi_api/utils/handle_wd_errors.py index 8d069d6..5b33336 100644 --- a/src/bots_subs/hi_api/utils/handle_wd_errors.py +++ b/src/bots_subs/hi_api/utils/handle_wd_errors.py @@ -11,11 +11,11 @@ def __init__(self) -> None: logger.info("class WdErrorsHandler:") def handle_err_wd( - self, - error: dict, - function: str = "", - params: dict | None = None, - ): + self, + error: dict, + function: str = "", + params: dict | None = None, + ): """Handle errors related to the specified function. This method processes an error dictionary returned from an API call, diff --git a/src/bots_subs/hi_api/utils/out_json.py b/src/bots_subs/hi_api/utils/out_json.py index ab91c29..1475ec6 100644 --- a/src/bots_subs/hi_api/utils/out_json.py +++ b/src/bots_subs/hi_api/utils/out_json.py @@ -188,7 +188,7 @@ def outbot_json_bot(err): return err_code -def outbot_json(js_text, fi: str="", line: str="", timesleeps: int=0, NoWait: bool=False): +def outbot_json(js_text, fi: str = "", line: str = "", timesleeps: int = 0, NoWait: bool = False): # --- success = js_text.get("success", 0) # --- diff --git a/src/bots_subs/qs_bot.py b/src/bots_subs/qs_bot.py index 9ba6b9a..2fd212c 100644 --- a/src/bots_subs/qs_bot.py +++ b/src/bots_subs/qs_bot.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) -def QS_line(line, user: str="Mr. Ibrahem") -> bool: +def QS_line(line, user: str = "Mr. Ibrahem") -> bool: # --- # https://quickstatements.toolforge.org/api.php?format=v1&action=import&compress=1&submit=1&batchname=df&username=Mr.Ibrahembot&token=$2&data=Q24173161|Dar|"جين في متفطرة خراجية" # --- diff --git a/src/bots_subs/wd_api/wd_bot.py b/src/bots_subs/wd_api/wd_bot.py index a17ed21..116f90f 100644 --- a/src/bots_subs/wd_api/wd_bot.py +++ b/src/bots_subs/wd_api/wd_bot.py @@ -1,9 +1,9 @@ """ """ import logging +from typing import Sequence from .submit_bot import submitAPI -from typing import Sequence logger = logging.getLogger(__name__) @@ -50,7 +50,7 @@ def Get_infos_wikidata(params): return table -def Get_item_descriptions_or_labels(q, ty: str="descriptions or labels"): +def Get_item_descriptions_or_labels(q, ty: str = "descriptions or labels"): """Retrieve item descriptions or labels from a given entity ID. This function queries an API to obtain either descriptions or labels for @@ -104,7 +104,7 @@ def Get_item_descriptions_or_labels(q, ty: str="descriptions or labels"): return table -def Get_Item_API_From_Qid(q, sites: str="", titles: str="", props: str=""): +def Get_Item_API_From_Qid(q, sites: str = "", titles: str = "", props: str = ""): # "sites": "arwiki", # "titles": "ويكيبيديا:مشروع_ويكي_بيانات", # url = 'wikidata.org/w/api.php?action=wbgetentities&ids=' + q + '&format=json' @@ -160,7 +160,7 @@ def Get_Item_API_From_Qid(q, sites: str="", titles: str="", props: str=""): return table -def Get_Property_API(q: str="", p: str="", titles: str="", sites: str=""): +def Get_Property_API(q: str = "", p: str = "", titles: str = "", sites: str = ""): # url = 'https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=' + q + '&property=' + p + '&format=json' # json1 = tools.loads_json( html) # --- diff --git a/src/bots_subs/wd_api/wd_desc.py b/src/bots_subs/wd_api/wd_desc.py index 5ddf2ed..70d48e1 100644 --- a/src/bots_subs/wd_api/wd_desc.py +++ b/src/bots_subs/wd_api/wd_desc.py @@ -47,7 +47,7 @@ def del_keys(d): return d -def wwdesc(newdesc, qid, i, fixlang, ask: str="", tage: str=""): +def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): """Process and update descriptions for a given query ID. This function takes a dictionary of new descriptions and processes it to diff --git a/src/bots_subs/wd_api/wd_sparql_bot.py b/src/bots_subs/wd_api/wd_sparql_bot.py index 79e2918..f2cc03c 100644 --- a/src/bots_subs/wd_api/wd_sparql_bot.py +++ b/src/bots_subs/wd_api/wd_sparql_bot.py @@ -52,7 +52,7 @@ def get_query_data(query): return data -def wd_sparql_generator_url(quary, returnq: bool=False): +def wd_sparql_generator_url(quary, returnq: bool = False): """Generate a list of unique item identifiers from a SPARQL query. This function takes a SPARQL query as input, executes it to retrieve @@ -107,12 +107,12 @@ def wd_sparql_generator_url(quary, returnq: bool=False): def sparql_generator_url( quary, - printq: bool=False, - add_date: bool=True, - key: str="", - geterror: bool=False, - returndict: bool=False, - returnq: bool=False, + printq: bool = False, + add_date: bool = True, + key: str = "", + geterror: bool = False, + returndict: bool = False, + returnq: bool = False, ): # --- if add_date: @@ -174,7 +174,7 @@ def sparql_generator_url( return qlist -def sparql_generator_big_results(spq, offset: int=0, limit: int=5000, alllimit: int=0): +def sparql_generator_big_results(spq, offset: int = 0, limit: int = 5000, alllimit: int = 0): """Generate a list of results from a SPARQL query with pagination support. This function executes a SPARQL query and retrieves results in batches, diff --git a/src/bots_subs/wiki_sql.py b/src/bots_subs/wiki_sql.py index 195ecf4..862683d 100644 --- a/src/bots_subs/wiki_sql.py +++ b/src/bots_subs/wiki_sql.py @@ -134,11 +134,11 @@ def make_labsdb_dbs_p(wiki): def sql_connect_pymysql( query, - db: str="", - host: str="", - update: bool=False, + db: str = "", + host: str = "", + update: bool = False, default_return=None, - return_dict: bool=False, + return_dict: bool = False, values=None, ): # --- @@ -195,11 +195,11 @@ def sql_connect_pymysql( def make_sql_connect( query, - db: str="", - host: str="", - update: bool=False, + db: str = "", + host: str = "", + update: bool = False, default_return=None, - return_dict: bool=False, + return_dict: bool = False, values=None, ): # --- @@ -230,7 +230,7 @@ def make_sql_connect( def sql_new( queries, - wiki: str="", + wiki: str = "", values=None, ): # --- diff --git a/src/cy/cy_bot/do_text.py b/src/cy/cy_bot/do_text.py index 92fb452..60a264a 100644 --- a/src/cy/cy_bot/do_text.py +++ b/src/cy/cy_bot/do_text.py @@ -662,7 +662,7 @@ def make_new_text(item, title, text: str): return text -def do_One_Page(title, text: str, item: str=""): +def do_One_Page(title, text: str, item: str = ""): # --- Check = CheckTempalteInPageText(text) # --- diff --git a/src/cy/mv.py b/src/cy/mv.py index 27eaee0..9975b1a 100644 --- a/src/cy/mv.py +++ b/src/cy/mv.py @@ -157,7 +157,7 @@ def onep(title) -> None: page.save(newtext=new_text, summary="بوت:تجربة تحديث بيانات اللاعب") -def split_pages(pages, parts: int=4): +def split_pages(pages, parts: int = 4): length = len(pages) part_size = length // parts remaining = length % parts diff --git a/src/des/desc.py b/src/des/desc.py index 5347a51..46d2530 100644 --- a/src/des/desc.py +++ b/src/des/desc.py @@ -210,7 +210,7 @@ def Add_desc(q, value, lang) -> str: WD_API_Bot.Des_API(q, value, lang, ask="") -def work_one_item(start, lang, tab, c, total: int, findlab: bool=False) -> str: +def work_one_item(start, lang, tab, c, total: int, findlab: bool = False) -> str: # --- """work_one_item used in np/si3.py""" # --- diff --git a/src/des/na.py b/src/des/na.py index f9854b3..484d9a1 100644 --- a/src/des/na.py +++ b/src/des/na.py @@ -50,7 +50,7 @@ def action(json1) -> None: logger.info(f" <> * q in items_done. {q}") -def make_quarry(ar_suff: str="", item_p31_cat: str="", en_suff: str="", en_priff: str=""): +def make_quarry(ar_suff: str = "", item_p31_cat: str = "", en_suff: str = "", en_priff: str = ""): quaaa = """ #تسمية تصانيف مواليد في SELECT DISTINCT #?item ?label ?item_ar diff --git a/src/des/railway.py b/src/des/railway.py index 38b9612..6c65675 100644 --- a/src/des/railway.py +++ b/src/des/railway.py @@ -26,7 +26,7 @@ } -def Get_P_API_id(claims, P, onlyone: bool=False): +def Get_P_API_id(claims, P, onlyone: bool = False): # --- lista = [] # --- @@ -40,7 +40,7 @@ def Get_P_API_id(claims, P, onlyone: bool=False): return "" if onlyone else lista -def work_railway(wditem, p31, q: str=""): +def work_railway(wditem, p31, q: str = ""): # --- if "railway" not in sys.argv: return diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index 373aa47..009ffae 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -8,11 +8,11 @@ """ import sys +from typing import Sequence import pywikibot from bots_subs.hi_api import HimoAPIBot from pywikibot.pagegenerators import WikidataSPARQLPageGenerator -from typing import Sequence WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") @@ -332,7 +332,7 @@ def change_one_lab(text: str, lang): return new_lab -def make_en_label(labels: Sequence[str], q, Add: bool=False): +def make_en_label(labels: Sequence[str], q, Add: bool = False): org_lab = "" new_lab = "" # --- diff --git a/src/nep/bots/helps.py b/src/nep/bots/helps.py index db9ed5b..7c816b7 100644 --- a/src/nep/bots/helps.py +++ b/src/nep/bots/helps.py @@ -132,7 +132,7 @@ def get_female_for_p17(contry_lab, tyy): return lab -def get_label_txt(lng, wdi, property, array: int=0, fallback: bool=False): +def get_label_txt(lng, wdi, property, array: int = 0, fallback: bool = False): if property in wdi.get("claims", {}): if len(wdi.get("claims", {}).get(property, "")) > array: lnkProperty = wdi.get("claims", {}).get(property)[array].getTarget() diff --git a/src/nep/bots/its.py b/src/nep/bots/its.py index 5ada7ad..9e8b017 100644 --- a/src/nep/bots/its.py +++ b/src/nep/bots/its.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) -def its_a_generalthing(wditem, shortstr, longdescrstr, myclaim, claimstr: str=""): +def its_a_generalthing(wditem, shortstr, longdescrstr, myclaim, claimstr: str = ""): # --- pp = wditem.get("claims", {}).get(myclaim, []) # --- @@ -168,7 +168,7 @@ def its_a_computergame(lng, wditem) -> str: return "" -def its_a_sports_season(wditem, claimstr: str=""): +def its_a_sports_season(wditem, claimstr: str = ""): # --- # LNKsport=wditem.get('claims',{}).get('P3450')[0].get('mainsnak',{}).get('datavalue',{}).get('value',{}).get('id','')#.getTarget() # --- @@ -199,7 +199,7 @@ def its_a_sports_season(wditem, claimstr: str=""): return laste -def its_songs(type_of_item, wditem, shortstr, claimstr: str=""): +def its_songs(type_of_item, wditem, shortstr, claimstr: str = ""): # my_description = its_a_generalthing( wditem , da , '%s من أداء ' % da ,'P175') myclaim = "P175" # --- @@ -253,7 +253,7 @@ def its_songs(type_of_item, wditem, shortstr, claimstr: str=""): return laste -def its_a_p50(type_of_item, wditem, shortstr, claimstr: str=""): +def its_a_p50(type_of_item, wditem, shortstr, claimstr: str = ""): myclaim = "P50" # --- P136 = get_mainsnak(wditem.get("claims", {}).get("P136", [{}])[0]) diff --git a/src/nep/bots/scientific_article.py b/src/nep/bots/scientific_article.py index e6dca92..dcd4b4f 100644 --- a/src/nep/bots/scientific_article.py +++ b/src/nep/bots/scientific_article.py @@ -287,7 +287,7 @@ def make_scientific_desc(lang, date, precision): return desc -def make_scientific_article(item, p31, num: int, TestTable: bool=False): +def make_scientific_article(item, p31, num: int, TestTable: bool = False): # --- tablem = {"descriptions": {}, "qid": "", "fixlang": []} # --- diff --git a/src/nep/nldesc.py b/src/nep/nldesc.py index 6134d04..612b1cc 100644 --- a/src/nep/nldesc.py +++ b/src/nep/nldesc.py @@ -137,7 +137,7 @@ def Add_desc(q, value, lang) -> None: WD_API_Bot.Des_API(q, value, lang, ask="") -def action_one_item(lngr, q, item={}, claimstr: str=""): +def action_one_item(lngr, q, item={}, claimstr: str = ""): global items2do global totaledits # --- diff --git a/src/nep/si3.py b/src/nep/si3.py index 40c120e..1b6db7e 100644 --- a/src/nep/si3.py +++ b/src/nep/si3.py @@ -152,7 +152,7 @@ def work_qid_desc(item, topic, num: int) -> None: work_a_desc(NewDesc, q, []) -def ISRE(qitem, num: int, lenth, no_donelist: bool=True, P31_list: bool=False, get_nl_des: bool=True): +def ISRE(qitem, num: int, lenth, no_donelist: bool = True, P31_list: bool = False, get_nl_des: bool = True): # --- logger.info(f"--- *<> >{num}/{lenth}: q:{qitem}") # --- diff --git a/src/nep/space_others.py b/src/nep/space_others.py index 8b79acb..ff7a945 100644 --- a/src/nep/space_others.py +++ b/src/nep/space_others.py @@ -31,7 +31,7 @@ logger = logging.getLogger(__name__) -def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str=""): +def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): my_description = "" # --- if type_of_item == "Q2467461": @@ -125,7 +125,7 @@ def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str=""): return my_description -def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr: str=""): +def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): my_description = "" # --- # logger.info( "Make others desc:P31:%s" % type_of_item ) diff --git a/src/nep/wr_people.py b/src/nep/wr_people.py index aaa7079..f4ba07e 100644 --- a/src/nep/wr_people.py +++ b/src/nep/wr_people.py @@ -36,7 +36,7 @@ def get_claim_id(item, prop): ) -def work_people2(item, topic, num: int=0, years: str=""): +def work_people2(item, topic, num: int = 0, years: str = ""): # --- q = item["q"] # --- diff --git a/src/neq/quarries.py b/src/neq/quarries.py index 489404e..0e8eef6 100644 --- a/src/neq/quarries.py +++ b/src/neq/quarries.py @@ -37,7 +37,7 @@ """ -def do_qua(qid, prop: str="", ad: str="", ar_values: str=""): +def do_qua(qid, prop: str = "", ad: str = "", ar_values: str = ""): qua = "SELECT ?item WHERE {\n" # --- if ar_values: diff --git a/src/prop_labs/gemini_bot.py b/src/prop_labs/gemini_bot.py index 32e1e02..e5d24e1 100644 --- a/src/prop_labs/gemini_bot.py +++ b/src/prop_labs/gemini_bot.py @@ -76,7 +76,7 @@ contents = [] -def send_ai(text: str, sleep_time: int=3): +def send_ai(text: str, sleep_time: int = 3): time_start = time.time() model = genai.GenerativeModel( diff --git a/src/wd_gent.py b/src/wd_gent.py index efd6fd1..84bf5d8 100644 --- a/src/wd_gent.py +++ b/src/wd_gent.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) -def fetch_user_new_pages(limit: int="max", namespace: str="0", user: str=""): +def fetch_user_new_pages(limit: int = "max", namespace: str = "0", user: str = ""): api = load_main_api("www", "wikidata") new_api = api.NewApi() generator = new_api.Get_Newpages(limit=limit, namespace=namespace, user=user) @@ -64,7 +64,7 @@ def fetch_new_pages(value): return generator -def get_gent(listonly: bool=True, *args): +def get_gent(listonly: bool = True, *args): # --- options = {} # --- diff --git a/src/wd_utils/utils.py b/src/wd_utils/utils.py index 13f5353..ce457c1 100644 --- a/src/wd_utils/utils.py +++ b/src/wd_utils/utils.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) -def load_data_from_url(page_name: str="descraptions.json"): +def load_data_from_url(page_name: str = "descraptions.json"): if not page_name.endswith(".json"): page_name = f"{page_name}.json" From 180d7fce91819a137dff08135c0fc5e32d2a439f Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 02:32:09 +0300 Subject: [PATCH 04/11] . --- src/bots_subs/wd_api/wd_bot.py | 4 ++-- src/des/ru_st_2_latin.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bots_subs/wd_api/wd_bot.py b/src/bots_subs/wd_api/wd_bot.py index 116f90f..b5a86e9 100644 --- a/src/bots_subs/wd_api/wd_bot.py +++ b/src/bots_subs/wd_api/wd_bot.py @@ -1,7 +1,7 @@ """ """ import logging -from typing import Sequence + from .submit_bot import submitAPI @@ -12,7 +12,7 @@ def format_sitelinks(sitelinks): return {x["site"]: x["title"] for d, x in sitelinks.items()} -def format_labels_descriptions(labels: Sequence[str]): +def format_labels_descriptions(labels: str): return {x["language"]: x["value"] for _, x in labels.items()} diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index 009ffae..2146b8f 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -8,7 +8,7 @@ """ import sys -from typing import Sequence + import pywikibot from bots_subs.hi_api import HimoAPIBot @@ -332,7 +332,7 @@ def change_one_lab(text: str, lang): return new_lab -def make_en_label(labels: Sequence[str], q, Add: bool = False): +def make_en_label(labels: str, q, Add: bool = False): org_lab = "" new_lab = "" # --- From c2fbfacf611cae1baa3e85482702e6d86918d43f Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 03:06:43 +0300 Subject: [PATCH 05/11] . --- src/bots_subs/wd_api/wd_bot.py | 1 - src/cy/cy_bot/cy_helps.py | 6 +++--- src/des/ru_st_2_latin.py | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bots_subs/wd_api/wd_bot.py b/src/bots_subs/wd_api/wd_bot.py index b5a86e9..68ec030 100644 --- a/src/bots_subs/wd_api/wd_bot.py +++ b/src/bots_subs/wd_api/wd_bot.py @@ -2,7 +2,6 @@ import logging - from .submit_bot import submitAPI logger = logging.getLogger(__name__) diff --git a/src/cy/cy_bot/cy_helps.py b/src/cy/cy_bot/cy_helps.py index 2f2e785..8a16e31 100644 --- a/src/cy/cy_bot/cy_helps.py +++ b/src/cy/cy_bot/cy_helps.py @@ -97,11 +97,11 @@ def get_temp_arg(temp, arg): return "" -def ec_de_code(tt, type): +def ec_de_code(tt, z_type): fao = tt - if type == "encode": + if z_type == "encode": fao = urllib.parse.quote(tt) - elif type == "decode": + elif z_type == "decode": fao = urllib.parse.unquote(tt) return fao diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index 2146b8f..e04d93c 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -9,7 +9,6 @@ import sys - import pywikibot from bots_subs.hi_api import HimoAPIBot from pywikibot.pagegenerators import WikidataSPARQLPageGenerator From 5a297000621d3838cc1eca4fb81de5fb05fd06b7 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 03:24:26 +0300 Subject: [PATCH 06/11] . --- src/WDYe/common.py | 1 + src/WDYe/disam2.py | 1 + src/WDYe/med.py | 4 ++-- src/cy/jsub.py | 4 ++-- src/cy/mv.py | 4 ++-- src/des/desc.py | 4 ++-- src/des/fam.py | 1 + src/des/film.py | 1 + src/des/ru_st_2_latin.py | 3 ++- src/nep/bots/scientific_article.py | 1 + src/nep/si3g.py | 4 ++-- src/prop_labs/fill_ar_props.py | 3 ++- src/prop_labs/wd_Session.py | 1 + src/wd_gent.py | 1 - tests/desc_dicts/test_utils.py | 1 + 15 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/WDYe/common.py b/src/WDYe/common.py index fba1b46..2f96670 100644 --- a/src/WDYe/common.py +++ b/src/WDYe/common.py @@ -12,6 +12,7 @@ import logging import pywikibot + from bots_subs.wd_api import newdesc from desc_dicts.descraptions import DescraptionsTable diff --git a/src/WDYe/disam2.py b/src/WDYe/disam2.py index 850939c..6226320 100644 --- a/src/WDYe/disam2.py +++ b/src/WDYe/disam2.py @@ -11,6 +11,7 @@ import logging import pywikibot + from bots_subs import open_url from bots_subs.wd_api import wd_bot, wd_sparql_bot from bots_subs.wd_api.wd_desc import work_api_desc diff --git a/src/WDYe/med.py b/src/WDYe/med.py index c7ad167..ca4c97f 100644 --- a/src/WDYe/med.py +++ b/src/WDYe/med.py @@ -13,12 +13,12 @@ import urllib import urllib.parse +from shared.api_page import load_main_api + from bots_subs import open_url from bots_subs.hi_api import HimoAPIBot from bots_subs.wd_api import wd_sparql_bot -from shared.api_page import load_main_api - WD_API_Bot = HimoAPIBot(mr_or_bot="mr", www="www") logger = logging.getLogger(__name__) diff --git a/src/cy/jsub.py b/src/cy/jsub.py index 13e1f02..4ce4b5e 100644 --- a/src/cy/jsub.py +++ b/src/cy/jsub.py @@ -22,11 +22,11 @@ """ -import wd_gent from cy_bot.do_text import do_One_Page - from shared.api_page import load_main_api +import wd_gent + skip_titles = [ "قالب:نتيجة سباق الدراجات", "قالب:نتيجة سباق الدراجات/بداية", diff --git a/src/cy/mv.py b/src/cy/mv.py index 9975b1a..b0a2c7d 100644 --- a/src/cy/mv.py +++ b/src/cy/mv.py @@ -18,11 +18,11 @@ import sys import tqdm -import wd_gent import wikitextparser as wtp - from shared.api_page import load_main_api +import wd_gent + logger = logging.getLogger(__name__) diff --git a/src/des/desc.py b/src/des/desc.py index 46d2530..9b99748 100644 --- a/src/des/desc.py +++ b/src/des/desc.py @@ -46,6 +46,8 @@ import re import sys +from shared.api_page import load_main_api + from bots_subs.hi_api import HimoAPIBot from bots_subs.qs_bot import QS_line from bots_subs.wd_api import wd_bot @@ -53,8 +55,6 @@ from des.contries2 import ContriesTable2 from des.places import placesTable -from shared.api_page import load_main_api - WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") logger = logging.getLogger(__name__) diff --git a/src/des/fam.py b/src/des/fam.py index 8deb0cf..22435f4 100644 --- a/src/des/fam.py +++ b/src/des/fam.py @@ -15,6 +15,7 @@ import sys import tqdm + from bots_subs.wd_api import newdesc, wd_sparql_bot from des.railway import railway_tables, work_railway from desc_dicts.descraptions import ( diff --git a/src/des/film.py b/src/des/film.py index 96db0aa..0ad4e94 100644 --- a/src/des/film.py +++ b/src/des/film.py @@ -12,6 +12,7 @@ import re import pywikibot + from bots_subs.wd_api import wd_sparql_bot from bots_subs.wd_api.wd_desc import work_api_desc diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index e04d93c..cabc64c 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -10,9 +10,10 @@ import sys import pywikibot -from bots_subs.hi_api import HimoAPIBot from pywikibot.pagegenerators import WikidataSPARQLPageGenerator +from bots_subs.hi_api import HimoAPIBot + WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") letters_to_latin = { diff --git a/src/nep/bots/scientific_article.py b/src/nep/bots/scientific_article.py index dcd4b4f..737ee04 100644 --- a/src/nep/bots/scientific_article.py +++ b/src/nep/bots/scientific_article.py @@ -8,6 +8,7 @@ import re import dateutil.parser + from desc_dicts.descraptions_dict import Scientific_descraptions from nep.bots.helps import Get_P_API_time diff --git a/src/nep/si3g.py b/src/nep/si3g.py index e932058..518ed11 100644 --- a/src/nep/si3g.py +++ b/src/nep/si3g.py @@ -54,11 +54,11 @@ import time from pathlib import Path +from shared.api_page import load_main_api + import wd_gent from nep import si3 -from shared.api_page import load_main_api - logger = logging.getLogger(__name__) sys.argv.append("-family:wikidata") diff --git a/src/prop_labs/fill_ar_props.py b/src/prop_labs/fill_ar_props.py index a661459..d1565f1 100644 --- a/src/prop_labs/fill_ar_props.py +++ b/src/prop_labs/fill_ar_props.py @@ -33,9 +33,10 @@ from SPARQLWrapper import JSON, SPARQLWrapper from tqdm import tqdm from translate_bot import translate_en_to_ar -from wd_core_useraccount import User_tables_ibrahem from wd_Session import WikidataSession +from wd_core_useraccount import User_tables_ibrahem + logger = logging.getLogger(__name__) WDQS_ENDPOINT = "https://query.wikidata.org/sparql" diff --git a/src/prop_labs/wd_Session.py b/src/prop_labs/wd_Session.py index 79e0da1..8ea968d 100644 --- a/src/prop_labs/wd_Session.py +++ b/src/prop_labs/wd_Session.py @@ -8,6 +8,7 @@ from typing import Dict, List import requests + from wd_core_useraccount import User_tables_ibrahem logger = logging.getLogger(__name__) diff --git a/src/wd_gent.py b/src/wd_gent.py index 84bf5d8..57a8824 100644 --- a/src/wd_gent.py +++ b/src/wd_gent.py @@ -6,7 +6,6 @@ import pywikibot from pywikibot import pagegenerators - from shared.api_page import load_main_api logger = logging.getLogger(__name__) diff --git a/tests/desc_dicts/test_utils.py b/tests/desc_dicts/test_utils.py index 7167e32..d2242c3 100644 --- a/tests/desc_dicts/test_utils.py +++ b/tests/desc_dicts/test_utils.py @@ -3,6 +3,7 @@ import os import pytest + from src.wd_utils.utils import ( are_dates_same, get_file_date, From be1ff4da7dc2414cb605f21ba8c8e84fce875794 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 03:26:07 +0300 Subject: [PATCH 07/11] . --- src/bots_subs/hi_api/req_bots_new/descriptions_wd.py | 2 +- src/bots_subs/wd_api/submit_bot.py | 2 +- src/bots_subs/wd_api/wd_desc.py | 8 ++++---- src/des/railway.py | 6 +++--- src/nep/bots/helps.py | 4 ++-- src/nep/nldesc.py | 2 +- src/nep/others/read_json.py | 2 +- src/nep/si3.py | 2 +- src/nep/si3g_qua.py | 3 +-- src/nep/tables/si_tables.py | 3 +-- src/nep/wr_people.py | 4 ++-- src/people/add_qids.py | 2 +- src/prop_labs/chutes.py | 1 - src/prop_labs/openrouter.py | 1 - 14 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py index c1caa2c..829c6a0 100644 --- a/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/descriptions_wd.py @@ -64,7 +64,7 @@ def Des_API(self, Qid, desc: str, lang, ask: str = "", rea: bool = True, nowait: # --- if not desc.strip(): logger.info("<> Des_API desc is empty.") - return + return None # --- # save the edit out = ( diff --git a/src/bots_subs/wd_api/submit_bot.py b/src/bots_subs/wd_api/submit_bot.py index 3625b81..5a35f00 100644 --- a/src/bots_subs/wd_api/submit_bot.py +++ b/src/bots_subs/wd_api/submit_bot.py @@ -46,7 +46,7 @@ def submitAPI(params): except requests.exceptions.ReadTimeout: logger.info(f"ReadTimeout: {mainurl}") - except Exception as e: + except Exception: logger.exception("Exception:", exc_info=True) _known_exceptions = [ "('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))", diff --git a/src/bots_subs/wd_api/wd_desc.py b/src/bots_subs/wd_api/wd_desc.py index 70d48e1..445dfad 100644 --- a/src/bots_subs/wd_api/wd_desc.py +++ b/src/bots_subs/wd_api/wd_desc.py @@ -89,7 +89,7 @@ def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): # --- if len(langes) == 2 and "en-gb" in langes and "en-ca" in langes: logger.info("wwdesc: only en-gb and en-ca, Skipp... ") - return + return None # --- # dlangs = ','.join(queries_list) # summary = ('Bot: - Add descriptions:(%d langs) %s' % ( len(queries_list), str(dlangs) )) #ملخص العمل @@ -117,7 +117,7 @@ def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): # --- if queries_list == [] and fixlang == []: logger.info(" *** no addedlangs") - return + return None # --- value = "" if "ar" in newdesc: @@ -126,7 +126,7 @@ def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): try: key = queries_list[0] value = f"{newdesc[key]['value']}@{key}" - except Exception as e: + except Exception: logger.exception("Exception:", exc_info=True) value = "" # --- @@ -143,7 +143,7 @@ def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): # --- if not skipp: logger.info("<> - no skipp ") - return + return None # --- err_wait = "احترازًا من الإساء، يُحظر إجراء هذا الفعل مرات كثيرة في فترةٍ زمنية قصيرة، ولقد تجاوزت هذا الحد" # --- diff --git a/src/des/railway.py b/src/des/railway.py index 6c65675..af86c0f 100644 --- a/src/des/railway.py +++ b/src/des/railway.py @@ -43,7 +43,7 @@ def Get_P_API_id(claims, P, onlyone: bool = False): def work_railway(wditem, p31, q: str = ""): # --- if "railway" not in sys.argv: - return + return None # --- if not wditem: wditem = wd_bot.Get_Item_API_From_Qid(q) @@ -83,7 +83,7 @@ def work_railway(wditem, p31, q: str = ""): } # --- if not to_do_descs: - return + return None # --- wditem_desc = wditem.get("descriptions", {}) newdesc = {} @@ -136,7 +136,7 @@ def work_railway(wditem, p31, q: str = ""): # --- if not newdesc: print("nothing to add..") - return + return None # --- # een = ['en-gb', 'en-ca'] # --- diff --git a/src/nep/bots/helps.py b/src/nep/bots/helps.py index 7c816b7..85af8d9 100644 --- a/src/nep/bots/helps.py +++ b/src/nep/bots/helps.py @@ -52,7 +52,7 @@ def Get_P_API_time(item, P): return qlist[0] # --- sasa = [x["time"].split("-")[0].split("+0000000")[1] for x in qlist if x["time"].startswith("+0000000")] - Faso = {i: "" for i in sasa} + Faso = dict.fromkeys(sasa, "") return qlist[0] if len(Faso.keys()) == 1 else False @@ -87,7 +87,7 @@ def log_new_types(lists) -> str: with open(jsonfils, "w", encoding="utf-8") as nfile: json.dump(tabe, nfile) # Handle the exception and log the traceback. - except Exception as e: + except Exception: logger.exception("Exception:", exc_info=True) diff --git a/src/nep/nldesc.py b/src/nep/nldesc.py index 612b1cc..fd95a16 100644 --- a/src/nep/nldesc.py +++ b/src/nep/nldesc.py @@ -168,7 +168,7 @@ def action_one_item(lngr, q, item={}, claimstr: str = ""): items2do -= 1 # --- if "P31" not in claims: - return + return None # --- type_ids = claims.get("P31", {}) # --- diff --git a/src/nep/others/read_json.py b/src/nep/others/read_json.py index 2886d3d..62f8985 100644 --- a/src/nep/others/read_json.py +++ b/src/nep/others/read_json.py @@ -61,7 +61,7 @@ def read_bad_json(file): # --- fa = str(lala) fa = fa.split("{")[1].split("}")[0] - fa = f"{{fa}}" + fa = "{fa}" wd_file = json.loads(fa) print(f'Bad json "{file}"') return wd_file diff --git a/src/nep/si3.py b/src/nep/si3.py index 1b6db7e..b9d6a9d 100644 --- a/src/nep/si3.py +++ b/src/nep/si3.py @@ -165,7 +165,7 @@ def ISRE(qitem, num: int, lenth, no_donelist: bool = True, P31_list: bool = Fals # --- if not item: logger.info(f'*<> >{num} error with item "{q}" < :') - return + return None # --- if item.get("q", q) != q: q = item.get("q", q) diff --git a/src/nep/si3g_qua.py b/src/nep/si3g_qua.py index 5d77bba..36d8e30 100644 --- a/src/nep/si3g_qua.py +++ b/src/nep/si3g_qua.py @@ -30,8 +30,7 @@ # --- arg, _, value = arg.partition(":") # --- - if arg.startswith("-"): - arg = arg[1:] + arg = arg.removeprefix("-") # --- if arg == "limit": limit[1] = value diff --git a/src/nep/tables/si_tables.py b/src/nep/tables/si_tables.py index 6f90cdc..f770335 100644 --- a/src/nep/tables/si_tables.py +++ b/src/nep/tables/si_tables.py @@ -26,8 +26,7 @@ # --- arg, _, value = arg.partition(":") # --- - if arg.startswith("-"): - arg = arg[1:] + arg = arg.removeprefix("-") # --- if arg.lower() in ["offset", "off"]: print(f"offsetbg[1] = int({value})") diff --git a/src/nep/wr_people.py b/src/nep/wr_people.py index f4ba07e..9adcc83 100644 --- a/src/nep/wr_people.py +++ b/src/nep/wr_people.py @@ -64,7 +64,7 @@ def work_people2(item, topic, num: int = 0, years: str = ""): # --- if not p21_c: print(f" work_people2 p21_c == {p21_c} ") - return + return None # --- for lang, lang_tab in taber.items(): # --- @@ -76,7 +76,7 @@ def work_people2(item, topic, num: int = 0, years: str = ""): # --- if not NewDesc: print(" work_people nothing to add. ") - return + return None # --- logger.info(f"<> **{num}: work_people:{q} ({topic})") # --- diff --git a/src/people/add_qids.py b/src/people/add_qids.py index 2a62ee6..c8110b6 100644 --- a/src/people/add_qids.py +++ b/src/people/add_qids.py @@ -36,7 +36,7 @@ """ -from people.people_get_topic import job_to_qid, nat_to_qid +from people.people_get_topic import job_to_qid uux = { "academic": "Q3400985", diff --git a/src/prop_labs/chutes.py b/src/prop_labs/chutes.py index a9ccafa..dade332 100644 --- a/src/prop_labs/chutes.py +++ b/src/prop_labs/chutes.py @@ -1,5 +1,4 @@ import asyncio -import json from pathlib import Path import aiohttp diff --git a/src/prop_labs/openrouter.py b/src/prop_labs/openrouter.py index 17ecfc6..8704d65 100644 --- a/src/prop_labs/openrouter.py +++ b/src/prop_labs/openrouter.py @@ -1,5 +1,4 @@ import json -import os from pathlib import Path import requests From 0e0d01d38246b2a520298b75ed7a35f164e0e94f Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 03:30:24 +0300 Subject: [PATCH 08/11] . --- src/WDYe/alias.py | 2 +- src/WDYe/catwithoutp31.py | 2 +- src/WDYe/common.py | 2 +- src/WDYe/disam2.py | 5 --- src/WDYe/label.py | 4 +-- src/WDYe/med.py | 3 +- src/WDYe/module.py | 2 +- src/WDYe/template.py | 2 +- src/WDYe/wikicategory.py | 2 +- .../hi_api/h_wd_newapi/wd_newapi_bot.py | 6 +++- .../hi_api/req_bots_new/claims_wd.py | 4 ++- .../hi_api/req_bots_new/labels_wd.py | 4 ++- src/bots_subs/wd_api/newdesc.py | 6 ++-- src/bots_subs/wd_api/wd_desc.py | 4 ++- src/des/book.py | 2 +- src/des/desc.py | 3 +- src/des/film.py | 2 +- src/des/galaxy.py | 2 +- src/des/p155tables.py | 34 ------------------- src/nep/bots/tax_desc.py | 18 +++++----- src/nep/nldesc.py | 6 ++-- src/nep/si3g_qua.py | 2 +- src/nep/space_others.py | 8 ++--- src/neq/nldes3.py | 1 - src/neq/quarries.py | 11 +++--- src/people/new3.py | 32 +++++++++-------- src/prop_labs/openrouter.py | 1 - 27 files changed, 72 insertions(+), 98 deletions(-) diff --git a/src/WDYe/alias.py b/src/WDYe/alias.py index 819ca9b..b5f6c27 100644 --- a/src/WDYe/alias.py +++ b/src/WDYe/alias.py @@ -50,7 +50,7 @@ def WORK(item, table, type) -> None: # --- arlab = table["label"][0] arlab2 = arlab - alias = table["alias"] + # alias = table["alias"] if type in allise: logger.info(f'<> type:"{type}" in allise:"{allise[type]}" ') arlab2 = re.sub(f"^{type} ", f"{allise[type]} ", arlab2) diff --git a/src/WDYe/catwithoutp31.py b/src/WDYe/catwithoutp31.py index f37f010..854e353 100644 --- a/src/WDYe/catwithoutp31.py +++ b/src/WDYe/catwithoutp31.py @@ -70,7 +70,7 @@ def Get_Sitelinks_From_wikidata( if props: params["props"] = props # --- - if isinstance(add_props, (list, tuple)): + if isinstance(add_props, list | tuple): for x in add_props: if x not in params["props"]: params["props"] += f"|{x}" diff --git a/src/WDYe/common.py b/src/WDYe/common.py index 2f96670..6396a09 100644 --- a/src/WDYe/common.py +++ b/src/WDYe/common.py @@ -121,7 +121,7 @@ def main() -> None: logger.info("*<> main:") - queries_list = sorted(list(queries.keys())) + queries_list = sorted(queries.keys()) lenth = len(queries_list) for numb, topic in enumerate(queries_list, start=1): if topic in DescraptionsTable: diff --git a/src/WDYe/disam2.py b/src/WDYe/disam2.py index 6226320..209e20c 100644 --- a/src/WDYe/disam2.py +++ b/src/WDYe/disam2.py @@ -67,11 +67,6 @@ def work2(q, topic) -> None: def mainfromQuarry() -> None: logger.info("*<> mainfromQuarry:") - Quarry = """SELECT DISTINCT ?item -WHERE { - ?item schema:description "یک صفحهٔ ابهام\\u200cزدایی در ویکی\\u200cپدیا"@fa. -} -limit 10000""" Quarry2 = """SELECT ?item WHERE {VALUES (?item) {(wd:Q29976539) } diff --git a/src/WDYe/label.py b/src/WDYe/label.py index 03a97f7..bf51050 100644 --- a/src/WDYe/label.py +++ b/src/WDYe/label.py @@ -59,9 +59,9 @@ def action_item2(wditem) -> int: global items2do items2do -= 1 if "arwiki" in wditem.sitelinks: - ma = wditem.sitelinks["arwiki"] + wditem.sitelinks["arwiki"] if "ar" in wditem.sitelinks: - ma = wditem.sitelinks["arwiki"] + wditem.sitelinks["arwiki"] # print(ma) # site = ma.title # if site: diff --git a/src/WDYe/med.py b/src/WDYe/med.py index ca4c97f..beba178 100644 --- a/src/WDYe/med.py +++ b/src/WDYe/med.py @@ -268,7 +268,8 @@ def looog() -> None: # --- for x, value in log2.items(): q = "{{Q| " + x + "}}" - text2 += "\n|-\n| %s || {{" % q + text2 += f"\n|-\n| {q} ||" + text2 += "{{" text2 += f"Label | {x} | en" text2 += "}} ||" text2 += ",".join(value) + "\n" diff --git a/src/WDYe/module.py b/src/WDYe/module.py index bcf1aa2..1b77084 100644 --- a/src/WDYe/module.py +++ b/src/WDYe/module.py @@ -10,5 +10,5 @@ topic = "Wikimedia module" for ll in LIST: - quarry = "SELECT ?item WHERE { ?item wdt:P31 wd:%s.}" % ll + quarry = f"SELECT ?item WHERE {{ ?item wdt:P31 wd:{ll}.}}" newdesc.mainfromQuarry2(topic, quarry, translations) diff --git a/src/WDYe/template.py b/src/WDYe/template.py index d34802f..90ff4ed 100644 --- a/src/WDYe/template.py +++ b/src/WDYe/template.py @@ -18,5 +18,5 @@ # newdesc.mainfromQuarry( topic , quarry2, translations) for ll in list: - quarry = "SELECT ?item WHERE { ?item wdt:P31 wd:%s.}" % ll + quarry = f"SELECT ?item WHERE {{ ?item wdt:P31 wd:{ll}.}}" newdesc.mainfromQuarry2(topic, quarry, translations) diff --git a/src/WDYe/wikicategory.py b/src/WDYe/wikicategory.py index 6467646..18efb24 100644 --- a/src/WDYe/wikicategory.py +++ b/src/WDYe/wikicategory.py @@ -25,5 +25,5 @@ # newdesc.mainfromQuarry( topic , quarry2, translations) for ll in list: - quarry = "SELECT ?item WHERE { ?item wdt:P31 wd:%s.}" % ll + quarry = f"SELECT ?item WHERE {{ ?item wdt:P31 wd:{ll}.}}" newdesc.mainfromQuarry2(topic, quarry, translations) diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py index 440c343..f9ea36a 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py @@ -26,8 +26,12 @@ def __init__(self, login_bot, mr_or_bot: str = "bot") -> None: # --- logger.info(f"<> WdAPI: {mr_or_bot}, {self.usernamex=} \n") - def post_to_newapi(self, params={}, data={}, tage: str = "", editgroups: str = "", max_retry: int = 0, **kwargs): + def post_to_newapi(self, params=None, data=None, tage: str = "", editgroups: str = "", max_retry: int = 0, **kwargs): # --- + if data is None: + data = {} + if params is None: + params = {} if not params and data: params = data # --- diff --git a/src/bots_subs/hi_api/req_bots_new/claims_wd.py b/src/bots_subs/hi_api/req_bots_new/claims_wd.py index be1b113..96a043a 100644 --- a/src/bots_subs/hi_api/req_bots_new/claims_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/claims_wd.py @@ -186,8 +186,10 @@ def _Set_Quall2(self, js, qualifiers, nowait: bool = False) -> str: # --- self.add_quall(Claimid, quall_prop, valueline) - def Claim_API2(self, uid, proprty, numeric, qualifiers=[], nowait: bool = False): + def Claim_API2(self, uid, proprty, numeric, qualifiers=None, nowait: bool = False): # --- + if qualifiers is None: + qualifiers = [] if lag_bot.bad_lag(nowait): return "" # --- diff --git a/src/bots_subs/hi_api/req_bots_new/labels_wd.py b/src/bots_subs/hi_api/req_bots_new/labels_wd.py index 9c1c13c..b6ddd34 100644 --- a/src/bots_subs/hi_api/req_bots_new/labels_wd.py +++ b/src/bots_subs/hi_api/req_bots_new/labels_wd.py @@ -36,8 +36,10 @@ def __init__(self, wdapi_new, Des_API) -> None: self.Des_API_funcs = Des_API # pass - def Alias_API(self, Qid, Alias, lang, ret, Remove=[], nowait: bool = False): + def Alias_API(self, Qid, Alias, lang, ret, Remove=None, nowait: bool = False): # --- + if Remove is None: + Remove = [] if lag_bot.bad_lag(nowait): return "" # --- diff --git a/src/bots_subs/wd_api/newdesc.py b/src/bots_subs/wd_api/newdesc.py index 75ecddf..af9d579 100644 --- a/src/bots_subs/wd_api/newdesc.py +++ b/src/bots_subs/wd_api/newdesc.py @@ -30,7 +30,7 @@ def work2_with_replacement(item, topic, translations, replacement_ke) -> None: # logger.info( '<> **newdesc: work2:' + item.title(as_link=False)) # ItemDescriptions = {} # --- - keys1 = sorted([x for x in translations[topic].keys()]) + keys1 = sorted(translations[topic].keys()) # --- if "en" in keys1: keys1.append("en-gb") @@ -63,7 +63,7 @@ def work2_with_replacement(item, topic, translations, replacement_ke) -> None: def work22(q, topic, translations) -> None: # --- - keys = sorted([x for x in translations[topic].keys()]) + keys = sorted(translations[topic].keys()) if "en" in keys: keys.append("en-gb") keys.append("en-ca") @@ -129,7 +129,7 @@ def mainfromQuarry2(topic, Quarry, translations) -> None: def work2(item, topic, translations) -> None: # --- - keys = sorted([x for x in translations[topic].keys()]) + keys = sorted(translations[topic].keys()) if "en" in keys: keys.append("en-gb") keys.append("en-ca") diff --git a/src/bots_subs/wd_api/wd_desc.py b/src/bots_subs/wd_api/wd_desc.py index 445dfad..6202c2c 100644 --- a/src/bots_subs/wd_api/wd_desc.py +++ b/src/bots_subs/wd_api/wd_desc.py @@ -180,8 +180,10 @@ def wwdesc(newdesc, qid, i, fixlang, ask: str = "", tage: str = ""): logger.info(skipp) -def work_api_desc(newdesc, qid, fixlang=[]) -> None: +def work_api_desc(newdesc, qid, fixlang=None) -> None: # --- + if fixlang is None: + fixlang = [] newdesc = del_keys(newdesc) # --- langes = list(newdesc.keys()) diff --git a/src/des/book.py b/src/des/book.py index 88469a4..e7e72b0 100644 --- a/src/des/book.py +++ b/src/des/book.py @@ -167,7 +167,7 @@ def GetQuery(Qid, lang, keys): else: ur += f' ?auths rdfs:label ?auth{lang} filter (lang(?auth{lang}) = "{lang}") .' # --- - ur += '\nOPTIONAL {?item schema:description ?itemDes filter(lang(?itemDes) = "%s")}' % lang + ur += f'\nOPTIONAL {{?item schema:description ?itemDes filter(lang(?itemDes) = "{lang}")}}' ur += "FILTER(!BOUND(?itemDes)) }\n GROUP BY ?item " # --- # logger.info(ur) diff --git a/src/des/desc.py b/src/des/desc.py index 9b99748..2550aa9 100644 --- a/src/des/desc.py +++ b/src/des/desc.py @@ -154,7 +154,8 @@ def get_property_label_for_qids(properties, List): # --- for qid in List: num += 1 - lino = "{{subst:user:Mr._Ibrahem/line2|%s" % qid + lino = "{{" + lino += f"subst:user:Mr._Ibrahem/line2|{qid}" for prop in properties: lino += f"|{prop}" lino += "}}\n" diff --git a/src/des/film.py b/src/des/film.py index 0ad4e94..16f067d 100644 --- a/src/des/film.py +++ b/src/des/film.py @@ -261,7 +261,7 @@ def MakeDesc(Qid, pa, lang): if lang not in by_list: logger.info(f'<>> cant find "by" in by_list for lang: "{lang}"') return False - co = "من أداء " if (Qid == "Q482994") and (lang == "ar") else f"{by_list[lang]} " + "من أداء " if (Qid == "Q482994") and (lang == "ar") else f"{by_list[lang]} " # --- if (lang in pa) and (pa[lang] != ""): if auth := pa[lang]: diff --git a/src/des/galaxy.py b/src/des/galaxy.py index 70066a5..34d88b8 100644 --- a/src/des/galaxy.py +++ b/src/des/galaxy.py @@ -18,5 +18,5 @@ translations = {"Q318": DescraptionsTable.get("galaxy") or Qid_Descraptions.get("Q318") or {}} for q in translations: - quarry = "SELECT ?item WHERE { ?item wdt:P31 wd:%s.} limit 50000" % q + quarry = f"SELECT ?item WHERE {{ ?item wdt:P31 wd:{q}.}} limit 50000" newdesc.mainfromQuarry2(q, quarry, translations) diff --git a/src/des/p155tables.py b/src/des/p155tables.py index d1693b6..7b69747 100644 --- a/src/des/p155tables.py +++ b/src/des/p155tables.py @@ -940,7 +940,6 @@ "team eventing": "أحداث الفرق", "ice dancing": "الرقص على الجليد", "– qualification": "– تصفيات", - "ice dancing": "الرقص على الجليد", "World Figure Skating Championships - ice dancing": "بطولة العالم للتزلج الفني - الرقص على الجليد", "World Figure Skating Championships": "بطولة العالم للتزلج الفني", "ladies' singles free skating": "تزلج حر فردي للسيدات", @@ -959,13 +958,11 @@ "ConIFA World Football Cup": "كأس العالم لاتحاد الجمعيات المستقلة لكرة القدم", "ATP Tour": "رابطة محترفي التنس", "ATP Tour tournaments": "بطولات رابطة محترفي التنس", - "ATP Tour tournaments": "بطولات رابطة محترفي التنس", "ATP World Tour": "بطولات العالم لرابطة محترفات التنس", "ATP Challenger Tour": "بطولات تشالنجر لرابطة محترفات التنس", "WTA Auckland Open": "أوكلاند المفتوحة للسيدات", "WTA Madrid Open (tennis)": "مدريد المفتوحة للسيدات (تنس)", "WTA Tour tournaments": "بطولات رابطة محترفات التنس", - "WTA Tour tournaments": "بطولات رابطة محترفات التنس", "WTA Tour": "رابطة محترفات التنس", "UCI Continental Teams": "الفرق القارية للاتحاد الدولي للدراجات", "UCI Continental Teams (Asia)": "الفرق القارية للاتحاد الدولي للدراجات (آسيا)", @@ -982,11 +979,6 @@ "UCI Africa Tour": "طواف أفريقيا للدراجات", "UCI Oceania Tour": "طواف أوقيانوسيا للدراجات", "UCI Women's World Tour": "طواف العالم للدراجات للسيدات", - "UCI America Tour": "طواف أمريكا للدراجات", - "UCI Asia Tour": "طواف آسيا للدراجات", - "UCI Europe Tour": "طواف أوروبا للدراجات", - "UCI Africa Tour": "طواف أفريقيا للدراجات", - "UCI Oceania Tour": "طواف أوقيانوسيا للدراجات", "Former UCI WorldTeams": "فرق دراجات هوائية عالمية سابقة", "UCI WorldTeam riders": "دراجو فرق دراجات هوائية عالمية", "UCI WorldTeams": "فرق دراجات هوائية عالمية", @@ -1022,14 +1014,10 @@ "OFC U-17 Championships": "كأس أوقيانوسيا للأمم تحت 17 سنة", "OFC Nations Cup": "كأس أوقيانوسيا للأمم", "OFC U-20 Championships": "كأس أوقيانوسيا للأمم تحت 20 سنة", - "OFC Nations Cup": "كأس أوقيانوسيا للأمم", - "OFC U-17 Championships": "كأس أوقيانوسيا للأمم تحت 17 سنة", - "OFC U-20 Championships": "كأس أوقيانوسيا للأمم تحت 20 سنة", "OFC Champions League": "دوري أبطال أوقيانوسيا", "AFC Asian Cup Finals": "نهائيات كأس آسيا", "AFC Futsal Championships": "بطولة آسيا لكرة القدم الخماسية", "AFC U-16 Women's Championships": "بطولة آسيا تحت 16 سنة لكرة القدم للسيدات", - "AFC Futsal Championships": "بطولة آسيا لكرة القدم الخماسية", "AFC President's Cup": "كأس رئيس الاتحاد الآسيوي", "AFC Solidarity Cup": "كأس التضامن الآسيوي", "AFC Women's Asian Cup": "كأس الأمم الآسيوية لكرة القدم للسيدات", @@ -1043,9 +1031,7 @@ "CONCACAF Women's Championships": "بطولة أمريكا الشمالية للسيدات", "CONCACAF Women's U-10 Championships": "بطولة أمريكا الشمالية للسيدات تحت 10 سنة", "CONCACAF Women's U-17 Championships": "بطولة أمريكا الشمالية للسيدات تحت 17 سنة", - "CONCACAF U17 Championships": "الكأس الذهبية تحت 17 سنة لكرة القدم", "CONCACAF Champions League": "دوري أبطال الكونكاكاف", - "CONCACAF Under-20 Championships": "الكأس الذهبية تحت 20 سنة لكرة القدم", "AFF U-23 Championships": "بطولة اتحاد آسيان تحت 23 سنة", "AFF U-23 Youth Championships": "بطولة اتحاد آسيان تحت 23 سنة للشباب", "AFF Championships": "بطولة اتحاد آسيان لكرة القدم", @@ -1054,8 +1040,6 @@ "EHF Cup": "كأس أوروبا لكرة اليد", "Women's EHF Cup": "كأس أوروبا لكرة اليد للسيدات", "Women's EHF Challenge Cup": "كأس التحدي الأوروبية لكرة اليد للسيدات", - "EHF Champions League": "دوري أبطال أوروبا لكرة اليد", - "EHF Cup": "كأس أوروبا لكرة اليد", "Women's EHF Cup Winners' Cup": "كأس أبطال الكؤوس الأوروبية لكرة اليد للسيدات", "EHF Women's Cup Winners' Cup": "كأس أبطال الكؤوس الأوروبية لكرة اليد للسيدات", "EHF Women's Champions League": "دوري أبطال أوروبا لكرة اليد للسيدات", @@ -1082,12 +1066,10 @@ "FIBA": "الاتحاد الدولي لكرة السلة", "FIBA AmeriCup": "بطولة أمم الأمريكتين لكرة السلة", "FIBA Africa Championships": "بطولة أمم أفريقيا لكرة السلة", - "FIBA EuroBasket": "بطولة أمم أوروبا لكرة السلة", "FIBA Asia Championships": "بطولة أمم آسيا لكرة السلة", "FIBA Basketball World Cup": "بطولة كأس العالم لكرة السلة", "FIBA World Championships": "بطولة كأس العالم لكرة السلة", "FIBA World Championship for Women": "بطولة كأس العالم لكرة السلة للسيدات", - "FIBA Korać Cup": "كأس كوراتش لكرة السلة", "FIFA World Cup": "كأس العالم لكرة القدم", # "FIFA World Cup":"كأس العالم", # "FIFA Women's World Cup":"كأس العالم للسيدات", @@ -1110,16 +1092,10 @@ "IAAF Diamond League": "دوري ماسي", "IAAF World Indoor Championships in Athletics": "بطولة العالم لألعاب القوى داخل الصالات", "IAAF World Cross Country Championships": "بطولة العالم للعدو الريفي", - "IAAF World Indoor Championships in Athletics": "بطولة العالم لألعاب القوى داخل الصالات", "IAAF World Indoor Championships": "بطولة العالم لألعاب القوى داخل الصالات", "IAAF World Indoor Games": "بطولة العالم لألعاب القوى داخل الصالات", "IAAF World Junior Championships in Athletics": "بطولة العالم للناشئين لألعاب القوى", - "IAAF World Cross Country Championships": "بطولة العالم للعدو الريفي", - "IAAF World Indoor Championships": "بطولة العالم لألعاب القوى داخل الصالات", - "IAAF World Indoor Games": "بطولة العالم لألعاب القوى داخل الصالات", "SAFF Championships": "بطولة اتحاد جنوب آسيا لكرة القدم", - "SAFF Championships": "بطولة اتحاد جنوب آسيا لكرة القدم", - "FIS Nordic World Ski Championships": "بطولة العالم للتزلج النوردي على الثلج", "FIS Nordic World Ski Championships": "بطولة العالم للتزلج النوردي على الثلج", "FIVB Women's Volleyball World Championships": "بطولة العالم لكرة الطائرة للسيدات", "FIVB Volleyball World Cup": "كأس العالم لكرة الطائرة", @@ -1147,7 +1123,6 @@ "UEFA Women's Championships": "بطولة أمم أوروبا للسيدات", "UEFA Futsal Euro": "بطولة أوروبا لكرة الصالات", "UEFA Euro": "بطولة أمم أوروبا", - "UEFA Champions League": "دوري أبطال أوروبا", "2017–18 UEFA Champions League": "دوري أبطال أوروبا 2017–18", # "UEFA European Championships":"بطولة أمم أوروبا لكرة القدم", "UEFA Nations League": "دوري الأمم الأوروبية", @@ -1160,12 +1135,10 @@ "UEFA European Championships": "بطولة أمم أوروبا", "UEFA European Football Championships": "بطولة أمم أوروبا", "UEFA European Under-10 Championships": "بطولة أمم أوروبا تحت 10 سنة", - "UEFA Europa League": "الدوري الأوروبي", "UEFA Youth League": "الدوري الأوروبي للشباب", "UEFA Futsal Championships": "بطولة أمم أوروبا داخل الصالات", "UEFA European Under-16 Football Championships": "بطولة أوروبا تحت 16 سنة لكرة القدم", "UEFA European Under-17 Football Championships": "بطولة أوروبا تحت 17 سنة لكرة القدم", - "UEFA Women's Under-17 Championships": "بطولة أوروبا تحت 17 سنة لكرة القدم للسيدات", "UEFA European Under-19 Football Championships": "بطولة أوروبا تحت 19 سنة لكرة القدم", "UEFA Women's Under-19 Championships": "بطولة أوروبا تحت 19 سنة لكرة القدم للسيدات", "UEFA European Under-21 Championships": "بطولة أوروبا تحت 21 سنة لكرة القدم", @@ -1175,16 +1148,12 @@ "UNAF U-17 Tournament": "بطولة أمم شمال أفريقيا تحت 17 سنة", "UNAF U-20 Tournament": "بطولة أمم شمال أفريقيا تحت 20 سنة", "UNAF Club Cup": "كأس اتحاد شمال أفريقيا", - "UNAF U-17 Tournament": "بطولة أمم شمال أفريقيا تحت 17 سنة", - "UNAF Club Cup": "كأس اتحاد شمال أفريقيا", - "UNAF U-20 Tournament": "بطولة أمم شمال أفريقيا تحت 20 سنة", "UNAF U-23 Tournament": "بطولة أمم شمال أفريقيا تحت 23 سنة", "FINA World Aquatics Championships": "بطولة العالم للألعاب المائية", "FINA Water Polo World League": "الدوري العالمي لكرة الماء", "FINA": "الاتحاد الدولي للسباحة", "FINA World Swimming Championships (25 m)": "بطولة العالم للسباحة (25 متر)", "FINA World Swimming Championships": "بطولة العالم للسباحة", - "FINA World Aquatics Championships": "بطولة العالم للألعاب المائية", } olympics = { @@ -1201,8 +1170,6 @@ # --- "Women's road race": "سباق الطريق للسيدات", "Women's time trial": "سباق الطريق ضد الساعة للسيدات", - "Women's road race": "سباق الطريق للسيدات", - "Women's time trial": "سباق الطريق ضد الساعة للسيدات", # --- "Men's road race": "سباق الطريق", "Men's team time trial": "سباق الطريق ضد الساعة للفرق", @@ -1247,7 +1214,6 @@ "women's": "سيدات", "womens": "سيدات", "ladies": "سيدات", - "ladies": "سيدات", "mens": "رجال", "men's": "رجال", # --- diff --git a/src/nep/bots/tax_desc.py b/src/nep/bots/tax_desc.py index cc973ef..5d566dc 100644 --- a/src/nep/bots/tax_desc.py +++ b/src/nep/bots/tax_desc.py @@ -39,19 +39,19 @@ def make_tax_des_new(item) -> str: if not P105ar: return "" # --- - nan = """SELECT DISTINCT ?item ?P171 ?item105 - WHERE { - BIND(wd:Q111771064 AS ?item) - VALUES ?P171 { - %s - } + tata = " ".join([f"wd:{x}" for x in lab_for_p171.keys()]) + # --- + nan = f"""SELECT DISTINCT ?item ?P171 ?item105 + WHERE {{ + BIND(wd:Q111771064 AS ?item) + VALUES ?P171 {{ + {tata} + }} ?item wdt:P31 wd:Q16521. ?item wdt:P171* ?P171. ?P171 wdt:P105 wd:Q37517. ?item wdt:P105 ?item105. - }""" % " ".join( - [f"wd:{x}" for x in lab_for_p171.keys()] - ) + }}""" nan = nan.replace("Q111771064", q) # --- if "err" in sys.argv: diff --git a/src/nep/nldesc.py b/src/nep/nldesc.py index fd95a16..473bacc 100644 --- a/src/nep/nldesc.py +++ b/src/nep/nldesc.py @@ -137,7 +137,9 @@ def Add_desc(q, value, lang) -> None: WD_API_Bot.Des_API(q, value, lang, ask="") -def action_one_item(lngr, q, item={}, claimstr: str = ""): +def action_one_item(lngr, q, item=None, claimstr: str = ""): + if item is None: + item = {} global items2do global totaledits # --- @@ -199,7 +201,7 @@ def action_one_item(lngr, q, item={}, claimstr: str = ""): do_P1433_new_list(wditem, P31) break # --- - logger.info("o_type: [%s]" % type_of_item) + logger.info(f"o_type: [{type_of_item}]") # --- if type_of_item: if type_of_item == "Q7604686": diff --git a/src/nep/si3g_qua.py b/src/nep/si3g_qua.py index 36d8e30..54935a8 100644 --- a/src/nep/si3g_qua.py +++ b/src/nep/si3g_qua.py @@ -106,7 +106,7 @@ def one_item(qid, num: int) -> None: return # --- descriptions = item.get("descriptions", {}) - endes = descriptions.get("en", "") + descriptions.get("en", "") # --- ardes = descriptions.get("ar", "") # --- diff --git a/src/nep/space_others.py b/src/nep/space_others.py index ff7a945..8dddea2 100644 --- a/src/nep/space_others.py +++ b/src/nep/space_others.py @@ -94,7 +94,7 @@ def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): elif type_of_item in Space_tab: labr = Space_tab[type_of_item] if orig_desc in [labr, ""]: - my_description = its_a_generalthing(wditem, labr, "%s في " % labr, "P59") + my_description = its_a_generalthing(wditem, labr, f"{labr} في ", "P59") # --- elif type_of_item == "Q2831984": # ألبوم قصص مصورة uit de serie P179 if orig_desc in ["", "ألبوم قصص مصورة"]: @@ -120,7 +120,7 @@ def Make_space_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): my_description = "" logger.info(f"test:[{test}] != my_description[{my_description}]") # --- - logger.info("Make space desc:[%s]" % my_description) + logger.info(f"Make space desc:[{my_description}]") # --- return my_description @@ -144,7 +144,7 @@ def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): elif type_of_item in bldiat: my_description = its_a_thing_located_in_country(wditem, bldiat[type_of_item], "بلدية") if my_description in ["بلدية", ""]: - my_description = "بلدية في %s" % bldiat[type_of_item] + my_description = f"بلدية في {bldiat[type_of_item]}" # --- # أغاني وألبومات صوتية وما شابهه elif type_of_item in songs_type: @@ -159,7 +159,7 @@ def Make_others_desc(lng, wditem, type_of_item, orig_desc, claimstr: str = ""): elif type_of_item in Geo_entity: labr = Geo_entity[type_of_item] if orig_desc in [labr, ""]: - my_description = its_something_in_an_entity(wditem, "%s في" % labr) + my_description = its_something_in_an_entity(wditem, f"{labr} في") # --- elif type_of_item == "Q8502": # a جبل if orig_desc in ["جبل", ""]: diff --git a/src/neq/nldes3.py b/src/neq/nldes3.py index 8184379..ba8af5e 100644 --- a/src/neq/nldes3.py +++ b/src/neq/nldes3.py @@ -76,7 +76,6 @@ def get_sparql_queries(): quaries = [] # --- for x in quas: - quaa = f"SELECT ?item WHERE {{ ?item wdt:P31 wd:{x} . FILTER NOT EXISTS {{ ?item schema:description ?itemar. FILTER((LANG(?itemar)) = 'ar') }} }}" # --- in_sp = SPARQLSE.get(x) # --- diff --git a/src/neq/quarries.py b/src/neq/quarries.py index 0e8eef6..f624417 100644 --- a/src/neq/quarries.py +++ b/src/neq/quarries.py @@ -73,18 +73,17 @@ def do_qua(qid, prop: str = "", ad: str = "", ar_values: str = ""): SPARQLSE[f"{p50}dfd"] = do_qua(p50, prop="wdt:P50") SPARQLSE[p50] = ( - """ + f""" SELECT DISTINCT ?item (GROUP_CONCAT(DISTINCT(STR(?labe)); separator="@@") as ?lab) - WHERE { - ?item wdt:P31 wd:%s . + WHERE {{ + ?item wdt:P31 wd:{p50} . ?item wdt:P50 ?pp. ?pp rdfs:label ?labe . FILTER((LANG(?labe)) = "ar") . - FILTER(NOT EXISTS {?item schema:description ?des.FILTER((LANG(?des)) = "ar")}) - } + FILTER(NOT EXISTS {{?item schema:description ?des.FILTER((LANG(?des)) = "ar")}}) + }} GROUP BY ?item """ - % p50 ) diff --git a/src/people/new3.py b/src/people/new3.py index ffb6796..575f2c5 100644 --- a/src/people/new3.py +++ b/src/people/new3.py @@ -155,24 +155,26 @@ def check_quarry_new(tab): # logger.info( "@@".join( tabe[numb] ) ) logger.info(f"find qua for {len(value)} description.") # --- - qua = """SELECT - (concat(strafter(str(?item),"/entity/")) as ?q)#?item - (GROUP_CONCAT(DISTINCT(LANG(?des2)); separator=",") as ?deskey) - (GROUP_CONCAT(DISTINCT(?des); separator=",") as ?desc) - (GROUP_CONCAT(DISTINCT(strafter(str(?p211),"/entity/")); separator=",") as ?p21) - WHERE { - values ?des { %s } - ?item wdt:P31 wd:Q5 . - ?item wdt:P21 ?p211. - ?item schema:description ?des. - ?item schema:description ?des2. - } - group by ?item - #limit 1000 - """ % " ".join( + data_str = " ".join( f'"{f}"@en "{f.lower()}"@en' for f in tabe[numb] ) # --- + qua = f"""SELECT + (concat(strafter(str(?item),"/entity/")) as ?q)#?item + (GROUP_CONCAT(DISTINCT(LANG(?des2)); separator=",") as ?deskey) + (GROUP_CONCAT(DISTINCT(?des); separator=",") as ?desc) + (GROUP_CONCAT(DISTINCT(strafter(str(?p211),"/entity/")); separator=",") as ?p21) + WHERE {{ + values ?des {{ {data_str} }} + ?item wdt:P31 wd:Q5 . + ?item wdt:P21 ?p211. + ?item schema:description ?des. + ?item schema:description ?des2. + }} + group by ?item + #limit 1000 + """ + # --- if limit[1]: qua += f"\n limit {limit[1]}" # --- diff --git a/src/prop_labs/openrouter.py b/src/prop_labs/openrouter.py index 8704d65..8a720be 100644 --- a/src/prop_labs/openrouter.py +++ b/src/prop_labs/openrouter.py @@ -39,7 +39,6 @@ def translate_text(text: str): "- لا تضف تعليقات.\n" ) # --- - prompt2 = f"Translate to Arabic: {text}" # --- payload = { "model": MODEL, From 30c6850081f8382920ae39fafaa58bae5a9aae92 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 07:06:22 +0300 Subject: [PATCH 09/11] . --- pyproject.toml | 94 ++++++++++++++++++- src/WDYe/common.py | 1 - src/WDYe/disam2.py | 1 - src/WDYe/med.py | 4 +- src/bots_subs/hi_api/__init__.py | 1 + .../hi_api/h_wd_newapi/wd_newapi_bot.py | 19 ++-- .../hi_api/utils/handle_wd_errors.py | 6 +- src/bots_subs/hi_api/utils/lag_bot.py | 2 +- src/cy/jsub.py | 4 +- src/cy/mv.py | 4 +- src/des/desc.py | 4 +- src/des/fam.py | 1 - src/des/film.py | 1 - src/des/ru_st_2_latin.py | 3 +- src/nep/bots/scientific_article.py | 1 - src/nep/si3g.py | 4 +- src/people/new3.py | 4 +- src/prop_labs/fill_ar_props.py | 3 +- src/prop_labs/wd_Session.py | 1 - src/wd_gent.py | 1 + tests/desc_dicts/test_utils.py | 1 - 21 files changed, 125 insertions(+), 35 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6b0b50c..26e62f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ exclude = ''' | buck-out | build | dist + | typings )/ ''' @@ -70,6 +71,7 @@ exclude = [ ".tox", ".venv", ".vscode", + "typings", "__pypackages__", "_build", "buck-out", @@ -109,6 +111,8 @@ ignore = [ "N802", "UP007", "UP045", + "UP031", + "F841", ] select = [ "E", # pycodestyle (error) @@ -149,7 +153,6 @@ warn_return_any = true warn_unused_configs = true disallow_untyped_defs = false ignore_missing_imports = true -line-length = 120 [tool.pylint.messages_control] max-line-length = 120 @@ -158,3 +161,92 @@ disable = [ "C0103", # invalid-name "R0913", # too-many-arguments ] + + +[tool.pyright] +# Target Python version for type analysis +pythonVersion = "3.13" +stubPath = "typings" +# Paths to include and exclude from checking +include = ["src"] +exclude = ["typings", "**/node_modules", "**/__pycache__", ".venv"] + +# Diagnostic modes: "basic" or "standard" or "strict" +typeCheckingMode = "basic" + +# Automatically find virtual environments +venvPath = "." +venv = ".venv" + +# Fine-tune specific warning rules +reportMissingTypeStubs = false +reportGeneralTypeIssues = false +reportUnknownMemberType = false +enableReachabilityAnalysis = false +strictListInference = false +strictDictionaryInference = false +strictSetInference = false +deprecateTypingAliases = false +enableExperimentalFeatures = false + +analyzeUnannotatedFunctions = true +disableBytesTypePromotions = true +strictParameterNoneValue = true +enableTypeIgnoreComments = true +reportMissingModuleSource = "warning" +reportInvalidTypeForm = "warning" +reportMissingImports = "warning" +reportUndefinedVariable = "warning" + +reportReturnType = false +reportArgumentType = false +reportAttributeAccessIssue = "warning" +reportAssignmentType = "warning" +reportOptionalMemberAccess = "warning" +reportCallIssue = "warning" +reportOptionalSubscript = "warning" + + +# ----- +reportAbstractUsage = false +reportAssertAlwaysTrue = false +reportAssertTypeFailure = false +reportCallInDefaultInitializer = false +reportConstantRedefinition = false +reportDeprecated = false +reportDuplicateImport = false +reportFunctionMemberAccess = false +reportImplicitOverride = false +reportImplicitStringConcatenation = false +reportImportCycles = false +reportIncompatibleMethodOverride = false +reportIncompatibleVariableOverride = false +reportIncompleteStub = false +reportInconsistentOverload = false +reportIndexIssue = false +reportInvalidStringEscapeSequence = false +reportInvalidStubStatement = false +reportInvalidTypeArguments = false +reportInvalidTypeVarUse = false +reportMatchNotExhaustive = false +reportMissingParameterType = false +reportMissingSuperCall = false +reportMissingTypeArgument = false +reportOperatorIssue = false +reportOptionalCall = false +reportOptionalContextManager = false +reportOptionalIterable = false +reportOptionalOperand = false +reportOverlappingOverload = false +reportPossiblyUnboundVariable = false +reportPrivateImportUsage = false +reportPrivateUsage = false +reportPropertyTypeMismatch = false +reportRedeclaration = false +reportTypeCommentUsage = false +reportTypedDictNotRequiredAccess = false +reportUnboundVariable = false +reportUnhashable = false +reportUninitializedInstanceVariable = false +reportUnknownArgumentType = false +reportUnknownLambdaType = false diff --git a/src/WDYe/common.py b/src/WDYe/common.py index 6396a09..413bf46 100644 --- a/src/WDYe/common.py +++ b/src/WDYe/common.py @@ -12,7 +12,6 @@ import logging import pywikibot - from bots_subs.wd_api import newdesc from desc_dicts.descraptions import DescraptionsTable diff --git a/src/WDYe/disam2.py b/src/WDYe/disam2.py index 209e20c..a41b47d 100644 --- a/src/WDYe/disam2.py +++ b/src/WDYe/disam2.py @@ -11,7 +11,6 @@ import logging import pywikibot - from bots_subs import open_url from bots_subs.wd_api import wd_bot, wd_sparql_bot from bots_subs.wd_api.wd_desc import work_api_desc diff --git a/src/WDYe/med.py b/src/WDYe/med.py index beba178..a136a9c 100644 --- a/src/WDYe/med.py +++ b/src/WDYe/med.py @@ -13,12 +13,12 @@ import urllib import urllib.parse -from shared.api_page import load_main_api - from bots_subs import open_url from bots_subs.hi_api import HimoAPIBot from bots_subs.wd_api import wd_sparql_bot +from shared.api_page import load_main_api + WD_API_Bot = HimoAPIBot(mr_or_bot="mr", www="www") logger = logging.getLogger(__name__) diff --git a/src/bots_subs/hi_api/__init__.py b/src/bots_subs/hi_api/__init__.py index 003dd97..529d0cf 100644 --- a/src/bots_subs/hi_api/__init__.py +++ b/src/bots_subs/hi_api/__init__.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 """ """ + from newapi import WikiLoginClient from .h_wd_newapi.wd_login_wrap import log_in_wikidata diff --git a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py index f9ea36a..de15a47 100644 --- a/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py +++ b/src/bots_subs/hi_api/h_wd_newapi/wd_newapi_bot.py @@ -12,21 +12,26 @@ logger = logging.getLogger(__name__) -class WdAPI(WdErrorsHandler): - def __init__(self, login_bot, mr_or_bot: str = "bot") -> None: +class WdAPI: + def __init__( + self, + login_bot: WikiLoginClient, + mr_or_bot: str = "bot", + ) -> None: # --- - self.login_bot: WikiLoginClient = login_bot + self.wd_error_handler = WdErrorsHandler() + self.login_bot = login_bot # --- self.lang = "test" if "testwikidata" in sys.argv else "www" self.family = "wikidata" # --- self.usernamex = self.login_bot.username # --- - WdErrorsHandler.__init__(self) - # --- logger.info(f"<> WdAPI: {mr_or_bot}, {self.usernamex=} \n") - def post_to_newapi(self, params=None, data=None, tage: str = "", editgroups: str = "", max_retry: int = 0, **kwargs): + def post_to_newapi( + self, params=None, data=None, tage: str = "", editgroups: str = "", max_retry: int = 0, **kwargs + ): # --- if data is None: data = {} @@ -64,7 +69,7 @@ def post_to_newapi(self, params=None, data=None, tage: str = "", editgroups: str # --- if error: # --- - er = self.handle_err_wd(error, function="", params=params) + er = self.wd_error_handler.handle_err_wd(error, function="", params=params) # --- logger.info(f"<>post_to_newapi: <> handle_err_wd: {er}") # return er diff --git a/src/bots_subs/hi_api/utils/handle_wd_errors.py b/src/bots_subs/hi_api/utils/handle_wd_errors.py index 5b33336..ba5058e 100644 --- a/src/bots_subs/hi_api/utils/handle_wd_errors.py +++ b/src/bots_subs/hi_api/utils/handle_wd_errors.py @@ -83,8 +83,10 @@ def handle_err_wd( logger.info("<> ** maxlag. ") return False # --- - params["data"] = {} - logger.info(f"<>{function} ERROR: <>info: {err_info}, {params=}") + params_v = params if params else {} + params_v["data"] = {} + # --- + logger.info(f"<>{function} ERROR: <>info: {err_info}, {params_v=}") # --- if "raise" in sys.argv: raise Exception(error) diff --git a/src/bots_subs/hi_api/utils/lag_bot.py b/src/bots_subs/hi_api/utils/lag_bot.py index 5321f17..d2b6199 100644 --- a/src/bots_subs/hi_api/utils/lag_bot.py +++ b/src/bots_subs/hi_api/utils/lag_bot.py @@ -45,7 +45,7 @@ def find_lag(err) -> None: else: logger.info(f"<> lagese == FFa_lag[1] ({FFa_lag[1]})") # --- - logger.info(f"<> max lag: sleep for {lagese+1} secound.") + logger.info(f"<> max lag: sleep for {lagese + 1} secound.") # --- time.sleep(FFa_lag[1] + 1) diff --git a/src/cy/jsub.py b/src/cy/jsub.py index 4ce4b5e..13e1f02 100644 --- a/src/cy/jsub.py +++ b/src/cy/jsub.py @@ -22,10 +22,10 @@ """ +import wd_gent from cy_bot.do_text import do_One_Page -from shared.api_page import load_main_api -import wd_gent +from shared.api_page import load_main_api skip_titles = [ "قالب:نتيجة سباق الدراجات", diff --git a/src/cy/mv.py b/src/cy/mv.py index b0a2c7d..9975b1a 100644 --- a/src/cy/mv.py +++ b/src/cy/mv.py @@ -18,10 +18,10 @@ import sys import tqdm +import wd_gent import wikitextparser as wtp -from shared.api_page import load_main_api -import wd_gent +from shared.api_page import load_main_api logger = logging.getLogger(__name__) diff --git a/src/des/desc.py b/src/des/desc.py index 2550aa9..a575209 100644 --- a/src/des/desc.py +++ b/src/des/desc.py @@ -46,8 +46,6 @@ import re import sys -from shared.api_page import load_main_api - from bots_subs.hi_api import HimoAPIBot from bots_subs.qs_bot import QS_line from bots_subs.wd_api import wd_bot @@ -55,6 +53,8 @@ from des.contries2 import ContriesTable2 from des.places import placesTable +from shared.api_page import load_main_api + WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") logger = logging.getLogger(__name__) diff --git a/src/des/fam.py b/src/des/fam.py index 22435f4..8deb0cf 100644 --- a/src/des/fam.py +++ b/src/des/fam.py @@ -15,7 +15,6 @@ import sys import tqdm - from bots_subs.wd_api import newdesc, wd_sparql_bot from des.railway import railway_tables, work_railway from desc_dicts.descraptions import ( diff --git a/src/des/film.py b/src/des/film.py index 16f067d..d6b6bad 100644 --- a/src/des/film.py +++ b/src/des/film.py @@ -12,7 +12,6 @@ import re import pywikibot - from bots_subs.wd_api import wd_sparql_bot from bots_subs.wd_api.wd_desc import work_api_desc diff --git a/src/des/ru_st_2_latin.py b/src/des/ru_st_2_latin.py index cabc64c..e04d93c 100644 --- a/src/des/ru_st_2_latin.py +++ b/src/des/ru_st_2_latin.py @@ -10,9 +10,8 @@ import sys import pywikibot -from pywikibot.pagegenerators import WikidataSPARQLPageGenerator - from bots_subs.hi_api import HimoAPIBot +from pywikibot.pagegenerators import WikidataSPARQLPageGenerator WD_API_Bot = HimoAPIBot(mr_or_bot="bot", www="www") diff --git a/src/nep/bots/scientific_article.py b/src/nep/bots/scientific_article.py index 737ee04..dcd4b4f 100644 --- a/src/nep/bots/scientific_article.py +++ b/src/nep/bots/scientific_article.py @@ -8,7 +8,6 @@ import re import dateutil.parser - from desc_dicts.descraptions_dict import Scientific_descraptions from nep.bots.helps import Get_P_API_time diff --git a/src/nep/si3g.py b/src/nep/si3g.py index 518ed11..e932058 100644 --- a/src/nep/si3g.py +++ b/src/nep/si3g.py @@ -54,11 +54,11 @@ import time from pathlib import Path -from shared.api_page import load_main_api - import wd_gent from nep import si3 +from shared.api_page import load_main_api + logger = logging.getLogger(__name__) sys.argv.append("-family:wikidata") diff --git a/src/people/new3.py b/src/people/new3.py index 575f2c5..2494528 100644 --- a/src/people/new3.py +++ b/src/people/new3.py @@ -155,9 +155,7 @@ def check_quarry_new(tab): # logger.info( "@@".join( tabe[numb] ) ) logger.info(f"find qua for {len(value)} description.") # --- - data_str = " ".join( - f'"{f}"@en "{f.lower()}"@en' for f in tabe[numb] - ) + data_str = " ".join(f'"{f}"@en "{f.lower()}"@en' for f in tabe[numb]) # --- qua = f"""SELECT (concat(strafter(str(?item),"/entity/")) as ?q)#?item diff --git a/src/prop_labs/fill_ar_props.py b/src/prop_labs/fill_ar_props.py index d1565f1..a661459 100644 --- a/src/prop_labs/fill_ar_props.py +++ b/src/prop_labs/fill_ar_props.py @@ -33,9 +33,8 @@ from SPARQLWrapper import JSON, SPARQLWrapper from tqdm import tqdm from translate_bot import translate_en_to_ar -from wd_Session import WikidataSession - from wd_core_useraccount import User_tables_ibrahem +from wd_Session import WikidataSession logger = logging.getLogger(__name__) diff --git a/src/prop_labs/wd_Session.py b/src/prop_labs/wd_Session.py index 8ea968d..79e0da1 100644 --- a/src/prop_labs/wd_Session.py +++ b/src/prop_labs/wd_Session.py @@ -8,7 +8,6 @@ from typing import Dict, List import requests - from wd_core_useraccount import User_tables_ibrahem logger = logging.getLogger(__name__) diff --git a/src/wd_gent.py b/src/wd_gent.py index 57a8824..84bf5d8 100644 --- a/src/wd_gent.py +++ b/src/wd_gent.py @@ -6,6 +6,7 @@ import pywikibot from pywikibot import pagegenerators + from shared.api_page import load_main_api logger = logging.getLogger(__name__) diff --git a/tests/desc_dicts/test_utils.py b/tests/desc_dicts/test_utils.py index d2242c3..7167e32 100644 --- a/tests/desc_dicts/test_utils.py +++ b/tests/desc_dicts/test_utils.py @@ -3,7 +3,6 @@ import os import pytest - from src.wd_utils.utils import ( are_dates_same, get_file_date, From 6ab558461d63a150e8b33dc4cb94260ea585dee3 Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 07:41:53 +0300 Subject: [PATCH 10/11] . --- src1/lex-examples/gemini.py | 1 - tests/conftest.py | 2 -- tests/desc_dicts/test_utils.py | 2 -- 3 files changed, 5 deletions(-) diff --git a/src1/lex-examples/gemini.py b/src1/lex-examples/gemini.py index d6a8222..1143b45 100644 --- a/src1/lex-examples/gemini.py +++ b/src1/lex-examples/gemini.py @@ -1,5 +1,4 @@ import json -import re import sys from pathlib import Path diff --git a/tests/conftest.py b/tests/conftest.py index d9aaf16..87887af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,8 +3,6 @@ Common fixtures for mocking API, DB, and other dependencies. """ -import sys -from unittest.mock import MagicMock, patch import pytest from pytest_socket import disable_socket diff --git a/tests/desc_dicts/test_utils.py b/tests/desc_dicts/test_utils.py index 7167e32..f77c00e 100644 --- a/tests/desc_dicts/test_utils.py +++ b/tests/desc_dicts/test_utils.py @@ -1,8 +1,6 @@ -import datetime import json import os -import pytest from src.wd_utils.utils import ( are_dates_same, get_file_date, From d00d96fceb7172dd5864e9925140ccec7071bdef Mon Sep 17 00:00:00 2001 From: Ibrahem Date: Tue, 7 Jul 2026 08:05:15 +0300 Subject: [PATCH 11/11] Update conftest.py --- tests/conftest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 87887af..4465d2b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,5 +9,12 @@ @pytest.fixture(autouse=True) -def stop_nets() -> None: +def stop_nets(request): + # Check if 'network' mark is present in the current test item + if "network" in request.node.keywords: + from pytest_socket import enable_socket + + enable_socket() + return + # Otherwise, disable the socket for all other tests disable_socket(allow_unix_socket=True)