Exemple #1
0
def parseKeywordListFromFile(keywords_file_path):
	keyword_list = []
	keyword_type_dict = {}
	keyword_ref_dict = {}
	lines = osfile.readFileLines(keywords_file_path)
	for line in lines:
		line = line.strip()
		if line and (not '#' in line):
			word_list = re.findall(r'\S+', line)
			if len(word_list) > 1:
				keyword = word_list[0]
				if len(word_list) == 3:
					keyword_type = word_list[1]
					keyword_ref = word_list[2]
				elif len(word_list) == 2:
					if 'LITERAL' in word_list[1] or 'KEYWORD' in word_list[1]:
						keyword_type = word_list[1]
						keyword_ref = ''
					else:
						keyword_type = ''
						keyword_ref = word_list[1]
				if not keyword in keyword_list:
					keyword_list.append(keyword)
					keyword_type_dict[keyword] = keyword_type
					keyword_ref_dict[keyword] = keyword_ref
	return (keyword_list, keyword_type_dict, keyword_ref_dict)
Exemple #2
0
def parseKeywordListFromFile(keywords_file_path):
	keyword_list = []
	keyword_type_dict = {}
	keyword_ref_dict = {}
	lines = osfile.readFileLines(keywords_file_path)
	for line in lines:
		line = line.strip()
		if line and (not '#' in line):
			word_list = re.findall(r'\S+', line)
			if len(word_list) > 1:
				keyword = word_list[0]
				if len(word_list) == 3:
					keyword_type = word_list[1]
					keyword_ref = word_list[2]
				elif len(word_list) == 2:
					if 'LITERAL' in word_list[1] or 'KEYWORD' in word_list[1]:
						keyword_type = word_list[1]
						keyword_ref = ''
					else:
						keyword_type = ''
						keyword_ref = word_list[1]
				if not keyword in keyword_list:
					keyword_list.append(keyword)
					keyword_type_dict[keyword] = keyword_type
					keyword_ref_dict[keyword] = keyword_ref
	return (keyword_list, keyword_type_dict, keyword_ref_dict)
Exemple #3
0
 def genTransDict(self):
     language = const.settings.get('language')
     language_file_path = self.getLanguageFile(language)
     if os.path.isfile(language_file_path):
         trans_block = []
         lines = osfile.readFileLines(language_file_path)
         for line in lines:
             line = line.strip()
             if line and line[0] != '#':
                 trans_block.append(line)
         info_block_list = utils.splitToBlocks(trans_block, sep='msgid')
         for info_block in info_block_list:
             key = ''
             value = ''
             is_key_line = False
             is_value_line = False
             for line in info_block:
                 if 'msgid' in line:
                     is_key_line = True
                 if 'msgstr' in line:
                     is_key_line = False
                     is_value_line = True
                 if is_key_line:
                     line = line.replace('msgid', '').strip()
                     line = line[1:-1]
                     key += line
                 if is_value_line:
                     line = line.replace('msgstr', '').strip()
                     line = line[1:-1]
                     value += line
             if key in self.trans_dict:
                 self.trans_dict[key] = value
Exemple #4
0
	def genTransDict(self):
		language = const.settings.get('language')
		language_file_path = self.getLanguageFile(language)
		if os.path.isfile(language_file_path):
			trans_block = []
			lines = osfile.readFileLines(language_file_path)
			for line in lines:
				line = line.strip()
				if line and line[0] != '#':
					trans_block.append(line)
			info_block_list = utils.splitToBlocks(trans_block, sep = 'msgid')
			for info_block in info_block_list:
				key = ''
				value = ''
				is_key_line = False
				is_value_line = False
				for line in info_block:
					if 'msgid' in line:
						is_key_line = True
					if 'msgstr' in line:
						is_key_line = False
						is_value_line = True
					if is_key_line:
						line = line.replace('msgid', '').strip()
						line = line[1:-1]
						key += line
					if is_value_line:
						line = line.replace('msgstr', '').strip()
						line = line[1:-1]
						value += line
				if key in self.trans_dict:
					self.trans_dict[key] = value
Exemple #5
0
def getPlatformFromFile(platform_file_path):
	lines = osfile.readFileLines(platform_file_path)
	for line in lines:
		if 'name=' in line:
			(key, value) = utils.getKeyValue(line)
			platform = value
			break
	return platform
Exemple #6
0
def getPlatformFromFile(platform_file_path):
	lines = osfile.readFileLines(platform_file_path)
	for line in lines:
		if 'name=' in line:
			(key, value) = utils.getKeyValue(line)
			platform = value
			break
	return platform
