Manual:Pywikibot/PAWS/ur

This page is a translated version of the page Manual:Pywikibot/PAWS and the translation is 37% complete.
Outdated translations are marked like this.
See Wikitech:PAWS for more details.

اس دستاویز میں نوٹ بک کے ذریعہ پائی ویکیپیڈیا کے استعمال کا خاکہ پیش کیا گیا ہے، یہ نوٹ بک ویکیمیڈیا لیبز پر ہوسٹ کی گئی ہے جو 'PAWS' (Pywikibot: A Web Shell) استعمال کرتا ہے۔

PAWS Terminal supports copy and paste in Chromium-based browsers only. (Google Chrome, Opera, Safari and new Microsoft Edge are fine.) If you use a different browser, you can try with context menu only (right-click) or you will need to manually type the commands mentioned in this walk-through. You can also create a bash file with in content the command and call in terminal with bash file.sh.
Warning Warning: All notebooks and terminals in PAWS are subject to termination without notice. You are encouraged to run your task on other places (such as Toolforge) if your task lasts for more than hours.

ویکیمیڈیا کھاتہ بنائیں

اس طریقہ کار کی پیروی کرنے کے لیے ویکیمیڈیا منصوبہ پر آپ کا کھاتہ ہونا ضروری ہے۔

کھاتہ بن جانے کے بعد https://test.wikipedia.org/ پر جائیں اور اوپر دائیں جانب اپنا نام جانچیں۔

If you are a new user on Wikimedia log in with your account on Meta-Wiki, Wikipedia, Wikidata, and Commons. And in each of them read and delete all pending messages you have (on the top).

نوٹ بک میں سائن ان

ہوسٹ کردہ نوٹ بک شروع کرنے کے لیے https://hub-paws.wmcloud.org/hub پر جائیں۔

"Sign in with MediaWiki" پر کلک کریں، بعد ازاں جب "Use OAuth for Authentication" کی اجازت مانگی جائے تو "Allow" پر کلک کریں۔ پہلی مرتبہ جب آپ PAWS میں رسائی حاصل کریں تو آپ کو ایک سرور بنانا پڑے گا۔ Click the green "Start my Server" button. It's normal to wait a few minutes for the new server to start up.

سرور کی تخلیق مکمل ہوتے ہی آپ https://paws.wmflabs.org/paws/user/<username>/tree جیسے کسی ربط پر پہنچ جائیں گے۔

ٹرمینل شروع کریں

نیا تعاملی ٹرمینل شروع کرنے کے لیے،

  1. [$paws اپنے PAWS کے سرورق] پر جائیں
  2. دائیں جانب موجود 'New' پر کلک کریں، اور
  3. 'Terminal' منتخب کریں۔
  1. click: File > New > Terminal

اس کے بعد https://paws.wmflabs.org/paws/user/<username>/terminals/1 ربط کے ساتھ ایک نیا دریچہ کھلے گا، جس میں لینکس کا '$' پرامپٹ نظر آئے گا۔

یہ ٹرمینل کوئی ایمیولیٹر نہیں ہے۔ یہ حقیقی بیش شیل ہے جو ڈوکر کنٹینر میں واقع حقیقی لینکس تنصیب کے ایک جز کے طور پر نصب ہے، چنانچہ آپ کسی بھی بیش کمانڈ کو استعمال کر سکتے ہیں، نیز لینکس پر نصب شدہ دیگر دستیاب کمانڈز بھی استعمال کیے جا سکتے ہیں۔

کچھ دستیاب کمانڈزدیکھنے کے لیے ls /bin/ کمانڈ استعمال کر سکتے ہیں۔

$ ls /bin/
bash         cat            domainname  journalctl  mkdir          pwd         stty                            tar           zcmp
unzip2       chacl          echo        kill        mknod          rbash       su                              tempfile      zdiff
../..
$ ls /usr/bin/
2to3-3.4                 dvipdf                     lcf                         printf               systemd-path                         
X11                      dwp                        ld                          prlimit              systemd-run
../..

To see them all, press TAB twice.


Login to the wiki

This will establish your account on the server and allow you to log in from the command line. درج ذیل کمانڈ اس بات کی تصدیق کرے گی کہ آپ https://test.wikipedia.org/ میں لاگ ان ہو سکتے ہیں۔ یہ OAuth کا استعمال کرتا ہے، لہذا پاسورڈ درج کرنے کی ضرورت نہیں ہے۔

$ pwb.py login
Logging in to wikipedia:test as <username>
Logged in on wikipedia:test as <username>.

You can connect pywikibot to a different wiki by creating a file named user-config.py in your $HOME directory (/home/paws) and adding mylang and family variables:

