def ui_menu():
    cmd = ui_read_command()
    cmd = validate_cmd(cmd)
    if (cmd[0] == "add"):
        ui_add(storage, cmd)
        ui_menu()
    if (cmd[0] == "insert"):
        ui_insert(storage, cmd)
        ui_menu()
    if (cmd[0] == "remove"):
        if (len(cmd) == 4):
            remove_to(storage, int(cmd[1]), int(cmd[3]))
        elif (cmd[1] == "in" or cmd[1] == "out"):
            remove_type(storage, cmd[1])
        else:
            remove(storage, int(cmd[1]))
        ui_menu()
    if (cmd[0] == "replace"):
        replace(storage, cmd)
        ui_menu()
    if (cmd[0] == "default"):
        create_df_storage(storage)
        ui_menu()
    if (cmd[0] == "list"):
        if (len(cmd) == 1):
            ui_list(storage)
        elif (len(cmd) == 2):
            ui_list_type(storage, cmd[1])
        elif (cmd[1] == "balance"):
            ui_list_balance(storage, int(cmd[2]))
        else:
            ui_list_value(storage, cmd[1], int(cmd[2]))
        ui_menu()
    if (cmd[0] == "exit"):
        exit()
Exemplo n.º 2
0
def remove(duplicate):

    Pokemon_List = remove(Pokemon)

    assert callable(remove)
    assert isinstance(remove(Pokemon), list)
    assert '' in remove(Pokemon)
Exemplo n.º 3
0
def ui_menu():
    cmd = ui_read_command()
    cmd = validate_cmd(cmd)
    if(cmd[0] == "add"):
        ui_add(storage, cmd)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "insert"):
        ui_insert(storage, cmd)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "remove"):
        if(len(cmd) == 4):
                remove_to(storage, int(cmd[1]), int(cmd[3]))
        elif(cmd[1] == "in" or cmd[1] == "out"):
             remove_type(storage, cmd[1])
        else:
            remove(storage, int(cmd[1]))
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "replace"):
        replace(storage, cmd)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "default"):
        create_df_storage(storage)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "list"):
        if(len(cmd)==1):
            ui_list(storage)
        elif(len(cmd) == 2):
            ui_list_type(storage, cmd[1])
        elif(cmd[1] == "balance"):
            ui_list_balance(storage, int(cmd[2]))
        else:
            ui_list_value(storage, cmd[1], int(cmd[2]))
        ui_menu()
    if(cmd[0] == "exit"):
        exit()
    if(cmd[0] == "sum"):
        sum_type(storage, cmd[1])
        ui_menu()
    if(cmd[0] == "max"):
        max_tr(storage, cmd[1], int(cmd[2]))
        ui_menu()
    if(cmd[0] == "filter"):
        l = len(cmd)
        if(l == 2):
            filter_type(storage, cmd[1])
            ui_list(storage)
        if(l == 3):
            filter(storage, cmd[1], int(cmd[2]))
            ui_list(storage)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "undo"):
        storage.clear()
        storage.update(undo(stack,storage))
        ui_menu()
