Skip to main content

Convert a wikipedia article to a git repository

Project description

Wikiblame

Convert a wikipedia article to a git repository.

Then, offer to explore it with emacs in version control mode (vc-annotate), or with git blame, or gitg.

This is a much nicer way to find out where certain changes happened in a wiki page.

📥 Installation

You can run the wikiblame.py file directly, or install the executable wikiblame with:

pip install -e .

🔋 Dependencies

Wikiblame uses the mwclient module to communicate with the MediaWiki API.

It is packaged in most systems (for example, as python3-mwclient in Debian), but you can also install it with:

pip install mwclient

It also uses git to create a local repository with one commit per revision of the article.

Depending on the program you want to use to see the history of the file, you may want to have emacs and/or gitg too.

📖 Usage

usage: wikiblame [-h] [-n N] [--oldest TIMESTAMP] [--newest TIMESTAMP] [--site SITE] [-v] article

positional arguments:
  article        name of the wikipedia article

options:
  -h, --help           show this help message and exit
  -n N, --revisions N  number of revisions
  --oldest TIMESTAMP   oldest revision, like 2022-01-01T00:00:00Z
  --newest TIMESTAMP   newest revision (latest if not set)
  --site SITE          wikimedia site to access (default: en.wikipedia.org)
  -v, --verbose        show retrieved revisions

💡 Examples

Simple use

In this example we see the history of the article on Electron microscope:

> wikiblame 'Electron microscope'
Using last 50 revisions. Use --revisions or --oldest otherwise.
Getting revisions of "Electron microscope" at en.wikipedia.org ...
Initialized empty Git repository in /tmp/tmpibe68vu1/.git/

Directory with the history as a git repository: /tmp/tmpibe68vu1
  1. Open with emacs
  2. Open with git blame
  3. Open with gitg
  4. Exit (it will remove /tmp/tmpibe68vu1)
>

One can run in the temporary directory (/tmp/tmpibe68vu1 in the example) tools like gitg to quickly see who made what change when.

After exiting, the temporary directory is deleted.

Different starting date

Example using a different starting date, verbose output, and selecting git blame:

> wikiblame 'Electron microscope' --oldest 2020-01-01T00:00:00Z -v
Getting revisions of "Electron microscope" at en.wikipedia.org ...
  Sun Sep 22 19:58:41 2024  Alfa-ketosav      /* Main operating modes */
  Tue Aug 20 03:12:45 2024  Citation bot      Add: pmid, authors 1-1. Removed parameters. Some a
  Thu Aug  8 04:15:15 2024  JL-Bot            removing stale construction template as last edite
  Wed Jul 31 20:54:20 2024  SFBB              there was no TU-Berlin before 1946
  [...]
  Mon Jan 13 19:02:34 2020  Neurogeek         /* See also */  Quantum Microscopy
  Sun Jan 12 19:38:40 2020  Needforspeed888   Add link
Initialized empty Git repository in /tmp/tmp4fp88fcy/.git/

Directory with the history as a git repository: /tmp/tmpibe68vu1
  1. Open with emacs
  2. Open with git blame
  3. Open with gitg
  4. Exit (it will remove /tmp/tmpibe68vu1)
> 2

[...]
e7672bb2 (Materialscientist    2020-09-07 10:13:25 +0200    1) {{short description|Type of microscope with electrons as a source of
e7672bb2 (Materialscientist    2020-09-07 10:13:25 +0200    2) illumination}}
eb63cc02 (JackintheBox         2019-05-04 03:48:58 +0200    3) [[File:Electron Microscope.jpg|thumb|right|A modern transmission
eb63cc02 (JackintheBox         2019-05-04 03:48:58 +0200    4) electron microscope]][[File:Electron
[...]

>
  1. Open with emacs
  2. Open with git blame
  3. Open with gitg
  4. Exit (it will remove /tmp/tmpibe68vu1)
> 4

⚖️ License

This program is licensed under the GPL v3. See the project license for further details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wikiblame-1.0.2.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wikiblame-1.0.2-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file wikiblame-1.0.2.tar.gz.

File metadata

  • Download URL: wikiblame-1.0.2.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wikiblame-1.0.2.tar.gz
Algorithm Hash digest
SHA256 397e3bef0fde9aff766ab9dea708e2a91ef31ccbe14b999e167d83b75359e5d4
MD5 0bce556f42ad95eb486017efc8e9baca
BLAKE2b-256 4dbb94adf7a6074960fa477163da7fa220316bbb2aaa0b9d399ef53636fafc27

See more details on using hashes here.

Provenance

The following attestation bundles were made for wikiblame-1.0.2.tar.gz:

Publisher: publish-to-test-pypi.yml on jordibc/wikiblame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wikiblame-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: wikiblame-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for wikiblame-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e3d9c948179e9fa53d984caa891d422c2d82a3cc913dbc20c9812b71b487ab
MD5 7bfc43980115c649e25918aac97d03bb
BLAKE2b-256 a51ced210dd9892292acadcfe8a5c09b5967ce352d0bbeba5c1397920c33f430

See more details on using hashes here.

Provenance

The following attestation bundles were made for wikiblame-1.0.2-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on jordibc/wikiblame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page