示例#1
0
文件: gmosh.py 项目: mTxServ/gmosh
def main(args):
    # working directory
    curdir = args.dir and args.dir[0] or os.getcwd()

    # directory to output things to
    out = args.out and args.out or len(args.files) > 0 and args.files or [
        curdir
    ]
    file_list = list(
        filter(os.path.isfile, chain.from_iterable(map(glob, out))))
    # include folders that do not exist yet:
    folder_list = list(filter(lambda x: not os.path.isfile(x), out))
    # the addon.json file
    addonFile = args.addon and args.addon[0] or 'addon.json'

    if args.download:
        workshoputils.download(folder_list, args.extract)
        return
    elif args.workshopinfo:
        print(
            json.dumps(workshoputils.workshopinfo(folder_list),
                       sort_keys=True,
                       indent=4))
        return
    elif args.extract:
        # Extract a GMA file
        extract(file_list, folder_list or ['out'])
        return
    elif args.dump:
        # Dump the contents of GMA files
        dump_gma(file_list)
        return
    elif args.list:
        # List the files contained in a GMA file(s)
        list_files(file_list)
        return
    elif args.new:
        # Wizard for creating an addon.json file
        new_addon(curdir, addonFile)
        return

    # Try to get the addon information
    try:
        addon = addoninfo.addon_info_from_path(curdir, addonFile)
    except addoninfo.AddonNotFoundError as err:
        print(err)
        return

    if args.verify:
        # Verify the addon files
        verify_files(curdir, addon)
    elif args.create_gma:
        # Create a GMA file from an existing addon
        creategma(addon, out)
    else:
        # Publish the addon
        message = args.message and args.message[
            0] or addon.getdefault_changelog()
        publish(addon, args.logo and args.logo[0], message)
示例#2
0
文件: gmoshui.py 项目: FPtje/gmosh
def wsIdInfo(widget):
    workshopid = widget.wsID.value()
    info = workshoputils.workshopinfo([workshopid])
    if not info:
        errorMsg("Unable to retrieve addon info. Make sure the workshop ID is correct.")
        return

    return info
示例#3
0
def wsIdInfo(widget):
    workshopid = widget.wsID.value()
    info = workshoputils.workshopinfo([workshopid])
    if not info:
        errorMsg("Unable to retrieve addon info. Make sure the workshop ID is correct.")
        return

    return info
示例#4
0
文件: gmosh.py 项目: mTxServ/gmosh
def main(args):
	# working directory
	curdir = args.dir and args.dir[0] or os.getcwd()

	# directory to output things to
	out = args.out and args.out or len(args.files) > 0 and args.files or [curdir]
	file_list = list(filter(os.path.isfile, chain.from_iterable(map(glob, out))))
	# include folders that do not exist yet:
	folder_list = list(filter(lambda x: not os.path.isfile(x), out))
	# the addon.json file
	addonFile = args.addon and args.addon[0] or 'addon.json'

	if args.download:
		workshoputils.download(folder_list, args.extract)
		return
	elif args.workshopinfo:
		print(json.dumps(workshoputils.workshopinfo(folder_list), sort_keys=True, indent = 4))
		return
	elif args.extract:
		# Extract a GMA file
		extract(file_list, folder_list or ['out'])
		return
	elif args.dump:
		# Dump the contents of GMA files
		dump_gma(file_list)
		return
	elif args.list:
		# List the files contained in a GMA file(s)
		list_files(file_list)
		return
	elif args.new:
		# Wizard for creating an addon.json file
		new_addon(curdir, addonFile)
		return

	# Try to get the addon information
	try:
		addon = addoninfo.addon_info_from_path(curdir, addonFile)
	except addoninfo.AddonNotFoundError as err:
		print(err)
		return

	if args.verify:
		# Verify the addon files
		verify_files(curdir, addon)
	elif args.create_gma:
		# Create a GMA file from an existing addon
		creategma(addon, out)
	else:
		# Publish the addon
		message = args.message and args.message[0] or addon.getdefault_changelog()
		publish(addon, args.logo and args.logo[0], message)