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