CoreData

DataCore

class panda_core_data.DataCore(*args, name=None, replace=False, **kwargs)

Bases: panda_core_data.data_core_bases.data_model.DataModel, panda_core_data.data_core_bases.data_template.DataTemplate

Class where everything is kept.

__call__(mods_path, core_mod_folder='core', raws_folder='raws', models_folder='models', templates_folder='templates', **kwargs)

Automatically import all data types based on the paths in the params

Parameters:
  • mods_path (Union[Path, str]) – Absolute root folder to the root mods folder
  • core_mod_folder (Union[Path, str]) – Name of the core mod folder. The base mod
  • raws_folder (Union[Path, str]) – Name of the raw folder
  • models_folder (Union[Path, str]) – Name of the models folder
  • templates_folder (Union[Path, str]) – Name of the templates folder
  • raw_models_folder (Path or str or bool) – Name of the raws that are related to the models. Default is ‘models_folder’ param
  • raw_templates_folder (Path or str or bool) – Name of the raws that are related to the templates. Default is the ‘templates_folder’ param
Raises:

PCDInvalidPath – If any of the folders are invalid

DataTemplate

class panda_core_data.data_core_bases.data_template.DataTemplate(*args, **kwargs)

Bases: panda_core_data.data_core_bases.base_data.BaseData

all_template_instances

Gets all the template instances

Yield Template:returns a generator of all instanced templates
Return type:Iterator[Template]
all_templates

Get all Template types

Return type:Tuple[Template]
Returns:return a list of template types
get_template_type(template_name, **kwargs)

Get Data type from a list of all Template types

Parameters:
  • template_name (str) – The name of the Template
  • default – Default value to be returned if the template type couldn’t be found
Return type:

Template

Returns:

the Template

instance_template(data_type_name, path, **kwargs)

Create a new instance of a Template

Parameters:
  • template_type_name – name of the Template
  • path (Union[Path, str]) – path to the raw file
Return type:

Template

Returns:

The instanced Template

recursively_instance_template(path, *args, **kwargs)

Instance Template recursively based on the raws inside the folders

Return type:List[Template]

DataModel

class panda_core_data.data_core_bases.data_model.DataModel(*args, **kwargs)

Bases: panda_core_data.data_core_bases.base_data.BaseData

all_model_instances

Gets all the model instances.

Yield Model:returns a generator of all instanced templates
Return type:Iterator[Model]
all_models

Get all Model types

Return type:Tuple[Model]
Returns:return a list of model types
get_model_type(model_name, **kwargs)

Get Data type from a list of all Model types

Parameters:
  • model_name (str) – The name of the Model
  • default – Default value to be returned if the model type couldn’t be found
Return type:

Model

Returns:

the Model

instance_model(data_type_name, path, **kwargs)

Create a new instance of a Model

Parameters:
  • model_type_name – name of the Model
  • path (Union[Path, str]) – path to the raw file
Return type:

Model

Returns:

The instanced Model

recursively_instance_model(path, *args, **kwargs)

Instance Model recursively based on the raws inside the folders

Return type:Iterator[Model]

BaseData

class panda_core_data.data_core_bases.base_data.BaseData(excluded_extensions=False)
classmethod __init_subclass__()

This function checks if a method is lacking inside any class that inherits this, and also automatically creates docstrings into those methods based on the original method

static add_module(path)

Automatically import the module from the python file and add it’s directory to sys.path if it wasn’t in there before.

Parameters:path (Union[Path, str]) – The path to the python file
Return module:Returns the imported module
Return type:module
static all_datas()

Get all DataType types

Return type:List[DataType]
Returns:return a list of data types
static get_data_type(data_name, data_dict, default=None)

Get Data type from a list of all DataType types

Parameters:
  • data_name (str) – The name of the DataType
  • default (Optional[bool]) – Default value to be returned if the data type couldn’t be found
Return type:

DataType

Returns:

the DataType

static instance_data(data_name, get_data_type, path, **kwargs)

Create a new instance of a DataType

Parameters:
  • data_type_name – name of the DataType
  • path (Union[Path, str]) – path to the raw file
Return type:

DataType

Returns:

The instanced DataType

recursively_add_module(path)

Recursively add a module with DataType from the supplied path

Parameters:path (str) – Path to the data module
Return type:List[module]
static recursively_instance_data()

Instance DataType recursively based on the raws inside the folders

Return type:List[DataType]