Skip to content

Init

blackline.project.init

DEFAULT_DATASET_FOLDER = 'dataset' module-attribute

DEFAULT_ORGANIZATION_FOLDER = 'organization' module-attribute

DEFAULT_RESOURCE_FOLDER = 'resource' module-attribute

DEFAULT_SYSTEM_FOLDER = 'system' module-attribute

INIT_ADAPTER = f'# See details docs at https://docs.getblackline.com/# Only required fields are shown here.profiles:{DEFAULT_PROFILE}:type: <type_name>config:...' module-attribute

INIT_DATASET = '\n# See details docs at https://docs.getblackline.com/\n# Only required fields are shown here.\ndataset:\n - key: <requred_key>\n ...\n' module-attribute

INIT_DATASET_FILENAME = 'dataset.yaml' module-attribute

INIT_DATASET_FOLDER = 'dataset' module-attribute

INIT_ORGANIZATION = '\n# See details docs at https://docs.getblackline.com/\n# Only required fields are shown here.\norganization:\n - key: <requred_key>\n ...\n' module-attribute

INIT_ORGANIZATION_FILENAME = 'organization.yaml' module-attribute

INIT_ORGANIZATION_FOLDER = 'organization' module-attribute

INIT_RESOURCE = '\n# See details docs at https://docs.getblackline.com/\n# Only required fields are shown here.\nresource:\n - key: <requred_key>\n resource_type: <requred_resource_type>\n privacy_declarations:\n - name: <requred_name>\n data_categories:\n - <requred_data_category>\n data_use: <requred_data_use>\n data_subjects:\n - <requred_data_subject>\n data_qualifier: <requred_data_qualifier>\n ...\n' module-attribute

INIT_RESOURCE_FILENAME = 'resource.yaml' module-attribute

INIT_RESOURCE_FOLDER = 'resource' module-attribute

INIT_SYSTEM = '\n# See details docs at https://docs.getblackline.com/\n# Only required fields are shown here.\nsystem:\n - key: <requred_key>\n ...\n' module-attribute

INIT_SYSTEM_FILENAME = 'system.yaml' module-attribute

INIT_SYSTEM_FOLDER = 'system' module-attribute

InitProject