Exemple #7
0
def getProgrammerInfoBlock(programmer_file_path, programmer):
	lines = osfile.readFileLines(programmer_file_path)
	info_block_list = utils.splitToBlocks(lines, sep = '.name')
	for info_block in info_block_list:
		programmer_name_line = info_block[0]
		(key, programmer_name) = utils.getKeyValue(programmer_name_line)
		if programmer_name == programmer:
			programmer_info_block = info_block
			break
	return programmer_info_block
Exemple #8
0
def getBoardInfoBlock(board_file_path, board):
	board_info_block = []
	lines = osfile.readFileLines(board_file_path)
	info_block_list = utils.splitToBlocks(lines, sep = '.name', none_sep = 'menu.')
	for info_block in info_block_list:
		board_name_line = info_block[0]
		(key, board_name) = utils.getKeyValue(board_name_line)
		if board_name == board:
			board_info_block = info_block
			break
	return board_info_block
Exemple #9
0
def splitBoardsFile(boards_file_path):
	boards_file_header_block = []
	boards_file_body_block = []
	lines = osfile.readFileLines(boards_file_path)
	is_header = True
	for line in lines:
		if '.name' in line:
			is_header = False
		if is_header:
			boards_file_header_block.append(line)
		else:
			boards_file_body_block.append(line)
	return (boards_file_header_block, boards_file_body_block)
Exemple #10
0
def splitBoardsFile(boards_file_path):
	boards_file_header_block = []
	boards_file_body_block = []
	lines = osfile.readFileLines(boards_file_path)
	is_header = True
	for line in lines:
		if '.name' in line:
			is_header = False
		if is_header:
			boards_file_header_block.append(line)
		else:
			boards_file_body_block.append(line)
	return (boards_file_header_block, boards_file_body_block)
Exemple #11
0
def parsePlatformInfo(platform_file_path):
	platform_info_key_list = []
	platform_info_dict = {}
	lines = osfile.readFileLines(platform_file_path)
	for line in lines:
		line = line.strip()
		if line and (not '#' in line):
			(key, value) = utils.getKeyValue(line)
			if 'tools.' in key:
				key = regulariseToolsKey(key)
			platform_info_key_list.append(key)
			platform_info_dict[key] = value
	return (platform_info_key_list, platform_info_dict)
Exemple #12
0
def parseVersionInfo(arduino_root):
	version = 1000
	version_text = 'unknown'
	lib_path = os.path.join(arduino_root, 'lib')
	version_file_path = os.path.join(lib_path, 'version.txt')
	if os.path.isfile(version_file_path):
		lines = osfile.readFileLines(version_file_path)
		for line in lines:
			line = line.strip()
			if line:
				version_text = line
				break
	if version_text != 'unknown':
		version = convertTextToVersion(version_text)
	return (version, version_text)
Exemple #13
0
 def genAbvDict(self):
     self.abv_language_dict = {}
     self.abv_text_dict = {}
     template_root = const.template_root
     iso_file_path = os.path.join(template_root, 'ISO639_1')
     lines = osfile.readFileLines(iso_file_path)
     for line in lines:
         line = line.strip()
         if line:
             info_list = line.split('=')
             lang_abv = info_list[0].strip()
             lang = info_list[1].strip()
             lang_text = info_list[2].strip()
             self.abv_language_dict[lang_abv] = lang
             self.abv_text_dict[lang_abv] = '%s (%s)' % (lang_text, lang)
Exemple #14
0
def parseVersionInfo(arduino_root):
	version = 1000
	version_text = 'unknown'
	lib_path = os.path.join(arduino_root, 'lib')
	version_file_path = os.path.join(lib_path, 'version.txt')
	if os.path.isfile(version_file_path):
		lines = osfile.readFileLines(version_file_path)
		for line in lines:
			line = line.strip()
			if line:
				version_text = line
				break
	if version_text != 'unknown':
		version = convertTextToVersion(version_text)
	return (version, version_text)
Exemple #15
0
def getBoardInfoBlock150(board_file_path, board):
	board_info_block = []
	lines = osfile.readFileLines(board_file_path)
	info_block_list = utils.splitToBlocks(lines, sep = '.name')
	for info_block in info_block_list:
		for line in info_block:
			if '.name' in line:
				(key, board_name) = utils.getKeyValue(line)
			if '.container' in line:
				(key, board_name) = utils.getKeyValue(line)
				break
		if board_name == board:
			board_info_block = info_block
			break
	return board_info_block
