-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathBoardHelper.py
37 lines (33 loc) · 1.21 KB
/
BoardHelper.py
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
#-*- coding: utf-8 -*-
import const
from re import search as ReSearch
def __parseBoards(fp):
boardsinfo = {}
cur_board_name = ""
for line in fp.readlines():
line = line.strip()
if line == '' or line.startswith('#'):
continue
value = line.split("=")[-1]
if ReSearch(const.boards_name_matcher, line):
cur_board_name = value
boardsinfo[cur_board_name] = {}
if cur_board_name == "":
continue
if ReSearch(const.boards_upload_protocol_matcher, line):
boardsinfo[cur_board_name]["protocol"] = value
if ReSearch(const.boards_upload_maximum_size_matcher, line):
boardsinfo[cur_board_name]["maximum_size"] = int(value)
if ReSearch(const.boards_upload_speed_matcher, line):
boardsinfo[cur_board_name]["speed"] = value
if ReSearch(const.boards_mcu_matcher, line):
boardsinfo[cur_board_name]["mcu"] = value
return boardsinfo
def getBoardsInfo():
try:
fp = open(const.boards_txt, "r")
boardsinfo = __parseBoards(fp)
fp.close()
return True, boardsinfo
except Exception, e:
return False, repr(e)