Skip to content

Bundle

Module for managing Helix bundle files.

Bundle ¤

Class representing a Helix bundle file.

This class provides methods to import and export Helix bundle files.

Note

This class is not intended to be instantiated directly. Please access it through an instantiated Helix object.

Example:

helix = Helix()
bundle = helix.bundle

Source code in helixapi\bundle.py
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
class Bundle:
    """
    Class representing a Helix bundle file.

    This class provides methods to import and export Helix bundle files.

    !!! note

        This class is not intended to be instantiated directly.
        Please access it through an instantiated `Helix` object.

        Example:
        ```py
        helix = Helix()
        bundle = helix.bundle
        ```
    """

    def __init__(self, file_path=None, setlists_callback=None):
        """
        Initialize the Bundle class.

        Args:
            file_path (str, optional): Path to the bundle file to load. Defaults to None.

        Examples:
        ``` py
        bundle = Bundle()
        ```

        Returns:
            None
        """
        self._setlists_callback = setlists_callback
        self.import_bundle(file_path)

    @property
    def name(self):
        """
        Get the name of the bundle.

        Returns:
            str: The name of the bundle.
        """
        return self.metadata['meta']['name']

    @name.setter
    def name(self, value):
        """
        Set the name of the bundle.

        Args:
            value (str): The name of the bundle.
        """
        self.data['meta']['name'] = value

    def export_bundle(self, file_path=None):
        """
        Export the bundle to a file.

        Args:
            file_path (str): Path to export the bundle file to.

        Raises:
            Exception: If the file path is not specified or the file type is incorrect.
        """
        logging.debug(f"Exporting bundle: {file_path}")

        if not file_path:
            raise Exception('File path must be specified.')
        elif FileType.get_type(file_path) == FileType.BUNDLE:
            Files._export_file(file_path=file_path, data=self.data, metadata=self.metadata)
        else:
            raise Exception('File type must be a bundle.')

    def import_bundle(self, file_path=None):
        """
        Import the bundle from a file.

        Args:
            file_path (str): Path to the bundle file to import.

        Raises:
            Exception: If the file path is not specified or the file type is incorrect.
        """
        logging.debug(f"Importing bundle: {file_path}")

        if not file_path:
            self.data, self.metadata = Files._import_file(TemplatePath.BUNDLE.value)            
        elif FileType.get_type(file_path) == FileType.BUNDLE:
            self.data, self.metadata = Files._import_file(file_path)
        else:
            raise Exception('File path must be a bundle or None (to load the bundle template).')

        # Call the callback to notify Helix to reload setlists
        if self._setlists_callback:
            self._setlists_callback(self.data)

name property writable ¤

Get the name of the bundle.

Returns:

Name Type Description
str

The name of the bundle.

export_bundle(file_path=None) ¤

Export the bundle to a file.

Parameters:

Name Type Description Default
file_path str

Path to export the bundle file to.

None

Raises:

Type Description
Exception

If the file path is not specified or the file type is incorrect.

Source code in helixapi\bundle.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def export_bundle(self, file_path=None):
    """
    Export the bundle to a file.

    Args:
        file_path (str): Path to export the bundle file to.

    Raises:
        Exception: If the file path is not specified or the file type is incorrect.
    """
    logging.debug(f"Exporting bundle: {file_path}")

    if not file_path:
        raise Exception('File path must be specified.')
    elif FileType.get_type(file_path) == FileType.BUNDLE:
        Files._export_file(file_path=file_path, data=self.data, metadata=self.metadata)
    else:
        raise Exception('File type must be a bundle.')

import_bundle(file_path=None) ¤

Import the bundle from a file.

Parameters:

Name Type Description Default
file_path str

Path to the bundle file to import.

None

Raises:

Type Description
Exception

If the file path is not specified or the file type is incorrect.

Source code in helixapi\bundle.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def import_bundle(self, file_path=None):
    """
    Import the bundle from a file.

    Args:
        file_path (str): Path to the bundle file to import.

    Raises:
        Exception: If the file path is not specified or the file type is incorrect.
    """
    logging.debug(f"Importing bundle: {file_path}")

    if not file_path:
        self.data, self.metadata = Files._import_file(TemplatePath.BUNDLE.value)            
    elif FileType.get_type(file_path) == FileType.BUNDLE:
        self.data, self.metadata = Files._import_file(file_path)
    else:
        raise Exception('File path must be a bundle or None (to load the bundle template).')

    # Call the callback to notify Helix to reload setlists
    if self._setlists_callback:
        self._setlists_callback(self.data)