Exemplo n.º 4
0
def dependencies(source,action):
    text.text_formatting(_(">> Resolving dependencies.."), 0, 'info')
    root = functions.get_root(cons.sprpckg_dir+source+".xml")
    #Bağımlılıklar çözülüyor
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        text.text_formatting(str(dependcount) + _(" dependencies have found."), 1, 'info')
        #Tamamen kaldırma işlemi için ....
        if action == "remove":
            text.text_formatting(_("Following suprapackage(s) will remove. "), 1, 'info')
            for dep in root[2]:
                try:
                    text.text_formatting(dep.text + " ==> " + get_description(dep.text), 1, 'info')
                except:
                    text.text_formatting(dep.text + _(" ==> There is no description for this suprapackage"), 1, 'warning')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(_("Are you want to remove these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    functions.remove(package,"skip",source)
            else:
                text.text_formatting(_("Dependencies coulnd't removed so remove process couldn't continue."), 0, 'error')
                sys.exit(1)
        else:
            text.text_formatting(_("Following suprapackage(s) will install. "), 0, 'info')
            for dep in root[2]:
                if not search.srch_pynr(dep.text,'Peynir/Name','absolute') and not suprapackage_check(str(dep.text)):
                    text.text_formatting(dep.text + _(" couldn't found in repository, you can install it manually"), 1, 'warning')
                    os.remove(cons.sprpckg_dir + source + ".xml")
                    sys.exit(1)
                else:
                    try:
                        text.text_formatting(dep.text + " ==> " + get_description(dep.text), 1, 'info')
                    except:
                        text.text_formatting(dep.text + _(" ==> There is no description for this suprapackage"), 1, 'info')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(_("Are you want to install these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    if not functions.suprapackage_check(package):
                        functions.install(package,"","") #İç içe bağımlılık sorunu olacak o neden ilave bir fonksiyon paramatresi ise bu soruyu bir kez sordurulabilir
                    else:
                        text.text_formatting(">> " + package + _(" is already installed"), 0, 'info')
                    mdfy.modify_add(cons.sprpckg_dir+package+".xml","<Dependencies","'>"," " + source,"previous") 
            else:
                os.remove(cons.sprpckg_dir+source+".xml")
                text.text_formatting(_("Dependencies coulnd't installed so install process couldn't continue."), 0, 'error')
                sys.exit(1)
    else:
        text.text_formatting(_("There is a no dependencies"), 1, 'info')
Exemplo n.º 5
0
    def helper_remove_podcast(self):
        
        podcast = self.podcastList.selectedItems()
        podcastname = [n.text() for n in podcast]

        for podcast in self.podcastList.selectedItems():
            self.podcastList.takeItem(
                self.podcastList.row(podcast)
                )
        functions.remove(podcast)
Exemplo n.º 6
0
def run_check():
    print("in run_check")
    path = './public'
    path_backup = './backup'

    content_main = compute_dir_index(path)
    content_backup = compute_dir_index(path_backup)
    subdirs = content_main["subdirs"]
    result = compute_diff(content_main, content_backup)

    created_file = result["created"]
    updated_file = result["updated"]
    deleted_file = result["deleted"]
    deleted_dir = result["deleted_dirs"]

    utils.copy_to_backup(created_file, updated_file, subdirs)
    utils.remove(deleted_file, deleted_dir)
Exemplo n.º 7
0
def command_line(dictionary):
    while True:
        command = input('Enter your command: ')
        if command == 'exit':
            return 'exit'
        elif command == 'move':
            functions.move()
        elif command == 'help':
            for command, description in list(commands_list.items()):
                print(command + ' = ' + description)
        elif command == 'add':
            functions.add()
            return functions.update()

        elif command == 'remove':
            functions.remove()
        elif command == 'print':
            continue
        elif command == 'show':
            functions.show()
        elif command == 'train':
            return functions.train(dictionary)
Exemplo n.º 8
0
def main():
    method = None
    option = None
    directory = None
    out = None
    key = None

    method, option, directory, out, key = init_options()

    if option == '-i':
        init(method, directory, out, key)
    elif option == '-t':
        track(method, directory, out, key)
    elif option == '-x':
        if remove(directory):
            print("Programa guarda removido da pasta " + str(directory))
def test_remove_type():
    storage = {22: [], 23: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    remove(storage, 23)
    remove(storage, 22)
    assert len(storage[23]) == 0
    assert len(storage[22]) == 0
Exemplo n.º 10
0
def ui_menu1():
    print("\nTo exit the application input 9\n"
          "To add a new transaction in the current day input 0\n"
          "To insert a new transaction in a certain day input  1\n"
          "To remove transactions input 2\n"
          "To replace a transaction input 3\n"
          "To list the transactions input 4\n"
          "To sum the transaction considering their type input 5\n"
          "To get the maximum value of a transaction considering its type input 6\n"
          "To undo an operation input 7\n"
          "To get a default account input 8\n")
    menu = int(input())
    cmd = ui_read_comm(menu)
    cmd = validate_cmd(cmd)
    if(cmd[0] == "add"):
        ui_add(storage, cmd)
        add_stack(stack, storage)
        ui_menu1()
    if(cmd[0] == "insert"):
        ui_insert(storage, cmd)
        add_stack(stack, storage)
        ui_menu1()
    if(cmd[0] == "remove"):
        if(len(cmd) == 4):
                remove_to(storage, int(cmd[1]), int(cmd[3]))
        elif(cmd[1] == "in" or cmd[1] == "out"):
             remove_type(storage, cmd[1])
        else:
            remove(storage, int(cmd[1]))
        add_stack(stack, storage)
        ui_menu1()
    if(cmd[0] == "replace"):
        replace(storage, cmd)
        add_stack(stack, storage)
        ui_menu()
    if(cmd[0] == "default"):
        create_df_storage(storage)
        add_stack(stack, storage)
        ui_menu1()
    if(cmd[0] == "list"):
        if(len(cmd)==1):
            ui_list(storage)
        elif(len(cmd) == 2):
            ui_list_type(storage, cmd[1])
        elif(cmd[1] == "balance"):
            ui_list_balance(storage, int(cmd[2]))
        else:
            ui_list_value(storage, cmd[1], int(cmd[2]))
        ui_menu1()
    if(cmd[0] == "exit"):
        exit()
    if(cmd[0] == "sum"):
        sum_type(storage, cmd[1])
        ui_menu1()
    if(cmd[0] == "max"):
        max_tr(storage, cmd[1], int(cmd[2]))
        ui_menu()
    if(cmd[0] == "filter"):
        l = len(cmd)
        if(l == 2):
            filter_type(storage, cmd[1])
            ui_list(storage)
        if(l == 3):
            filter(storage, cmd[1], int(cmd[2]))
            ui_list(storage)
        add_stack(stack, storage)
        ui_menu1()
    if(cmd[0] == "undo"):
        storage.clear()
        storage.update(undo(stack,storage))
        ui_menu1()
Exemplo n.º 11
0
from functions import create, remove, menu, show
menu()
n = int(input("Uildliin dugaar oruulna uu: "))
if n == 1:
    show()
elif n == 2:
    create()
elif n == 3:
    remove()
elif n == 4:
    print("homework")
else:
    print("Ta programmaas garlaa")
Exemplo n.º 12
0
                functions.hours_by_subject(historical_records)
                try:
                    #! Hours studied by subject over the past week.
                    functions.past_seven_days(historical_records)
                except IndexError:
                    pass
                #! Average hours studied per day by subject.
                functions.hours_studied_per_day(historical_records)
            else:
                print('Please try again...')
                cont = input('Press "Enter" to continue: ')

        elif '6' == first_input[0]:
            functions.clear_terminal()
            functions.backup(historical_records)
        elif '7' == first_input[0]:
            functions.remove(historical_records)

        elif '8' == first_input[0]:
            help.help()
        else:
            print('Please Try again...')
            cont = input('Press "Enter" to continue: ')
    except KeyboardInterrupt:
        print('\n\n*****************************************************')
        print('You have stopped the program with "^C"')
        print('\n*****************************************************')
        time.sleep(2)
        functions.clear_terminal()
        break
Exemplo n.º 13
0
def main():
    if not os.geteuid() == 0:
        sys.exit(
            _("You must be root to run this application, please use sudo and try again."
              ))
    functions.db_file_check()
    parser = argparse.ArgumentParser(
        description=
        '''Suprapackage Manager for Archlinux. It's also a framework for configuring Archlinux or other pacman based distribution.''',
        prog='peynir')
    parser.add_argument(
        "-d",
        "--debug",
        help="Log everyhing (including info, warning and errors)",
        action="store_true")
    parser.add_argument("-S",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Install suprapackage")
    parser.add_argument("-U",
                        metavar='Suprapackage',
                        help="Install local suprapackage")
    parser.add_argument("-R",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Remove suprapackage")
    parser.add_argument("-Rs",
                        nargs='*',
                        metavar='Suprapackage',
                        help="Remove suprapackage and its dependencies")
    parser.add_argument("-Sy", help="Update repository", action="store_true")
    parser.add_argument("-Syy",
                        help="Update peynir and pacman repository",
                        action="store_true")
    parser.add_argument("-Su", help="Upgrade the system", action="store_true")
    parser.add_argument("-Syu", help="Upgrade the system", action="store_true")
    parser.add_argument("-Ss", help="Search suprapackege in repository")
    parser.add_argument("-Qs", help="Search suprapackege in local")
    parser.add_argument(
        "-O", help="Repair system or package (not fully implemented)")
    parser.add_argument("--noconfirm",
                        help="Do not prompt for any confirmation",
                        action="store_true")
    parser.add_argument(
        "--cachedir",
        help=
        "[path] Overrides the default location of the suprapackage cache directory."
    )
    parser.add_argument("--silence", help="No output", action="store_true")

    args = parser.parse_args()

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    if args.noconfirm:
        cons.confm = True
    if args.debug:
        cons.debug = True
    if args.silence:
        cons.silence = True
    if args.cachedir:
        cons.cachedir = args.cachedir.strip()
        if not cons.cachedir[len(cons.cachedir) - 1:len(cons.cachedir)] == "/":
            cons.cachedir = cons.cachedir + "/"
            print(cons.cachedir)

    if args.Sy:
        functions.sync_repo(0)
    if args.Syy:
        functions.sync_repo(1)
    if args.Su:
        functions.upgrade()
    if args.Syu:
        functions.sync_repo(1)
        functions.upgrade()
    if args.S:
        functions.db_file_check(
        )  #Burada ve diğer gereksiz kullanımları temizle
        for i in args.S:
            rqst = i.lower()
            if search.srch_pynr(rqst, 'Peynir/Name', 'absolute'):
                functions.install(rqst, "", "")
            else:
                text.text_formatting(
                    'error: ' + rqst + ' no such a suprapackage', 0, "warning")

    if args.R:
        functions.db_file_check()
        for i in args.R:
            rqst = i.lower()
            functions.remove(rqst, "", "")
    if args.Rs:
        functions.db_file_check()
        for i in args.Rs:
            rqst = i.lower()
            functions.remove(rqst, "complete", "")
    if args.Ss:
        functions.db_file_check()
        for i in args.Ss.split():
            rqst = i.lower()
            text.text_formatting("Results for " + rqst, 0, 'info')
            search.srch_pynr(rqst, 'Peynir/Name', 'find')
    if args.Qs:
        functions.db_file_check()
        for i in args.Qs.split():
            rqst = i.lower()
            text.text_formatting("Results for " + rqst, 0, 'info')
            search.local_search(rqst)
    if args.U:
        functions.db_file_check()
        if "/" in args.U:
            position = args.U.rfind('/')
            adress = args.U[:position]
            package = args.U[position + 1:]
        else:
            adress = ""
        if package[-3:] != "xml" and "." in package:
            text.text_formatting(_("Invalid package format"), 0, "error")
            sys.exit(1)
        elif not "." in package:
            package = package + ".xml"

        if not functions.suprapackage_check(package[:-4]):
            functions.install(package, "local", adress)
        else:
            text.text_formatting(
                _(">> This suprapackage already installed in your system."), 0,
                'error')
Exemplo n.º 14
0
from functions import create, organize, remove

if __name__ == '__main__':
    print('Welcome to DeClutter')
    src_path = input('Enter Source Path: ')
    dest_path = os.path.join(src_path,'DeClutter')
    
    print('Destination: ',dest_path)
    print('Enter your desired choice')
    print('1. Run DeClutter')
    print('2. Remove DeClutter')
    choice = int(input('Choice: '))

    if choice == 1:
        print('Running...')
        try:
            assert create(dest_path)
        except:
            pass
        finally:
            organize(src_path,dest_path)
            print('Successful!')
        
    elif choice == 2:
        print("Removing Files...")
        organize(src_path,dest_path)
        remove(src_path,dest_path)
        print('Files removed successfully')
    
    else:
        print('Stopped')
Exemplo n.º 15
0
def dependencies(source, action):
    text.text_formatting(_(">> Resolving dependencies.."), 0, 'info')
    root = functions.get_root(cons.sprpckg_dir + source + ".xml")
    #Bağımlılıklar çözülüyor
    dependcount = len(root[2])
    dependencies = root[2]
    if dependcount > 0:
        text.text_formatting(
            str(dependcount) + _(" dependencies have found."), 1, 'info')
        #Tamamen kaldırma işlemi için ....
        if action == "remove":
            text.text_formatting(_("Following suprapackage(s) will remove. "),
                                 1, 'info')
            for dep in root[2]:
                try:
                    text.text_formatting(
                        dep.text + " ==> " + get_description(dep.text), 1,
                        'info')
                except:
                    text.text_formatting(
                        dep.text +
                        _(" ==> There is no description for this suprapackage"
                          ), 1, 'warning')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(
                    _("Are you want to remove these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    functions.remove(package, "skip", source)
            else:
                text.text_formatting(
                    _("Dependencies coulnd't removed so remove process couldn't continue."
                      ), 0, 'error')
                sys.exit(1)
        else:
            text.text_formatting(_("Following suprapackage(s) will install. "),
                                 0, 'info')
            for dep in root[2]:
                if not search.srch_pynr(dep.text, 'Peynir/Name',
                                        'absolute') and not suprapackage_check(
                                            str(dep.text)):
                    text.text_formatting(
                        dep.text +
                        _(" couldn't found in repository, you can install it manually"
                          ), 1, 'warning')
                    os.remove(cons.sprpckg_dir + source + ".xml")
                    sys.exit(1)
                else:
                    try:
                        text.text_formatting(
                            dep.text + " ==> " + get_description(dep.text), 1,
                            'info')
                    except:
                        text.text_formatting(
                            dep.text +
                            _(" ==> There is no description for this suprapackage"
                              ), 1, 'info')
            if cons.confm:
                answer = _("Y")
            else:
                answer = input(
                    _("Are you want to install these suprapackages (Y/N): "))
                answer = answer.upper()
            if answer == _("Y"):
                for dep in root[2]:
                    package = dep.text
                    if not functions.suprapackage_check(package):
                        functions.install(
                            package, "", ""
                        )  #İç içe bağımlılık sorunu olacak o neden ilave bir fonksiyon paramatresi ise bu soruyu bir kez sordurulabilir
                    else:
                        text.text_formatting(
                            ">> " + package + _(" is already installed"), 0,
                            'info')
                    mdfy.modify_add(cons.sprpckg_dir + package + ".xml",
                                    "<Dependencies", "'>", " " + source,
                                    "previous")
            else:
                os.remove(cons.sprpckg_dir + source + ".xml")
                text.text_formatting(
                    _("Dependencies coulnd't installed so install process couldn't continue."
                      ), 0, 'error')
                sys.exit(1)
    else:
        text.text_formatting(_("There is a no dependencies"), 1, 'info')
Exemplo n.º 16
0
import change_in_dirs
import functions

a = change_in_dirs.compute_dir_index()

functions.generate(2)
functions.remove(2)

b = change_in_dirs.compute_dir_index()

data = change_in_dirs.compute_diff(b,a)
print(data)
created_files = data["created"]
print(created_files)

functions.compile_and_move(data)
Exemplo n.º 17
0
def main():
    if not os.geteuid()==0:
        sys.exit(_("You must be root to run this application, please use sudo and try again."))
    functions.db_file_check()
    parser = argparse.ArgumentParser(description='''Suprapackage Manager for Archlinux. It's also a framework for configuring Archlinux or other pacman based distribution.''', prog='peynir')
    parser.add_argument("-d", "--debug", help="Log everyhing (including info, warning and errors)", action="store_true")
    parser.add_argument("-S", nargs='*', metavar='Suprapackage', help="Install suprapackage")
    parser.add_argument("-U", metavar='Suprapackage', help="Install local suprapackage")
    parser.add_argument("-R", nargs='*', metavar='Suprapackage', help="Remove suprapackage")
    parser.add_argument("-Rs", nargs='*', metavar='Suprapackage', help="Remove suprapackage and its dependencies")
    parser.add_argument("-Sy", help="Update repository", action="store_true")
    parser.add_argument("-Syy", help="Update peynir and pacman repository", action="store_true")   
    parser.add_argument("-Su", help="Upgrade the system", action="store_true")
    parser.add_argument("-Syu", help="Upgrade the system", action="store_true")  
    parser.add_argument("-Ss", help="Search suprapackege in repository")  
    parser.add_argument("-Qs", help="Search suprapackege in local")
    parser.add_argument("-O", help="Repair system or package (not fully implemented)")
    parser.add_argument("--noconfirm", help="Do not prompt for any confirmation", action="store_true")
    parser.add_argument("--cachedir", help="[path] Overrides the default location of the suprapackage cache directory.")
    parser.add_argument("--silence", help="No output", action="store_true")

    args = parser.parse_args()
    
    if len(sys.argv)==1:
        parser.print_help()
        sys.exit(1)
    if args.noconfirm:
        cons.confm = True
    if args.debug:
        cons.debug = True
    if args.silence:
        cons.silence = True
    if args.cachedir:
        cons.cachedir = args.cachedir.strip()
        if not cons.cachedir[len(cons.cachedir)-1:len(cons.cachedir)] == "/":
            cons.cachedir = cons.cachedir+"/"
            print(cons.cachedir)
    
    if args.Sy:
        functions.sync_repo(0)
    if args.Syy:
        functions.sync_repo(1)
    if args.Su:
        functions.upgrade()
    if args.Syu:
        functions.sync_repo(1)
        functions.upgrade()
    if args.S:
        functions.db_file_check() #Burada ve diğer gereksiz kullanımları temizle
        for i in args.S:
            rqst = i.lower()
            if search.srch_pynr(rqst,'Peynir/Name','absolute'):
                functions.install(rqst,"","")
            else:
                text.text_formatting('error: '+ rqst +' no such a suprapackage',0, "warning")
    
    if args.R:
       functions.db_file_check() 
       for i in args.R:
           rqst = i.lower()
           functions.remove(rqst,"","")
    if args.Rs:
       functions.db_file_check() 
       for i in args.Rs:
           rqst = i.lower()
           functions.remove(rqst,"complete","")
    if args.Ss:
       functions.db_file_check() 
       for i in args.Ss.split():
           rqst = i.lower()
           text.text_formatting("Results for " + rqst, 0, 'info')
           search.srch_pynr(rqst,'Peynir/Name','find')
    if args.Qs:
       functions.db_file_check() 
       for i in args.Qs.split():
           rqst = i.lower()
           text.text_formatting("Results for " + rqst, 0, 'info' )
           search.local_search(rqst)
    if args.U:
       functions.db_file_check() 
       if "/" in args.U:
           position = args.U.rfind('/')
           adress = args.U[:position]
           package = args.U[position+1:]
       else:
           adress = ""
       if package[-3:] != "xml" and "." in package:
           text.text_formatting(_("Invalid package format"), 0, "error")
           sys.exit(1)
       elif not "." in package: 
           package = package+".xml"
             
       if not functions.suprapackage_check(package[:-4]):
           functions.install(package,"local",adress)
       else:
           text.text_formatting(_(">> This suprapackage already installed in your system."), 0, 'error')