teddecor.Util
Util
A collection of modules and helpful features that that are commonly used.
1"""Util 2 3A collection of modules and helpful features that that are commonly used. 4""" 5 6__all__ = ["import_scope", "slash"] 7 8 9def slash() -> str: 10 """Get the type of slash based on the os. 11 12 Returns: 13 str: OS filesystem specific slash character 14 """ 15 from sys import platform 16 17 return "\\" if "win" in platform else "/" 18 19 20def CR() -> str: 21 """Get platform specific CR 22 23 Returns: 24 str: CR character 25 """ 26 from sys import platform 27 28 return "\r\n" if "win" in platform else "\n" 29 30 31def import_scope(rel_path: str = "../"): 32 """Imports a directory to your pythons env path. This allows you to use a module or package that is in a local directory but out of scope.""" 33 path = rel_path.replace("\\/", slash()) 34 35 if path.startswith("~"): 36 from pathlib import Path 37 38 path = path.replace("~", str(Path.home())) 39 40 from sys import path as envpath 41 42 envpath.insert(0, path)
def
import_scope(rel_path: str = '../')
32def import_scope(rel_path: str = "../"): 33 """Imports a directory to your pythons env path. This allows you to use a module or package that is in a local directory but out of scope.""" 34 path = rel_path.replace("\\/", slash()) 35 36 if path.startswith("~"): 37 from pathlib import Path 38 39 path = path.replace("~", str(Path.home())) 40 41 from sys import path as envpath 42 43 envpath.insert(0, path)
Imports a directory to your pythons env path. This allows you to use a module or package that is in a local directory but out of scope.
def
slash() -> str:
10def slash() -> str: 11 """Get the type of slash based on the os. 12 13 Returns: 14 str: OS filesystem specific slash character 15 """ 16 from sys import platform 17 18 return "\\" if "win" in platform else "/"
Get the type of slash based on the os.
Returns: str: OS filesystem specific slash character