Manual talk:Pywikibot/2016
Add topicThis page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
![]() Archives
|
---|
Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it may take a while before you get a response.
Request for a new script
[edit]I suggest to create a new script: block.py, which can be used to mass block and unblock accounts and IP addresses. It can be very useful when dealing with proxies or when having to block a bunch of sockpuppets. I accede there's a potential for abuse, since any rogue admin could, in practice, go ahead and start blocking people without any reason. Many scripts perform also dangerous actions, such as delete/speedy_delete.py, and in case of misuse, we can ask the stewards for an emergency desysop for abuse. Thank you. —MarcoAurelio (talk) 22:50, 16 February 2016 (UTC)
- Better place for your request would be phab: @xqt 07:19, 19 February 2016 (UTC)
Wikidata: How get value
[edit]RESOLVED | |
solved with "item.claims['P1343'][1].qualifiers.get('P854')[0].target" |
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Help me with Wikidata. In documentation and examples talk only how to set property or get only main claim. But how get value of P854 from item Q13515 -> P1343 -> Q17378135 -> P854 ? It example item: https://www.wikidata.org/wiki/Q13515
I tried "print(item.claims['P1343'][1].target)", it return only 'Q17378135' but not subproperties with values. Also .getSource return 'none'. Also https://www.wikidata.org/wiki/Wikidata:Pywikibot_-_Python_3_Tutorial/Data_Harvest (at bottom page) talk to use .amount and .unit, but it return error. Vladis13 (talk) 14:59, 1 April 2016 (UTC)
Add/edit property in qualifer
[edit]How add/edit property of qualifier of property source? Example item, branch: P1343 -> Q17378135, in this need change sub-property e.g. P854 or add new. To get list of it can use "item.claims['P1343'][1].qualifiers.items()".
On the manual is recipe "Example 8" but it only create top property, also don't work recipe from "Example 9". I trying already a few days. Vladis13 (talk) 16:08, 2 April 2016 (UTC)
How remove qualifier
[edit]On test page the path: claims > P1343 > Q17378135 > P958. I tried like
for claim in item.claims['P1343']: qualifier = claim.qualifiers['P958'] claim.removeQualifier(qualifier)
and other, but get error "'Claim' object has no attribute 'removeQualifier'".
Also I tried the simple case: claims > P1705 > P364, but get error "KeyError: P364" or same as above.
Manuals and wiki doesn't describes the methods removeQualifier and remove/edit Claim. --~ Vladis13 (talk) 16:52, 8 April 2016 (UTC)
- As noted in the description of this talk page, please use one of the communication methods listed on Manual:Pywikibot/Communication rather than asking on this talk page.
- As for your question -- you're looking for
Claim.removeQualifiers
: - Valhallasw (talk) 18:04, 12 April 2016 (UTC)
>>> help(item.claims['P1343'][0].removeQualifiers)</code> Help on method removeQualifiers in module pywikibot.page: removeQualifiers(self, qualifiers, **kwargs) method of pywikibot.page.Claim instance Remove the qualifiers. @param qualifiers: the qualifiers to remove @type qualifiers: list Claim
- I tried it, but get error as above,
- Also, I did ask this question in IRC (and I'd wait answer all day), did ask in mailinglist, also ask here, and on "Wikidata talk:Creating a bot", and on russian forum of bot-owners. Also, about it nothing in manual, Answer on all it are silence.
- Also, before it I few days ask the other questons on forums, but get silens... You only on irc reply for one question after few hours my wait in chat.
- I poor speak english for free and understood talk on irc. Vladis13 (talk) 20:44, 12 April 2016 (UTC)
- Note the 's' at the end of removeQualifiers. You might need to use the most recent nightly version rather than the 2.0 version, as not all new wikibase features are available in 2.0.
- As for the mailinglist -- I don't see your email there, so it must somehow have slipped through the cracks. The list should be https://lists.wikimedia.org/mailman/listinfo/pywikibot (pywikibot@lists.wikimedia.org). IRC can indeed take a bit of time for an answer (several hours in some cases) because of people in different time zones. Valhallasw (talk) 21:08, 12 April 2016 (UTC)
How to fix 'WindowsError: Windows version 1 not supported yet'?
[edit]
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
As the title says, I'm having this issue when I try to run the command generate_user_files.py
(and probably with other files from pywikibot too). I've searched some time for a solution for this problem, but haven't found one yet... (Edit: I'm using Windows 10, maybe pywikibot confuses Windows 1 with Windows 10) DarkShadowTNT (talk) 18:57, 10 May 2016 (UTC)
- Hello DarkShadowTNT,
- Please file a bug in Phabricator: https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?tags=pywikibot-core . Please include:
- the output of pwb.py version, if this command is functional,
- where you downloaded pywikibot,
- the python version, and
- the output of python -c "import platform; print platform.version()" in the console. Valhallasw (talk) 20:06, 10 May 2016 (UTC)
- Looks like phab:T132273 which is already solved. The bot must be updated then. ~ @xqt 15:58, 13 May 2016 (UTC)
- It's already fixed. The problem was not on my side, it was probably a mistake made by wmflabs when they updated the pywikibot files. DarkShadowTNT (talk) 17:46, 13 May 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
claimit - 'ClaimRobot' object has no attribute 'source_values'
[edit]
when running
./pwb.py claimit -ns:120 -searchitem:Q150 P36 '20 - Mit Beschreibung'
on my own wikidatabase the following error occurs:
'ClaimRobot' object has no attribute 'source_values'
If anyone has an idea, how to define the source for claimit.py, I'd be happy. Mika77 (talk) 11:57, 23 August 2016 (UTC)
- Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it is likely you will get a response faster via one of the other channels. Valhallasw (talk) 12:27, 23 August 2016 (UTC)
space adding/removing
[edit]
Hello, can you help please hot to add/remove spaces in text
For exmaple "J.R.R.Tolkien" should transform to "J. R. R. Tolkien"
I tried to use replace.py and user-fixes.py
(u' \. ', u'\. '),
(u' \..?', u'\. .?'),
(u'.?\..?', u'.?\. .?'),
But that's don't work.
Hope on your help, thanks BotAndNoob (talk) 17:07, 29 August 2016 (UTC)
Can't config pywikibot
[edit]
When I run the following lines into the command prompt, it tells me an error that there is no such a command, files, etc. of the name python
cd "d:\pywikibot"
python pwb.py login
May somebody help?thanks! 222.167.212.50 (talk) 02:24, 30 August 2016 (UTC)
- And it also did say pwb.py is not a command or file too 222.167.212.50 (talk) 02:30, 30 August 2016 (UTC)
- did you really installed python.exe? @xqt 07:08, 31 August 2016 (UTC)
- Yes, Python 3.5, from the official site 222.167.212.50 (talk) 09:36, 1 September 2016 (UTC)
- Are you Windows user?
- In that case you do not need to write "python pwb.py login", just "pwb.py login" Ashot (talk) 16:25, 1 September 2016 (UTC)
- Anyway python pwb.py login should work too. Seems the python installation wasn't correct because neither the python.exe nor the .py file is registered in a right way. @xqt 14:32, 3 September 2016 (UTC)
- Screenshot on Windows 8.1 Ashot (talk) 16:13, 3 September 2016 (UTC)
Script request/help
[edit]
I'm not familiar with Python or Pywikibot but believe it could do this easily. A script passed three command-line arguments (article name, edit summary, local filename) replaces the article with the contents of local filename. Just uploads new wiki-source overwriting the existing article.
I tried something like this but it didn't work
import pywikibot, sys
- Usage: savepage [article name] [edit comment] [local file]
f = open(sys.argv[3], 'r')
newtext = f.read()
site = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(site, sys.argv[1])
page.text = newtext
page.save(sys.argv[2]) GreenC bot (talk) 16:57, 4 September 2016 (UTC)
- The above code:
- http://pastebin.com/QzSsfhRB GreenC bot (talk) 16:58, 4 September 2016 (UTC)
- use basic.py as a very basic script and use it in that way you need. @xqt 17:12, 4 September 2016 (UTC)
- Actually it seems to work now by changing
- page.text = newtext.decode('utf-8') GreenC bot (talk) 17:26, 4 September 2016 (UTC)
- You may try pagefromfile.py which is a ready-to-use script uploading pages given by file. @xqt 04:39, 6 September 2016 (UTC)
Can't start new thread -error
[edit]
A Command
python2.7 pwb.py weblinkchecker.py -start:!
works fine few seconds (retrieves 240 pages, finds a broken link) but then:
File "/chroot/python27/lib/python2.7/threading.py", line 743, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread
<class 'thread.error'>
Any idea what to do to fix this? Thank you. 87.100.134.231 (talk) 09:36, 10 September 2016 (UTC)
- Please file this bug at phabricator [1] and add the full traceback and the result of pwb.py version
- [1] https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?project=pywikibot-core @xqt 09:53, 10 September 2016 (UTC)
Edits marked as bot
[edit]
RESOLVED
Actually correctly flagging as a bot edit.
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
For some reason my Pywikibot edits are not marked as bot edits. I've tried hard-coding in page.py so the botedit variable is True throughout. My login ID is a registered bot and should default as a bot edit. Is there something else I should do? GreenC (talk) 16:05, 12 September 2016 (UTC)
- Please file this at phabricator [1] and add the result of pwb.py version
- [1] https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?project=pywikibot-core @xqt 07:33, 13 September 2016 (UTC)
- Yeah as noted there is actually no problem with pwb the problem doesn't exist.. this entire thread could be deleted GreenC (talk) 12:38, 13 September 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
Pywikibot and cron
[edit]
After I'm run Pywikibot based script via cron, I'm get system mail with all pywikibot.output text. Single problem - all Russian symbols have been replaced to English via some sort of translit. How can I'm change this behavior? I'm need utf-8 log of script output, not ASCII-only. 95.37.79.244 (talk) 01:04, 24 September 2016 (UTC)
About Manual:Pywikibot
[edit]
IMO, old version of the PWB Manual main page was better :) Everythink is needed was easily visible and easily accesible. XXN (talk) 11:07, 8 November 2016 (UTC)
Bug transcludes redirect
[edit]
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Hi, I post this strange comportment here.
python pwb.py listpages.py -transcludes:Utilisateur:Épiméthée/Vauban-Intelligence -lang:fr
print nothing, but Special:Linked pages list a few articles (replaced after, empty now).
When I delete the redirect, pywikibot find pages.
Thank you Framawiki (talk) 22:37, 3 December 2016 (UTC)
- Please use Phabricator to file a bug. Anyway there are not transclusions for that page. use -ref Option instead of -transcludes to find links pointed to this site. Refer listpages -help. @xqt 08:24, 4 December 2016 (UTC)
- Thanks, I will try next time this command. Framawiki (talk) 20:25, 6 December 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.
OAuth
[edit]
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Hello,
I've this error when I try to save a page with OAuth. It works with password login.
pywikibot.exceptions.OtherPageSaveError: Edit to page wiktionary:fr:Discussion utilisateur:Benoît Prieur failed:
Logged in on wiktionary:fr via OAuth as Framabot, but expect as None
CRITICAL: Closing network session.
Any idea ? Thank you. Framawiki (talk) 20:24, 6 December 2016 (UTC)
- Just add username in user-config :) Framawiki (talk) 09:31, 23 December 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.