Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrIbrahem committed Apr 18, 2024
1 parent 703ad25 commit 44600df
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 6 deletions.
4 changes: 4 additions & 0 deletions fix_mass/fix_sets/fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def main(ids):
printe.output(f"found {len(ids) - len(ids2)} done")
ids = ids2
# ---
printe.output(f"<<purple>> len of ids: {len(ids)}")
printe.output(f"<<purple>> len of ids: {len(ids)}")
printe.output(f"<<purple>> len of ids: {len(ids)}")
# ---
for study_id in ids:
work_one_study(study_id)

Expand Down
1 change: 1 addition & 0 deletions ncc_core/nc_import/api_bots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# pip install scrapy
11 changes: 11 additions & 0 deletions ncc_core/nc_import/api_bots/ncc_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
from nc_import.api_bots.ncc_page import ncc_MainPage, ncc_NEW_API
"""
# ---
from newapi.ncc_page import MainPage, NEW_API

ncc_NEW_API = NEW_API
ncc_MainPage = MainPage
53 changes: 53 additions & 0 deletions ncc_core/nc_import/api_bots/wiki_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
from nc_import.api_bots.wiki_page import ncc_MainPage, ncc_NEW_API
"""
import sys
from newapi.super import super_login
from newapi.super import bot_api
from newapi.super import super_page
from newapi.super import catdepth_new
from mdpy.bots import user_account_new

# ---
# User_tables = {"username": user_account_new.my_username, "password": user_account_new.my_password}
# ---
# if "botuser" in sys.argv:
User_tables = {"username": user_account_new.bot_username, "password": user_account_new.bot_password}
# ---
super_login.User_tables["wikipedia"] = User_tables
# ---
Login = super_login.Login
# ---
bot_api.login_def = Login
super_page.login_def = Login
catdepth_new.login_def = Login
# ---
NEW_API = bot_api.NEW_API
MainPage = super_page.MainPage
change_codes = super_page.change_codes
CatDepth = catdepth_new.subcatquery
CatDepthLogin = catdepth_new.login_wiki
# ---
# xxxxxxxxxxx


def test():
page = MainPage("Mr. Ibrahem/sandbox", "ar", family="wikipedia")
exists = page.exists()
text = page.get_text()
timestamp = page.get_timestamp()
user = page.get_user()
links = page.page_links()
words = page.get_words()
purge = page.purge()
templates = page.get_templates()
save_page = page.save(newtext="", summary="", nocreate=1, minor="")


if __name__ == "__main__":
# python3 core8/pwb.py nc_import/api_bots/wiki_page ask
super_page.print_test[1] = True
super_login.print_test[1] = True
test()
5 changes: 3 additions & 2 deletions ncc_core/nc_import/bots/get_langs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"""
import re
import wikitextparser as wtp
from newapi.ncc_page import MainPage as ncc_MainPage
from nc_import.api_bots.ncc_page import ncc_MainPage
from newapi import printe



def get_text():
"""
Retrieves text content from a specific page.
Expand All @@ -21,6 +20,7 @@ def get_text():
# ---
return text


def get_langs_codes():
"""
Extracts language codes from the text content of a page.
Expand Down Expand Up @@ -51,6 +51,7 @@ def get_langs_codes():
# ---
return langs


if __name__ == "__main__":
# python3 core8/pwb.py nc_import/bots/get_langs
get_langs_codes()
2 changes: 1 addition & 1 deletion ncc_core/nc_import/bots/gt_pages.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from newapi.wiki_page import NEW_API
from nc_import.api_bots.wiki_page import NEW_API


def get_pages(code):
Expand Down
5 changes: 4 additions & 1 deletion ncc_core/nc_import/bots/import_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"""
import re
import sys
from newapi.ncc_page import MainPage as ncc_MainPage, NEW_API as ncc_NEW_API
from nc_import.api_bots.ncc_page import ncc_MainPage, ncc_NEW_API
from newapi import printe
from nc_import.bots import upload_file
from nc_import.bots.db import add_to_db

# upload = upload_file.upload_by_url(file_name, text, url, comment='', code="en", family="wikipedia")


Expand All @@ -24,6 +25,7 @@ def get_file_text(title):

return text


def categories_work(text):
"""
remove all categories from the text
Expand All @@ -35,6 +37,7 @@ def categories_work(text):
# ---
return text


def import_file(title, code):
"""
Imports a file from NC Commons to Wikipedia.
Expand Down
3 changes: 2 additions & 1 deletion ncc_core/nc_import/bots/upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# ---
sys.argv.append("botuser")
# ---
from newapi.wiki_page import NEW_API
from nc_import.api_bots.wiki_page import NEW_API

# api_new = NEW_API('ar', family='wikipedia')
# api_new.Login_to_wiki()
# json1 = api_new.post_params(params, addtoken=False)
Expand Down
2 changes: 1 addition & 1 deletion ncc_core/nc_import/bots/wrk_pages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import wikitextparser as wtp
from newapi import printe
from newapi.wiki_page import MainPage
from nc_import.api_bots.wiki_page import MainPage
from nc_import.bots.import_files import import_file

"""
Expand Down

0 comments on commit 44600df

Please sign in to comment.