Пример #1
0
def gener_fortran_file(file):
    with open(file, 'r') as f:
        for line in f:
            line = line.strip()
            if line:
                strnums = line.split()
                for strnum in strnums:
                    yield Mio.coerce_string(strnum)
Пример #2
0
def gener_fortran_file(file):
    with open(file,'r') as f:
        for line in f:
            line = line.strip()
            if line:
                strnums = line.split()
                for strnum in strnums:
                    yield Mio.coerce_string(strnum)                
Пример #3
0
def read_input(filename,filetag=filetagtry,endtag='end',subdir=''):
    datadict = {}
    with open(subdir+filename,'r') as f:
        for key, value, isfile in yield_file_items(f,filetag):
            if not value:
                genernew = Mio.yield_until(f,endtag)
                if isfile: # read list of structures
                    value = [read_input(file,filetag,endtag,subdir) for file in genernew]
                else: # read array
                    value = Mio.my_read_array(genernew)
            else:
                if isfile:
                    try: # read file with array
                        value = Mio.my_read_array(subdir+value)
                    except ValueError: # read structure file
                        value = read_input(value,filetag,endtag,subdir)
                else:
                    value = Mio.coerce_string(value)
            datadict[key] = value
    return datadict
Пример #4
0
def read_input(filename, filetag=filetagtry, endtag='end', subdir=''):
    datadict = {}
    with open(subdir + filename, 'r') as f:
        for key, value, isfile in yield_file_items(f, filetag):
            if not value:
                genernew = Mio.yield_until(f, endtag)
                if isfile:  # read list of structures
                    value = [
                        read_input(file, filetag, endtag, subdir)
                        for file in genernew
                    ]
                else:  # read array
                    value = Mio.my_read_array(genernew)
            else:
                if isfile:
                    try:  # read file with array
                        value = Mio.my_read_array(subdir + value)
                    except ValueError:  # read structure file
                        value = read_input(value, filetag, endtag, subdir)
                else:
                    value = Mio.coerce_string(value)
            datadict[key] = value
    return datadict