コード例 #1
0
ファイル: language.py プロジェクト: beticocc/Stino
 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
コード例 #2
0
ファイル: language.py プロジェクト: ErgNoor/Stino
	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
コード例 #3
0
ファイル: compilation.py プロジェクト: beticocc/Stino
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
コード例 #4
0
ファイル: compilation.py プロジェクト: beticocc/Stino
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
コード例 #5
0
ファイル: arduino.py プロジェクト: Tyilo/Stino
def parseBoardFile(platform, boards_file_path):
	board_list = []
	board_file_dict = {}
	board_type_list_dict = {}
	board_item_list_dict = {}
	type_caption_dict = {}

	(boards_file_header_block, boards_file_body_block) = splitBoardsFile(boards_file_path)
	(board_type_list, board_type_caption_dict) = parseBoardHeader(boards_file_header_block)

	for board_type in board_type_caption_dict:
		type_key = utils.genKey(board_type, platform)
		type_caption_dict[type_key] = board_type_caption_dict[board_type]

	board_info_block_list = utils.splitToBlocks(boards_file_body_block, sep = '.name', none_sep = 'menu.')
	for board_info_block in board_info_block_list:
		board_name_line = board_info_block[0]
		(key, board) = utils.getKeyValue(board_name_line)
		if not board in board_list:
			board_list.append(board)

			board_key = utils.genKey(board, platform)
			board_file_dict[board_key] = boards_file_path
			board_type_list_dict[board_key] = []

			for board_type in board_type_list:
				item_list = []
				board_type_info_block = utils.getTypeInfoBlock(board_info_block, board_type)
				item_blocks = utils.splitToBlocks(board_type_info_block, sep = '.name', key_length = 4)
				for item_block in item_blocks:
					item_name_line = item_block[0]
					(key, item) = utils.getKeyValue(item_name_line)
					if not item in item_list:
						item_list.append(item)
				if item_list:
					board_type_list_dict[board_key].append(board_type)
					key = utils.genKey(board_type, board_key)
					board_item_list_dict[key] = item_list
	return (board_list, board_file_dict, board_type_list_dict, board_item_list_dict, type_caption_dict)
コード例 #6
0
ファイル: arduino.py プロジェクト: beticocc/Stino
def parseBoardFile(platform, boards_file_path):
	board_list = []
	board_file_dict = {}
	board_type_list_dict = {}
	board_item_list_dict = {}
	type_caption_dict = {}

	(boards_file_header_block, boards_file_body_block) = splitBoardsFile(boards_file_path)
	(board_type_list, board_type_caption_dict) = parseBoardHeader(boards_file_header_block)

	for board_type in board_type_caption_dict:
		type_key = utils.genKey(board_type, platform)
		type_caption_dict[type_key] = board_type_caption_dict[board_type]

	board_info_block_list = utils.splitToBlocks(boards_file_body_block, sep = '.name', none_sep = 'menu.')
	for board_info_block in board_info_block_list:
		board_name_line = board_info_block[0]
		(key, board) = utils.getKeyValue(board_name_line)
		if not board in board_list:
			board_list.append(board)

			board_key = utils.genKey(board, platform)
			board_file_dict[board_key] = boards_file_path
			board_type_list_dict[board_key] = []

			for board_type in board_type_list:
				item_list = []
				board_type_info_block = utils.getTypeInfoBlock(board_info_block, board_type)
				item_blocks = utils.splitToBlocks(board_type_info_block, sep = '.name', key_length = 4)
				for item_block in item_blocks:
					item_name_line = item_block[0]
					(key, item) = utils.getKeyValue(item_name_line)
					if not item in item_list:
						item_list.append(item)
				if item_list:
					board_type_list_dict[board_key].append(board_type)
					key = utils.genKey(board_type, board_key)
					board_item_list_dict[key] = item_list
	return (board_list, board_file_dict, board_type_list_dict, board_item_list_dict, type_caption_dict)
コード例 #7
0
ファイル: compilation.py プロジェクト: beticocc/Stino
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
コード例 #8
0
ファイル: arduino.py プロジェクト: Tyilo/Stino
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)
コード例 #9
0
ファイル: arduino.py プロジェクト: beticocc/Stino
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)
コード例 #10
0
ファイル: compilation.py プロジェクト: beticocc/Stino
def genOptionInfoBlockList(info_block):
	block_list = utils.splitToBlocks(info_block, sep = '.name', key_length = 4)
	name_key_list = []
	for block in block_list:
		name_line = block[0]
		(key, value) = utils.getKeyValue(name_line)
		key = key.replace('.name', '.')
		name_key_list.append(key)

	option_info_block_list = []
	for name_key in name_key_list:
		option_info_block = []
		for line in info_block:
			if name_key in line:
				option_info_block.append(line)
		option_info_block_list.append(option_info_block)
	return option_info_block_list
コード例 #11
0
ファイル: arduino.py プロジェクト: Tyilo/Stino
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)
コード例 #12
0
ファイル: arduino.py プロジェクト: beticocc/Stino
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)