<commit_before># -*-coding:Utf-8 -*-

"""Contains functions that interpret commmands from the CLI and
call request functions
"""

# Compatibility 2.7-3.4
from __future__ import absolute_import
from __future__ import unicode_literals
from builtins import input

from . import requests_functions as req

from . import user as user
from . import target as target
from . import usergroup as usergroup
from . import targetgroup as targetgroup


def list(obj):
    """List all object of this type"""
    return req.list(obj)


def search(obj):
    """Search an object of this type which match the pattern"""
    pattern = input("Pattern: ")
    return req.search(obj, {"<pattern>": pattern})


def show(obj):
    """Ask arguments for showing the object"""
    name = input("Name: ")
    return req.show(obj, {"<name>": name})


def delete(obj):
    """Ask arguments for deleting an existing object"""
    name = input("Name: ")
    return req.delete(obj, {"<name>": name})<commit_msg>Solve partially the issue #59, the "-f" option has still to be implemented<commit_after># -*-coding:Utf-8 -*-

"""Contains functions that interpret commmands from the CLI and
call request functions
"""

# Compatibility 2.7-3.4
from __future__ import absolute_import
from __future__ import unicode_literals
from builtins import input

from . import requests_functions as req

from . import user as user
from . import target as target
from . import usergroup as usergroup
from . import targetgroup as targetgroup


def ask_confirmation(prompt_confirmation):
    """Same as input() but check if user key in a correct input"""
    confirmation = input(prompt_confirmation)

    # Loop until user types [Y/n]
    while confirmation.upper() != "Y" and confirmation.upper() != "N":
        print("You didn't type 'Y' or 'N', please try again.")
        print(confirmation)
        print(confirmation.upper())
        confirmation = input(prompt_confirmation)

    return confirmation

def list(obj):
    """List all object of this type"""
    return req.list(obj)


def search(obj):
    """Search an object of this type which match the pattern"""
    pattern = input("Pattern: ")
    return req.search(obj, {"<pattern>": pattern})


def show(obj):
    """Ask arguments for showing the object"""
    name = input("Name: ")
    return req.show(obj, {"<name>": name})


def delete(obj):
    """Ask arguments for deleting an existing object"""
    name = input("Name: ")
    confirmation = ask_confirmation("Are you sure you want to delete " + \
        name + "? [Y/n] ")

    if confirmation.upper() == "Y":
        return req.delete(obj, {"<name>": name})
    else:
        print("Operation aborted.")

        return None
{'fraction_non_alphanumeric': 0.11924219910846955, 'fraction_numerical': 0.004457652303120356, 'mean_word_length': 3.6034188034188035, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6709288', 'n_tokens_mistral': 781, 'n_tokens_neox': 750, 'n_words': 291}