Source code in BAR /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
class InitProject:
    def __init__(
        self,
        path: Path,
        name: str,
        overwrite: bool = False,
        default_profile: str = DEFAULT_PROFILE,
        catalogue: str = DEFAULT_CATALOGUE_FOLDER,
        adapters: str = DEFAULT_ADAPTERS_FOLDER,
        organization: str = DEFAULT_ORGANIZATION_FOLDER,
        system: str = DEFAULT_SYSTEM_FOLDER,
        resource: str = DEFAULT_RESOURCE_FOLDER,
        dataset: str = DEFAULT_DATASET_FOLDER,
        init_organization: str = INIT_ORGANIZATION,
        init_system: str = INIT_SYSTEM,
        init_resource: str = INIT_RESOURCE,
        init_dataset: str = INIT_DATASET,
        init_adapter: str = INIT_ADAPTER,
    ) -> None:
        """
        A class for initializing a new Blackline project.

        Args:
            path: The path to the directory where the project should be created.
            name : The name of the project.
            overwrite : Whether to overwrite an existing project with the same name.
            default_profile : The default profile to use.
            catalogue : The name of the catalogue folder.
            adapters: The name of the adapters folder.
            organization: The name of the organization folder.
            system: The name of the system folder.
            resource: The name of the resource folder.
            dataset: The name of the dataset folder.
            init_organization: The initial organization configuration.
            init_system: The initial system configuration.
            init_resource: The initial resource configuration.
            init_dataset: The initial dataset configuration.
            init_adapter: The initial adapter configuration.

        Attributes:
            path (Path): The path to the directory where the project should be created.
            name (str): The name of the project.
            overwrite (bool): Whether to overwrite an existing project with the same name. # noqa: E501
            default_profile (str): The default profile to use.
            catalogue_path (Path): The path to the catalogue folder.
            adapters_path (Path): The path to the adapters folder.
            organization (str): The name of the organization folder.
            system (str): The name of the system folder.
            resource (str): The name of the resource folder.
        """
        self.path = path
        self.name = name
        self.overwrite = overwrite
        self.default_profile = default_profile
        self.catalogue_path = Path(path, catalogue or DEFAULT_CATALOGUE_FOLDER)
        self.adapters_path = Path(path, adapters or DEFAULT_ADAPTERS_FOLDER)
        self.organization = organization
        self.system = system
        self.resource = resource
        self.dataset = dataset
        self.init_organization: str = init_organization
        self.init_system = init_system
        self.init_resource = init_resource
        self.init_dataset = init_dataset
        self.init_adapter = init_adapter
        self.project_config = ProjectConfig(
            name=self.name,
            config_version=PROJECT_CONFIG_VERSION,
            version=PROJECT_VERSION,
            default_profile=self.default_profile,
            catalogue_path=self.catalogue_path,
            adapters_path=self.adapters_path,
            project_root=self.path,
        )

    def init_project(self) -> None:
        """Creates a new project."""

        self.create_project_yaml()
        self.create_adapter()
        self.create_catalogue()

    def create_project_yaml(self) -> None:
        """Creates a YAML file for the project configuration."""

        self.path.mkdir(exist_ok=True)
        env = Environment(loader=PackageLoader("blackline.project", "templates"))
        template = env.get_template("blackline_project.yml")
        project = template.render(config=self.project_config)
        Path(self.path, PROJECT_CONFIG_FILE).write_text(project)

    def create_adapter(
        self,
    ) -> Path:
        """Creates an adapter for the project.

        Returns:
            Path: The path of the adapter.
        """
        adapter_path = self.create_adapter_folders()
        self.create_adapter_file(resource_path=adapter_path)
        return adapter_path

    def create_adapter_folders(
        self,
    ) -> Path:
        """Creates folders for the adapter.

        Returns:
            Path: The path of the adapter folder.
        """

        resource_path = Path(
            self.adapters_path,
            self.organization,
            self.system,
            self.resource,
        )
        resource_path.mkdir(parents=True, exist_ok=True)
        return resource_path

    def create_adapter_file(
        self,
        resource_path: Path,
    ) -> None:
        """Creates a file for the adapter.

        Args:
            resource_path: The path of the adapter folder.

        Returns:
            None
        """
        Path(resource_path, INIT_DATASET_FILENAME).write_text(self.init_adapter)

    def create_catalogue(self) -> None:
        """Creates the catalogue folder and files.

        Args:
            None

        Returns:
            None
        """
        (
            organization_path,
            system_path,
            resource_path,
            dataset_path,
        ) = self.create_catalogue_folders()
        self.create_catalogue_files(
            organization_path=organization_path,
            system_path=system_path,
            resource_path=resource_path,
            dataset_path=dataset_path,
        )

    def create_catalogue_folders(self) -> Tuple[Path, Path, Path, Path]:
        """Creates folders for the catalogue.


        Returns:
            A tuple containing the paths of the organisation, system, resource and dataset folders. # noqa: E501
        """
        catalogue_path = self.catalogue_path
        organisation_path = Path(catalogue_path, self.organization)
        system_path = Path(organisation_path, self.system)
        resource_path = Path(system_path, self.resource)
        dataset_path = Path(resource_path, self.dataset)
        dataset_path.mkdir(parents=True, exist_ok=True)
        return organisation_path, system_path, resource_path, dataset_path

    def create_catalogue_files(
        self,
        organization_path: Path,
        system_path: Path,
        resource_path: Path,
        dataset_path: Path,
    ) -> None:
        """Create the catalogue files in the specified paths.

        Args:
            organization_path: Path to the organization folder.
            system_path: Path to the system folder.
            resource_path: Path to the resource folder.
            dataset_path: Path to the dataset folder.

        Returns:
            None
        """
        Path(organization_path, INIT_ORGANIZATION_FILENAME).write_text(
            self.init_organization
        )
        Path(system_path, INIT_SYSTEM_FILENAME).write_text(self.init_system)
        Path(resource_path, INIT_RESOURCE_FILENAME).write_text(self.init_resource)
        Path(dataset_path, INIT_DATASET_FILENAME).write_text(self.init_dataset)

adapters_path = Path(path, adapters or DEFAULT_ADAPTERS_FOLDER) instance-attribute

catalogue_path = Path(path, catalogue or DEFAULT_CATALOGUE_FOLDER) instance-attribute

dataset = dataset instance-attribute

default_profile = default_profile instance-attribute

init_adapter = init_adapter instance-attribute

init_dataset = init_dataset instance-attribute

init_organization: str = init_organization instance-attribute

init_resource = init_resource instance-attribute

init_system = init_system instance-attribute

name = name instance-attribute

organization = organization instance-attribute

overwrite = overwrite instance-attribute

path = path instance-attribute

project_config = ProjectConfig(name=self.name, config_version=PROJECT_CONFIG_VERSION, version=PROJECT_VERSION, default_profile=self.default_profile, catalogue_path=self.catalogue_path, adapters_path=self.adapters_path, project_root=self.path) instance-attribute

resource = resource instance-attribute

system = system instance-attribute

