mirror of
https://github.com/daylinmorgan/swydd.git
synced 2024-11-23 15:20:43 -06:00
docs: add clearer automagic-snippet
This commit is contained in:
parent
4f0c3c7da0
commit
28480919f7
1 changed files with 6 additions and 9 deletions
15
README.md
15
README.md
|
@ -16,15 +16,12 @@
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# https://github.com/daylinmorgan/swydd?tab=readme-ov-file#automagic-snippet
|
# https://github.com/daylinmorgan/swydd?tab=readme-ov-file#automagic-snippet
|
||||||
# fmt: off
|
_src = (_i := __import__)("pathlib").Path(__file__).parent / "swydd/__init__.py"
|
||||||
if not (src := __import__("pathlib").Path(__file__).parent / "swydd/__init__.py").is_file(): # noqa
|
if not (_i("importlib.util").util.find_spec("sywdd") or _src.is_file()):
|
||||||
try: __import__("swydd") # noqa
|
_i("sys").stderr.write(f"installing swydd to {_src}\n")
|
||||||
except ImportError:
|
_r= _i("urllib.request").request.urlopen("https://swydd.dayl.in/swydd.py")
|
||||||
import sys; from urllib.request import urlopen; from urllib.error import URLError # noqa
|
_src.parent.mkdir(exist_ok=True)
|
||||||
try: r = urlopen("https://raw.githubusercontent.com/daylinmorgan/swydd/main/src/swydd/__init__.py") # noqa
|
_src.write_text(_r.read().decode("utf-8"))
|
||||||
except URLError as e: sys.exit(f"{e}\n") # noqa
|
|
||||||
src.parent.mkdir(exist_ok=True); src.write_text(r.read().decode("utf-8")); # noqa
|
|
||||||
# fmt: on
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Alternatives
|
## Alternatives
|
||||||
|
|
Loading…
Reference in a new issue