Example #1
0
def getDefsList( dirForFound, cbFindCond, cbGetFileList, typeInFile, ofile ):
	# Создаем список найденных файлов
	fileList = cbGetFileList( dirForFound, typeInFile )
	
	# читаем файл и выбираем из него директивы
	f = io.open( ofile+'.h', 'w', encoding='utf-8')
	f.write(u'#-*- coding: utf-8 -*-\n')
	definedList = list('') # сюда складываем все
	for at in fileList:
		# содержимое
		string = IOOperations.getFileContent( at )
		
		# удаляем закомменченное
		strPure = PreProc.delCom( string )
		
		# Дробим на строки
		
		stringSplit = strPure.split('\n')
		for item in stringSplit:
			if cbFindCond( item ):
				f.write(item+'\n')
				newItem = item.split()[1]
				definedList.append( newItem )
	f.close()
	
	# сохраняем результаты поиска
	f = io.open( ofile+'.py', 'w', encoding='utf-8')
	f.write(u'#-*- coding: utf-8 -*-\n')
	f.write( ofile.split('/')[-1]+'List'+u' = [\n' )
	for at in definedList:
		f.write(u'\''+at+u'\','+u'\n')
	f.write(u']\n')
	f.close()
Example #2
0
# И обрабатываем его
fileList = list()
for p in files :
	if p.find('.inc') != -1:
		fileList.append( dirForFound[0]+p )

import PreProc 
PreProc.getMacroFile( fileList )
import mFu

# Обрабатываем файл с кодом
ifile = '../src/_v1_IRQ.asm'
# читаем
string = IOOperations.getFileContent( ifile )
commFree = PreProc.delCom( string )
 
commFreeList = commFree.split('\n')

# замена в файлах
i = 0
f = io.open('mFu.asm', 'w', encoding='utf-8')
f.write(u'#-*- coding: utf-8 -*-\n')
for item in commFreeList:
	itemSplit = item.split()
	if len( itemSplit ) > 0:
		args = list('')
		if itemSplit[0] in mFu.macDictFu:	# поиск имени макроса
			# получаем аргументы
			args = PreProc.getArgs( item, i )
			print args