Manual:Pywikibot/replace.py/tr

Replace.py, çerçevesinin bir parçasıdır.

Bu bot, metnin yerini alır. Bir XML dökümünden veya bir metin dosyasından hangi sayfaların değişiklik gerektirebileceği hakkında bilgi alır veya yalnızca tek bir sayfayı değiştirir. Daha fazla bilgi almak için şunu kullanın:

Windows kullanıyorsanız, " " komutunu atlayabilirsiniz.

Genel bakış
Bu betiğini temelde iki şekilde kullanabilirsiniz:


 * 1) Değiştirilecek metin ve değiştirilecek metin dahil olmak üzere tüm parametreleri komut satırına yazarsınız. Bu, basit görevler için kullanışlıdır. Örneğin,   yalnızca maddelerde  "color" kelimesini arar, küçük harf oluşumlarını "colour" olarak değiştirir, her seferinde değiştirmeyi onaylamanızı ister ve varsayılan düzenleme açıklamasını kullanır. Dikkatli olun, çünkü rengin renge değiştirilmemesi gereken durumlar vardır (örn. Cascading Style Sheets maddesinde); en azından her zaman doğru olduğundan% 100 emin olmadığınız sürece asla böyle bir değişikliği otomatik olarak çalıştırmayın! Bu, komutun neredeyse en basit şeklidir (minimum parametrelerde aşağıya bakın). , color kelimesini arama çubuğuna yazmaya eşdeğerdir ve makale toplamanın hızlı bir yoludur, ancak colored ve colors bulamayacaktır.
 * Eski veya yeni metin boşluk içeriyorsa, tırnak işareti kullanın!
 * Tekrarlanan görevler bir toplu iş dosyasında (Windows) veya kabuk betikte (Linux) saklanabilir.
 * 1) Eski ve yeni metin, istisnalar ve düzenleme yorumu dahil olmak üzere ana parametreleri bir dosyada saklarsınız. Birkaç görev (düzeltmeler adı verilir) tek bir dosyada saklanabilir ve tekrar tekrar kullanılabilir. Bu dosya ya pywikibot dağıtımınızda bulunan, ancak her güncellemede değişikliğe tabi olan   olabilir, bu nedenle onu kendiniz için kaydetmeniz gerekir ya da kişisel kullanım için tasarlanmış ancak Pywiki'ye dahil edilmeyen   olabilir ve   ile oluşturuldu. Bu sonuncusu biraz farklı bir sözdizimine sahiptir, ancak bir örneği vardır. Bu çok daha verimli ve esnektir ancak biraz hazırlık gerektirir. Bu iki yöntem birleştirilebilir; ancak, düzeltmede saklanan bazı parametreler komut satırında verilen karşılık gelen parametrenin üzerine yazılır.

Bu seçeneklerden birini seçtikten sonra, başka bir kararınız var:


 * 1) You make simple text replacements like the above one. This is a good way for changing words, templates, categories, section titles or names, but is not flexible. For example, the above command will replace "color", but not colors, colored and Color in upper case. (If you are worried only about the case, you may still type  .)
 * 2) You use regular expressions (often mentioned as regexes). These seek patterns and replace them with patterns. There are some examples in . For agglutinative and inflecting languages this is the only efficient way of spelling corrections.

Your third decision will be this:


 * 1) You search for pages to be modified in the live wiki. This will result in acceptable speed if you work with templates, categories or the search engine, but is usually very slow for simple iteration of pages, especially in large and medium sized wikis. So  is the least recommended way of usage as it wastes your time and the resources of the server. (However, sometimes it is necessary and unavoidable if your wiki does not have dumps.)
 * 2) You download an XML dump of your wiki from https://dumps.wikimedia.org (usually xxwiki-latest-pages-articles.xml.bz2) and use it with . This will speed up your bot and use your time as well as the time of your computer and the server more efficiently. This is the recommended way of searching for color, colors and colored together, because the search engine unfortunately does not handle regexes. The disadvantage of this method is that you won't find articles into which the given text has got since the composition of the last dump.
 * Direct access to the dumps of your wiki is something like huwiki/. Change the first two letters to your language code.
 * Dumps at the given link are available only for Wikimedia wikis. For other wikis, contact the maintainer of that wiki to learn if they have dumps.

