Skip to content

Commit 626ede3

Browse files
authored
Merge pull request #1422 from fpistm/scripts
scripts: update
2 parents 70bd40f + 22491b3 commit 626ede3

File tree

173 files changed

+1699
-3047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+1699
-3047
lines changed

Diff for: CI/utils/stm32common.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
import os
21
import re
32
import shutil
43

54

65
# Create a folder if not exists
76
def createFolder(path):
87
try:
9-
if not os.path.exists(path):
10-
os.makedirs(path)
8+
if not path.exists():
9+
path.mkdir()
1110
except OSError:
1211
print("Error: Creating directory. " + path)
1312

1413

1514
# Delete targeted folder recursively
1615
def deleteFolder(path):
17-
if os.path.isdir(path):
16+
if path.is_dir():
1817
shutil.rmtree(path, ignore_errors=True)
1918

2019

2120
# copy src folder recursively to dest
2221
def copyFolder(src, dest, ign_patt=set()):
2322
try:
24-
if os.path.isdir(src):
23+
if src.is_dir():
2524
shutil.copytree(src, dest, ignore=shutil.ignore_patterns(*ign_patt))
2625
except OSError as e:
2726
print("Error: Folder %s not copied. %s" % src, e)
2827

2928

3029
def genSTM32List(path, pattern):
3130
stm32_list = [] # Serie
32-
dir_pattern = re.compile("^STM32(.*)xx_HAL_Driver$", re.IGNORECASE)
31+
dir_pattern = re.compile(r"^STM32(.*)xx_HAL_Driver$", re.IGNORECASE)
3332

3433
if pattern is not None:
3534
serie_pattern = re.compile(pattern, re.IGNORECASE)
3635
else:
3736
serie_pattern = re.compile(".*", re.IGNORECASE)
3837

39-
for file in os.listdir(path):
40-
res = dir_pattern.match(file)
38+
for file in path.iterdir():
39+
res = dir_pattern.match(file.name)
4140
if res and serie_pattern.search(res.group(1)):
4241
stm32_list.append(res.group(1))
4342
stm32_list.sort()

0 commit comments

Comments
 (0)