Best Python code snippet using lisa_python
cli.py
Source:cli.py  
...123def list(component_type):124    """List components that are available on your machine"""125    config_loader = initialise_component_loader()126    component_types = sorted({127         "displays": lambda: config_loader.load_by_type(ComponentType.DISPLAY),128         "datafeeds": lambda: config_loader.load_by_type(ComponentType.DATA_FEED),129         "filters": lambda: config_loader.load_by_type(ComponentType.FILTER),130         "notifications": lambda: config_loader.load_by_type(ComponentType.NOTIFICATION)131    }.items(), key=lambda t: t[0])132    def print_ids(creators):133        ids = {c.id_key_value[1] if hasattr(c, "id_key_value") else c.get_id() for c in creators}134        for i in sorted(ids):135            click.echo(" - %s" % i)136    for k, v in component_types:137        if component_type == k or component_type == "all":138            click.echo("Available %s:" % k)139            print_ids(v())140        if component_type == "all":141            click.echo("")142def read_dashboard_from_config(dashboard_config, configs):143    try:144        return dashboard_config.read_yaml(configs)...configuration.py
Source:configuration.py  
...78        self._component_configs_loader = component_configs_loader79        self._secret_store = secrets80        self._initialise_parsers()81    def _initialise_parsers(self):82        display_configs = self._component_configs_loader.load_by_type(ComponentType.DISPLAY)83        self._display_config_section_parser = ComponentConfigParser(display_configs,  self._secret_store)84        data_feed_configs = self._component_configs_loader.load_by_type(ComponentType.DATA_FEED)85        self._data_feed_config_section_parser = ComponentConfigParser(data_feed_configs, self._secret_store)86        filter_configs = self._component_configs_loader.load_by_type(ComponentType.FILTER)87        filter_parser = ComponentConfigParser(filter_configs,  self._secret_store)88        notification_configs = \89            self._component_configs_loader.load_by_type(ComponentType.NOTIFICATION)90        self._notification_config_section_parser = NotificationComponentsConfigParser(91            notification_configs,92            filter_parser,93            self._secret_store94        )95    def read_yaml(self, yaml_configs):96        dashboards = []97        for yaml_config in yaml_configs:98            try:99                config = yaml.safe_load(yaml_config)100            except yaml.YAMLError as err:101                raise ConfigYamlParsingError(err, yaml_config)102            dashboards.append(self._create_dashboard(config))103        return self._dashboard_merger.merge(dashboards)...load_scan.py
Source:load_scan.py  
...4import matplotlib.pyplot as plt5from mpl_toolkits.mplot3d.art3d import Poly3DCollection6import numpy as np7from skimage import measure8def load_by_type(path, file_type, contains=""):9    return [10        dicom.read_file(os.path.join(path, s))11        for s in os.listdir(path)12        if s.startswith(file_type) and (contains in s)13    ]14def load_planning(path):15    plans = load_by_type(path, "RS.", contains="GTV")16    return plans17def load_slices(path):18    slices = load_by_type(path, "CT.")19    slices.sort(key=lambda x: int(x.InstanceNumber))20    try:21        slice_thickness = np.abs(22            slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2]23        )24    except:25        slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)26    for s in slices:27        s.SliceThickness = slice_thickness28    return slices29def load_scan(path):30    return {31        "slices": load_slices(path),32        "planning": load_planning(path),...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
