def execute_rm_command(db, objs, tags, options, credentials, unixPaths=None):
    if len(tags) == 0:
        raise RemoveError('Remove what?')
    failures = []
    for tag in tags:
        nsDone = tagDone = False
        fulltag = db.abs_tag_path(tag, inPref=True)
        if db.ns_exists(fulltag):
            if options.recurse:
                nsResult = db.rm_r(fulltag[1:])
            else:
                nsResult = db.delete_namespace(fulltag)
            if nsResult:
                raise RemoveError(fishlib.human_status(nsResult, 
                                        db.abs_tag_path(tag, True, True),
                                        {412: '(probably not empty)'}))
            nsDone = True

        if db.tag_exists(fulltag):
            if options.force or options.recurse:
                db.untag_by_query(u'has %s' % fulltag[1:],
                                  [fulltag[1:]])
            else:
                ids = db.query(u'has %s' % fulltag[1:])
                if type(ids) in (int, long):
                    raise RemoveError(fishlib.human_status(ids))
                elif len(ids) > 0:
                    raise RemoveError(u'%s tagged with %s:\n%s'
                                      % (flags.Plural(len(ids),
                                                 'object').decode('UTF-8'),
                                         db.abs_tag_path(tag, True, True),
                                          u'  Use -f to force removal'))
            tagResult = db.delete_abstract_tag(fulltag)
            if tagResult:
                raise RemoveError(fishlib.human_status(tagResult,
                                         db.abs_tag_path(tag, True, True)))
            tagDone = True

        if not nsDone and not tagDone:
            failures.append(tag)

    if failures:
        if not options.force:
            raise RemoveError(u'No tag or namespace found for: %s'
                              % u' '.join(failures))
dataset/ETHPy150Open njr0/fish/fish/ls.py/execute_rm_command/original