mylang = 'test'
family = 'wikipedia'

You can type vim user-config.py in the terminal, then I to insert text, add the text, then Esc to exist insert mode, then :wq and Enter to finishing editing.


تخلیق صفحہ

نیا صفحہ بنانے کے لیے ٹرمینل میں درج ذیل کمانڈ درج کریں، اس کمانڈ میں موجود '<username>' کو اپنے صارف نام سے تبدیل کر دیں اور جب آپکی تبدیلیوں کو قبول کرنے کی درخواست کی جائے تو 'Y' دبائیں۔

$ pwb.py add_text -up -talk -page:"User talk:<username>" -text:"Hello. ~~~~"
Loading User talk:<username>...

>>> User talk:<username> <<<
@@ -0,0 +1 @@
+ Hello. ~~~~

Do you want to accept these changes? ([Y]es, [N]o, [a]ll, open in [b]rowser): Y
Page [[User talk:<username>]] saved

اب آپ ویکی میں ترمیم کر چکے ہیں۔ اپنی تبدیلیوں کو دیکھنے کے لیے اپنے براؤزر میں https://test.wikipedia.org/wiki/User_talk:<username> ربط کھول سکتے ہیں۔

ان کمانڈ لائن اسکرپٹس کے متعلق مزید تفصیلات پڑھنے کے لیے '-help' کمانڈ لائن آپشن استعمال کر سکتے ہیں۔

$ pwb.py add_text -help
...

صفحہ لائیں

Fetching many pages is achieved with the "listpages" command.

To get the contents of the page you created in the previous section, enter the following command:

$ pwb.py listpages -page:"User talk:<username>" -save
   1 <username>
Saving User talk:<username> to /home/paws/User_talk_<username>
1 page(s) found

Now if you run $ ls the saved page should be present.

حقیقی اسکرپٹ نمونہ

When a website used on Wikipedia changes its URL, the links on Wikipedia become outdated, and possible also dead links if the website doesn't redirect from the old URLs to the new URLs. For example, Encyclopedia Britannica (EB) has changed their links, such as moving pages from http://www.britannica.com/EBchecked/media/ to http://www.britannica.com/topic/[topic name]/images-videos/*. You can find the list of usages of the old URL on English Wikipedia at w:Special:LinkSearch/http://www.britannica.com/EBchecked/media. Updating all those links manually will be very time consuming. Thankfully EB has maintained redirects from their old URLs to the new URLs, so this does not need to be fixed immediately.

For a simpler example, English Wikipedia currently contains links to http://britannica.com/EBchecked/ instead of http://www.britannica.com/EBchecked/; i.e. a 'www.' subdomain is missing in the URL.

There are currently 14 cases on English Wikipedia: w:Special:LinkSearch/http://britannica.com/EBchecked/

Wikipedia in other language also have this problem. e.g. there is one case on German Wikipedia: w:de:Spezial:Weblinksuche/http://britannica.com/EBchecked/

In order to fix those links, we can use Pywikibot replace.py script. In this demo we will use the '-simulate' argument to avoid writing to the wiki, as there are strict rules about automated editing of English Wikipedia.

First, let's list all of the pages which link to http://britannica.com/EBchecked/.

$ pwb.py listpages -lang:en -weblink:"britannica.com/EBchecked/"
   1 Bhatner fort
   2 Mohammad Ishaq Khan
   3 Fringe theories/Noticeboard/Archive 7
   4 El Riego phase
   5 Catalonia/Archive 4
   6 Stephen I of Hungary
   7 Stephen I of Hungary/Archive 1
   8 Väinö Tanner
   9 Tokaji
  10 Transylvania/Archive5
  11 Hungarians in Romania
  12 Transylvania
  13 Uttarakhand
  14 Françoise Giroud
14 page(s) found

Now we check those pages actually have the literal URL in the page; i.e. they are not using a template.

$ pwb.py listpages -lang:en -weblink:"britannica.com/EBchecked/" -grep:"britannica.com\/EBchecked"
   1 Bhatner fort
   2 Mohammad Ishaq Khan
   3 Fringe theories/Noticeboard/Archive 7
   4 El Riego phase
   5 Catalonia/Archive 4
   6 Stephen I of Hungary
   7 Stephen I of Hungary/Archive 1
   8 Väinö Tanner
   9 Tokaji
  10 Transylvania/Archive5
  11 Hungarians in Romania
  12 Transylvania
  13 Uttarakhand
  14 Françoise Giroud
14 page(s) found

Now use replace to add the missing "www."

