Skip to content

Python Files

There are a couple scripts and functions that are available in the .\pys directory.

Read their comments to understand more. All links lead to the resource-packs version of the scripts

custom_functions.py

Simply a housing for six functions that I use.

Functions:

check(module)

Like what it says. When this function is called, it checks whether module is installed. If it isn't, it uses pip to install that specified function.

I am not using subprocess to run pip install module as subprocess does not work when invoked in terminal, unlike pip.

pip does spawn some yellow text saying not to invoke, but if it works, it works ¯\(ツ)

cdir()

When this function is called, a string is returned, with the exact path to the repository.

It is just a QOL function to prevent extra code at the start of other scripts.

clear()

Clears the terminal when the function is called.

load_json(path)

Returns JSON loaded as dictionary from file path and parses errors in a cooler way.

dump_json(path,dictionary)

Saves JSON with indentation to path

Checks first n letters of string with each item in list_search.

  • If there is more than one item that matches the first n letters of string, n is increased by 1

This continues until only one item matches the first n characters of the string, or the string runs out of characters to check for.

folder_creator.py

Creates folders based on the json files.

pre_commit.py

Does 3 processes

  1. Counts finished packs, compatibility subpacks and pack icons, while making the HTML for the site
  2. Updates incomplete_packs.json, incomplete_compatibilities.json, incomplete_pack_icons.json, name_to_json.json and index.html
  3. Updates README with the numbers from above
Flags:

--use-relative-location, -rl

  • Uses relative location in your folder than the Web URL version

--format, -f

If you want a better explanation, there are comments in each script and have a more detailed explanation on what is going on.


Contributors