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 This script uses the pyenliven.compatiblizemod submodule to try to make
the mod the mod
''' '''
from __future__ import print_function
import re import re
import sys import sys
import os import os
UTILITIES_DIR = os.path.dirname(os.path.realpath(__file__)) from find_pyenliven import pyenliven
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 pyenliven.compatiblizemod import main from pyenliven.compatiblizemod import main

1
utilities/enissue.py

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

2
utilities/enlynx.py

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' '''
Specify a label or search term, optionally with a page #. Specify a label or search term, optionally with a page #.
@ -30,6 +31,7 @@ Examples:
''' '''
from __future__ import print_function
import sys import sys
import subprocess import subprocess
me = "enlynx.py" 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 #!/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 sys
import os import os
import shutil import shutil
@ -17,31 +46,7 @@ def show_error(msg, code=1):
def usage(): def usage():
print("Usage:") print(__doc__)
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("")
def main(): def main():
@ -170,7 +175,7 @@ def main():
print("") print("")
print("") print("")
print(step0) print(step0)
print("The new mod is the " + thisName + " folder. Remember to:") print("The new mod is tgeneratemod.pyhe " + thisName + " folder. Remember to:")
ender = "." ender = "."
if (toMod is not None) and (len(toMod) > 0): if (toMod is not None) and (len(toMod) > 0):
ender = "" ender = ""

2
utilities/mtcompile-program-local.py

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

32
utilities/mtoldtonew.py

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

Loading…
Cancel
Save