コード例 #1
0
ファイル: SetupFile.py プロジェクト: Springhead/Springhead
    def __read_file(self):
        # initialize
        self.path_list = {}
        self.prog_list = {}
        self.data_list = {}

        # read file
        kvf = KvFile(self.path)
        if kvf.read() <= 0:
            print('%s: can\'t open file "%s"' % (self.clsname, self.path))
            return -1
        self.kvf = kvf

        # prog list
        keys = kvf.change_section(self.PROG)
        keys = kvf.keys()
        for key in keys:
            self.prog_list[key] = kvf.get(key)

        # path list
        keys = kvf.change_section(self.PATH)
        keys = kvf.keys()
        for key in keys:
            self.path_list[key] = kvf.get(key)

        # data list
        keys = kvf.change_section(self.DATA)
        keys = kvf.keys()
        for key in keys:
            self.data_list[key] = kvf.get(key)

        if self.verbose > 1:
            for key in self.prog_list.keys():
                print('prog: %s = %s' % (key, self.prog_list[key]))
            for key in self.path_list.keys():
                print('path: %s = %s' % (key, self.path_list[key]))
            for key in self.data_list.keys():
                print('data: %s = %s' % (key, self.data_list[key]))

        self.file_read = True
        return 0
コード例 #2
0
ファイル: NameManager.py プロジェクト: grg909/Springhead
kvf = KvFile(inifile, sep='=')
count = kvf.read(dic={'TOPDIR': topdir})
if count < 0:
	error.print(kvf.error())
keys = sorted(kvf.keys())

if verbose:
	def fixed(name, width):
		name += ':'
		if len(name) < width-1:
			name += ' ' * (width-len(name))
		return name

	print('names defined (%d):' % count)
	for key in keys:
		value = util.pathconv(kvf.get(key), 'unix')
		if os.path.isfile(value):	kind = 'file'
		elif os.path.isdir(value):	kind = 'dir'
		else:				kind = 'name'
		print('  %s%s (%s)' % (fixed(key, 24), value, kind))

# ----------------------------------------------------------------------
#  Make Windows batch file to export names.
#	This is unnecessary if names can be exported directly!!
#
if test_only:
	sys.exit(0)

headers	 = [ '@echo off', 'rem FILE: %s' % outfile, '' ]
trailers = [ '', 'rem end: %s' % outfile ]
コード例 #3
0
    print('  inifile:\t%s' % (options.inifile))

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['UnityTestScript', 'Python', 'Springhead2', 'SceneList']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    sys.exit(-1)
if kvf.check(mandatory_keys) != 0:
    sys.exit(-1)

# set defaults
defaults = {}
spr2root = kvf.get('Springhead2')
defaults['UnityProject'] = spr2root + '/src/Unity'
defaults['TestRoot'] = spr2root + '/src/UnityTest'
defaults['IniFile'] = defaults['TestRoot'] + '/UnityTest.ini'
defaults['ScenesDir'] = 'Assets/Scenes'
defaults['TestMainLogFile'] = defaults['TestRoot'] + '/log/TestMain.log'
for key in defaults.keys():
    if kvf.get(key) is None:
        kvf.set(key, defaults[key])
if options.verbose:
    print('  ------------------------------------------------')
    for key in sorted(mandatory_keys):
        print('  %s:\t%s' % (key, kvf.get(key)))
    print('  ------------------------------------------------')
    for key in sorted(defaults.keys()):
        print('  %s:\t%s' % (key, kvf.get(key)))
コード例 #4
0
    print('  scene:\t%s' % (scene))

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Unity', 'Python', 'Springhead2', 'DllPath']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    sys.exit(-1)
if kvf.check(mandatory_keys) != 0:
    sys.exit(-1)

