qualitybase 0.1.0__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.
Files changed (46) hide show
  1. qualitybase-0.1.0/LICENSE +22 -0
  2. qualitybase-0.1.0/PKG-INFO +291 -0
  3. qualitybase-0.1.0/README.md +248 -0
  4. qualitybase-0.1.0/pyproject.toml +160 -0
  5. qualitybase-0.1.0/setup.cfg +4 -0
  6. qualitybase-0.1.0/src/qualitybase/__init__.py +4 -0
  7. qualitybase-0.1.0/src/qualitybase/__main__.py +9 -0
  8. qualitybase-0.1.0/src/qualitybase/cli.py +436 -0
  9. qualitybase-0.1.0/src/qualitybase/commands/__init__.py +5 -0
  10. qualitybase-0.1.0/src/qualitybase/commands/base.py +41 -0
  11. qualitybase-0.1.0/src/qualitybase/commands/help.py +26 -0
  12. qualitybase-0.1.0/src/qualitybase/commands/varenv.py +55 -0
  13. qualitybase-0.1.0/src/qualitybase/commands/version.py +24 -0
  14. qualitybase-0.1.0/src/qualitybase/services/__init__.py +2 -0
  15. qualitybase-0.1.0/src/qualitybase/services/cli.py +78 -0
  16. qualitybase-0.1.0/src/qualitybase/services/dev/__init__.py +2 -0
  17. qualitybase-0.1.0/src/qualitybase/services/dev/build.py +35 -0
  18. qualitybase-0.1.0/src/qualitybase/services/dev/clean.py +72 -0
  19. qualitybase-0.1.0/src/qualitybase/services/dev/env.py +236 -0
  20. qualitybase-0.1.0/src/qualitybase/services/dev/help.py +44 -0
  21. qualitybase-0.1.0/src/qualitybase/services/dev/lib.py +85 -0
  22. qualitybase-0.1.0/src/qualitybase/services/dev.py +79 -0
  23. qualitybase-0.1.0/src/qualitybase/services/django/__init__.py +2 -0
  24. qualitybase-0.1.0/src/qualitybase/services/django/manage.py +57 -0
  25. qualitybase-0.1.0/src/qualitybase/services/django.py +231 -0
  26. qualitybase-0.1.0/src/qualitybase/services/publish/__init__.py +2 -0
  27. qualitybase-0.1.0/src/qualitybase/services/publish/release.py +429 -0
  28. qualitybase-0.1.0/src/qualitybase/services/publish/socialnetwork.py +391 -0
  29. qualitybase-0.1.0/src/qualitybase/services/publish.py +131 -0
  30. qualitybase-0.1.0/src/qualitybase/services/quality/__init__.py +2 -0
  31. qualitybase-0.1.0/src/qualitybase/services/quality/cleanup.py +96 -0
  32. qualitybase-0.1.0/src/qualitybase/services/quality/complexity.py +62 -0
  33. qualitybase-0.1.0/src/qualitybase/services/quality/lint.py +163 -0
  34. qualitybase-0.1.0/src/qualitybase/services/quality/security.py +176 -0
  35. qualitybase-0.1.0/src/qualitybase/services/quality/test.py +42 -0
  36. qualitybase-0.1.0/src/qualitybase/services/quality.py +125 -0
  37. qualitybase-0.1.0/src/qualitybase/services/service/__init__.py +12 -0
  38. qualitybase-0.1.0/src/qualitybase/services/service/help.py +85 -0
  39. qualitybase-0.1.0/src/qualitybase/services/service/main.py +92 -0
  40. qualitybase-0.1.0/src/qualitybase/services/service/run.py +116 -0
  41. qualitybase-0.1.0/src/qualitybase/services/utils.py +565 -0
  42. qualitybase-0.1.0/src/qualitybase.egg-info/PKG-INFO +291 -0
  43. qualitybase-0.1.0/src/qualitybase.egg-info/SOURCES.txt +44 -0
  44. qualitybase-0.1.0/src/qualitybase.egg-info/dependency_links.txt +1 -0
  45. qualitybase-0.1.0/src/qualitybase.egg-info/requires.txt +22 -0
  46. qualitybase-0.1.0/src/qualitybase.egg-info/top_level.txt +1 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 qualitybase contributors
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.
22
+
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.4
2
+ Name: qualitybase
3
+ Version: 0.1.0
4
+ Summary: Standardized services and tooling for managing code quality, development workflows, and project maintenance in Python projects
5
+ Author-email: Hicinformatic <hicinformatic@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/hicinformatic/python-qualitybase
8
+ Project-URL: Repository, https://github.com/hicinformatic/python-qualitybase
9
+ Project-URL: Documentation, https://github.com/hicinformatic/python-qualitybase#readme
10
+ Project-URL: Issues, https://github.com/hicinformatic/python-qualitybase/issues
11
+ Keywords: code-quality,linting,testing,development-tools,python,ci-cd,code-analysis
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Provides-Extra: lint
25
+ Requires-Dist: ruff>=0.5.0; extra == "lint"
26
+ Requires-Dist: mypy>=1.0.0; extra == "lint"
27
+ Requires-Dist: semgrep>=1.0.0; extra == "lint"
28
+ Requires-Dist: pylint>=3.0.0; extra == "lint"
29
+ Provides-Extra: quality
30
+ Requires-Dist: radon>=6.0.0; extra == "quality"
31
+ Requires-Dist: vulture>=2.0.0; extra == "quality"
32
+ Requires-Dist: autoflake>=2.0.0; extra == "quality"
33
+ Provides-Extra: security
34
+ Requires-Dist: bandit>=1.7.0; extra == "security"
35
+ Requires-Dist: safety>=3.0.0; extra == "security"
36
+ Requires-Dist: pip-audit>=2.7.0; extra == "security"
37
+ Requires-Dist: semgrep>=1.0.0; extra == "security"
38
+ Provides-Extra: test
39
+ Requires-Dist: pytest>=8.3.0; extra == "test"
40
+ Requires-Dist: pytest-cov>=4.1.0; extra == "test"
41
+ Requires-Dist: pytest-xdist>=3.5.0; extra == "test"
42
+ Dynamic: license-file
43
+
44
+ # python-qualitybase
45
+
46
+ Qualitybase is a Python library that provides standardized services and tooling for managing code quality, development workflows, and project maintenance in Python projects.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install qualitybase
52
+ ```
53
+
54
+ For development:
55
+
56
+ ```bash
57
+ pip install -e .
58
+ pip install -e ".[dev,lint,quality,security,test]"
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ Qualitybase provides a unified entry point via the `service.py` script:
64
+
65
+ ```bash
66
+ ./service.py <service> <command>
67
+ ```
68
+
69
+ ### Available Services
70
+
71
+ - **`quality`**: Quality checks (lint, security, test, complexity, cleanup)
72
+ - **`dev`**: Development tools (venv, install, clean, build, etc.)
73
+ - **`django`**: Django-specific services
74
+ - **`publish`**: Package publishing and distribution
75
+ - **`cli`**: Command-line interface for packages
76
+
77
+ ### Examples
78
+
79
+ ```bash
80
+ # Quality checks
81
+ ./service.py quality lint
82
+ ./service.py quality security
83
+ ./service.py quality all
84
+
85
+ # Development tools
86
+ ./service.py dev venv
87
+ ./service.py dev install-dev
88
+ ./service.py dev clean
89
+
90
+ # Help
91
+ ./service.py quality help
92
+ ./service.py dev help
93
+ ```
94
+
95
+ ## CLI System
96
+
97
+ Qualitybase includes a flexible CLI system that allows packages to define custom commands through a `commands` directory.
98
+
99
+ ### Command Discovery
100
+
101
+ The CLI system automatically discovers commands from:
102
+
103
+ 1. **`commands/` directory**: A directory next to `cli.py` containing command modules
104
+ 2. **`.commands.json` configuration file**: A JSON file that can specify:
105
+ - `packages`: List of packages to discover commands from
106
+ - `directories`: List of directories to scan for commands
107
+ - `commands`: Direct command definitions
108
+
109
+ ### Creating Commands
110
+
111
+ Commands can be created in two ways:
112
+
113
+ #### Method 1: Using the `Command` class
114
+
115
+ Create a file in the `commands/` directory (e.g., `commands/mycommand.py`):
116
+
117
+ ```python
118
+ from .base import Command
119
+
120
+ def _mycommand_command(args: list[str]) -> bool:
121
+ """Description of what this command does."""
122
+ # Command implementation
123
+ print("Hello from mycommand!")
124
+ return True
125
+
126
+ mycommand_command = Command(_mycommand_command, "Description of what this command does")
127
+ ```
128
+
129
+ The command will be automatically discovered and available as:
130
+ ```bash
131
+ ./service.py cli mycommand
132
+ ```
133
+
134
+ #### Method 2: Using functions ending with `_command`
135
+
136
+ ```python
137
+ def mycommand_command(args: list[str]) -> bool:
138
+ """Description of what this command does."""
139
+ # Command implementation
140
+ print("Hello from mycommand!")
141
+ return True
142
+ ```
143
+
144
+ ### Command Naming
145
+
146
+ - Functions ending with `_command` are automatically discovered
147
+ - The command name is derived from the function name (removing `_command` suffix)
148
+ - Private functions (starting with `_`) have the underscore removed
149
+ - `Command` instances can use any name, but follow similar naming conventions
150
+
151
+ ### Command Structure
152
+
153
+ Commands receive a list of string arguments and return a boolean indicating success:
154
+
155
+ ```python
156
+ def mycommand_command(args: list[str]) -> bool:
157
+ """Command description for help text."""
158
+ if not args:
159
+ print("Usage: mycommand <arg1> <arg2>")
160
+ return False
161
+
162
+ # Process arguments
163
+ arg1 = args[0]
164
+ # ... command logic ...
165
+
166
+ return True # Success
167
+ ```
168
+
169
+ ### Built-in Commands
170
+
171
+ Qualitybase provides several built-in commands in `qualitybase/commands/`:
172
+
173
+ - **`help`**: Display available commands
174
+ - **`version`**: Show package version information
175
+ - **`varenv`**: Show or manage environment variables
176
+
177
+ ### Example: Custom Command
178
+
179
+ Create `src/mypackage/commands/greet.py`:
180
+
181
+ ```python
182
+ from .base import Command
183
+
184
+ def greet_command(args: list[str]) -> bool:
185
+ """Greet someone by name."""
186
+ if not args:
187
+ print("Usage: greet <name>")
188
+ return False
189
+
190
+ name = args[0]
191
+ print(f"Hello, {name}!")
192
+ return True
193
+
194
+ greet_command = Command(greet_command, "Greet someone by name")
195
+ ```
196
+
197
+ Then use it:
198
+ ```bash
199
+ ./service.py cli greet Alice
200
+ # Output: Hello, Alice!
201
+ ```
202
+
203
+ ### Configuration File
204
+
205
+ You can configure command discovery using `.commands.json`:
206
+
207
+ ```json
208
+ {
209
+ "packages": ["otherpackage"],
210
+ "directories": ["custom_commands"],
211
+ "commands": []
212
+ }
213
+ ```
214
+
215
+ ## Environment Variables
216
+
217
+ ### `ENVFILE_PATH`
218
+
219
+ The `ENVFILE_PATH` environment variable allows you to automatically specify the path to a `.env` file to load when starting services.
220
+
221
+ **Usage:**
222
+
223
+ ```bash
224
+ # Absolute path
225
+ ENVFILE_PATH=/path/to/.env ./service.py dev install-dev
226
+
227
+ # Relative path (relative to project root)
228
+ ENVFILE_PATH=.env.local ./service.py quality lint
229
+ ```
230
+
231
+ **Behavior:**
232
+
233
+ - If the path is relative, it is resolved relative to the project root
234
+ - The `.env` file is automatically loaded before command execution
235
+ - Uses `python-dotenv` to parse the file (installed automatically if needed)
236
+ - Works with `dev` and `cli` services
237
+
238
+ **Example:**
239
+
240
+ ```bash
241
+ # Create a .env.local file
242
+ echo "API_KEY=secret123" > .env.local
243
+
244
+ # Use this file
245
+ ENVFILE_PATH=.env.local ./service.py dev install-dev
246
+ ```
247
+
248
+ ### `ENSURE_VIRTUALENV`
249
+
250
+ The `ENSURE_VIRTUALENV` environment variable allows you to automatically activate the `.venv` virtual environment if it exists, before executing commands.
251
+
252
+ **Usage:**
253
+
254
+ ```bash
255
+ ENSURE_VIRTUALENV=1 ./service.py dev help
256
+ ENSURE_VIRTUALENV=1 ./service.py quality lint
257
+ ```
258
+
259
+ **Behavior:**
260
+
261
+ - Must be set to `1` to be active
262
+ - Automatically activates the `.venv` virtual environment at the project root
263
+ - Modifies `sys.executable`, `PATH`, and `sys.path` to use the venv's Python
264
+ - Only works if the `.venv` directory exists
265
+ - Compatible with Windows and Unix
266
+
267
+ **Note:** The `ensure_virtualenv()` function is also automatically called by the main service, but `ENSURE_VIRTUALENV` allows you to force activation even in contexts where it might not be automatic.
268
+
269
+ **Example:**
270
+
271
+ ```bash
272
+ # Create a virtual environment
273
+ python -m venv .venv
274
+
275
+ # Use it automatically
276
+ ENSURE_VIRTUALENV=1 ./service.py quality all
277
+ ```
278
+
279
+ ## Architecture
280
+
281
+ Qualitybase uses a service-based architecture:
282
+
283
+ - Each service domain is organized in its own module directory
284
+ - Services are accessed through a unified entry point (`service.py`)
285
+ - Services can be invoked via `./service.py <service> <command>` or directly via Python modules
286
+ - The system ensures virtual environment setup and proper dependency management
287
+ - Services are designed to work consistently across different Python projects
288
+
289
+ ## Development
290
+
291
+ See `.agentia/rules/` for project rules and guidelines.
@@ -0,0 +1,248 @@
1
+ # python-qualitybase
2
+
3
+ Qualitybase is a Python library that provides standardized services and tooling for managing code quality, development workflows, and project maintenance in Python projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install qualitybase
9
+ ```
10
+
11
+ For development:
12
+
13
+ ```bash
14
+ pip install -e .
15
+ pip install -e ".[dev,lint,quality,security,test]"
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Qualitybase provides a unified entry point via the `service.py` script:
21
+
22
+ ```bash
23
+ ./service.py <service> <command>
24
+ ```
25
+
26
+ ### Available Services
27
+
28
+ - **`quality`**: Quality checks (lint, security, test, complexity, cleanup)
29
+ - **`dev`**: Development tools (venv, install, clean, build, etc.)
30
+ - **`django`**: Django-specific services
31
+ - **`publish`**: Package publishing and distribution
32
+ - **`cli`**: Command-line interface for packages
33
+
34
+ ### Examples
35
+
36
+ ```bash
37
+ # Quality checks
38
+ ./service.py quality lint
39
+ ./service.py quality security
40
+ ./service.py quality all
41
+
42
+ # Development tools
43
+ ./service.py dev venv
44
+ ./service.py dev install-dev
45
+ ./service.py dev clean
46
+
47
+ # Help
48
+ ./service.py quality help
49
+ ./service.py dev help
50
+ ```
51
+
52
+ ## CLI System
53
+
54
+ Qualitybase includes a flexible CLI system that allows packages to define custom commands through a `commands` directory.
55
+
56
+ ### Command Discovery
57
+
58
+ The CLI system automatically discovers commands from:
59
+
60
+ 1. **`commands/` directory**: A directory next to `cli.py` containing command modules
61
+ 2. **`.commands.json` configuration file**: A JSON file that can specify:
62
+ - `packages`: List of packages to discover commands from
63
+ - `directories`: List of directories to scan for commands
64
+ - `commands`: Direct command definitions
65
+
66
+ ### Creating Commands
67
+
68
+ Commands can be created in two ways:
69
+
70
+ #### Method 1: Using the `Command` class
71
+
72
+ Create a file in the `commands/` directory (e.g., `commands/mycommand.py`):
73
+
74
+ ```python
75
+ from .base import Command
76
+
77
+ def _mycommand_command(args: list[str]) -> bool:
78
+ """Description of what this command does."""
79
+ # Command implementation
80
+ print("Hello from mycommand!")
81
+ return True
82
+
83
+ mycommand_command = Command(_mycommand_command, "Description of what this command does")
84
+ ```
85
+
86
+ The command will be automatically discovered and available as:
87
+ ```bash
88
+ ./service.py cli mycommand
89
+ ```
90
+
91
+ #### Method 2: Using functions ending with `_command`
92
+
93
+ ```python
94
+ def mycommand_command(args: list[str]) -> bool:
95
+ """Description of what this command does."""
96
+ # Command implementation
97
+ print("Hello from mycommand!")
98
+ return True
99
+ ```
100
+
101
+ ### Command Naming
102
+
103
+ - Functions ending with `_command` are automatically discovered
104
+ - The command name is derived from the function name (removing `_command` suffix)
105
+ - Private functions (starting with `_`) have the underscore removed
106
+ - `Command` instances can use any name, but follow similar naming conventions
107
+
108
+ ### Command Structure
109
+
110
+ Commands receive a list of string arguments and return a boolean indicating success:
111
+
112
+ ```python
113
+ def mycommand_command(args: list[str]) -> bool:
114
+ """Command description for help text."""
115
+ if not args:
116
+ print("Usage: mycommand <arg1> <arg2>")
117
+ return False
118
+
119
+ # Process arguments
120
+ arg1 = args[0]
121
+ # ... command logic ...
122
+
123
+ return True # Success
124
+ ```
125
+
126
+ ### Built-in Commands
127
+
128
+ Qualitybase provides several built-in commands in `qualitybase/commands/`:
129
+
130
+ - **`help`**: Display available commands
131
+ - **`version`**: Show package version information
132
+ - **`varenv`**: Show or manage environment variables
133
+
134
+ ### Example: Custom Command
135
+
136
+ Create `src/mypackage/commands/greet.py`:
137
+
138
+ ```python
139
+ from .base import Command
140
+
141
+ def greet_command(args: list[str]) -> bool:
142
+ """Greet someone by name."""
143
+ if not args:
144
+ print("Usage: greet <name>")
145
+ return False
146
+
147
+ name = args[0]
148
+ print(f"Hello, {name}!")
149
+ return True
150
+
151
+ greet_command = Command(greet_command, "Greet someone by name")
152
+ ```
153
+
154
+ Then use it:
155
+ ```bash
156
+ ./service.py cli greet Alice
157
+ # Output: Hello, Alice!
158
+ ```
159
+
160
+ ### Configuration File
161
+
162
+ You can configure command discovery using `.commands.json`:
163
+
164
+ ```json
165
+ {
166
+ "packages": ["otherpackage"],
167
+ "directories": ["custom_commands"],
168
+ "commands": []
169
+ }
170
+ ```
171
+
172
+ ## Environment Variables
173
+
174
+ ### `ENVFILE_PATH`
175
+
176
+ The `ENVFILE_PATH` environment variable allows you to automatically specify the path to a `.env` file to load when starting services.
177
+
178
+ **Usage:**
179
+
180
+ ```bash
181
+ # Absolute path
182
+ ENVFILE_PATH=/path/to/.env ./service.py dev install-dev
183
+
184
+ # Relative path (relative to project root)
185
+ ENVFILE_PATH=.env.local ./service.py quality lint
186
+ ```
187
+
188
+ **Behavior:**
189
+
190
+ - If the path is relative, it is resolved relative to the project root
191
+ - The `.env` file is automatically loaded before command execution
192
+ - Uses `python-dotenv` to parse the file (installed automatically if needed)
193
+ - Works with `dev` and `cli` services
194
+
195
+ **Example:**
196
+
197
+ ```bash
198
+ # Create a .env.local file
199
+ echo "API_KEY=secret123" > .env.local
200
+
201
+ # Use this file
202
+ ENVFILE_PATH=.env.local ./service.py dev install-dev
203
+ ```
204
+
205
+ ### `ENSURE_VIRTUALENV`
206
+
207
+ The `ENSURE_VIRTUALENV` environment variable allows you to automatically activate the `.venv` virtual environment if it exists, before executing commands.
208
+
209
+ **Usage:**
210
+
211
+ ```bash
212
+ ENSURE_VIRTUALENV=1 ./service.py dev help
213
+ ENSURE_VIRTUALENV=1 ./service.py quality lint
214
+ ```
215
+
216
+ **Behavior:**
217
+
218
+ - Must be set to `1` to be active
219
+ - Automatically activates the `.venv` virtual environment at the project root
220
+ - Modifies `sys.executable`, `PATH`, and `sys.path` to use the venv's Python
221
+ - Only works if the `.venv` directory exists
222
+ - Compatible with Windows and Unix
223
+
224
+ **Note:** The `ensure_virtualenv()` function is also automatically called by the main service, but `ENSURE_VIRTUALENV` allows you to force activation even in contexts where it might not be automatic.
225
+
226
+ **Example:**
227
+
228
+ ```bash
229
+ # Create a virtual environment
230
+ python -m venv .venv
231
+
232
+ # Use it automatically
233
+ ENSURE_VIRTUALENV=1 ./service.py quality all
234
+ ```
235
+
236
+ ## Architecture
237
+
238
+ Qualitybase uses a service-based architecture:
239
+
240
+ - Each service domain is organized in its own module directory
241
+ - Services are accessed through a unified entry point (`service.py`)
242
+ - Services can be invoked via `./service.py <service> <command>` or directly via Python modules
243
+ - The system ensures virtual environment setup and proper dependency management
244
+ - Services are designed to work consistently across different Python projects
245
+
246
+ ## Development
247
+
248
+ See `.agentia/rules/` for project rules and guidelines.