File: helpers.py

package info (click to toggle)
cloud-init 25.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,412 kB
  • sloc: python: 135,894; sh: 3,883; makefile: 141; javascript: 30; xml: 22
file content (21 lines) | stat: -rw-r--r-- 541 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pathlib import Path

import cloudinit


def get_top_level_dir() -> Path:
    """Return the absolute path to the top cloudinit project directory

    @return Path('<top-cloudinit-dir>')
    """
    return Path(cloudinit.__file__).parent.parent.resolve()


def cloud_init_project_dir(sub_path: str) -> str:
    """Get a path within the cloudinit project directory

    @return str of the combined path

    Example: cloud_init_project_dir("my/path") -> "/path/to/cloud-init/my/path"
    """
    return str(get_top_level_dir() / sub_path)