8.3. Data Collection in jinja

class nettoolkit.j2config.data_collect.ABSRegion(device_details, custom_data_file)[source]

Bases: ABC

Abstract Base Class Template to define custom/regional dataframe

Parameters:
  • device_details (DataFrame) – Pandas DataFrame with device var information

  • custom_data_file (str) – custom datafile.

Inherits:

ABC (ABC): abstract base class

Abstract Properties:

frames(list) : must be defined in custom class method, which should return a list of DataFrame(s) to override var attributes.

abstract property frames

must be defined in custom class method, which should return a list of DataFrame(s) to override var attributes.

class nettoolkit.j2config.data_collect.DeviceDetails(device_file)[source]

Bases: object

Device details operations

Parameters:

device_file (str) – Excel device database file

Raises:
  • Exception – Raised for input error: if device filename missing

  • Exception – Raised for input error: if provided device file missing or read fails.

Returns:

DeviceDetails object

Return type:

DeviceDetails

merge_vars(frames)[source]

merges var details from two different dataframes ( region and device - databases ) (support definition)

Parameters:

frames (list) – list of DataFrame(s) to be merged

Returns:

merged DataFrame (var)

Return type:

DataFrame

merge_with_var_frames(regional_frames)[source]

merge device var details with provided custom regional DataFrame(s) custom regional frame variables/values overrides device var variables/values.

Parameters:

regional_frames (list) – list of custom regional DataFrames to be added to var.

merged_table_columns()[source]

merges all different type of interfaces/protocols details in to a single dataframe.

Returns:

Pandas DataFrame object collecting all interfaces/protocols details

Return type:

DataFrame

read_device()[source]

reads device database

Returns:

dictionary of dataframe

Return type:

dict

read_table()[source]

reads table dataframe and add var/table to dataframe dictionary

verify_input_dev_file()[source]

check if provided input device file

Raises:
  • Exception – Raised for input error: if device filename missing

  • Exception – Raised for input error: if provided device file missing or read fails.

nettoolkit.j2config.data_collect.read_excel(file)[source]

read excel file, all worksheet

Parameters:

file (str) – excel file name

Returns:

dictionary of dataframes.

Return type:

dict

nettoolkit.j2config.data_collect.read_worksheet(file, wks)[source]

read an excel worksheet

Parameters:
  • file (str) – excel file name

  • wks (str) – worksheet name

Raises:

Exception – Raised for file read fail, or worksheet missing

Returns:

Pandas DataFrame Object

Return type:

DataFrame

nettoolkit.j2config.data_collect.to_int(item)[source]

try to converts item to integer

Parameters:

item (str) – input string

Returns:

returns integer value if it is number, else same as input string

Return type:

int, str