This is an attempt to create an automated ModCabinet wiki for the BL2/TPS mods housed in the BLCMods github. The current ModCabinet wiki relies on modders manually updating the entries, and as a result the ModCabinet is extremely under-populated (to say nothing of the hassle required for the folks who do keep their mods updated on there).
The util will attempt to loop through a local github checkout, looking for
files named cabinet.info
, which mostly just contain a line per mod in
the same directory which specifies which categories the mod should belong
in. The app should be able to read in mod summaries both from the mod
files themselves, and from README files stored alongside the mods.
Obviously it's a bit insane to try and write something to parse through a bunch of effectively freeform text all over the place, but hopefully it can be wrangled into something useful, which can then be run every 15 minutes or something.
At the moment, the app works quite well, with the caveats of the items noted in the TODO below. I will eventually get some better documentation in here about how to get this running, in case anyone else ever needs/wants to take over generating these pages.
This is a Python 3 app. It may work in Python 2 but no attempt has been
made to find out. Required modules (installable via pip
, of course):
gitpython
Jinja2
python-Levenshtein
appdirs
coverage
(only to run coverage on the unit tests, for development
purposes. Not needed just to run.)In case Apocalyptech ever gets hit by a bus or something, someone else might end up wanting to take over running this thing. Here's how:
python3 -m venv cabinetsorter
(or whatever you want to call it).
That'll create a new cabinetsorter
dir in your current dir,
containing the venv.. cabinetsorter/bin/activate
(the dot
at the beginning is important). Your command prompt should now
have a (cabinetsorter)
prefix on it, to indicate that you're
operating "in" that venv.pip install --upgrade pip
to get on the latest version of the
python package manager (this step's optional, but it'll nag you
until it's up-to-date anyway, so you might as well).pip install -r requirements.txt
, or just
install them one by one with pip install <module>
, from the list
above.
requirements.txt
doesn't list the coverage
module since that's
only used in conjunction with unit tests, so if you care about
running those, you might want to install coverage
too. If you're
just running the sorter, though, don't sweat it.sorter.py
once; it'll complain that you don't have a config
file set up, but more importantly it'll tell you the path that it's
looking for, for the file.cabinetsorter.ini.example
so that the app will find it.
On a Linux machine that'll likely be ~/.config/cabinetsorter/cabinetsorter.ini
mods
section of the INI file describes the mod repo itself.
clone_url
can just be the anonymous HTTPS URL used to clone the
repo.base_url
is the base URL used to link directly to files
inside the repo (usually the same as clone_url
but with .git
changed to /tree/master
).download_url
is the URL used to embed screenshots in our markdown
files, and will have a raw.githubusercontent.com
hostname.repo_dir
is the checkout location of the repo on-disk. I keep
them inside the repos
directory right inside the cabinetsorter
checkout.wiki
section of the INI file describes the wiki repo itself
(github project wikis are really just separate github repos themselves.)
clone_url
is the URL used to check out the wiki. github itself will
not actually show the correct URL here -- it'll only tell you the
"anonymous" HTTPS url. You need to use the SSH-based URL which lets
you push new content, etc. Its form will be git@github.com:BLCM/ModCabinet.wiki.git
.
On my own system, I'm doing some shenanigans where I upload using
an account different from my "main" github account, so I actually
specify the hostname bit there as github.com-apocalyptechcabinet
,
which I've configured SSH to use an alternate IdentityFile
, and
set the HostName
to github.com
and User
to git
. If you don't
care about using a separate github user for this, don't bother with
that -- just use the URL mentioned earlier.cabinet_dir
is the checkout location of the wiki repo on-disk.
Like the mods repo, I keep it inside the repos
directory right inside
the cabinetsorter
checkout.repos
subdir, simply go in there, and do a
git clone
using the clone_url
s for both the "mods" and "wiki" section
of the INI file you just configured.
repos/BLCMods
dir contains a checkout of
the mod archive, and the repos/ModCabinet.wiki
contains a checkout
of the current wiki.-f
/--force
flag to
force it to Do Stuff regardless. Also, for your very first time running
the app, you'll want to use the -i
/--initial
flag, which sets the
file modification times for all the files in the BLCMods
checkout. (This
is useful because it uses the file modification times to populate the
"last updated" report on the mod pages. Otherwise the reported "last
updated" times will end up being the timestamp when you cloned the repo.)
-g
/--no-git
flag to prevent the app from trying to interact with github in any way.
The app also keeps caches of it's "remembered" state of the BLCMods repo
in the cache
dir. You can clean that dir out whenever you like, or just
use the -x
/--ignore-cache
argument to ignore it. There's a few other
options which can be used, use -h
/--help
to see them all.*/10 * * * * cd /home/pez/git/b2patching/cabinetsorter && /home/pez/virtualenv/mcpcabinetsorter/bin/python /home/pez/git/b2patching/cabinetsorter/sorter.py -q
-q
/--quiet
option will prevent the app from outputting any
text unless there's an actual error with processing. This way your
system running the cron won't send you an email unless there's a problem
which might need your attention.load_unknown
wiki_filename
processingwiki_link
ModFile.load_unknown()
, check for FT-style categories__eq__
on ModURL objects for the various tests in there@no-mod-comment
style directives in cabinet.info
filesgit pull
has already happened
and it looks like there's nothing to do. I think we'll have to
cache the git commit at which we last successfully run, and compare
against that.full_filename
var in ModFile. I bet
we can...Borderlands ModCabinet Sorter is licensed under the GPLv3 or later. See COPYING.txt for the full text of the license.