Page MenuHomePhabricator

improve diff visualization for Wikibase entities
Open, MediumPublicFeature

Description

pywikibot.showDiff(oldText, newText) is currently used to compare two wikicode strings. But what about data items?

We should either:

  • use the API to get a diff in structured format (pending on T41147), or:
  • convert dicts to strings somehow, before sending them to difflib

More ideas are welcome.


Version: core-(2.0)
Severity: enhancement

Details

Reference
bz64468
Related Changes in Gerrit:

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:24 AM
bzimport set Reference to bz64468.

Created attachment 15216
console output by pywikibot.showDiff used on two json.dumps-ed dictionaries

(In reply to Betacommand from comment #1)

use json.dumps to get a string?

Really? This is a small piece of what I got on my terminal using json.dumps before showDiff, after changing a single alias.
We need a smarter function than json.dumps.

Attached:

alias.png (620×1 px, 189 KB)

thats probably because you didnt configure the dumps for human reading. Try:
json.dumps(data, indent=4, sort_keys=True) should give you much cleaner results

Change 160254 had a related patch set uploaded by XZise:
[FIX] init: Return valid json in str() for WbTime and WbQuantity

https://gerrit.wikimedia.org/r/160254

Change 160254 merged by jenkins-bot:
[FIX] init: Return valid json in str() for WbTime and WbQuantity

https://gerrit.wikimedia.org/r/160254

jayvdb set Security to None.

A usable JSON diff was added to pywikibot.WikidataBot.user_edit_entity as part of T85242 .

Change 332189 had a related patch set uploaded (by Phantom42):
Add DictPatchManager and WikibasePatchManager

https://gerrit.wikimedia.org/r/332189

I am currently working on this (created DictPatchManager and WikibasePatchManager)

Xqt triaged this task as Medium priority.Nov 6 2018, 6:54 AM
Dvorapa subscribed.

Please undo if still working on it

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:23 PM

Change #332189 abandoned by JJMC89:

[pywikibot/core@master] Add DictPatchManager and WikibasePatchManager

Reason:

stale patch that cannot be merged - feel free to unabandon if you will update it

https://gerrit.wikimedia.org/r/332189