jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/523801 )

Change subject: Add user_agent_description option
......................................................................

Add user_agent_description option

https://meta.wikimedia.org/wiki/User-Agent_policy suggests that the client
should use descriptive name with contact info, etc. however pywikibot does
not provide an easy way to do it unless you use specific username (which
is impossible for SPARQL bots for example) or override whole user agent string.
script_name etc. only base on filenames and thus does not allow to add
more descriptive text or contact info.

Adding user_agent_description would allow to add one string to user-config.py 
like:

ser_agent_description = "https://example.org/CoolTool/; [email protected]"

and have it become part of the user-agent string.

Change-Id: I28a0446e117dab7fc778aebeecb1f9f0702f2502
---
M pywikibot/comms/http.py
M pywikibot/config2.py
2 files changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index c1e1bc1..b95eadd 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -203,6 +203,8 @@

     script_comments = []
     username = ''
+    if config.user_agent_description:
+        script_comments.append(config.user_agent_description)
     if site:
         script_comments.append(str(site))

diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index b405b79..8ef04fc 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -156,6 +156,10 @@
 user_agent_format = ('{script_product} ({script_comments}) {pwb} ({revision}) '
                      '{http_backend} {python}')

+# User agent description
+# This is a free-form string that can be user to describe specific bot/tool,
+# provide contact information, etc.
+user_agent_description = None
 # Fake user agent.
 # Some external websites reject bot-like user agents. It is possible to use
 # fake user agents in requests to these websites.

--
To view, visit https://gerrit.wikimedia.org/r/523801
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I28a0446e117dab7fc778aebeecb1f9f0702f2502
Gerrit-Change-Number: 523801
Gerrit-PatchSet: 3
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: Dalba <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to