Exemplo n.º 1
0
def add_queststyles(repos_sn, json_arg):
    """  """

    now = datetime.utcnow();

    text = json_arg['text'];
    label_texts = re.split('\s*[;,,;/.。、\s]+\s*', text)

    labels = get_update_labels(repos_sn, label_texts, label_type="S")

    new_set = set(labels.values())

    orig_queststyles = drecall(ts_repos_queststyles(repos_sn=repos_sn))
    if orig_queststyles:
        old_set = set(orig_queststyles.labels)
        if old_set == new_set:
            return

        new_set = new_set.union(old_set)

    queststyles = ts_repos_queststyles(repos_sn=repos_sn)
    queststyles.labels = sorted(int(x) for x in new_set)
    queststyles.updated_ts = now

    dmerge(queststyles, orig_queststyles)

    return
Exemplo n.º 2
0
def delete_repos_queststyles(repos_sn: int, label_sn:int):
    """  """

    now = datetime.utcnow();

    orig_queststyles = drecall(ts_repos_queststyles(repos_sn=repos_sn))

    queststyles = ts_repos_queststyles(orig_queststyles)
    queststyles.labels = [] + queststyles.labels
    try:
        pos = queststyles.labels.index(label_sn)
    except:
        return

    del queststyles.labels[pos]

    queststyles.updated_ts = now

    dmerge(queststyles, orig_queststyles)

    return