コード例 #1
0
def main(args):
    """Entry point. args should be a list of length 1 or 2 where item 0 is the
    bmml path and item 1 is the output dir

    """
    out = {}

    try:
        out['bmml_path'] = args[0]
    except IndexError:
        print(usage)
        print()
        print("You must specify the bmml path")
        sys.exit(1)

    out['name'] = utils.prompt_user("What is the name of this project (which"
            " will become the name of the resulting Django app)?",
            checks=[utils.checks.identifier],
            )

    # write out project.json
    outdir = os.getcwd()
    outfile = open(os.path.join(outdir, "project.json"), "w")
    json.dump(out, outfile)
    outfile.write("\n")
    outfile.close()

    print("Output written to project.json")
    print("Done!")
コード例 #2
0
def edit_bmml(bmml):
    print()
    print("Regarding \"%s\"" % bmml.path)
    print(utils.split_lines("What should its name be? This is the name"
            " used to reference back-links,"
            " so it should be an identifier"))
    name = utils.prompt_user("Enter name", checks=[utils.checks.identifier]) 

    print()
    print(utils.split_lines("Now, under what URL path should serve this"
            " page? This goes straight to Django's urls file so this"
            " should be a regex"))
    regex = utils.prompt_user("Enter URL regex", checks=[utils.checks.not_empty])

    bmml.data['name'] = name
    bmml.data['regex'] = regex
    print(utils.split_lines("So file %s is going to serve on \"%s\" and have reference name %s" % (bmml.path, regex, name)))
    print("Got it, moving on...")
コード例 #3
0
def list_jobs_for_function(fun):
    options = []
    jobId = '0'
    time = 15
    filter = {
        "SubmitTimeAfter":
        datetime.datetime.now() - datetime.timedelta(minutes=time)
    }
    if fun == 0:
        response = config.comprehend.list_dominant_language_detection_jobs(
            Filter=filter)
        props = response["DominantLanguageDetectionJobPropertiesList"]

    elif fun == 1:
        response = config.comprehend.list_entities_detection_jobs(
            Filter=filter)
        props = response["EntitiesDetectionJobPropertiesList"]

    elif fun == 2:
        response = config.comprehend.list_key_phrases_detection_jobs(
            Filter=filter)
        props = response["KeyPhrasesDetectionJobPropertiesList"]

    elif fun == 3:
        response = config.comprehend.list_pii_entities_detection_jobs(
            Filter=filter)
        props = response["PiiEntitiesDetectionJobPropertiesList"]

    elif fun == 4:
        response = config.comprehend.list_sentiment_detection_jobs(
            Filter=filter)
        props = response["SentimentDetectionJobPropertiesList"]

    elif fun == 5:
        response = config.comprehend.list_topics_detection_jobs(Filter=filter)
        props = response["TopicsDetectionJobPropertiesList"]

    for jobs in props:
        object_text = "Job started: " + str(
            jobs["SubmitTime"]) + " Status: " + str(jobs["JobStatus"])
        options.append({"text": object_text, "function": ''})

    options.append({"text": "None", "function": ''})
    if len(props) == 0:
        print("No jobs to check")
        return -1
    else:
        user_input = prompt_user("Which job do you want to check?", options)
        if 1 <= user_input < len(options):
            jobId = props[user_input - 1]["JobId"]
        elif user_input == len(options):
            return -1
        else:
            print("Please enter a valid selection")
            list_jobs_for_function(fun)
    return jobId