Squashed 'kiauh/core/submodules/simple_config_parser/' content from commit 90081a6

git-subtree-dir: kiauh/core/submodules/simple_config_parser
git-subtree-split: 90081a6539ec38adf6a1a5bb707a0e9934567c7f
This commit is contained in:
dw-0
2024-09-24 19:22:13 +02:00
commit 2f924a2550
46 changed files with 4056 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
[example_section]
[gcode_macro CANCEL_PRINT]
[gcode_macro SET_PAUSE_NEXT_LAYER]
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
[update_manager moonraker-obico]
[include moonraker_obico_macros.cfg]
[include moonraker-obico-update.cfg]
[example_section two]
[valid_content]
[valid content]
[content123]
[a]
[valid_content] # comment
[something];comment
[mcu]
[printer]
[printer]
[stepper_x]
[stepper_y]
[stepper_z]
[printer]
[stepper_a]
[stepper_b]
[stepper_c]
[delta_calibrate]
[printer]
[stepper_left]
[stepper_right]
[stepper_bed]
[stepper_arm]
[delta_calibrate]
[extruder]
[heater_bed]
[bed_mesh]
[bed_tilt]
[bed_screws]
[screws_tilt_adjust]
[z_tilt]
[quad_gantry_level]
[skew_correction]
[z_thermal_adjust]
[safe_z_home]
[homing_override]
[endstop_phase stepper_z]
[gcode_macro my_cmd]
[delayed_gcode my_delayed_gcode]
[save_variables]
[idle_timeout]
[virtual_sdcard]
[sdcard_loop]
[force_move]
[pause_resume]
[firmware_retraction]
[gcode_arcs]
[respond]
[exclude_object]
[input_shaper]
[adxl345]
[lis2dw]
[mpu9250 my_accelerometer]
[resonance_tester]
[board_pins my_aliases]
[duplicate_pin_override]
[probe]
[bltouch]
[smart_effector]
[probe_eddy_current my_eddy_probe]
[axis_twist_compensation]
[stepper_z1]
[extruder1]
[dual_carriage]
[extruder_stepper my_extra_stepper]
[manual_stepper my_stepper]
[verify_heater heater_config_name]
[homing_heaters]
[thermistor my_thermistor]
[adc_temperature my_sensor]
[heater_generic my_generic_heater]
[temperature_sensor my_sensor]
[temperature_probe my_probe]
[fan]
[heater_fan heatbreak_cooling_fan]
[controller_fan my_controller_fan]
[temperature_fan my_temp_fan]
[fan_generic extruder_partfan]
[led my_led]
[neopixel my_neopixel]
[dotstar my_dotstar]
[pca9533 my_pca9533]
[pca9632 my_pca9632]
[servo my_servo]
[gcode_button my_gcode_button]
[output_pin my_pin]
[pwm_tool my_tool]
[pwm_cycle_time my_pin]
[static_digital_output my_output_pins]
[multi_pin my_multi_pin]
[tmc2130 stepper_x]
[tmc2208 stepper_x]
[tmc2209 stepper_x]
[tmc2660 stepper_x]
[tmc2240 stepper_x]
[tmc5160 stepper_x]
[ad5206 my_digipot]
[mcp4451 my_digipot]
[mcp4728 my_dac]
[mcp4018 my_digipot]
[display]
[display_data my_group_name my_data_name]
[display_template my_template_name]
[display_glyph my_display_glyph]
[menu __some_list __some_name]
[menu some_name]
[menu some_list]
[menu some_list some_command]
[menu some_list some_input]
[filament_switch_sensor my_sensor]
[filament_motion_sensor my_sensor]
[tsl1401cl_filament_width_sensor]
[hall_filament_width_sensor]
[load_cell]
[sx1509 my_sx1509]
[samd_sercom my_sercom]
[adc_scaled my_name]
[replicape]
[palette2]
[angle my_angle_sensor]

View File

@@ -0,0 +1,19 @@
section: invalid
not_a_valid_section
[missing_square_bracket
missing_square_bracket]
[]
[ ]
[indented_section]
[indented_section] # comment
[indented_section] ; comment
;[commented_section]
#[another_commented_section]
; [commented_section]
# [another_commented_section]
this_is_an_option: 123
this_is_an_indented_option: 123
this_is_an_option_block_start:
#
;

View File

@@ -0,0 +1,39 @@
# ======================================================================= #
# Copyright (C) 2024 Dominik Willner <th33xitus@gmail.com> #
# #
# https://github.com/dw-0/simple-config-parser #
# #
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
from pathlib import Path
import pytest
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
from tests.utils import load_testdata_from_file
BASE_DIR = Path(__file__).parent.joinpath("test_data")
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
NON_MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("non_matching_data.txt")
@pytest.fixture
def parser():
return SimpleConfigParser()
@pytest.mark.parametrize("line", load_testdata_from_file(MATCHING_TEST_DATA_PATH))
def test_match_section(parser, line):
"""Test that a line matches the definition of a section"""
assert (
parser._match_section(line) is True
), f"Expected line '{line}' to match section definition!"
@pytest.mark.parametrize("line", load_testdata_from_file(NON_MATCHING_TEST_DATA_PATH))
def test_non_matching_section(parser, line):
"""Test that a line does not match the definition of a section"""
assert (
parser._match_section(line) is False
), f"Expected line '{line}' to not match section definition!"