$ pwb.py replace -lang:en -simulate -weblink:"britannica.com/EBchecked/" -grep:"britannica.com\/EBchecked" "http://britannica.com/EBchecked/" "http://www.britannica.com/EBchecked/"
The summary message for the command line replacements will be something like: Bot: Automated text replacement  (-http://britannica.com/EBchecked/ +http://www.britannica.com/EBchecked/)
Press Enter to use this automatic message, or enter a description of the
changes your bot will make: 
Logging in to wikipedia:en as <username>
Retrieving 14 pages from wikipedia:en.
Retrieving 14 pages from wikipedia:en.


>>> Stephen I of Hungary <<<
@@ -47 +47 @@
- Stephen's birth date is uncertain because it was not recorded in contemporaneous documents.{{sfn|Györffy|1994|p=64}} Hungarian and Polish chronicles written centuries later give three different years: 967, 969 and 975.{{sfn|Kristó|2001|p=15}} The unanimous testimony of his three late 11th-century or early 12th-century [[hagiographies]] and other Hungarian sources, which state that Stephen was "still an adolescent" in 997,<ref>''Hartvic, Life of King Stephen of Hungary'' (ch. 5), p. 381.</ref> substantiate the reliability of the later year (975).{{sfn|Györffy|1994|p=64}}{{sfn|Kristó|2001|p=15}} Stephen's ''[[Life of Saint Stephen, King of Hungary (Vita minor)|Lesser Legend]]'' adds that he was born in [[Esztergom]],{{sfn|Györffy|1994|p=64}}{{sfn|Kristó|2001|p=15}}<ref name=Britannica>{{cite encyclopedia|title=Stephen I|url=http://britannica.com/EBchecked/topic/565415/Stephen-I|encyclopedia=[[Encyclopædia Britannica]]|publisher=Encyclopædia Britannica, Inc.|year=2008|accessdate=2008-07-29}}</ref> which implies that he was born after 972 because his father, [[Géza, Grand Prince of the Hungarians]], chose Esztergom as royal residence around that year.{{sfn|Györffy|1994|p=64}} Géza promoted the spread of Christianity among his subjects by force, but never ceased worshipping pagan gods.{{sfn|Kontler|1999|p=51}}{{sfn|Berend|Laszlovszky|Szakács|2007|p=331}} Both his son's ''[[Life of Saint Stephen, King of Hungary (Vita maior)|Greater Legend]]'' and the nearly contemporaneous [[Thietmar of Merseburg]] described Géza as a cruel monarch, suggesting that he was a despot who mercilessly consolidated his authority over the rebellious Hungarian lords.{{sfn|Berend|Laszlovszky|Szakács|2007|p=331}}{{sfn|Bakay|1999|p=547}}
+ Stephen's birth date is uncertain because it was not recorded in contemporaneous documents.{{sfn|Györffy|1994|p=64}} Hungarian and Polish chronicles written centuries later give three different years: 967, 969 and 975.{{sfn|Kristó|2001|p=15}} The unanimous testimony of his three late 11th-century or early 12th-century [[hagiographies]] and other Hungarian sources, which state that Stephen was "still an adolescent" in 997,<ref>''Hartvic, Life of King Stephen of Hungary'' (ch. 5), p. 381.</ref> substantiate the reliability of the later year (975).{{sfn|Györffy|1994|p=64}}{{sfn|Kristó|2001|p=15}} Stephen's ''[[Life of Saint Stephen, King of Hungary (Vita minor)|Lesser Legend]]'' adds that he was born in [[Esztergom]],{{sfn|Györffy|1994|p=64}}{{sfn|Kristó|2001|p=15}}<ref name=Britannica>{{cite encyclopedia|title=Stephen I|url=http://www.britannica.com/EBchecked/topic/565415/Stephen-I|encyclopedia=[[Encyclopædia Britannica]]|publisher=Encyclopædia Britannica, Inc.|year=2008|accessdate=2008-07-29}}</ref> which implies that he was born after 972 because his father, [[Géza, Grand Prince of the Hungarians]], chose Esztergom as royal residence around that year.{{sfn|Györffy|1994|p=64}} Géza promoted the spread of Christianity among his subjects by force, but never ceased worshipping pagan gods.{{sfn|Kontler|1999|p=51}}{{sfn|Berend|Laszlovszky|Szakács|2007|p=331}} Both his son's ''[[Life of Saint Stephen, King of Hungary (Vita maior)|Greater Legend]]'' and the nearly contemporaneous [[Thietmar of Merseburg]] described Géza as a cruel monarch, suggesting that he was a despot who mercilessly consolidated his authority over the rebellious Hungarian lords.{{sfn|Berend|Laszlovszky|Szakács|2007|p=331}}{{sfn|Bakay|1999|p=547}}

Do you want to accept these changes? ([y]es, [N]o, [e]dit, open in [b]rowser, [a]ll, [q]uit): N

...

In PAWS, and any terminal that supports color, the diff of changes will show the added "www." in green text color, making it easier to find the proposed changes.

پائی ویکی بوٹ میں

  Warning: Don't write passwords in files of server, the files are public!

اس کے بعد ہم PAWS کی پائیتھون نشست استعمال کریں گے۔

  1. اپنے [$paws PAWS سرورق] پر جائیں،
  2. دائیں جانب موجود 'New' پر کلک کریں، اور
  3. 'Python 3' منتخب کریں۔

اب نیا دریچہ کھل جائے گا۔

خانہ ترمیم میں ذیل میں موجود متن درج کریں اور Cell منیو سے 'Run' منتخب کریں (یا shift+enter دبائیں)

import pywikibot

نیچے نیا خانہ ترمیم کھل جائے گا۔ APISite object جو https://test.wikipedia.org/ سے مربوط ہو، کو تخلیق کرنے کے لیے درج ذیل متن درج کریں۔

site = pywikibot.Site('test', 'wikipedia')

اب نئے خانہ ترمیم میں "site" درج کریں اور "Run" پر کلک کریں۔

site

اب ایسا ظاہر ہونا چاہیے

 Out[3]: APISite("test", "wikipedia")

صفحہ آبجیکٹ بنائیں:

page = pywikibot.Page(site, 'test')

موجود ہے یا نہیں اسے جانچیں:

page.exists()

اب اس طرح ظاہر ہونا چاہیے

 VERBOSE:pywiki:Found 1 wikipedia:test processes running, including this one.
 Out[5]: True

صفحہ پر موجود متن دکھائیں:

page.text

آبجیکٹ میں موجود متن صفحہ کو تبدیل کریں:

page.text = 'Hello world'

ویکی میں صفحہ محفوظ کریں:

page.save()

اب جواب اس طرح ہوگا:

Page [[Test]] saved
INFO:pywiki:Page [[Test]] saved

The interactive Python 3 notebook allows many lines to be run together. The above could be put into one text box and Run

import pywikibot

site = pywikibot.Site('test', 'wikipedia')
page = pywikibot.Page(site, 'test')

page.text = 'Hello world!'
page.save()

The log of your interactive Python session can be saved or downloaded for future reference.

PAWS کے ذریعہ آن لائن دستاویزوں تک رسائی

Pywikibot documentation may be found at https://doc.wikimedia.org/pywikibot/. It is primarily sourced from docstrings, which can be loaded in the interactive Python 3 notebook using the Python built-in function help().

For example, to look at the arguments for the save method above, run either:

help(page.save)

or

help(pywikibot.Page.save)

پائی ویکی بوٹ اسکرپٹس میں ترمیم

پائی ویکی بوٹ کا کتب خانہ اور اسکرپٹس /srv/paws میں رکھی گئی ہیں اور یہ ریڈ آنلی ہیں۔ پائی ویکی بوٹ کے نصب شدہ کتب خانہ میں PAWS کے ذریعہ ترمیم نہیں کی جا سکتی۔

البتہ ان اسکرپٹس کو PAWS میں پیسٹ کرنے کے بعد ان میں ترمیم کی جا سکتی ہے۔

ترمیم شدہ "checkimages.py" چلانے کے لیے

  1. ٹرمینل میں "cp /srv/pwb/scripts/checkimages.py ~" درج کریں۔
  2. اپنے PAWS سرورق میں checkimages.py فائل پر کلک کریں
  3. کوڈ میں ترمیم کریں اور اپنی ترامیم محفوظ کریں
  4. ٹرمینل میں "pwb.py ~/checkimages.py -simulate" درج کریں۔
  1. In the terminal, enter cp /srv/paws/pwb/scripts/checkimages.py ~
  1. In a browser, go to your PAWS home and click on the file checkimages.py.
  1. In the browser, you can edit the file.

Edit the code -- for instance, just after the start = time.time() code on line 1775, add a new line 1776 that will print out your name: print("MYNAME's version.")

  1. In the editing interface, use the File menu and click Save to save your modifications.
  1. In the terminal, enter pwb.py ~/checkimages.py -simulate -limit:10

(If no '-limit:x' defined, the program would run until all images checked, it may take long time.)

See also


If you need more help on setting up your Pywikibot visit the #pywikibot IRC channel connect or pywikibot@ mailing list.