zephyr/boards
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
..
96boards arch: treewide: Remove unnessecary flash size/address defconfig when !XIP 2024-06-13 20:15:35 -04:00
aconno
acrn
actinius dts: cleanup leading spaces 2024-06-21 08:46:12 -04:00
adafruit boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
adi boards: adi: Improve twister vendor filter coverage 2024-06-21 08:44:04 -04:00
alientek
altr doc: use proper pygment for .conf code-blocks 2024-06-20 14:07:32 -04:00
ambiq drivers: mspi: Add Ambiq apollo3p mspi controller 2024-06-14 21:07:00 -04:00
amd
andestech boards: andestech: Add missing supported drivers to board yaml 2024-06-18 15:55:06 +02:00
arduino doc: fix incorrect bullet lists 2024-06-20 14:07:32 -04:00
arm boards: mps2_an385: add NVS support 2024-06-19 13:43:45 -04:00
aspeed
atmarktechno
atmel drivers: counter: sam: Add qdec as tc special mode 2024-06-17 17:47:42 -04:00
bbc
bcdevices
beagle
blues
brcm
bytesatwork
cdns
circuitdojo
common
contextualelectronics
croxel boards: croxel_cx1825: fix: Remove arduino support claims 2024-06-24 22:25:45 -04:00
ct boards: ct: ctcc: add ctcc/nrf52840 board definition 2024-06-14 18:50:14 -04:00
cypress
digilent boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
dragino
ebyte
efinix
electronut
element14 arch: treewide: Remove unnessecary flash size/address defconfig when !XIP 2024-06-13 20:15:35 -04:00
enclustra/mercury_xu
ene
enjoydigital
espressif drivers: clock_control: Refactor for ESP32C6 2024-06-14 18:51:46 -04:00
ezurio Bluetooth: drivers: Convert IPC driver to new API 2024-06-11 19:42:49 -04:00
fanke
firefly
franzininho
gaisler
gd
google board: google_dragonclaw: add supported features 2024-06-14 19:35:34 +02:00
hardkernel Bluetooth: drivers: Convert ESP32 HCI driver to new API 2024-06-11 19:42:49 -04:00
heltec Bluetooth: drivers: Convert ESP32 HCI driver to new API 2024-06-11 19:42:49 -04:00
holyiot
infineon cy8cproto_062_4343w: board: fix polarity for LED_0 2024-06-24 09:46:01 +02:00
innblue
intel intel_adsp: ace30: use correct toolchain 2024-06-12 17:12:41 -05:00
ite Bluetooth: drivers: Convert H4 (UART) HCI driver to new API 2024-06-11 19:42:49 -04:00
khadas
kincony Bluetooth: drivers: Convert ESP32 HCI driver to new API 2024-06-11 19:42:49 -04:00
lilygo boards: lilygo: ttgo_lora32: initial support 2024-06-13 05:46:10 -04:00
lowrisc
luatos boards: docs: remove extra table line 2024-06-14 19:12:29 +02:00
m5stack boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
madmachine
makerdiary
mediatek/mt8195_adsp
microchip
mikroe boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
mxchip
native everywhere: replace double words 2024-06-25 06:05:35 -04:00
nordic boards: nordic: nrf54h20dk: Counter and i2c are supported by cpuppr 2024-06-24 12:41:47 -04:00
nuvoton everywhere: replace double words 2024-06-22 05:40:22 -04:00
nxp boards: nxp: lpcxpresso551s16: enable usbphy1 2024-06-24 14:49:45 -04:00
olimex boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
openisa boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
others boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
panasonic Bluetooth: drivers: Convert IPC driver to new API 2024-06-11 19:42:49 -04:00
particle
phytec doc: use proper pygment for .conf code-blocks 2024-06-20 14:07:32 -04:00
pine64 drivers: display: st7789v: convert to MIPI DBI API 2024-06-13 09:22:54 +02:00
pjrc
qemu linker: Add ROM_SECTIONS location 2024-06-20 12:08:58 -04:00
qorvo
quicklogic
rak boards: rak: Add Rak11720 board 2024-06-14 11:13:27 +02:00
raspberrypi boards: raspberrypi: rpi_5: Correct hyperlink target 2024-06-21 10:11:53 +02:00
raytac Bluetooth: drivers: Convert IPC driver to new API 2024-06-11 19:42:49 -04:00
renesas boards: renesas: dts: Various fixes 2024-06-24 12:43:12 -04:00
renode
ronoth
ruuvi
sc
seagate boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
seco doc: fix incorrect bullet lists 2024-06-20 14:07:32 -04:00
seeed doc: fix incorrect bullet lists 2024-06-20 14:07:32 -04:00
segger
shields dts: lora: add board support for reyax lora module 2024-06-14 17:12:49 -04:00
sifive
silabs libc: cleanup deprecated heap-related Kconfigs 2024-06-18 14:33:58 -04:00
sipeed boards: fix openocd deprecated configuration 2024-06-13 20:18:37 -04:00
snps snps: board: rmx100: add pmp 2024-06-14 21:05:36 -04:00
sparkfun boards: sparkfun: Add micromod nrf52840 board and asset tracker shield 2024-06-13 17:55:42 +02:00
st boards: arm: stm32h573 disco kit can flash on external NOR 2024-06-24 12:45:34 -04:00
starfive
tdk
technexion arch: treewide: Remove unnessecary flash size/address defconfig when !XIP 2024-06-13 20:15:35 -04:00
telink
ti boards: ti: sk_am62: Add OpenOCD support 2024-06-13 20:24:16 -04:00
toradex arch: treewide: Remove unnessecary flash size/address defconfig when !XIP 2024-06-13 20:15:35 -04:00
u-blox
udoo
up-bridge-the-gap Bluetooth: drivers: Convert H4 (UART) HCI driver to new API 2024-06-11 19:42:49 -04:00
vcc-gnd boards: docs: remove extra table line 2024-06-14 19:12:29 +02:00
vngiotlab
waveshare drivers: display: gc9x01: convert to MIPI DBI API 2024-06-14 17:11:20 -04:00
we
weact everywhere: replace double words 2024-06-22 05:40:22 -04:00
wemos
wiznet
xen doc: fix incorrect bullet lists 2024-06-20 14:07:32 -04:00
CMakeLists.txt
Kconfig
Kconfig.v1
Kconfig.v2
deprecated.cmake boards: silabs: Consistently name starter kits 2024-06-12 12:52:28 -04:00
index.rst