Browse Source

Use PEP8 more. Import print_function more. Declare encoding more.

master
poikilos 2 years ago
parent
commit
2aaacab590
  1. 9
      utilities/compatiblizemod.py
  2. 1
      utilities/enissue.py
  3. 2
      utilities/enlynx.py
  4. 58
      utilities/find_pyenliven.py
  5. 57
      utilities/generatemod.py
  6. 2
      utilities/mtcompile-program-local.py
  7. 32
      utilities/mtoldtonew.py

9
utilities/compatiblizemod.py

@ -4,17 +4,12 @@
This script uses the pyenliven.compatiblizemod submodule to try to make
the mod
'''
from __future__ import print_function
import re
import sys
import os
UTILITIES_DIR = os.path.dirname(os.path.realpath(__file__))
REPO_DIR = os.path.dirname(UTILITIES_DIR)
# try:
# from pyenliven.compatiblizemod import main
# except ModuleNotFoundError:
if os.path.isfile(os.path.join(REPO_DIR, "pyenliven", "__init__.py")):
sys.path.append(REPO_DIR)
from find_pyenliven import pyenliven
from pyenliven.compatiblizemod import main

1
utilities/enissue.py

@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Purpose: View and cache issues in the EnlivenMinetest repo.
Author: 2020-2021 Jake Gustafson

2
utilities/enlynx.py

@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Specify a label or search term, optionally with a page #.
@ -30,6 +31,7 @@ Examples:
'''
from __future__ import print_function
import sys
import subprocess
me = "enlynx.py"

58
utilities/find_pyenliven.py

@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import sys
import os
import platform
REPO_USER = "poikilos"
REPO_NAME = "EnlivenMinetest"
MODULE_NAME = "pyenliven" # See also import pyenliven statements
GIT_SERVER= "https://github.com"
CALLER_NAME = os.path.split(sys.argv[0])[1]
profile = os.environ.get('HOME')
if platform.system() == "Windows":
profile = os.environ['USERPROFILE']
tryRepo = os.path.join(profile, "git", REPO_NAME)
tryModule = os.path.join(tryRepo, MODULE_NAME)
MY_MODULE = os.path.dirname(os.path.abspath(__file__))
MY_REPO = os.path.dirname(MY_MODULE)
MY_REPOS = os.path.dirname(MY_REPO)
nearbyRepo = os.path.join(MY_REPOS, REPO_NAME)
def echo0(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
if os.path.isfile(os.path.join(nearbyRepo, MODULE_NAME, "__init__.py")):
sys.path.insert(0, nearbyRepo)
echo0("[{}] using nearby {}".format(CALLER_NAME, nearbyRepo))
elif os.path.isdir(tryModule):
sys.path.insert(0, tryRepo)
echo0("[{}] using git {}".format(CALLER_NAME, tryRepo))
else:
pass
# use the one in the python path (or fail)
# print("There is no {}".format(os.path.join(thisRepo, MODULE_NAME)))
import pyenliven
try:
import pyenliven
except ImportError as ex:
echo0("sys.path={}".format(sys.path))
echo0(str(ex))
echo0('"{}" is part of {}. You must install the repo:'
''.format(CALLER_NAME, REPO_NAME))
echo0("# Clone it then:")
echo0("python3 -m pip install {}".format(MODULE_NAME))
echo0('# or just put it in a directory near here such as via:')
echo0(' git clone {}/{}/{}'
' "{}"'.format(GIT_SERVER, REPO_USER, REPO_NAME, nearbyRepo))
sys.exit(1)

57
utilities/generatemod.py

@ -1,4 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
generatemod
___________
This script is part of <https://github.com/poikilos/EnlivenMinetest>.
Usage:
generatemod mod [options]
Options:
--fill adds only missing files to an existing mod (instead of
failing when directory exists).
[alias to] (do not actually use brackets) If you specify any two
options without --, the first will be an alias and the
second will be convert_to. The alias options are only for
mods that are aliases, as a shortcut to creating a mostly
complete mod (other than copyright information and
description) with only this script.
Examples:
generatemod mod_name
generatemod mod_name --fill
generatemod mod_name modname:item_name other_modname:convert_to
generatemod mod_name mobsmod:mob_name other_mobsmod:convert_to
'''
from __future__ import print_function
import sys
import os
import shutil
@ -17,31 +46,7 @@ def show_error(msg, code=1):
def usage():
print("Usage:")
print(sys.argv[0] + " mod [options]")
print("")
print("Options:")
print(
'''
--fill adds only missing files to an existing mod (instead of
failing when directory exists).
[alias to] (do not actually use brackets) If you specify any two
options without --, the first will be an alias and the
second will be convert_to. The alias options are only for
mods that are aliases, as a shortcut to creating a mostly
complete mod (other than copyright information and
description) with only this script.
'''
)
print("")
print("Examples:")
print(sys.argv[0] + " mod_name")
print(sys.argv[0] + " mod_name --fill")
print(sys.argv[0] + " mod_name modname:item_name other_modname:convert_to")
print(sys.argv[0] + " mod_name mobsmod:mob_name other_mobsmod:convert_to")
print("")
print("")
print(__doc__)
def main():
@ -170,7 +175,7 @@ def main():
print("")
print("")
print(step0)
print("The new mod is the " + thisName + " folder. Remember to:")
print("The new mod is tgeneratemod.pyhe " + thisName + " folder. Remember to:")
ender = "."
if (toMod is not None) and (len(toMod) > 0):
ender = ""

2
utilities/mtcompile-program-local.py

@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
---------------------------------------------------------------------
file information
@ -27,6 +28,7 @@
overview
---------------------------------------------------------------------
"""
from __future__ import print_function
import sys
import subprocess
import shutil

32
utilities/mtoldtonew.py

@ -1,16 +1,12 @@
#!/usr/bin/env python
import os
import csv
import sys
mtdeltas_csv = "mtoldtonew.csv"
if not os.path.isfile(mtdeltas_csv):
print("ERROR: missing " + mtdeltas_csv)
# exit(1)
files = []
'''
mtoldtonew
----------
This script uses mtoldtonew.csv to convert node names in "we" schem
file(s). The destination filename(s) are generated automatically. Each
will have "new" instead of "old" if the original file had "old" in the
name. Otherwise, it will have "new" added to the beginning of the name.
usageStr = '''
Usage:
python3 mtoldtonew.py <filename>
or
@ -29,12 +25,22 @@ Examples:
from mtoldtonew import oldToNew
oldToNew('file.we', quotechar='')
edit '%s' as needed (old name in column 1, new name in 2)
'''
usageStr += "edit '%s' as needed (old name in column 1, new name in 2)"
from __future__ import print_function
import os
import csv
import sys
mtdeltas_csv = "mtoldtonew.csv"
if not os.path.isfile(mtdeltas_csv):
print("ERROR: missing " + mtdeltas_csv)
# exit(1)
files = []
def usage():
print(usageStr)
print(__doc__)
mtdeltas = {}

Loading…
Cancel
Save