forked from UsergeTeam/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extends userge.utils (UsergeTeam#122)
* let me add short way * added shortcut for _parse_button * fixing pep8 😅 * extends userge.utils (thks @Krishna-Singhal idea) Co-authored-by: rking32 <[email protected]>
- Loading branch information
1 parent
7d33e5a
commit 036e6f8
Showing
5 changed files
with
130 additions
and
104 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,33 @@ | ||
# pylint: disable=missing-module-docstring | ||
# | ||
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >. | ||
# | ||
# This file is part of < https://github.com/UsergeTeam/Userge > project, | ||
# and is released under the "GNU v3.0 License Agreement". | ||
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE > | ||
# | ||
# All rights reserved. | ||
|
||
from glob import glob | ||
from os.path import isfile, relpath | ||
from typing import Dict, List, Union | ||
|
||
|
||
class SafeDict(Dict[str, str]): | ||
""" modded dict """ | ||
def __missing__(self, key: str) -> str: | ||
return '{' + key + '}' | ||
|
||
|
||
def get_import_path(root: str, path: str) -> Union[str, List[str]]: | ||
""" return import path """ | ||
seperator = '\\' if '\\' in root else '/' | ||
if isfile(path): | ||
return '.'.join(relpath(path, root).split(seperator))[:-3] | ||
all_paths = glob(root + path.rstrip(seperator) + f"{seperator}*.py", recursive=True) | ||
return sorted( | ||
[ | ||
'.'.join(relpath(f, root).split(seperator))[:-3] for f in all_paths | ||
if not f.endswith("__init__.py") | ||
] | ||
) |
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