__init__(path, name, overwrite=False, default_profile=DEFAULT_PROFILE, catalogue=DEFAULT_CATALOGUE_FOLDER, adapters=DEFAULT_ADAPTERS_FOLDER, organization=DEFAULT_ORGANIZATION_FOLDER, system=DEFAULT_SYSTEM_FOLDER, resource=DEFAULT_RESOURCE_FOLDER, dataset=DEFAULT_DATASET_FOLDER, init_organization=INIT_ORGANIZATION, init_system=INIT_SYSTEM, init_resource=INIT_RESOURCE, init_dataset=INIT_DATASET, init_adapter=INIT_ADAPTER)

A class for initializing a new Blackline project.

Parameters:

Name Type Description Default
path Path

The path to the directory where the project should be created.

required
name

The name of the project.

required
overwrite

Whether to overwrite an existing project with the same name.

False
default_profile

The default profile to use.

DEFAULT_PROFILE
catalogue

The name of the catalogue folder.

DEFAULT_CATALOGUE_FOLDER
adapters str

The name of the adapters folder.

DEFAULT_ADAPTERS_FOLDER
organization str

The name of the organization folder.

DEFAULT_ORGANIZATION_FOLDER
system str

The name of the system folder.

DEFAULT_SYSTEM_FOLDER
resource str

The name of the resource folder.

DEFAULT_RESOURCE_FOLDER
dataset str

The name of the dataset folder.

DEFAULT_DATASET_FOLDER
init_organization str

The initial organization configuration.

INIT_ORGANIZATION
init_system str

The initial system configuration.

INIT_SYSTEM
init_resource str

The initial resource configuration.

INIT_RESOURCE
init_dataset str

The initial dataset configuration.

INIT_DATASET
init_adapter str

The initial adapter configuration.

INIT_ADAPTER

Attributes:

Name Type Description
path Path

The path to the directory where the project should be created.

name str

The name of the project.

overwrite bool

Whether to overwrite an existing project with the same name. # noqa: E501

default_profile str

The default profile to use.

catalogue_path Path

The path to the catalogue folder.

adapters_path Path

The path to the adapters folder.

organization str

The name of the organization folder.

system str

The name of the system folder.

resource str

The name of the resource folder.

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def __init__(
    self,
    path: Path,
    name: str,
    overwrite: bool = False,
    default_profile: str = DEFAULT_PROFILE,
    catalogue: str = DEFAULT_CATALOGUE_FOLDER,
    adapters: str = DEFAULT_ADAPTERS_FOLDER,
    organization: str = DEFAULT_ORGANIZATION_FOLDER,
    system: str = DEFAULT_SYSTEM_FOLDER,
    resource: str = DEFAULT_RESOURCE_FOLDER,
    dataset: str = DEFAULT_DATASET_FOLDER,
    init_organization: str = INIT_ORGANIZATION,
    init_system: str = INIT_SYSTEM,
    init_resource: str = INIT_RESOURCE,
    init_dataset: str = INIT_DATASET,
    init_adapter: str = INIT_ADAPTER,
) -> None:
    """
    A class for initializing a new Blackline project.

    Args:
        path: The path to the directory where the project should be created.
        name : The name of the project.
        overwrite : Whether to overwrite an existing project with the same name.
        default_profile : The default profile to use.
        catalogue : The name of the catalogue folder.
        adapters: The name of the adapters folder.
        organization: The name of the organization folder.
        system: The name of the system folder.
        resource: The name of the resource folder.
        dataset: The name of the dataset folder.
        init_organization: The initial organization configuration.
        init_system: The initial system configuration.
        init_resource: The initial resource configuration.
        init_dataset: The initial dataset configuration.
        init_adapter: The initial adapter configuration.

    Attributes:
        path (Path): The path to the directory where the project should be created.
        name (str): The name of the project.
        overwrite (bool): Whether to overwrite an existing project with the same name. # noqa: E501
        default_profile (str): The default profile to use.
        catalogue_path (Path): The path to the catalogue folder.
        adapters_path (Path): The path to the adapters folder.
        organization (str): The name of the organization folder.
        system (str): The name of the system folder.
        resource (str): The name of the resource folder.
    """
    self.path = path
    self.name = name
    self.overwrite = overwrite
    self.default_profile = default_profile
    self.catalogue_path = Path(path, catalogue or DEFAULT_CATALOGUE_FOLDER)
    self.adapters_path = Path(path, adapters or DEFAULT_ADAPTERS_FOLDER)
    self.organization = organization
    self.system = system
    self.resource = resource
    self.dataset = dataset
    self.init_organization: str = init_organization
    self.init_system = init_system
    self.init_resource = init_resource
    self.init_dataset = init_dataset
    self.init_adapter = init_adapter
    self.project_config = ProjectConfig(
        name=self.name,
        config_version=PROJECT_CONFIG_VERSION,
        version=PROJECT_VERSION,
        default_profile=self.default_profile,
        catalogue_path=self.catalogue_path,
        adapters_path=self.adapters_path,
        project_root=self.path,
    )

