Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Update autodiscovery function for windows #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/en/guide/how-to/autodiscovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ from inspect import getmembers
from pathlib import Path
from types import ModuleType
from typing import Union
import os

from sanic.blueprints import Blueprint

Expand Down Expand Up @@ -82,7 +83,8 @@ def autodiscover(
if path not in _imported:
name = "module"
if "__init__" in path:
*_, name, __ = path.split("/")
sep = "\\" if os.name == 'nt' else "/"
*_, name, __ = path.split(sep)
spec = util.spec_from_file_location(name, path)
specmod = util.module_from_spec(spec)
_imported.add(path)
Expand Down
4 changes: 3 additions & 1 deletion src/ja/guide/how-to/autodiscovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ from inspect import getmembers
from pathlib import Path
from types import ModuleType
from typing import Union
import os

from sanic.blueprints import Blueprint

Expand Down Expand Up @@ -82,7 +83,8 @@ def autodiscover(
if path not in _imported:
name = "module"
if "__init__" in path:
*_, name, __ = path.split("/")
sep = "\\" if os.name == 'nt' else "/"
*_, name, __ = path.split(sep)
spec = util.spec_from_file_location(name, path)
specmod = util.module_from_spec(spec)
_imported.add(path)
Expand Down
4 changes: 3 additions & 1 deletion src/zh/guide/how-to/autodiscovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ from inspect import getmembers
from pathlib import Path
from types import ModuleType
from typing import Union
import os

from sanic.blueprints import Blueprint

Expand Down Expand Up @@ -88,7 +89,8 @@ def autodiscover(
if path not in _imported:
name = "module"
if "__init__" in path:
*_, name, __ = path.split("/")
sep = "\\" if os.name == 'nt' else "/"
*_, name, __ = path.split(sep)
spec = util.spec_from_file_location(name, path)
specmod = util.module_from_spec(spec)
_imported.add(path)
Expand Down