Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip reduce need to explicitly namespace Module() UI code
- Loading branch information
Showing
20 changed files
with
164 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# TODO: make this available under the shiny.modules API | ||
__all__ = ("namespaced_id",) | ||
|
||
from typing import Union, Optional | ||
|
||
from .types import MISSING, MISSING_TYPE | ||
|
||
|
||
def namespaced_id(id: str, ns: Union[str, MISSING_TYPE, None] = MISSING) -> str: | ||
""" | ||
Namespace an ID based on the current ``Module()``'s namespace. | ||
Parameters | ||
---------- | ||
id | ||
The ID to namespace.. | ||
""" | ||
if isinstance(ns, MISSING_TYPE): | ||
ns = get_current_namespace() | ||
|
||
if ns is None: | ||
return id | ||
else: | ||
return ns + "_" + id | ||
|
||
|
||
def get_current_namespace() -> Optional[str]: | ||
from .session import get_current_session | ||
|
||
session = get_current_session() | ||
if session is None: | ||
return None | ||
else: | ||
return session._ns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.