And, last but not least, you face one more decision:
 * 1) You search for pages and modify them on the fly. This will again result in acceptable speed if you work with templates, categories or the search engine, but may be very slow if you just search for a regex in the complete namespace or wiki.

At least these data should be given for the bot every time:
 * Minimal set of parameters
 * 1) Where and how to search for the pages to be edited?
 * The corresponding parameter may be any of  etc.; see the Source section of the below table.
 * 1) The old text to be replaced and the new one to be substituted.
 * This may be one or more pairs of strings or the name of a fix.
 * 1) It is not mandatory, but usually worth and strongly recommended for beginners to limit the work to the main namespace with . Thus you can avoid changing the contributions of users on talk pages or correcting the title of an article on a page where the talk is just about that title. Visible part of templates (but not the code itself!) and file descriptions are also in the scope of readers. It is better not to modify talk pages, user pages and project pages (the "Wikipedia" namespace) in the first time, and it needs special care and community consensus even later. Don't be surprised of angry reactions or your bot being blocked if you omit the namespace parameter.

Dosyalar
The bot uses three files in addition to the framework:


 * : the main module
 * : a few predefined "fixes"
 * : a file to add ones own fixes. The file is created nearly empty by

Files that may be used for input and/or output:
 * : a file with a list of articles if specified with the parameter "-file"


 * : a local XML dump if used with parameter "-xml"
 * : the log with a name that may be specified with parameter "-log"

Yerel
You can run replace.py with the following parameters (for example, ).

Examples
If you want to change templates from the old syntax, e.g., to the new syntax, e.g., download an XML dump file (page table) from https://dumps.wikimedia.org, then use this command:

You can match patterns across more than one line:

You can insert or append text to a page (note the replacement text has embedded new lines):

If you have a dump called foobar.xml and want to fix typos, e.g. Errror -> Error, use this:

If you have a page called 'John Doe' and want to convert HTML tags to wiki syntax, use:

If you run the bot without arguments you will be prompted multiple times for replacements:

The script asks the user before modifying an article. It is recommended to double-check the result to be sure that the bot did not introduce errors (especially with misspelled words). It is possible to specify a set of articles with an external text file containing Wiki links :

The bot is then called using something like:

Rather than specifying regular expressions at the command line, it's preferable to add them to

Example: Replacing multiple paragraphs
The original text of the page Sandbox is: This page is for any tests.

Welcome to the sandbox!

If you want to switch the statement (the second one goes before the first one), you type the following syntax:

To add a new line we use.

Example: Plenty of unbolding within an article
In this article there were really lots of bolded episode titles in several tables that were to be unbolded. This is the case when you may want to use a bot for one single article and this shows the role of some interesting parameters.


 * What are we looking for?
 * Texts between pairs of ,
 * which are within a table (we don't want to replace in the rest of the article!),
 * but do not contain a  character (just for safety, to make sure we are still within one cell — we might perhaps omit this),
 * paying attention to having many occurrences within a table (recursion),
 * and that the tables are wrapped to several lines (dotall),
 * and that every table opening tag should match its own closing tag and every beginning of bold text should match its own closing  (that's why we use  s to make the expressions ungreedy).

With the text parts before, between and after the boldings — these are put in parentheses to be able to refer to them with their group numbers, respectively.
 * What do we replace it with?

(It is wrapped here for readability, but you should write to one line, of course.) The bot will ask for the title since we have not given it. Using double quotation marks fits to the command line and gives the freedom to use apostrophes in the expression.
 * The command

Here you are. (Don't click if your computer is not strong enough!)
 * Result:

Advanced use of fixes: own functions
Being a wizard by means of replace.py is not a dream if you are familiar with the basics of Python programming. textlib.py (another module of the pywikibot framework) has a wonderful but not widely used ability. If you write a function instead of a constant text or a regular expression to the replacement text or the exceptions, it will recognize and execute it. With a little bit of programming you may take advantage of this feature, and use replace.py at a higher level. Needless to say, using an own function gives much more flexibility than a simple regex. You may also use a function to generate the replacement expressions so as to keep them clearly arranged.

To learn how to use your own functions in fixes.py and user-fixes.py and what is this good for, see hu:Szerkesztő:Bináris/Fixes and functions HOWTO.