Exemple #16
0
	def genAbvDict(self):
		self.abv_language_dict = {}
		self.abv_text_dict = {}
		template_root = const.template_root
		iso_file_path = os.path.join(template_root, 'ISO639_1')
		lines = osfile.readFileLines(iso_file_path)
		for line in lines:
			line = line.strip()
			if line:
				info_list = line.split('=')
				lang_abv = info_list[0].strip()
				lang = info_list[1].strip()
				lang_text = info_list[2].strip()
				self.abv_language_dict[lang_abv] = lang
				self.abv_text_dict[lang_abv] = '%s (%s)' % (lang_text, lang)
Exemple #17
0
def parseProgrammerInfo(platform, core_root):
	programmer_list = []
	programmer_file_dict = {}
	programmers_file_path = os.path.join(core_root, 'programmers.txt')
	if os.path.isfile(programmers_file_path):
		lines = osfile.readFileLines(programmers_file_path)
		programmer_info_block_list = utils.splitToBlocks(lines, sep = '.name')
		for programmer_info_block in programmer_info_block_list:
			programmer_name_line = programmer_info_block[0]
			(key, programmer) = utils.getKeyValue(programmer_name_line)
			if not programmer in programmer_list:
				programmer_list.append(programmer)

				programmer_key = utils.genKey(programmer, platform)
				programmer_file_dict[programmer_key] = programmers_file_path
	return (programmer_list, programmer_file_dict)
Exemple #18
0
def parseProgrammerInfo(platform, core_root):
	programmer_list = []
	programmer_file_dict = {}
	programmers_file_path = os.path.join(core_root, 'programmers.txt')
	if os.path.isfile(programmers_file_path):
		lines = osfile.readFileLines(programmers_file_path)
		programmer_info_block_list = utils.splitToBlocks(lines, sep = '.name')
		for programmer_info_block in programmer_info_block_list:
			programmer_name_line = programmer_info_block[0]
			(key, programmer) = utils.getKeyValue(programmer_name_line)
			if not programmer in programmer_list:
				programmer_list.append(programmer)

				programmer_key = utils.genKey(programmer, platform)
				programmer_file_dict[programmer_key] = programmers_file_path
	return (programmer_list, programmer_file_dict)
Exemple #19
0
def parseBoardFile150(platform, boards_file_path):
	board_list = []
	board_file_dict = {}
	board_type_list_dict = {}
	board_item_list_dict = {}

	board_type = 'menu.cpu'
	board_type_list = [board_type]
	type_key = utils.genKey(board_type, platform)
	type_caption_dict = {type_key:'Processor'}

	lines = osfile.readFileLines(boards_file_path)
	board_info_block_list = utils.splitToBlocks(lines, sep = '.name')
	for board_info_block in board_info_block_list:
		cpu = ''
		for line in board_info_block:
			if '.name' in line:
				(key, board) = utils.getKeyValue(line)
			if '.cpu' in line:
				(key, cpu) = utils.getKeyValue(line)
			if '.container' in line:
				(key, board) = utils.getKeyValue(line)
				break

		board_key = utils.genKey(board, platform)
		key = utils.genKey(board_type, board_key)

		if not board in board_list:
			board_list.append(board)

			board_file_dict[board_key] = boards_file_path
			if cpu:
				board_type_list_dict[board_key] = board_type_list
				board_item_list_dict[key] = [cpu]
		else:
			if cpu and (not cpu in board_item_list_dict[key]):
				board_item_list_dict[key].append(cpu)
	return (board_list, board_file_dict, board_type_list_dict, board_item_list_dict, type_caption_dict)
Exemple #20
0
def parseBoardFile150(platform, boards_file_path):
	board_list = []
	board_file_dict = {}
	board_type_list_dict = {}
	board_item_list_dict = {}

	board_type = 'menu.cpu'
	board_type_list = [board_type]
	type_key = utils.genKey(board_type, platform)
	type_caption_dict = {type_key:'Processor'}

	lines = osfile.readFileLines(boards_file_path)
	board_info_block_list = utils.splitToBlocks(lines, sep = '.name')
	for board_info_block in board_info_block_list:
		cpu = ''
		for line in board_info_block:
			if '.name' in line:
				(key, board) = utils.getKeyValue(line)
			if '.cpu' in line:
				(key, cpu) = utils.getKeyValue(line)
			if '.container' in line:
				(key, board) = utils.getKeyValue(line)
				break

		board_key = utils.genKey(board, platform)
		key = utils.genKey(board_type, board_key)

		if not board in board_list:
			board_list.append(board)

			board_file_dict[board_key] = boards_file_path
			if cpu:
				board_type_list_dict[board_key] = board_type_list
				board_item_list_dict[key] = [cpu]
		else:
			if cpu and (not cpu in board_item_list_dict[key]):
				board_item_list_dict[key].append(cpu)
	return (board_list, board_file_dict, board_type_list_dict, board_item_list_dict, type_caption_dict)