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):
gitpythonJinja2python-Levenshteinappdirscoverage(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:
- Set up a Python virtual env for the app, wherever you like, using
python3 -m venv cabinetsorter(or whatever you want to call it). That'll create a newcabinetsorterdir in your current dir, containing the venv. - Activate the venv using
. 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. - Run
pip install --upgrade pipto 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). - Go into the dir where you've checked out this project, and install
the dependencies with:
pip install -r requirements.txt, or just install them one by one withpip install <module>, from the list above.requirements.txtdoesn't list thecoveragemodule since that's only used in conjunction with unit tests, so if you care about running those, you might want to installcoveragetoo. If you're just running the sorter, though, don't sweat it.
- Run
sorter.pyonce; 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. - Copy
cabinetsorter.ini.exampleso that the app will find it. On a Linux machine that'll likely be~/.config/cabinetsorter/cabinetsorter.ini - The
modssection of the INI file describes the mod repo itself.clone_urlcan just be the anonymous HTTPS URL used to clone the repo.base_urlis the base URL used to link directly to files inside the repo (usually the same asclone_urlbut with.gitchanged to/tree/master).download_urlis the URL used to embed screenshots in our markdown files, and will have araw.githubusercontent.comhostname.repo_diris the checkout location of the repo on-disk. I keep them inside thereposdirectory right inside thecabinetsortercheckout.
- The
wikisection of the INI file describes the wiki repo itself (github project wikis are really just separate github repos themselves.)clone_urlis 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 begit@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 asgithub.com-apocalyptechcabinet, which I've configured SSH to use an alternateIdentityFile, and set theHostNametogithub.comandUsertogit. 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_diris the checkout location of the wiki repo on-disk. Like the mods repo, I keep it inside thereposdirectory right inside thecabinetsortercheckout.
- Manually check out both the mods repo and the wiki repo -- the app
currently doesn't support doing that automatically. If you're keeping
them checked out in the
repossubdir, simply go in there, and do agit cloneusing theclone_urls for both the "mods" and "wiki" section of the INI file you just configured.- Note that if you're starting this up on a brand new github wiki, the wiki needs to have at least the main page, so create the first page from the web UI and then do your checkouts.
- Doublecheck that the resulting
repos/BLCModsdir contains a checkout of the mod archive, and therepos/ModCabinet.wikicontains a checkout of the current wiki.
- By default, the sorter will only Do Things if it notices that there's been
an update to the mods repo. Since you just checked it out, there probably
won't be changes yet, to you'll want to use the
-f/--forceflag to force it to Do Stuff regardless. Also, for your very first time running the app, you'll want to use the-i/--initialflag, which sets the file modification times for all the files in theBLCModscheckout. (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.)- If you want to just test things out, you can also use the
-g/--no-gitflag 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 thecachedir. You can clean that dir out whenever you like, or just use the-x/--ignore-cacheargument to ignore it. There's a few other options which can be used, use-h/--helpto see them all.
- If you want to just test things out, you can also use the
- Once you're confident that it's working properly, you'll want to hook it
up an automated process which runs it occasionally. I wouldn't recommend
doing it more often than every 10 minutes. My cron line looks like this:
*/10 * * * * cd /home/pez/git/b2patching/cabinetsorter && /home/pez/virtualenv/mcpcabinetsorter/bin/python /home/pez/git/b2patching/cabinetsorter/sorter.py -q- Using the
-q/--quietoption 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.
- Using the
- Support doing initial git clones?
- README/Mod Description parsing could probably use some tweaking, but will have to do that carefully, of course.
- Update unit tests, they're pretty out of date now
- Make sure to have tests to explicitly check for MUT categories on FT and BLCMM files
- Make sure to test specifying a filename which doesn't exist
- Test stripping spaces from category names (silverxpenguin's Revalation, for instance)
- Test escaped quotes in BLCMM top-level category names
- Test unicode vs. latin1 mod files
- Test escaped leading hashes in cabinet.info files
- ModFile sorting (case-insensitive)
- Angle brackets in
load_unknown wiki_filenameprocessing- We've moved to always using full HTML HREFs instead of wiki
links, when calling
wiki_link - In
ModFile.load_unknown(), check for FT-style categories - Strip square brackets from ASCII art
- Test
__eq__on ModURL objects for the various tests in there - The new
@no-mod-commentstyle directives incabinet.infofiles
- Figure out something to do with, for instance, mopioid's Phaseclock. Also Robeth's TimeScale? Also Aaron0000's Pandemonium.
- The first time the app is run, without caches to read from, mods which share the name of an author will error out instead of being generated. That will get fixed on subsequent runs which do read from the cache. I don't care enough to fix that edge case at the moment, but it may bear looking into later. (vWolvenn's "Tsunami" is the only current case of this actually happening.)
- If we get a CRITICAL error midway through processing, the next run
will not try again, because the
git pullhas 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. - See if we can get rid of our
full_filenamevar 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.