Manual:Pywikibot/pagefromfile.py/fr

From mediawiki.org
This page is a translated version of the page Manual:Pywikibot/pagefromfile.py and the translation is 0% complete.

pagefromfile.py is a Pywikibot script used to upload pages to a wiki from a text file.

This bot takes its input from the UTF-8 text file that contains a number of pages to be put on the wiki. The pages should all have the same beginning and ending text (which may not overlap). The beginning and ending text is not uploaded with the page content by default.

A page name is by default taken from the first text block of the page content that is marked in bold (wrapped between ''' and '''). If you expect the page title not to be present in the text or marked by different markers, use -titlestart, -titleend, and -notitle parameters.

Specific arguments

ParamètreDescription
-file:xxx The filename we are getting our material from, the default value is "dict.txt". Notice that if the source file name contains any space character, you should wrap it with double quotations (i.e. -file:"Page title").
-begin:xxx The text that marks the beginning of a page, the default value is "{{-start-}}"
-end:xxx The text that marks the end of the page, the default value is "{{-stop-}}"
-include Include the beginning and end markers to the page
-textonly Text is given without markers. Only one page text is given. -begin and -end options are ignored.
-titlestart:xxx The text used in place of ''' for identifying the beginning of a page title
-titleend:xxx The text used in place of ''' for identifying the end of the page title
-notitle Do not include the page title, including titlestart and titleend, to the page. Can be used to specify unique page title above the page content
-title:xxx The page title is given directly. Ignores -titlestart, -titleend and -notitle options
-nocontent:xxx If the existing page contains specified statement, the page is skipped from editing
-noredirect Do not upload on redirect pages
-summary:xxx The text used as an edit summary for the upload. If the page exists, standard messages for prepending, appending, or replacement are appended after it
-autosummary Use MediaWiki's autosummary when creating a new page, overrides -summary
-minor Set the minor edit flag on page edits
-showdiff Show difference between current page and page to upload, also forces the bot to ask for confirmation on every edit

If the page to be uploaded already exists, it is skipped by default. But you can override this behavior if you want to:


ParamètreDescription
-appendtop Add the text to the top of the existing page
-appendbottom Add the text to the bottom of the existing page
-force Overwrite the existing page

It is possible to define a separator after the 'append' modes which is added between the existing and the new text. For example a parameter -appendtop:foo would add 'foo' between them. A new line can be added between them by specifying '\n' as a value.

Examples

Basic example

In the most basic form, pagefromfile takes a single text file with several wiki pages in it as input. For example, the contents could be:

{{-start-}}
'''Pywikibot''' is a Python library and collection of scripts that automate work on MediaWiki sites.
Originally designed for Wikipedia, it is now used throughout the Wikimedia Foundation's projects and on many other wikis.
{{-stop-}}
{{-start-}}
'''AutoWikiBrowser''' (often abbreviated '''AWB''') is a semi-automated MediaWiki editor designed to make tedious or repetitive editing tasks quicker and easier.
{{-stop-}}

Store this as a UTF-8 encoded text file, for example as 'pages.txt'. You can then run python pwb.py pagefromfile -showdiff -file:pages.txt. This will let the bot create Pywikibot and AutoWikiBrowser -- the first '''bolded''' elements in both pages. -showdiff will give you the opportunity to review changes before they are being made.

Different page titles

Often, the first bolded element is not necessarily the correct page title. For example, we might want to place the article about AutoWikiBrowser on AWB instead. To do so, add a line in front of each article, with the correct page title between triple quotes (i.e., bolded):

{{-start-}}
'''Pywikibot'''
'''Pywikibot''' is a Python library and collection of scripts that automate work on MediaWiki sites.
Originally designed for Wikipedia, it is now used throughout the Wikimedia Foundation's projects and on many other wikis.
{{-stop-}}
{{-start-}}
'''AWB'''
'''AutoWikiBrowser''' (often abbreviated '''AWB''') is a semi-automated MediaWiki editor designed to make tedious or repetitive editing tasks quicker and easier.
{{-stop-}}

and add the -notitle parameter to the call, i.e.: python pwb.py pagefromfile -showdiff -file:pages.txt -notitle.


Arguments globaux disponibles

Ces options remplaceront celles définies dans le fichier de configuration user-config.py .

Options globales
Paramètre Description Nom du paramètre de configuration dans user-config.py
-dir:PATH Lit les données de configuration du robot dans le dossier donné par PATH, au lieu du dossier par défaut.  
-config:fichier Nom du fichier de configuration utilisateur. Default is user-config.py. user-config.py
-lang:xx Définit la langue du wiki sur lequel vous voulez travailler, en outrepassant la configuration de user-config.py. xx doit être le code de la langue (exemple : fr). mylang
-family:xyz Définit la famille du wiki sur lequel vous voulez travailler, tel que wikipedia, wikitionary, wikitravel... Cela outrepassera la configuration de user-config.py. family
-user:xyz Se connecter en tant qu'utilisateur xyz au lieu du nom d'utilisateur par défaut. usernames
-daemonize:xyz Rend le contrôle immédiatement au terminal et redirige la sortie standard (stdout) et la sortie en erreur (stderr) vers le fichier xyz (seulement utilisé pour les robots qui n'ont pas besoin de l'entrée standard (stdin) ).  
-help Affiche le texte d'aide.  
-log Active l'enregistrement des journaux de connexion, en utilisant le nom de fichier par défaut "nom_du_script-bot.log" dans le sous dossier logs. log
-log:xyz Active l'enregistrement des logs dans un fichier avec xyz pour nom. logfilename
-nolog Désactive l'enregistrement des logs (activé par défaut)  
-maxlag Définir le maxlag, en secondes. Reporte les modifications du robot lors de périodes de latence du serveur. La valeur par défaut est celle de config.py. maxlag
-putthrottle:n
-pt:n
-put_throttle:n
Définit le temps minimum (en secondes) que le robot doit attendre entre deux enregistrements de pages. put_throttle
-debug:item
-debug
Active le fichier de log et incluant plus particulièrement les données de débogage pour l'élément item (1er cas) ou pour tous les éléments (2nd cas) debug_log
-verbose
-v
Demande au robot d'être plus verbeux ce qui peut aider pour le débogage. verbose_output
-cosmeticchanges
-cc
Inverse et outrepasse la valeur du paramètre cosmetic_changes de config.py ou de user-config.py (l'active si rien n'est mentionné dans ces fichiers). Tous les autre paramètres et restrictions restent inchangés. cosmetic_changes
-simulate Désactiver l'écriture sur serveur. Utile pour les tests et le débogage de nouveau code (si utilisé, ne fait aucun changement réel, mais montre ce qui aurait été changé). simulate
-<variable de configuration>:n Vous pouvez utilisez toutes les variables numériques de configuration données en tant qu'options et les modifier avec une ligne de commande.