-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-cmsis.py
More file actions
57 lines (48 loc) · 1.93 KB
/
Copy pathsync-cmsis.py
File metadata and controls
57 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pathlib
import urllib.request
import github
class GitHubDownloader:
def __init__(self, repo: str, ref: str):
self._ref = ref
self._github = github.Github()
self._repo = self._github.get_repo(repo)
def _download_file(self, file: github.ContentFile):
dest_path = pathlib.Path(file.path)
if dest_path.exists():
print(f'{dest_path} is already downloaded')
return
print(f'Downloading {file.download_url}')
dest_path.parent.mkdir(parents=True, exist_ok=True)
urllib.request.urlretrieve(file.download_url, file.path)
def download_dir(self, path: str):
for file in self._repo.get_contents(path, ref=self._ref):
self._download_file(file)
def download_file(self, path: str):
file = self._repo.get_contents(path, ref=self._ref)
self._download_file(file)
def main():
downloader = GitHubDownloader(repo='ARM-software/CMSIS_5', ref='5.7.0')
includes = [
'CMSIS/Core/Include',
'CMSIS/DSP/Include',
'CMSIS/DSP/PrivateInclude',
]
sources = [
'LICENSE.txt',
'CMSIS/DSP/Source/BasicMathFunctions/arm_add_q15.c',
'CMSIS/DSP/Source/BasicMathFunctions/arm_dot_prod_q15.c',
'CMSIS/DSP/Source/BasicMathFunctions/arm_mult_q15.c',
'CMSIS/DSP/Source/BasicMathFunctions/arm_offset_q15.c',
'CMSIS/DSP/Source/BasicMathFunctions/arm_scale_q15.c',
'CMSIS/DSP/Source/MatrixFunctions/arm_mat_init_q15.c',
'CMSIS/DSP/Source/MatrixFunctions/arm_mat_mult_fast_q15.c',
'CMSIS/DSP/Source/StatisticsFunctions/arm_max_q15.c',
'CMSIS/DSP/Source/StatisticsFunctions/arm_min_q15.c',
'CMSIS/DSP/Source/SupportFunctions/arm_fill_q15.c',
]
for include_dir in includes:
downloader.download_dir(include_dir)
for source_file in sources:
downloader.download_file(source_file)
if __name__ == '__main__':
main()