当前位置: 首页>>代码示例>>Python>>正文


Python Template.add_subtasks方法代码示例

本文整理汇总了Python中template.Template.add_subtasks方法的典型用法代码示例。如果您正苦于以下问题:Python Template.add_subtasks方法的具体用法?Python Template.add_subtasks怎么用?Python Template.add_subtasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在template.Template的用法示例。


在下文中一共展示了Template.add_subtasks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import add_subtasks [as 别名]
def main():
    parser = OptionParser(usage="%prog <template> [options]")

    # Defaulted
    parser.add_option("-c", "--config", dest="config", help="full path to YAML config file", default=Config.DEFAULT_CONFIG_FILE)

    # Defaulted
    parser.add_option("-a", "--all", dest="auto_all", action="store_true", help="automatically create all of the subtasks in the template")

    # One of these is required
    parser.add_option("-s", "--story", dest="story" , help="Story text to use for the parent story")
    parser.add_option("-i", "--issue", dest="issue", help="JIRA Issue to create all the subtasks under")

    # Most likely in config.yaml, but overridable
    parser.add_option("-e", "--assignee", dest="assignee", help="username of JIRA user to assign tasks and subtasks to")
    parser.add_option("-p", "--project_id", dest="project_id", help="name of template to work from")
    parser.add_option("-j", "--jira", dest="jira", help="JIRA api URL")
    parser.add_option("-u", "--username", dest="username", help="username to log into JIRA with")

    # Most likely defaulted, but possibly from config.yaml
    parser.add_option("-d", "--template_dir", dest="template_dir", help="name of template to work from")

    (options, args) = parser.parse_args()

    if len(args) != 1:
        die('template name not given')

    if not os.path.isfile(options.config):
        die("Config file '%s' does not exist or is not a file" % options.config)

    if not os.access(options.config, os.R_OK):
        die("Config file '%s' is not readable" % options.config)

    if options.story is None and options.issue is None:
        die("You must specify either a JIRA story (-s, --story) to create or a JIRA issue (-i, --issue) to modify")

    template=args[0]

    with open(options.config, 'r') as config_yaml:
        config_dict = yaml.load(config_yaml)


    password = Password()
    config = Config(password.password, template, options, config_dict)

    options = {
        'server': config.jira,
        'rest_api_version' : "latest",
    }

    jira = JIRA(options, basic_auth=(config.username, config.password))
    template = Template(jira, config.assignee, config.template_dir, config.template, config.auto_all, config_dict["issue_config"])

    if config.is_story():
        print "Creating story with description: '%s'" % config.story
        parent = jira.create_issue(config.story)
    else:
        print "Adding sub-tasks to issue: '%s'" % config.issue
        parent = jira.issue(config.issue)

    print parent
    print parent.fields.project.key

    subtasks = template.add_subtasks(parent)
    for subtask in subtasks:
        print subtask
    password.cache_password()
开发者ID:dannwebster,项目名称:jira-templator,代码行数:69,代码来源:main.py


注:本文中的template.Template.add_subtasks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。