PGhosh

category.py problem

Jan 29th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.92 KB | None | 0 0
  1. STDOUT:
  2. Global arguments available for all bots:
  3.  
  4. -dir:PATH         Read the bot's configuration data from directory given by
  5.                  PATH, instead of from the default directory.
  6.  
  7. -lang:xx          Set the language of the wiki you want to work on, overriding
  8.                  the configuration in user-config.py. xx should be the
  9.                  language code.
  10.  
  11. -family:xyz       Set the family of the wiki you want to work on, e.g.
  12.                  wikipedia, wiktionary, wikitravel, ...
  13.                  This will override the configuration in user-config.py.
  14.  
  15. -user:xyz         Log in as user 'xyz' instead of the default username.
  16.  
  17. -daemonize:xyz    Immediately return control to the terminal and redirect
  18.                  stdout and stderr to xyz (only use for bots that require
  19.                  no input from stdin).
  20.  
  21. -help             Show this help text.
  22.  
  23. -log              Enable the logfile, using the default filename
  24.                  "category.log"
  25.                  Logs will be stored in the logs subdirectory.
  26.  
  27. -log:xyz          Enable the logfile, using 'xyz' as the filename.
  28.  
  29. -nolog            Disable the logfile (if it is enabled by default).
  30.  
  31. -loghandler:xyz   Choose a value for 'xyz' from 'TRFH' (TimedRotatingFile-
  32.                  Handler) or 'RFH' (RotatingFileHandler). Has to be defined
  33.                  before '-log' on command line.
  34.  
  35. -maxlag           Sets a new maxlag parameter to a number of seconds. Defer bot
  36.                  edits during periods of database server lag. Default is set by
  37.  
  38.                  config.py
  39.  
  40. -putthrottle:n    Set the minimum time (in seconds) the bot will wait between
  41. -pt:n             saving pages.
  42.  
  43. -verbose          Have the bot provide additional output that may be
  44. -v                useful in debugging.
  45.  
  46. -cosmeticchanges  Toggles the cosmetic_changes setting made in config.py or
  47. -cc               user_config.py to its inverse and overrules it. All other
  48.                  settings and restrictions are untouched.
  49.  
  50. -simulate         Disables writing to the server. Useful for testing and
  51.                  debugging of new code (if given, doesn't do any real
  52.                   changes, but only shows what would have been changed).
  53.  
  54. STDOUT:
  55. Scripts to manage categories.
  56.  
  57. Syntax: python category.py action [-option]
  58.  
  59. where action can be one of these:
  60.  * add          - mass-add a category to a list of pages
  61.  * remove       - remove category tag from all pages in a category
  62.  * move         - move all pages in a category to another category
  63.  * tidy         - tidy up a category by moving its articles into subcategories
  64.  * tree         - show a tree of subcategories of a given category
  65.  * listify      - make a list of all of the articles that are in a category
  66.  
  67. and option can be one of these:
  68.  
  69. Options for "add" action:
  70.  * -person      - sort persons by their last name
  71.  * -create      - If a page doesn't exist, do not skip it, create it instead
  72. * -redirect    - Follow redirects
  73.  
  74. If action is "add", the following options are supported:
  75.  
  76. -cat              Work on all pages which are in a specific category.
  77.                  Argument can also be given as "-cat:categoryname" or
  78.                  as "-cat:categoryname|fromtitle" (using # instead of |
  79.                  is also allowed in this one and the following)
  80.  
  81. -catr             Like -cat, but also recursively includes pages in
  82.                  subcategories, sub-subcategories etc. of the
  83.                  given category.
  84.                  Argument can also be given as "-catr:categoryname" or
  85.                  as "-catr:categoryname|fromtitle".
  86.  
  87. -subcats          Work on all subcategories of a specific category.
  88.                  Argument can also be given as "-subcats:categoryname" or
  89.                  as "-subcats:categoryname|fromtitle".
  90.  
  91. -subcatsr         Like -subcats, but also includes sub-subcategories etc. of
  92.                  the given category.
  93.                  Argument can also be given as "-subcatsr:categoryname" or
  94.                  as "-subcatsr:categoryname|fromtitle".
  95.  
  96. -uncat            Work on all pages which are not categorised.
  97.  
  98. -uncatcat         Work on all categories which are not categorised.
  99.  
  100. -uncatfiles       Work on all files which are not categorised.
  101.  
  102. -uncattemplates   Work on all templates which are not categorised.
  103.  
  104. -file             Read a list of pages to treat from the named text file.
  105.                  Page titles in the file must be enclosed with [[brackets]]
  106.                  or separated by newlines. Argument can also be given as
  107.                  "-file:filename".
  108.  
  109. -filelinks        Work on all pages that use a certain image/media file.
  110.                  Argument can also be given as "-filelinks:filename".
  111.  
  112. -search           Work on all pages that are found in a MediaWiki search
  113.                  across all namespaces.
  114.  
  115. -namespace        Filter the page generator to only yield pages in the
  116. -ns               specified namespaces.  Separate multiple namespace numbers
  117.                  with commas. Example: -ns:"0,2,4" (Take care of quotation
  118.                  marks as comma may qualify as command line separator.)
  119.                  Will ask for namespaces if you write just -namespace or -ns.
  120.  
  121. -interwiki        Work on the given page and all equivalent pages in other
  122.                  languages. This can, for example, be used to fight
  123.                  multi-site spamming.
  124.                  Attention: this will cause the bot to modify
  125.                  pages on several wiki sites, this is not well tested,
  126.                  so check your edits!
  127.  
  128. -limit:n          When used with any other argument that specifies a set
  129.                  of pages, work on no more than n pages in total
  130.  
  131. -links            Work on all pages that are linked from a certain page.
  132.                  Argument can also be given as "-links:linkingpagetitle".
  133.  
  134. -imagelinks       Work on all images that are linked from a certain page.
  135.                  Argument can also be given as "-imagelinks:linkingpagetitle".
  136.  
  137. -newimages        Work on the 100 newest images. If given as -newimages:x,
  138.                  will work on the x newest images.
  139.  
  140. -new              Work on the 60 recent new pages. If given as -new:x,
  141.                  will work on the x newest pages.
  142.  
  143. -recentchanges    Work on new and edited pages returned by
  144.                  [[Special:Recentchanges]]. Can also be given as
  145.                  "-recentchanges:n" where n is the number of pages to be
  146.                  returned, else 100 pages are returned.
  147.  
  148. -rc-nobots        Same as above but doesn't work on pages that bots have edited
  149.  
  150. -ref              Work on all pages that link to a certain page.
  151.                   Argument can also be given as "-ref:referredpagetitle".
  152.  
  153. -start            Specifies that the robot should go alphabetically through
  154.                   all pages on the home wiki, starting at the named page.
  155.                   Argument can also be given as "-start:pagetitle".
  156.  
  157.                   You can also include a namespace. For example,
  158.                   "-start:Template:!" will make the bot work on all pages
  159.                   in the template namespace.
  160.  
  161. -prefixindex      Work on pages commencing with a common prefix.
  162.  
  163. -titleregex       Work on titles that match the given regular expression.
  164.  
  165. -transcludes      Work on all pages that use a certain template.
  166.                   Argument can also be given as "-transcludes:Title".
  167.  
  168. -unusedfiles      Work on all description pages of images/media files that are
  169.                   not used anywhere.
  170.                   Argument can be given as "-unusedfiles:n" where
  171.                   n is the maximum number of articles to work on.
  172.  
  173. -unwatched        Work on all articles that are not watched by anyone.
  174.                   Argument can be given as "-unwatched:n" where
  175.                   n is the maximum number of articles to work on.
  176.  
  177. -usercontribs     Work on articles that were edited by a certain user.
  178.                   Example: -usercontribs:DumZiBoT
  179.                   Normally up to 250 distinct pages are given. To get an other
  180.                   number of pages, add the number behind the username
  181.                   delimited with ";"
  182.                   Example: -usercontribs:DumZiBoT;500
  183.                   returns 500 distinct pages to work on.
  184.  
  185. -<mode>log        Work on articles that were on a specified special:log.
  186.                   You have options for every type of logs given by the
  187.                   <mode> parameter which could be one of the following:
  188.                       block, protect, rights, delete, upload, move, import,
  189.                       patrol, merge, suppress, review, stable, gblblock,
  190.                       renameuser, globalauth, gblrights, abusefilter, newusers
  191.                   Examples:
  192.                   -movelog gives 500 pages from move log (should be redirects)
  193.                   -deletelog:10 gives 10 pages from deletion log
  194.                   -protect:Dummy gives 500 pages from protect by user Dummy
  195.                   -patrol:Dummy;20 gives 20 pages patroled by user Dummy
  196.                   In some cases this must be written as -patrol:"Dummy;20"
  197.  
  198. -weblink          Work on all articles that contain an external link to
  199.                   a given URL; may be given as "-weblink:url"
  200.  
  201. -withoutinterwiki Work on all pages that don't have interlanguage links.
  202.                  Argument can be given as "-withoutinterwiki:n" where
  203.                  n is some number (??).
  204.  
  205. -random           Work on random pages returned by [[Special:Random]].
  206.                  Can also be given as "-random:n" where n is the number
  207.                  of pages to be returned, otherwise the default is 10 pages.
  208.  
  209. -randomredirect   Work on random redirect pages returned by
  210.                  [[Special:RandomRedirect]]. Can also be given as
  211.                  "-randomredirect:n" where n is the number of pages to be
  212.                  returned, else 10 pages are returned.
  213.  
  214. -gorandom         Specifies that the robot should starting at the random pages
  215.                  returned by [[Special:Random]].
  216.  
  217. -redirectonly     Work on redirect pages only, not their target pages.
  218.                  The robot goes alphabetically through all redirect pages
  219.                  on the wiki, starting at the named page. The
  220.                  argument can also be given as "-redirectonly:pagetitle".
  221.  
  222.                  You can also include a namespace. For example,
  223.                  "-redirectonly:Template:!" will make the bot work on
  224.                  all redirect pages in the template namespace.
  225.  
  226. -google           Work on all pages that are found in a Google search.
  227.                  You need a Google Web API license key. Note that Google
  228.                  doesn't give out license keys anymore. See google_key in
  229.                   config.py for instructions.
  230.                   Argument can also be given as "-google:searchstring".
  231.  
  232. -yahoo            Work on all pages that are found in a Yahoo search.
  233.                   Depends on python module pYsearch.  See yahoo_appid in
  234.                   config.py for instructions.
  235.  
  236. -page             Work on a single page. Argument can also be given as
  237.                   "-page:pagetitle".
  238.  
  239. Options for "listify" action:
  240.  * -overwrite   - This overwrites the current page with the list even if
  241.                   something is already there.
  242.  * -showimages  - This displays images rather than linking them in the list.
  243.  * -talkpages   - This outputs the links to talk pages of the pages to be
  244.                   listified in addition to the pages themselves.
  245.  
  246. Options for "remove" action:
  247.  * -nodelsum    - This specifies not to use the custom edit summary as the
  248.                   deletion reason.  Instead, it uses the default deletion reason
  249.  
  250.                   for the language, which is "Category was disbanded" in
  251.                   English.
  252.  
  253. Options for "move" action:
  254.  * -hist        - Creates a nice wikitable on the talk page of target category
  255.                   that contains detailed page history of the source category.
  256.  * -nodelete    - Don't delete the old category after move
  257.  
  258. Options for several actions:
  259. * -rebuild     - reset the database
  260. * -from:       - The category to move from (for the move option)
  261.                  Also, the category to remove from in the remove option
  262.                  Also, the category to make a list of in the listify option
  263. * -to:         - The category to move to (for the move option)
  264.                - Also, the name of the list to make in the listify option
  265.         NOTE: If the category names have spaces in them you may need to use
  266.         a special syntax in your shell so that the names aren't treated as
  267.          separate parameters.  For instance, in BASH, use single quotes,
  268.          e.g. -from:'Polar bears'
  269.  * -batch       - Don't prompt to delete emptied categories (do it
  270.                  automatically).
  271. * -summary:    - Pick a custom edit summary for the bot.
  272. * -inplace     - Use this flag to change categories in place rather than
  273.                  rearranging them.
  274. * -recurse     - Recurse through all subcategories of categories.
  275. * -pagesonly   - While removing pages from a category, keep the subpage links
  276.                  and do not remove them
  277. * -match       - Only work on pages whose titles match the given regex (for
  278.                  move and remove actions).
  279.  
  280. For the actions tidy and tree, the bot will store the category structure
  281. locally in category.dump. This saves time and server load, but if it uses
  282. these data later, they may be outdated; use the -rebuild parameter in this
  283. case.
  284.  
  285. For example, to create a new category from a list of persons, type:
  286.  
  287.  python category.py add -person
  288.  
  289. and follow the on-screen instructions.
  290.  
  291. Or to do it all from the command-line, use the following syntax:
  292.  
  293.  python category.py move -from:US -to:'United States'
  294.  
  295. This will move all pages in the category US to the category United States.
  296.  
  297.  
  298.  
  299. D:\Python 27 new Compat\compat>
Advertisement
Add Comment
Please, Sign In to add comment