示例#1
0
文件: check_acf.py 项目: gtg556h/junk
def check_acf(acf_filename, opts):
	app_state = acf.parse_acf(acf_filename)['AppState']

	if 'appID' in app_state:
		app_id = app_state['appID']
	else:
		app_id = app_state['appid']
        try:
            name = app_state['UserConfig']['name']
        except:
            name = app_state['name']
	ui._print('%s (%s):' % (name, app_id))

	library_root = find_library_root(acf_filename)

	game_path = find_game_path(app_state, library_root, acf_filename, opts)
	if game_path is None: return

	mounted_depots = get_mounted_depots(app_state)
	try:
		managed_depots = app_state['ManagedDepots'].split(',')
	except KeyError:
		#ui._cprint('back_yellow black', 'WARNING: No ManagedDepots, using MountedDepots instead!')
		managed_depots = UnknownLen(mounted_depots.keys())

	ok = depot_summary_ok(mounted_depots)
	colour = colours[ok]
	if opts.verbose or not ok:
		ui._print(g_indent, end='')
		ui._cprint(colour, str_depot_summary(mounted_depots, managed_depots))
	if not ok:
		if opts.uninstall:
			ui._print(g_indent, end='')
			path = os.path.join(os.path.curdir, acf_filename)
			os.rename(path, path + '~')
			ui._cprint('back_yellow black', 'UNINSTALLED!')
		return

	ok = check_depots_exist(mounted_depots, managed_depots, opts.steam_root, g_indent*2, opts)
	if not ok: return

	(ok, filenames) = check_all_depot_files_exist(mounted_depots, opts.steam_root, game_path, g_indent*2, opts)
	if opts.extra or opts.delete or opts.move:
		if opts.verbose: # So they don't appear to be under a manifest heading
			ui._print(g_indent*2 + 'Untracked files:')
		find_extra_files(game_path, filenames, g_indent*3, opts)
	if not ok: return

	ui._cprint('green', 'OK')
示例#2
0
def check_acf(acf_filename, opts):
    app_state = acf.parse_acf(acf_filename)['AppState']

    if 'appID' in app_state:
        app_id = app_state['appID']
    else:
        app_id = app_state['appid']
    name = app_state['UserConfig']['name']
    ui._print('%s (%s):' % (name, app_id))

    library_root = find_library_root(acf_filename)

    game_path = find_game_path(app_state, library_root, acf_filename, opts)
    if game_path is None: return

    mounted_depots = get_mounted_depots(app_state)
    try:
        managed_depots = app_state['ManagedDepots'].split(',')
    except KeyError:
        #ui._cprint('back_yellow black', 'WARNING: No ManagedDepots, using MountedDepots instead!')
        managed_depots = UnknownLen(mounted_depots.keys())

    ok = depot_summary_ok(mounted_depots)
    colour = colours[ok]
    if opts.verbose or not ok:
        ui._print(g_indent, end='')
        ui._cprint(colour, str_depot_summary(mounted_depots, managed_depots))
    if not ok:
        if opts.uninstall:
            ui._print(g_indent, end='')
            path = os.path.join(os.path.curdir, acf_filename)
            os.rename(path, path + '~')
            ui._cprint('back_yellow black', 'UNINSTALLED!')
        return

    ok = check_depots_exist(mounted_depots, managed_depots, opts.steam_root,
                            g_indent * 2, opts)
    if not ok: return

    (ok, filenames) = check_all_depot_files_exist(mounted_depots,
                                                  opts.steam_root, game_path,
                                                  g_indent * 2, opts)
    if opts.extra or opts.delete or opts.move:
        if opts.verbose:  # So they don't appear to be under a manifest heading
            ui._print(g_indent * 2 + 'Untracked files:')
        find_extra_files(game_path, filenames, g_indent * 3, opts)
    if not ok: return

    ui._cprint('green', 'OK')
示例#3
0
    def __init__(self, acf_file, library, add_to_apps):
        self.acf_file = acf_file
        self.library = library
        self.status = acf.parse_acf(acf_file)

        # Sanity check if the acf file appears to be valid before we add it to any lists:
        self.appid
        self.name

        if self.appid in app_names and app_names[self.appid] != self.name:
            print('{} in multiple libraries with different names: "{}", "{}"'.format(self.appid, app_names[self.appid], self.name))
        app_names[self.appid] = self.name

        if add_to_apps:
            if self.appid not in apps:
                apps[self.appid] = []
            apps[self.appid].append(self)
示例#4
0
    def __init__(self, acf_file, library, add_to_apps):
        self.acf_file = acf_file
        self.library = library
        self.status = acf.parse_acf(acf_file)

        # Sanity check if the acf file appears to be valid before we add it to any lists:
        self.appid
        self.name

        if self.appid in app_names and app_names[self.appid] != self.name:
            print('{} in multiple libraries with different names: "{}", "{}"'.
                  format(self.appid, app_names[self.appid], self.name))
        app_names[self.appid] = self.name

        if add_to_apps:
            if self.appid not in apps:
                apps[self.appid] = []
            apps[self.appid].append(self)