示例#1
0
def getMacros(spec, repoprefix):

	err = ""
	macros = {}
	obj = SpecParser(spec)
	if not obj.parse():
		err = obj.getError()
		return err, {}, -1

	if repoprefix == "":
		macros["project"] = obj.getMacro("project")
		macros["repo"] = obj.getMacro("repo")
		macros["provider"] = obj.getMacro("provider")
		macros["commit"] = obj.getMacro("commit")
		macros["ip"] = obj.getMacro("provider_prefix")
		if macros["ip"] == "":
			macros["ip"] = obj.getMacro("import_path")

	else:
		macros["project"] = obj.getMacro("%s_project" % repoprefix)
		macros["repo"] = obj.getMacro("%s_repo" % repoprefix)
		macros["provider"] = obj.getMacro("%s_provider" % repoprefix)
		macros["commit"] = obj.getMacro("%s_commit" % repoprefix)
		macros["ip"] = obj.getMacro("%s_provider_prefix" % repoprefix)
		if macros["ip"] == "":
			macros["ip"] = obj.getMacro("%s_import_path" % repoprefix)

	last_bug_id = obj.getBugIdFromLastChangelog()

	if macros["project"] == "":
		err = "Unable to detect project macro"
		return err, {}, -1

	if macros["repo"] == "":
		err = "Unable to detect repo macro"
		return err, {}, -1

	if macros["provider"] == "":
		err = "unable to detect provider macro"
		return err, {}, -1

	if macros["commit"] == "":
		err = "unable to detect commit macro"
		return err, {}, -1

	if macros["ip"] == "":
		err = "Unable to detect provider URL"
		return err, {}, -1

	return "", macros, last_bug_id
示例#2
0
def getMacros(spec):

    err = ""
    macros = {}
    obj = SpecParser(spec)
    if not obj.parse():
        err = obj.getError()
        return err, {}, -1

    macros["project"] = obj.getMacro("project")
    macros["repo"] = obj.getMacro("repo")
    macros["provider"] = obj.getMacro("provider")
    macros["commit"] = obj.getMacro("commit")
    last_bug_id = obj.getBugIdFromLastChangelog()

    if macros["project"] == "":
        err = "Unable to detect project macro"
        return err, {}, -1

    if macros["repo"] == "":
        err = "Unable to detect repo macro"
        return err, {}, -1

    if macros["provider"] == "":
        err = "unable to detect provider macro"
        return err, {}, -1

    if macros["commit"] == "":
        err = "unable to detect commit macro"
        return err, {}, -1

    macros["ip"] = obj.getMacro("import_path")
    if macros["ip"] == "":
        macros["provider_tld"] = obj.getMacro("provider_tld")

        if macros["provider_tld"] == "":
            err = "Unable to detect provider_tld macro"
            return err, {}, -1

        macros["ip"] = "%s.%s/%s/%s" % (macros["provider"],
                                        macros["provider_tld"],
                                        macros["project"], macros["repo"])

    return "", macros, last_bug_id