Browse Source

switch to repr

master
poikilos 4 weeks ago
parent
commit
142e6f097a
  1. 4
      pyenliven/mttexture.py
  2. 9
      utilities/run-any

4
pyenliven/mttexture.py

@ -33,7 +33,6 @@ import os
from collections import OrderedDict from collections import OrderedDict
from PIL import Image from PIL import Image
from pprint import pformat
def echo0(*args, **kwargs): def echo0(*args, **kwargs):
@ -179,7 +178,7 @@ def recompose_anim(options):
raise ValueError( raise ValueError(
"{} should be a(n) {} but got {} {}." "{} should be a(n) {} but got {} {}."
"".format(name, option_type_name, "".format(name, option_type_name,
type(value).__name__, pformat(value)) type(value).__name__, repr(value))
) )
framer = Framer() framer = Framer()
img = Image.open(options['path']) img = Image.open(options['path'])
@ -273,4 +272,3 @@ def main():
print('- & keep Lua same) with:') print('- & keep Lua same) with:')
print('-- name="{}"'.format(new_path)) print('-- name="{}"'.format(new_path))
return 0 return 0

9
utilities/run-any

@ -14,7 +14,6 @@ import subprocess
import copy import copy
import shlex import shlex
import platform import platform
from pprint import pformat
from collections import OrderedDict from collections import OrderedDict
SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__)) SCRIPTS_DIR = os.path.dirname(os.path.realpath(__file__))
@ -100,7 +99,7 @@ def show_and_return(cmd, enable_collect=False, cwd=None, shell=False):
# <https://cyberciti.biz/faq/python-run-external-command-and-get-output/>) # <https://cyberciti.biz/faq/python-run-external-command-and-get-output/>)
if shell not in [None, True, False]: if shell not in [None, True, False]:
raise ValueError("Expected None, True, or False for shell but got %s" raise ValueError("Expected None, True, or False for shell but got %s"
% pformat(shell)) % repr(shell))
if cwd is None: if cwd is None:
cwd = os.getcwd() cwd = os.getcwd()
if shell and not hasattr(cmd, "split"): if shell and not hasattr(cmd, "split"):
@ -140,7 +139,7 @@ def show_and_return(cmd, enable_collect=False, cwd=None, shell=False):
cmd = ["bash", "-c", "cd '" + cwd + "'; " + pre_bin + shlex.join(cmd)] cmd = ["bash", "-c", "cd '" + cwd + "'; " + pre_bin + shlex.join(cmd)]
else: else:
cmd = ["bash", "-c", "cd '" + cwd + "'; " + pre_bin + cmd] cmd = ["bash", "-c", "cd '" + cwd + "'; " + pre_bin + cmd]
run_msg = prefix+"Running %s" % pformat(cmd) run_msg = prefix+"Running %s" % repr(cmd)
run_msg += ' # shell=%s in "%s"' % (shell, cwd) run_msg += ' # shell=%s in "%s"' % (shell, cwd)
echo0(run_msg) echo0(run_msg)
if cwd is not None: if cwd is not None:
@ -298,7 +297,7 @@ def show_and_return(cmd, enable_collect=False, cwd=None, shell=False):
if len(meta['string']) > 0: if len(meta['string']) > 0:
raise NotImplementedError( raise NotImplementedError(
"The remaining %s wasn't processed: %s" "The remaining %s wasn't processed: %s"
% (_, pformat(meta['string'])) % (_, repr(meta['string']))
) )
return { return {
'code': code, 'code': code,
@ -387,7 +386,7 @@ def main():
if count < 1: if count < 1:
cmd_msg = cmd if isinstance(cmd, str) else shlex.join(cmd) cmd_msg = cmd if isinstance(cmd, str) else shlex.join(cmd)
print(" (Output of `%s` had %s line(s) of output.)" print(" (Output of `%s` had %s line(s) of output.)"
% (pformat(cmd_msg), count), % (repr(cmd_msg), count),
file=sys.stderr) file=sys.stderr)
else: else:
print("", file=sys.stderr) print("", file=sys.stderr)

Loading…
Cancel
Save