zephyr/dts/bindings/input
Lingao Meng 302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
..
adc-keys.yaml drivers: input: Implement driver for ADC keys 2024-02-26 11:35:19 +00:00
analog-axis.yaml input: analog_axis: rework deadzone calibration code 2024-03-26 11:10:10 -04:00
chipsemi,chsc6x.yaml drivers: input: CHSC6X Driver 2024-04-08 09:28:36 -04:00
cirque,pinnacle-common.yaml drivers: input: pinnacle: add driver for trackpad 2024-04-04 09:46:06 +01:00
cirque,pinnacle-i2c.yaml drivers: input: pinnacle: add driver for trackpad 2024-04-04 09:46:06 +01:00
cirque,pinnacle-spi.yaml drivers: input: pinnacle: add driver for trackpad 2024-04-04 09:46:06 +01:00
espressif,esp32-touch-sensor.yaml doc: driver: input: espressif touch_sensor Typo 2024-04-08 18:19:10 -05:00
focaltech,ft5336.yaml
futaba,sbus.yaml everywhere: replace double words 2024-06-25 06:05:35 -04:00
goodix,gt911.yaml
gpio-kbd-matrix.yaml input: gpio_kbd_matrix: add poll and scan mode support 2023-12-04 16:40:35 +00:00
gpio-keys.yaml input: gpio_keys: implement polling mode support 2024-01-10 18:21:49 +00:00
gpio-qdec.yaml input: gpio_qdec: add optical encoder support 2024-01-23 09:45:57 -05:00
hynitron,cst816s.yaml
input-keymap.yaml input: add a keymap driver 2024-01-19 15:14:25 +00:00
ite,it8xxx2-kbd.yaml
kbd-matrix-common.yaml input: kbd_matrix: add actual-key-mask support 2023-12-06 09:16:45 +00:00
microchip,cap1203.yaml
microchip,xec-kbd.yaml input: xec: use the generic keyboard code 2024-03-12 19:30:09 -04:00
nuvoton,npcx-kbd.yaml
pixart,pat912x.yaml input: pat912x: add a bunch of settings 2024-03-04 22:10:58 +01:00
pixart,paw32xx.yaml input: add a paw32xx driver 2024-04-23 22:13:51 +00:00
pixart,pmw3610.yaml input: pmw3610: add few config options 2024-03-20 09:02:50 +01:00
sitronix,cf1133.yaml drivers: input: add cf1133 controller touchscreen 2024-03-26 09:24:43 +00:00
st,stmpe811.yaml
xptek,xpt2046.yaml
zephyr,input-longpress.yaml
zephyr,input-sdl-touch.yaml
zephyr,lvgl-button-input.yaml
zephyr,lvgl-common-input.yaml
zephyr,lvgl-encoder-input.yaml
zephyr,lvgl-keypad-input.yaml doc: fix comma typo in lvgl bindings 2024-01-30 19:07:05 +01:00
zephyr,lvgl-pointer-input.yaml
zephyr,native-linux-evdev.yaml input: add a linux-evdev device 2023-12-18 12:23:59 +01:00