half-orm-dev 0.16.0a9__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.
- half_orm_dev/__init__.py +1 -0
- half_orm_dev/cli/__init__.py +9 -0
- half_orm_dev/cli/commands/__init__.py +56 -0
- half_orm_dev/cli/commands/apply.py +13 -0
- half_orm_dev/cli/commands/clone.py +102 -0
- half_orm_dev/cli/commands/init.py +331 -0
- half_orm_dev/cli/commands/new.py +15 -0
- half_orm_dev/cli/commands/patch.py +317 -0
- half_orm_dev/cli/commands/prepare.py +21 -0
- half_orm_dev/cli/commands/prepare_release.py +119 -0
- half_orm_dev/cli/commands/promote_to.py +127 -0
- half_orm_dev/cli/commands/release.py +344 -0
- half_orm_dev/cli/commands/restore.py +14 -0
- half_orm_dev/cli/commands/sync.py +13 -0
- half_orm_dev/cli/commands/todo.py +73 -0
- half_orm_dev/cli/commands/undo.py +17 -0
- half_orm_dev/cli/commands/update.py +73 -0
- half_orm_dev/cli/commands/upgrade.py +191 -0
- half_orm_dev/cli/main.py +103 -0
- half_orm_dev/cli_extension.py +38 -0
- half_orm_dev/database.py +1389 -0
- half_orm_dev/hgit.py +1025 -0
- half_orm_dev/hop.py +167 -0
- half_orm_dev/manifest.py +43 -0
- half_orm_dev/modules.py +456 -0
- half_orm_dev/patch.py +281 -0
- half_orm_dev/patch_manager.py +1694 -0
- half_orm_dev/patch_validator.py +335 -0
- half_orm_dev/patches/0/1/0/00_half_orm_meta.database.sql +34 -0
- half_orm_dev/patches/0/1/0/01_alter_half_orm_meta.hop_release.sql +2 -0
- half_orm_dev/patches/0/1/0/02_half_orm_meta.view.hop_penultimate_release.sql +3 -0
- half_orm_dev/patches/log +2 -0
- half_orm_dev/patches/sql/half_orm_meta.sql +208 -0
- half_orm_dev/release_manager.py +2841 -0
- half_orm_dev/repo.py +1562 -0
- half_orm_dev/templates/.gitignore +15 -0
- half_orm_dev/templates/MANIFEST.in +1 -0
- half_orm_dev/templates/Pipfile +13 -0
- half_orm_dev/templates/README +25 -0
- half_orm_dev/templates/conftest_template +42 -0
- half_orm_dev/templates/init_module_template +10 -0
- half_orm_dev/templates/module_template_1 +12 -0
- half_orm_dev/templates/module_template_2 +6 -0
- half_orm_dev/templates/module_template_3 +3 -0
- half_orm_dev/templates/relation_test +23 -0
- half_orm_dev/templates/setup.py +81 -0
- half_orm_dev/templates/sql_adapter +9 -0
- half_orm_dev/templates/warning +12 -0
- half_orm_dev/utils.py +49 -0
- half_orm_dev/version.txt +1 -0
- half_orm_dev-0.16.0a9.dist-info/METADATA +935 -0
- half_orm_dev-0.16.0a9.dist-info/RECORD +58 -0
- half_orm_dev-0.16.0a9.dist-info/WHEEL +5 -0
- half_orm_dev-0.16.0a9.dist-info/licenses/AUTHORS +3 -0
- half_orm_dev-0.16.0a9.dist-info/licenses/LICENSE +14 -0
- half_orm_dev-0.16.0a9.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/conftest.py +329 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
global-exclude *_test.py
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# halfORM package `{package_name}` for the `{dbname}` database.
|
|
2
|
+
|
|
3
|
+
This package has been generated by [hop](https://github.com/collorg/halfORM/blob/main/doc/hop.md) version {hop_version}.
|
|
4
|
+
|
|
5
|
+
Use the `hop` command in this directory of any subdirectory to synchronise
|
|
6
|
+
the modules in this package with any changes in your model.
|
|
7
|
+
|
|
8
|
+
If you manually add any file to this package, make sure its name
|
|
9
|
+
does not conflict with a relation name in your model.
|
|
10
|
+
|
|
11
|
+
# Usage
|
|
12
|
+
|
|
13
|
+
Before you can use this package you will have to:
|
|
14
|
+
|
|
15
|
+
- install [half-orm](https://github.com/collorg/halfORM),
|
|
16
|
+
- specify the connection parameters to the `{dbname}` database in `/etc/half_orm/{package_name}` file:
|
|
17
|
+
```
|
|
18
|
+
[database]
|
|
19
|
+
name = {dbname}
|
|
20
|
+
user = <username>
|
|
21
|
+
password = <password>
|
|
22
|
+
host = <ip address|localhost>
|
|
23
|
+
port = <port number|5432>
|
|
24
|
+
```
|
|
25
|
+
- install the package by running `pip3 install --upgrade .` in this directory.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Common test fixtures for {package_name} package.
|
|
2
|
+
|
|
3
|
+
This file provides base fixtures for database integration tests.
|
|
4
|
+
Developers can add schema-specific or table-specific fixtures by creating
|
|
5
|
+
conftest.py files in the appropriate subdirectories.
|
|
6
|
+
|
|
7
|
+
Generated by half_orm v{hop_release}
|
|
8
|
+
"""
|
|
9
|
+
import pytest
|
|
10
|
+
from half_orm.model import Model
|
|
11
|
+
from half_orm.relation import Relation
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.fixture(scope="session")
|
|
15
|
+
def database_model():
|
|
16
|
+
"""
|
|
17
|
+
Provide database Model for integration tests.
|
|
18
|
+
|
|
19
|
+
Scope: session (created once per test session)
|
|
20
|
+
Returns: Model instance for {package_name} database
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
def test_query(database_model):
|
|
24
|
+
users = database_model.get_relation_class('public.users')
|
|
25
|
+
assert users is not None
|
|
26
|
+
"""
|
|
27
|
+
return Model("{package_name}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.fixture
|
|
31
|
+
def relation_class():
|
|
32
|
+
"""
|
|
33
|
+
Provide Relation base class for tests.
|
|
34
|
+
|
|
35
|
+
Returns: half_orm.relation.Relation class
|
|
36
|
+
|
|
37
|
+
Example:
|
|
38
|
+
def test_inheritance(relation_class):
|
|
39
|
+
from {package_name}.public.users import Users
|
|
40
|
+
assert issubclass(Users, relation_class)
|
|
41
|
+
"""
|
|
42
|
+
return Relation
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""This module provides the model of the database for the package {package_name}.
|
|
2
|
+
"""
|
|
3
|
+
from half_orm.model import Model
|
|
4
|
+
from half_orm_dev.utils import resolve_database_config_name
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
_package_dir = Path(__file__).parent
|
|
8
|
+
_config_name = resolve_database_config_name(_package_dir)
|
|
9
|
+
|
|
10
|
+
MODEL = Model(_config_name, scope=__name__)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# pylint: disable=wrong-import-order, invalid-name, attribute-defined-outside-init
|
|
2
|
+
|
|
3
|
+
"""The module {module} provides the {class_name} class.
|
|
4
|
+
|
|
5
|
+
WARNING!
|
|
6
|
+
|
|
7
|
+
{warning}
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from half_orm.model import register
|
|
11
|
+
from {package_name} import MODEL, ho_dataclasses
|
|
12
|
+
fields_aliases=None
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Basic test file for the {module} module. DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
This test file ensures that {module}.{class_name} is instanciable and
|
|
4
|
+
a subclass of half_orm.relation.Relation
|
|
5
|
+
|
|
6
|
+
Fixtures are provided by tests/conftest.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from {module} import {class_name}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_instanciate_relation():
|
|
13
|
+
"""It should instanciate {class_name}."""
|
|
14
|
+
{class_name}()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_is_relation(relation_class):
|
|
18
|
+
"""
|
|
19
|
+
{class_name} should be a subclass of half_orm.Relation.
|
|
20
|
+
|
|
21
|
+
Uses relation_class fixture from tests/conftest.py
|
|
22
|
+
"""
|
|
23
|
+
assert issubclass({class_name}, relation_class)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Package for PostgreSQL {dbname} database.
|
|
2
|
+
You can edit the following parameters:
|
|
3
|
+
- version
|
|
4
|
+
- author
|
|
5
|
+
- author_email
|
|
6
|
+
- license
|
|
7
|
+
- keywords
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from setuptools import setup, find_packages
|
|
11
|
+
from codecs import open
|
|
12
|
+
from os import path
|
|
13
|
+
import re
|
|
14
|
+
import half_orm
|
|
15
|
+
|
|
16
|
+
PWD = path.abspath(path.dirname(__file__))
|
|
17
|
+
|
|
18
|
+
def get_long_description():
|
|
19
|
+
"""
|
|
20
|
+
Return the README.
|
|
21
|
+
"""
|
|
22
|
+
with open("README.md", encoding="utf8") as f:
|
|
23
|
+
return f.read()
|
|
24
|
+
|
|
25
|
+
def get_version(package):
|
|
26
|
+
"""
|
|
27
|
+
Return package version as listed in `__version__` in `init.py`.
|
|
28
|
+
"""
|
|
29
|
+
with open(path.join(package, "version.txt")) as f:
|
|
30
|
+
return f.read()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
package_name='{package_name}'
|
|
34
|
+
|
|
35
|
+
setup(
|
|
36
|
+
name=package_name,
|
|
37
|
+
|
|
38
|
+
version=get_version(package_name),
|
|
39
|
+
|
|
40
|
+
description='Package for {dbname} PG',
|
|
41
|
+
long_description=get_long_description(),
|
|
42
|
+
long_description_content_type='text/markdown',
|
|
43
|
+
url='',
|
|
44
|
+
|
|
45
|
+
author='',
|
|
46
|
+
author_email='',
|
|
47
|
+
license='',
|
|
48
|
+
|
|
49
|
+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
|
50
|
+
classifiers=[
|
|
51
|
+
# How mature is this project? Common values are
|
|
52
|
+
# 3 - Alpha
|
|
53
|
+
# 4 - Beta
|
|
54
|
+
# 5 - Production/Stable
|
|
55
|
+
'Development Status :: 3 - Alpha',
|
|
56
|
+
|
|
57
|
+
# Indicate who your project is intended for
|
|
58
|
+
'Intended Audience :: Developers',
|
|
59
|
+
'Topic :: Software Development :: Build Tools',
|
|
60
|
+
|
|
61
|
+
# Pick your license as you wish (should match "license" above)
|
|
62
|
+
'License :: OSI Approved :: MIT License',
|
|
63
|
+
|
|
64
|
+
# Specify the Python versions you support here. In particular, ensure
|
|
65
|
+
# that you indicate whether you support Python 2, Python 3 or both.
|
|
66
|
+
'Programming Language :: Python :: 3.6',
|
|
67
|
+
'Programming Language :: Python :: 3.7',
|
|
68
|
+
'Programming Language :: Python :: 3.8',
|
|
69
|
+
'Programming Language :: Python :: 3.9',
|
|
70
|
+
'Programming Language :: Python :: 3.10',
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
keywords='',
|
|
74
|
+
|
|
75
|
+
packages=find_packages(exclude=['contrib', 'docs', 'tests', 'patches', 'svg']),
|
|
76
|
+
|
|
77
|
+
install_requires=[
|
|
78
|
+
'half_orm=={half_orm_version}'
|
|
79
|
+
],
|
|
80
|
+
|
|
81
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
This file is part of the {package_name} package. It has been generated by the
|
|
2
|
+
command hop. To keep it in sync with your database structure, just rerun
|
|
3
|
+
hop update.
|
|
4
|
+
|
|
5
|
+
More information on the half_orm library on https://github.com/collorg/halfORM.
|
|
6
|
+
|
|
7
|
+
DO NOT REMOVE OR MODIFY THE LINES BEGINING WITH:
|
|
8
|
+
#>>> PLACE YOUR CODE BELOW...
|
|
9
|
+
#<<< PLACE YOUR CODE ABOVE...
|
|
10
|
+
|
|
11
|
+
MAKE SURE YOUR CODE GOES BETWEEN THESE LINES OR AT THE END OF THE FILE.
|
|
12
|
+
hop ONLY PRESERVES THE CODE BETWEEN THESE MARKS WHEN IT IS RUN.
|
half_orm_dev/utils.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
PWD = os.path.dirname(__file__)
|
|
4
|
+
HOP_PATH = os.path.join(PWD)
|
|
5
|
+
TEMPLATE_DIRS = os.path.join(HOP_PATH, 'templates')
|
|
6
|
+
|
|
7
|
+
def hop_version():
|
|
8
|
+
"Returns the version of hop"
|
|
9
|
+
hop_v = None
|
|
10
|
+
with open(os.path.join(HOP_PATH, 'version.txt'), encoding='utf-8') as version:
|
|
11
|
+
hop_v = version.read().strip()
|
|
12
|
+
return hop_v
|
|
13
|
+
|
|
14
|
+
def resolve_database_config_name(base_dir):
|
|
15
|
+
"""
|
|
16
|
+
Resolve database configuration name with backward compatibility.
|
|
17
|
+
|
|
18
|
+
Priority:
|
|
19
|
+
1. .hop/alt_config if exists → use content
|
|
20
|
+
2. .hop/config[halfORM][package_name] if exists → use it (backward compat)
|
|
21
|
+
3. Otherwise → use directory name
|
|
22
|
+
"""
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from configparser import ConfigParser
|
|
25
|
+
|
|
26
|
+
base_path = Path(base_dir)
|
|
27
|
+
|
|
28
|
+
# Priority 1: alt_config
|
|
29
|
+
alt_config_path = base_path / '.hop' / 'alt_config'
|
|
30
|
+
if alt_config_path.exists():
|
|
31
|
+
content = alt_config_path.read_text().strip()
|
|
32
|
+
if content:
|
|
33
|
+
return content
|
|
34
|
+
|
|
35
|
+
# Priority 2: package_name in .hop/config (backward compat)
|
|
36
|
+
config_path = base_path / '.hop' / 'config'
|
|
37
|
+
if config_path.exists():
|
|
38
|
+
config = ConfigParser()
|
|
39
|
+
try:
|
|
40
|
+
config.read(config_path)
|
|
41
|
+
if config.has_option('halfORM', 'package_name'):
|
|
42
|
+
package_name = config.get('halfORM', 'package_name')
|
|
43
|
+
if package_name:
|
|
44
|
+
return package_name
|
|
45
|
+
except Exception:
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
# Priority 3: directory name
|
|
49
|
+
return base_path.name
|
half_orm_dev/version.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.16.0-a9
|