cpu/stm32/gen_kconfig: use openpyxl package instead of xlrd
This commit is contained in:
parent
d39fd7c773
commit
127d6853c7
21
cpu/stm32/dist/kconfig/gen_kconfig.py
vendored
21
cpu/stm32/dist/kconfig/gen_kconfig.py
vendored
@ -9,8 +9,9 @@
|
||||
import os
|
||||
import argparse
|
||||
import datetime
|
||||
import warnings
|
||||
|
||||
import xlrd
|
||||
from openpyxl import load_workbook
|
||||
from jinja2 import FileSystemLoader, Environment
|
||||
|
||||
|
||||
@ -19,22 +20,26 @@ RIOTBASE = os.getenv(
|
||||
"RIOTBASE", os.path.abspath(os.path.join(CURRENT_DIR, "../../../..")))
|
||||
STM32_KCONFIG_DIR = os.path.join(RIOTBASE, "cpu/stm32/kconfigs")
|
||||
STM32_VENDOR_DIR = os.path.join(RIOTBASE, "cpu/stm32/include/vendor/cmsis")
|
||||
MODEL_COLUMN = 1
|
||||
|
||||
|
||||
def parse_sheet(cpu_fam, sheets):
|
||||
"""Parse the Excel sheet and return a dict."""
|
||||
models = []
|
||||
for sheet in sheets:
|
||||
# Load the content of the xlsx sheet
|
||||
work_book = xlrd.open_workbook(sheet)
|
||||
sheet = work_book.sheet_by_name('ProductsList')
|
||||
# filter warning raised by openpyxl
|
||||
with warnings.catch_warnings(record=True):
|
||||
warnings.simplefilter("always")
|
||||
# Load the content of the xlsx sheet
|
||||
sheet = load_workbook(filename=sheet, data_only=True).active
|
||||
|
||||
# Extract models from sheet
|
||||
for rownum in range(sheet.nrows):
|
||||
row = sheet.row_values(rownum)
|
||||
if not row[0].startswith("STM32"):
|
||||
for idx, row in enumerate(sheet.rows):
|
||||
# Row index starts at 1
|
||||
model = str(sheet.cell(row=idx + 1, column=MODEL_COLUMN).value)
|
||||
if not model.startswith("STM32"):
|
||||
continue
|
||||
models.append(row[0].replace("-", "_"))
|
||||
models.append(model.replace("-", "_"))
|
||||
return sorted(models)
|
||||
|
||||
|
||||
|
||||
2
cpu/stm32/dist/kconfig/requirements.txt
vendored
2
cpu/stm32/dist/kconfig/requirements.txt
vendored
@ -1,2 +1,2 @@
|
||||
xlrd
|
||||
openpyxl
|
||||
jinja2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user