'Delete the User category named category_name. Any leading \'@\' is removed'

def do_delete_user_category(self, category_name):

    if category_name.startswith(u'@'):
        category_name = category_name[1:]
    db = self.library_view.model().db
    user_cats = db.prefs.get(u'user_categories', {})
    cat_keys = sorted(user_cats.keys(), key=sort_key)
    has_children = False
    found = False
    for k in cat_keys:
        if (k == category_name):
            found = True
            has_children = len(user_cats[k])
        elif k.startswith((category_name + u'.')):
            has_children = True
    if (not found):
        return error_dialog(self.tags_view, _(u'Delete    User    category'), (_(u'%s    is    not    a    User    category') % category_name), show=True)
    if has_children:
        if (not question_dialog(self.tags_view, _(u'Delete    User    category'), (_(u'%s    contains    items.    Do    you    really    want    to    delete    it?') % category_name))):
            return
    for k in cat_keys:
        if (k == category_name):
            del user_cats[k]
        elif k.startswith((category_name + u'.')):
            del user_cats[k]
    db.new_api.set_pref(u'user_categories', user_cats)
    self.tags_view.recount()
    self.user_categories_edited()
