please-av1ppp 0.0.1__tar.gz

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.
@@ -0,0 +1,164 @@
1
+ Pleasefile.py
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
112
+ .pdm.toml
113
+ .pdm-python
114
+ .pdm-build/
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Avi Parampampam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.3
2
+ Name: please_av1ppp
3
+ Version: 0.0.1
4
+ Summary: Simple task runner
5
+ Project-URL: Homepage, https://github.com/av1ppp/please
6
+ Project-URL: Issues, https://github.com/av1ppp/please/issues
7
+ Author-email: Avi Parampampam <aviparampampam@gmail.com>
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.12
10
+ Requires-Dist: setuptools>=74.1.1
11
+ Description-Content-Type: text/markdown
12
+
13
+ # 🙏 Please
14
+
15
+ Please is a simple task runner
16
+
17
+ ### TODO
18
+
19
+ - Add dependency support
@@ -0,0 +1,7 @@
1
+ # 🙏 Please
2
+
3
+ Please is a simple task runner
4
+
5
+ ### TODO
6
+
7
+ - Add dependency support
@@ -0,0 +1,4 @@
1
+ from .internal.env import loadenv, parseenv
2
+ from .internal.registertask import register_task as task
3
+ from .internal.shexec import shexec
4
+ from .internal.taskcontext import TaskContext
@@ -0,0 +1,107 @@
1
+ from pathlib import Path
2
+ from sys import argv, exit
3
+
4
+ from pkg_resources import get_distribution
5
+
6
+ from .internal.taskcontext import TaskContext
7
+ from .internal.tasks import tasks
8
+
9
+ dist = get_distribution("please")
10
+
11
+ pleasefile_names = [
12
+ Path("Pleasefile.py"),
13
+ Path("Pleasefile"),
14
+ ]
15
+
16
+ init_command = ["-i", "-init", "--init"]
17
+ help_command = ["-h", "-help", "--help"]
18
+ version_command = ["-v", "-version", "--version"]
19
+
20
+ help_indent = " "
21
+
22
+
23
+ def main():
24
+ load_pleasefile_if_exists()
25
+
26
+ args = argv[1:]
27
+
28
+ if len(args) == 0 or args[0] in help_command:
29
+ print_help()
30
+ return
31
+
32
+ if args[0] in init_command:
33
+ init_pleasefile()
34
+ return
35
+
36
+ if args[0] in version_command:
37
+ print_version()
38
+ return
39
+
40
+ if args[0] in tasks:
41
+ task = tasks[args[0]]
42
+ ctx = TaskContext()
43
+ task(ctx)
44
+ return
45
+
46
+ panic(f"Command or task '{args[0]}' not found. Try to use -h command.")
47
+
48
+
49
+ def init_pleasefile():
50
+ filename = pleasefile_names[0]
51
+ if filename.exists():
52
+ panic("Pleasefile already created")
53
+
54
+ with open(filename, mode="w") as file:
55
+ file.write(
56
+ """from please import TaskContext, task
57
+
58
+
59
+ @task()
60
+ def hello(ctx: TaskContext):
61
+ print("Hello world")
62
+ """
63
+ )
64
+
65
+
66
+ def print_version():
67
+ print("Please v" + dist.version)
68
+
69
+
70
+ def print_help():
71
+ print("PLEASE - simple task runner.")
72
+ print()
73
+
74
+ print("COMMANDS:")
75
+ print_command(init_command, "Create empty Pleasefile")
76
+ print_command(help_command, "Show this message")
77
+ print_command(version_command, "Show version")
78
+
79
+ if len(tasks) > 0:
80
+ print()
81
+ print("TASKS:")
82
+ for task_name, _ in tasks.items():
83
+ print(f"{help_indent}{task_name}")
84
+
85
+
86
+ def load_pleasefile_if_exists():
87
+ for filename in pleasefile_names:
88
+ if not filename.exists():
89
+ continue
90
+
91
+ with open(filename, mode="r") as file:
92
+ data = file.read()
93
+ exec(data)
94
+ return
95
+
96
+
97
+ def print_command(command: list, description: str):
98
+ print(help_indent + ", ".join(command).ljust(26, " ") + description)
99
+
100
+
101
+ def panic(*values: object):
102
+ print("ERROR:", *values)
103
+ exit(1)
104
+
105
+
106
+ if __name__ == "__main__":
107
+ main()
@@ -0,0 +1,24 @@
1
+ from os import PathLike, environ
2
+
3
+ Path = str | bytes | PathLike[str] | PathLike[bytes]
4
+
5
+
6
+ def parseenv(path: Path):
7
+ env: dict[str, str] = dict()
8
+
9
+ with open(path, mode="r") as file:
10
+ for line in file.readlines():
11
+ line = line.strip()
12
+ if len(line) == 0 or line.startswith("#"):
13
+ continue
14
+
15
+ splitted = line.split("=", maxsplit=2)
16
+ env[splitted[0].strip()] = splitted[1].strip()
17
+
18
+ return env
19
+
20
+
21
+ def loadenv(path: Path):
22
+ env = parseenv(path)
23
+ for key, value in env.items():
24
+ environ[key] = value
@@ -0,0 +1,24 @@
1
+ from .taskfunc import TaskFunc
2
+ from .tasks import tasks
3
+
4
+
5
+ def register_task(name: str | None = None):
6
+ def decorator(func: TaskFunc):
7
+ nonlocal name
8
+
9
+ if name is None:
10
+ name = func.__name__
11
+
12
+ if name in tasks:
13
+ raise Exception(f"Task {name} already registered")
14
+
15
+ tasks[name] = func
16
+
17
+ # def wrapper() -> None:
18
+ # context = TaskContext()
19
+ # return func(context)
20
+
21
+ # return wrapper
22
+ return func
23
+
24
+ return decorator
@@ -0,0 +1,40 @@
1
+ from collections.abc import Buffer
2
+ from os import _Environ as Env
3
+ from pathlib import Path
4
+ from subprocess import run as subprocess_run
5
+ from sys import stderr, stdout
6
+
7
+
8
+ def shexec(
9
+ args: list[str | Path] | str | Path,
10
+ env: Env | dict | None = None,
11
+ cwd: Path | str | None = None,
12
+ timeout: float | None = None,
13
+ input: Buffer | None = None,
14
+ capture_output: bool = False,
15
+ ):
16
+ return subprocess_run(
17
+ check=True,
18
+ input=input,
19
+ timeout=timeout,
20
+ args=_build_args(args),
21
+ capture_output=capture_output,
22
+ env=env,
23
+ cwd=cwd,
24
+ shell=True,
25
+ stdout=None if capture_output else stdout,
26
+ stderr=None if capture_output else stderr,
27
+ )
28
+
29
+
30
+ def _build_args(args: list[str | Path] | str | Path) -> str:
31
+ if isinstance(args, str):
32
+ return args
33
+ if isinstance(args, Path):
34
+ return str(args)
35
+ if isinstance(args, list):
36
+ cmd = ""
37
+ for arg in args:
38
+ cmd += str(arg) + " "
39
+ return cmd
40
+ raise TypeError("invalid args type")
@@ -0,0 +1,2 @@
1
+ class TaskContext:
2
+ pass
@@ -0,0 +1,5 @@
1
+ from typing import Callable
2
+
3
+ from .taskcontext import TaskContext
4
+
5
+ TaskFunc = Callable[[TaskContext], None]
@@ -0,0 +1,5 @@
1
+ from typing import Dict
2
+
3
+ from .taskfunc import TaskFunc
4
+
5
+ tasks: Dict[str, TaskFunc] = {}
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [tool.hatch.build.targets.wheel]
6
+ packages = ["please"]
7
+
8
+ [tool.hatch.build.targets.sdist]
9
+ exclude = ["ruff.toml"]
10
+
11
+ [project]
12
+ name = "please_av1ppp"
13
+ version = "0.0.1"
14
+ authors = [{ name = "Avi Parampampam", email = "aviparampampam@gmail.com" }]
15
+ description = "Simple task runner"
16
+ readme = "README.md"
17
+ requires-python = ">=3.12"
18
+ dependencies = ["setuptools>=74.1.1"]
19
+
20
+ [project.scripts]
21
+ pls = "please.cli:main"
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/av1ppp/please"
25
+ Issues = "https://github.com/av1ppp/please/issues"