Exemple #1
0
def vCommandWill(oCtx, uCmd, uStr):
    oCtx.userdata['oMain'].onecmd(uCmd)
    sOut, sErr = lCheckStdoutStdErr(oCtx)
    if sOut and bool(oCtx.config.verbose):
        tools.puts(oCtx, *sOut.split('\n'))
    vAddShareExamples('# ' + uStr)
    vAddShareExamples(uCmd)
def vCommandWill(oCtx, uCmd, uStr):
    oCtx.userdata['oMain'].onecmd(uCmd)
    sOut, sErr = lCheckStdoutStdErr(oCtx)
    if sOut and bool(oCtx.config.verbose):
        tools.puts(oCtx, *sOut.split('\n'))
    vAddShareExamples('# ' +uStr)
    vAddShareExamples(uCmd)
Exemple #3
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is there for the english grammar, but not used
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    # if the scenario specifies xmlid + other attributes in an "I
    # need" phrase then we want to look for the entry with the xmlid
    # only, and update the other attributes if we found something
    if 'xmlid' in values:
        domain = build_search_domain(ctx,
                                     model_name, {'xmlid': values['xmlid']},
                                     active=active)
    else:
        domain = build_search_domain(ctx, model_name, values, active=active)
    if domain is not None:
        ids = Model.search(domain)
    else:
        ids = []
    if not ids:  # nothing found
        ctx.found_item = values
        ctx.found_items = [values]
    else:
        if len(ids) == 1:
            ctx.found_item = Model.browse(ids[0])
        else:
            ctx.found_item = None
        ctx.found_items = Model.browse(ids)
        if 'xmlid' in values and len(values) > 1:
            new_attrs = values.copy()
            del new_attrs['xmlid']
            puts('writing %s to %s' % (new_attrs, ids))
            Model.write(ids, new_attrs)
Exemple #4
0
def impl(ctx, word1, word2, word3, model_name, domain):
    # n is there for the english grammar, but not used
    active_text = ' '.join(w for w in (word1, word2, word3) if w and w != 'n')
    assert active_text in ('', 'inactive', 'active', 'possibly inactive')
    Model = model(model_name)
    ctx.search_model_name = model_name
    values = parse_domain(domain)
    active = True
    if active_text == 'inactive':
        active = False
    elif active_text == 'possibly inactive':
        active = None
    # if the scenario specifies xmlid + other attributes in an "I
    # need" phrase then we want to look for the entry with the xmlid
    # only, and update the other attributes if we found something
    if 'xmlid' in values:
        domain = build_search_domain(ctx, model_name,
                                     {'xmlid': values['xmlid']},
                                     active=active)
    else:
        domain = build_search_domain(ctx, model_name, values, active=active)
    if domain is not None:
        ids = Model.search(domain)
    else:
        ids = []
    if not ids: # nothing found
        ctx.found_item = values
        ctx.found_items = [values]
    else:
        if len(ids) == 1:
            ctx.found_item = Model.browse(ids[0])
        else:
            ctx.found_item = None
        ctx.found_items = Model.browse(ids)
        if 'xmlid' in values and len(values) > 1:
            new_attrs = values.copy()
            del new_attrs['xmlid']
            puts('writing %s to %s' % (new_attrs, ids))
            Model.write(ids, new_attrs)