Skip to content

opensampl.create.insert_markers

Insert markers for code generation in openSAMPL files.

This module defines markers used to identify where new code should be inserted when generating new vendors, metrics, and reference types.

INSERT_MARKERS

Predefined insertion markers for various openSAMPL components.

Contains markers for inserting new vendors, metrics, references, and ORM classes at the appropriate locations in the codebase.

Source code in opensampl/create/insert_markers.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class INSERT_MARKERS:  # noqa N801
    """
    Predefined insertion markers for various openSAMPL components.

    Contains markers for inserting new vendors, metrics, references, and ORM classes
    at the appropriate locations in the codebase.
    """

    VENDOR = InsertMarker(
        filepath=opensampl_root / "vendors" / "constants.py",
        template_name="vendor_template.txt",
        comment_marker="# --- CUSTOM VENDORS ---",
    )
    METRICS = InsertMarker(
        filepath=opensampl_root / "metrics.py",
        template_name="metric_template.txt",
        comment_marker="# --- CUSTOM METRICS ---",
    )
    REFERENCES = InsertMarker(
        filepath=opensampl_root / "references.py",
        template_name="reference_template.txt",
        comment_marker="# --- CUSTOM REFERENCE TYPES ---",
    )
    ORM_CLASS = InsertMarker(
        filepath=opensampl_root / "db" / "orm.py",
        template_name="orm_metadata.txt",
        comment_marker="# --- CUSTOM TABLES ---",
    )
    ORM_RELATIONSHIP = InsertMarker(
        filepath=opensampl_root / "db" / "orm.py",
        template_name="orm_relationship.txt",
        comment_marker="# --- CUSTOM PROBE METADATA RELATIONSHIP ---",
    )

InsertMarker

Bases: BaseModel

Definition for a code insertion marker.

Attributes:

Name Type Description
filepath Path

Path to the file where insertion should occur.

comment_marker str

Comment string that marks the insertion point.

Source code in opensampl/create/insert_markers.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class InsertMarker(BaseModel):
    """
    Definition for a code insertion marker.

    Attributes:
        filepath: Path to the file where insertion should occur.
        comment_marker: Comment string that marks the insertion point.

    """

    filepath: Path
    template_name: str
    comment_marker: str

    @property
    def template_path(self) -> Path:
        """Path to the template"""
        return template_dir / self.template_name

template_path property

Path to the template