Files
h2inc-old/h2inc.py
2018-02-09 21:34:01 +01:00

53 lines
1.6 KiB
Python

# You are free to use and/or change this code for
# your own needs.
# Original code (c)2018 Jan Lerking
# Program to convert C-header (*.h) files to nasm include files (*.inc),
# for direct usage in assembly programming using nasm/yasm.
import os
import sys
from h2inc_parser import parseline, parseparsed
import h2inc_gui
tupline = []
preproc = ()
outfile = ''
folders = []
cnt = 0
def sourcedir_filecnt(sourcedir):
### Return the number of files, ending with '.h', in sourcedir - including subdirectories ###
cnt = 0
for folderName, subfolders, files in os.walk(sourcedir):
for file in files:
if file.lower().endswith('.h'):
cnt = cnt+1
return cnt
def sourcedir_foldercnt(sourcedir):
### Return the number of folders, if it contains '*.h' files, in sourcedir - including subdirectories ###
global cnt
global folders
for folderName, subfolders, files in os.walk(sourcedir):
if subfolders:
for subfolder in subfolders:
sourcedir_foldercnt(subfolder)
tempf = [file for file in files if file.lower().endswith('.h')]
if tempf:
cnt = cnt+1
print(folderName)
folders += [folderName]
print(folders)
return cnt
def process_files(sourcedir, destdir):
WorkPath = os.path.dirname(sourcedir)
print(WorkPath)
incpath = destdir
print(incpath)
if not os.path.exists(incpath):
os.makedirs(incpath)
pattern = '.h'
inputfile = 'gtkaboutdialog.h'
filehandle = open(WorkPath+'/'+inputfile, 'r')