create_adapter()

Creates an adapter for the project.

Returns:

Name Type Description
Path Path

The path of the adapter.

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_adapter(
    self,
) -> Path:
    """Creates an adapter for the project.

    Returns:
        Path: The path of the adapter.
    """
    adapter_path = self.create_adapter_folders()
    self.create_adapter_file(resource_path=adapter_path)
    return adapter_path

create_adapter_file(resource_path)

Creates a file for the adapter.

Parameters:

Name Type Description Default
resource_path Path

The path of the adapter folder.

required

Returns:

Type Description
None

None

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_adapter_file(
    self,
    resource_path: Path,
) -> None:
    """Creates a file for the adapter.

    Args:
        resource_path: The path of the adapter folder.

    Returns:
        None
    """
    Path(resource_path, INIT_DATASET_FILENAME).write_text(self.init_adapter)

create_adapter_folders()

Creates folders for the adapter.

Returns:

Name Type Description
Path Path

The path of the adapter folder.

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_adapter_folders(
    self,
) -> Path:
    """Creates folders for the adapter.

    Returns:
        Path: The path of the adapter folder.
    """

    resource_path = Path(
        self.adapters_path,
        self.organization,
        self.system,
        self.resource,
    )
    resource_path.mkdir(parents=True, exist_ok=True)
    return resource_path

create_catalogue()

Creates the catalogue folder and files.

Returns:

Type Description
None

None

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_catalogue(self) -> None:
    """Creates the catalogue folder and files.

    Args:
        None

    Returns:
        None
    """
    (
        organization_path,
        system_path,
        resource_path,
        dataset_path,
    ) = self.create_catalogue_folders()
    self.create_catalogue_files(
        organization_path=organization_path,
        system_path=system_path,
        resource_path=resource_path,
        dataset_path=dataset_path,
    )

create_catalogue_files(organization_path, system_path, resource_path, dataset_path)

Create the catalogue files in the specified paths.

Parameters:

Name Type Description Default
organization_path Path

Path to the organization folder.

required
system_path Path

Path to the system folder.

required
resource_path Path

Path to the resource folder.

required
dataset_path Path

Path to the dataset folder.

required

Returns:

Type Description
None

None

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_catalogue_files(
    self,
    organization_path: Path,
    system_path: Path,
    resource_path: Path,
    dataset_path: Path,
) -> None:
    """Create the catalogue files in the specified paths.

    Args:
        organization_path: Path to the organization folder.
        system_path: Path to the system folder.
        resource_path: Path to the resource folder.
        dataset_path: Path to the dataset folder.

    Returns:
        None
    """
    Path(organization_path, INIT_ORGANIZATION_FILENAME).write_text(
        self.init_organization
    )
    Path(system_path, INIT_SYSTEM_FILENAME).write_text(self.init_system)
    Path(resource_path, INIT_RESOURCE_FILENAME).write_text(self.init_resource)
    Path(dataset_path, INIT_DATASET_FILENAME).write_text(self.init_dataset)

create_catalogue_folders()

Creates folders for the catalogue.

Returns:

Type Description
Tuple[Path, Path, Path, Path]

A tuple containing the paths of the organisation, system, resource and dataset folders. # noqa: E501

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_catalogue_folders(self) -> Tuple[Path, Path, Path, Path]:
    """Creates folders for the catalogue.


    Returns:
        A tuple containing the paths of the organisation, system, resource and dataset folders. # noqa: E501
    """
    catalogue_path = self.catalogue_path
    organisation_path = Path(catalogue_path, self.organization)
    system_path = Path(organisation_path, self.system)
    resource_path = Path(system_path, self.resource)
    dataset_path = Path(resource_path, self.dataset)
    dataset_path.mkdir(parents=True, exist_ok=True)
    return organisation_path, system_path, resource_path, dataset_path

create_project_yaml()

Creates a YAML file for the project configuration.

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def create_project_yaml(self) -> None:
    """Creates a YAML file for the project configuration."""

    self.path.mkdir(exist_ok=True)
    env = Environment(loader=PackageLoader("blackline.project", "templates"))
    template = env.get_template("blackline_project.yml")
    project = template.render(config=self.project_config)
    Path(self.path, PROJECT_CONFIG_FILE).write_text(project)

init_project()

Creates a new project.

Source code in /opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages/blackline/project/init.py
def init_project(self) -> None:
    """Creates a new project."""

    self.create_project_yaml()
    self.create_adapter()
    self.create_catalogue()