Пример #1
0
def action_del(options):
    with Session() as session:
        regexp_list = get_list_by_exact_name(options.list_name)
        if not regexp_list:
            console('Could not find regexp list with name {}'.format(options.list_name))
            return
        regexp = get_regexp(list_id=regexp_list.id, regexp=options.regexp, session=session)
        if regexp:
            console('Removing regexp {} from list {}'.format(options.regexp, options.list_name))
            session.delete(regexp)
        else:
            console('Could not find regexp {} in list {}'.format(options.movie_title, options.list_name))
            return
Пример #2
0
def action_add(options):
    with Session() as session:
        regexp_list = get_list_by_exact_name(options.list_name)
        if not regexp_list:
            console('Could not find regexp list with name {}, creating'.format(options.list_name))
            regexp_list = create_list(options.list_name, session=session)

        regexp = get_regexp(list_id=regexp_list.id, regexp=options.regexp, session=session)
        if not regexp:
            console("Adding regexp {} to list {}".format(options.regexp, regexp_list.name))
            add_to_list_by_name(regexp_list.name, options.regexp, session=session)
            console('Successfully added regexp {} to regexp list {} '.format(options.regexp, regexp_list.name))
        else:
            console("Regexp {} already exists in list {}".format(options.regexp, regexp_list.name))