tedit 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tedit/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ __all__ = ["__version__"]
2
+ __version__ = "0.9.0"
tedit/__main__.py ADDED
@@ -0,0 +1,10 @@
1
+ from ._pip_only import enforce_pip_only
2
+ from . import __version__
3
+
4
+ def main():
5
+ enforce_pip_only("tedit")
6
+ from .app import run
7
+ run()
8
+
9
+ if __name__ == "__main__":
10
+ main()
tedit/_pip_only.py ADDED
@@ -0,0 +1,16 @@
1
+ import os, sys, pathlib
2
+ from importlib import metadata
3
+
4
+ def enforce_pip_only(package_name: str = "tedit") -> None:
5
+ here = pathlib.Path(__file__).resolve()
6
+ try:
7
+ dist = metadata.distribution(package_name)
8
+ dist_root = pathlib.Path(dist.locate_file(""))
9
+ if not str(here).startswith(str(dist_root)):
10
+ raise FileNotFoundError
11
+ except Exception:
12
+ sys.stderr.write(
13
+ "License notice: TE may be used only when installed via pip from the official PyPI package.\n"
14
+ f"Please run: pip install {package_name}\n"
15
+ )
16
+ sys.exit(1)