0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

online-judge-tools の verification-helper (oj-verify) の pkg_resources を置き換える

0
Posted at

onlinejudge_verify/documentation/build.py

7行目付近

build.py
  import copy
  import pathlib
  import traceback
+ from importlib.resources import files as files_fn
  from logging import getLogger
  from typing import *

- import pkg_resources
  import yaml

200行目付近

build.py
  # load files in onlinejudge_verify_resources/
  for path in _COPIED_STATIC_FILE_PATHS:
-     files[site_render_config.destination_dir / pathlib.Path(path)] = pkg_resources.resource_string(_RESOURCE_PACKAGE, path)
+     files[site_render_config.destination_dir / pathlib.Path(path)] = files_fn(_RESOURCE_PACKAGE).joinpath(path).read_bytes()

onlinejudge_verify/documentation/main.py

冒頭

main.py
  import json
  import pathlib
+ from importlib.resources import files
  from logging import getLogger
  from typing import *

- import pkg_resources
  import yaml

34行目付近

main.py
  def load_render_config(*, basedir: pathlib.Path) -> SiteRenderConfig:
      # load default _config.yml
-     default_config_yml = yaml.safe_load(pkg_resources.resource_string(_RESOURCE_PACKAGE, _CONFIG_YML_PATH))
+     default_config_yml = yaml.safe_load(files(_RESOURCE_PACKAGE).joinpath(_CONFIG_YML_PATH).read_bytes())
      assert default_config_yml is not None
      config_yml = default_config_yml
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?