# set defaults
defaults = {}
spr2root = kvf.get('Springhead2')
defaults['UnityProject'] = spr2root + '/src/Unity'
defaults['ScenesDir'] = 'Assets/Scenes'
defaults['TestRoot'] = spr2root + '/scr/UnityTest'
defaults['OutFile'] = defaults['TestRoot'] + '/bin/player.exe'
defaults['LogFile'] = defaults['TestRoot'] + '/log/build.log'
for key in defaults.keys():
    if kvf.get(key) is None:
        kvf.set(key, defaults[key])
if options.verbose:
    print('  ------------------------------------------------')
    for key in sorted(mandatory_keys):
        print('  %s:\t%s' % (key, kvf.get(key)))
    print('  ------------------------------------------------')
    for key in sorted(defaults.keys()):
        print('  %s:\t%s' % (key, kvf.get(key)))
コード例 #5
0
keys = sorted(kvf.keys())

if verbose:
    ##  Make fixed length string.
    #   @param name		Any string.
    #   @param width	Field width (int).
    #   @returns		Fixed width string.
    def fixed(name, width):
        name += ':'
        if len(name) < width - 1:
            name += ' ' * (width - len(name))
        return name

    print('names defined (%d):' % count)
    for key in keys:
        value = Util().pathconv(kvf.get(key), 'unix')
        if os.path.isfile(value): kind = 'file'
        elif os.path.isdir(value): kind = 'dir'
        else: kind = 'name'
        print('  %s%s (%s)' % (fixed(key, 24), value, kind))

# ----------------------------------------------------------------------
#  Make Windows batch file to export names.
#	This is unnecessary if names can be exported directly!!
#
if test_only:
    sys.exit(0)

##  Header strings of output file.
headers = ['@echo off', 'rem FILE: %s' % outfile, '']
##  Trailer strings of output file.
コード例 #6
0
f_op = FileOp(verbose=options.verbose)

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Unity', 'Springhead', 'UnityProject', 'DllPath']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    error.print(kvf.error())
if kvf.check(mandatory_keys) != 0:
    error.print(kvf.error())

# set defaults
defaults = {}
spr_root = kvf.get('Springhead')
defaults['ScenesDir'] = 'Assets/Springhead/Samples'
defaults['TestRoot'] = spr_root + '/core/test/UnityTest'
defaults['OutFile'] = defaults['TestRoot'] + '/bin/player.exe'
defaults['LogFile'] = defaults['TestRoot'] + '/log/build.log'
for key in defaults.keys():
    if kvf.get(key) is None:
        kvf.set(key, defaults[key])
if options.verbose:
    print('  ------------------------------------------------')
    for key in sorted(mandatory_keys):
        print('  %s:\t%s' % (key, kvf.get(key)))
    print('  ------------------------------------------------')
    for key in sorted(defaults.keys()):
        print('  %s:\t%s' % (key, kvf.get(key)))
コード例 #7
0
f_op = FileOp(verbose=options.verbose)

# ----------------------------------------------------------------------
#  Read init file
#
mandatory_keys = ['Springhead', 'UnityProject', 'SceneList']

kvf = KvFile(options.inifile)
if (kvf.read() < 0):
    sys.exit(-1)
if kvf.check(mandatory_keys) != 0:
    sys.exit(-1)

# set defaults
defaults = {}
spr_root = kvf.get('Springhead')
defaults['TestRoot'] = spr_root + '/core/test/UnityTest'
defaults['IniFile'] = defaults['TestRoot'] + '/UnityTest.ini'
defaults['ScenesDir'] = 'Assets/Springhead/Samples'
defaults['TestMainLogFile'] = defaults['TestRoot'] + '/log/TestMain.log'
for key in defaults.keys():
    if kvf.get(key) is None:
        kvf.set(key, defaults[key])
if options.verbose:
    print('  ------------------------------------------------')
    for key in sorted(mandatory_keys):
        print('  %s:\t%s' % (key, kvf.get(key)))
    print('  ------------------------------------------------')
    for key in sorted(defaults.keys()):
        print('  %s:\t%s' % (key, kvf.get(key)))