Fixed glob
Paths must be escaped first in case they contain special characters
This commit is contained in:
parent
641afed0a9
commit
d7eedc1068
@ -69,7 +69,7 @@ for module_path in (
|
|||||||
MINECRAFT_MODEL_READER,
|
MINECRAFT_MODEL_READER,
|
||||||
):
|
):
|
||||||
for path in glob.glob(
|
for path in glob.glob(
|
||||||
os.path.join(os.path.abspath(module_path), "**", "*.py"), recursive=True
|
os.path.join(glob.escape(os.path.abspath(module_path)), "**", "*.py"), recursive=True
|
||||||
):
|
):
|
||||||
if path not in added_source:
|
if path not in added_source:
|
||||||
rel_path: str = os.path.relpath(path, os.path.dirname(module_path))
|
rel_path: str = os.path.relpath(path, os.path.dirname(module_path))
|
||||||
|
@ -47,7 +47,7 @@ def _init_log():
|
|||||||
# set up handlers
|
# set up handlers
|
||||||
os.makedirs(logs_path, exist_ok=True)
|
os.makedirs(logs_path, exist_ok=True)
|
||||||
# remove all log files older than a week
|
# remove all log files older than a week
|
||||||
for path in glob.glob(os.path.join(logs_path, "*.log")):
|
for path in glob.glob(os.path.join(glob.escape(logs_path), "*.log")):
|
||||||
if (
|
if (
|
||||||
os.path.isfile(path)
|
os.path.isfile(path)
|
||||||
and os.path.getmtime(path) < time.time() - 3600 * 24 * 7
|
and os.path.getmtime(path) < time.time() - 3600 * 24 * 7
|
||||||
|
@ -92,7 +92,7 @@ def get_languages() -> List[str]:
|
|||||||
"""Get a list of all supported language codes."""
|
"""Get a list of all supported language codes."""
|
||||||
langs = set()
|
langs = set()
|
||||||
for d in _lang_dirs:
|
for d in _lang_dirs:
|
||||||
for l in glob.glob(os.path.join(d, "*.lang")):
|
for l in glob.glob(os.path.join(glob.escape(d), "*.lang")):
|
||||||
langs.add(os.path.basename(l)[:-5])
|
langs.add(os.path.basename(l)[:-5])
|
||||||
return sorted(langs)
|
return sorted(langs)
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ def _find_langs(path: str) -> Tuple[Optional[str], Optional[str], Optional[str]]
|
|||||||
"""Find the default, language specific and region specific lang paths."""
|
"""Find the default, language specific and region specific lang paths."""
|
||||||
langs = {
|
langs = {
|
||||||
parse_language_id(os.path.basename(lpath)[:-5]): lpath
|
parse_language_id(os.path.basename(lpath)[:-5]): lpath
|
||||||
for lpath in glob.glob(os.path.join(path, "*.lang"))
|
for lpath in glob.glob(os.path.join(glob.escape(path), "*.lang"))
|
||||||
}
|
}
|
||||||
|
|
||||||
default_key = parse_language_id(_default_language)
|
default_key = parse_language_id(_default_language)
|
||||||
|
@ -106,7 +106,7 @@ class OpenGLResourcePack:
|
|||||||
os.stat(path).st_mtime
|
os.stat(path).st_mtime
|
||||||
for pack in self._resource_pack.pack_paths
|
for pack in self._resource_pack.pack_paths
|
||||||
for path in glob.glob(
|
for path in glob.glob(
|
||||||
os.path.join(pack, "**", "*.*"), recursive=True
|
os.path.join(glob.escape(pack), "**", "*.*"), recursive=True
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
default=0,
|
default=0,
|
||||||
|
@ -11,7 +11,7 @@ KeyCharacterSet = set(string.ascii_lowercase + string.digits + "_.")
|
|||||||
class LangTestCase(unittest.TestCase):
|
class LangTestCase(unittest.TestCase):
|
||||||
def test_lang(self):
|
def test_lang(self):
|
||||||
for lang_dir in lang_dirs():
|
for lang_dir in lang_dirs():
|
||||||
for lang_path in glob.glob(os.path.join(lang_dir, "*")):
|
for lang_path in glob.glob(os.path.join(glob.escape(lang_dir), "*")):
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
lang_path.endswith(".lang"),
|
lang_path.endswith(".lang"),
|
||||||
f'{lang_path} does not end with ".lang".',
|
f'{lang_path} does not end with ".lang".',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user