예제 #1
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()
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()
 def export_graph_to_pajek(self, file=False, graph=False):
     if not file:
         file_pajek = 'graphs/graph_' + self.type + '.net'
     else:
         file_pajek = file
     if not graph:
         graph = self.graph
     print("export_graph_to_pajek - " + str(file_pajek))
     # pos = nx.spring_layout(self.graphs)
     # nx.draw_networkx_nodes(self.graphs, pos, node_size=100, node_color='red')
     # nx.draw_networkx_edges(self.graphs, pos)
     # nx.draw_networkx_labels(self.graphs, pos, font_size='8', font_color='blue')
     # plt.show()
     nx.write_pajek(graph, file_pajek)
     # functions.replace(file_pajek, '0.0 0.0 ellipse', '')
     functions.replace(file_pajek, '0.0 0.0 ellipse',
                       '" 0.0 0.0 box ic Red fos 25')
     functions.replace_if_type_node(file_pajek, ' SEG_', ' "SEG_', 'Red',
                                    'Red')
     functions.replace_if_type_node(file_pajek, ' IO_', ' "IO_', 'Red',
                                    'Grey')
     functions.replace_if_type_node(file_pajek, ' ARTW_', ' "ARTW_', 'Red',
                                    'Blue')
     functions.replace_if_type_node(file_pajek, ' CH_', ' "CH_', 'Red',
                                    'Orange')
     functions.replace_if_type_node(file_pajek, ' REF_', ' "REF_', 'Red',
                                    'Purple')
     functions.replace_if_type_node(file_pajek, ' EV_', ' "EV_', 'Red',
                                    'Yellow')
     functions.replace_if_type_node(file_pajek, ' E_', ' "E_', 'Red',
                                    'Grey')
예제 #4
0
def init():
    tab = [
        "-h", "--help", "-dir", "-er", "--encrypt", "-e", "decrypt", "-d",
        "--replace", "-r"
    ]
    if sys.argv[1] == "-h" or sys.argv[1] == "--help":
        functions.display_help()
        exit(0)
    if len(sys.argv) < 2:
        print("\033[1;31;40mBlad! Brak argumentow!")
        exit(1)
    if sys.argv[1] == "-dir":
        functions.find()
        exit(0)
    if (sys.argv[1] == "-c"):
        if len(sys.argv[1]) < 2:
            print("\033[1;31;40mZbyt mala ilosc argumentow!")
            exit(1)
        else:
            if (len(sys.argv) > 3):
                print("\033[1;31;40mBledne argumenty!")
                exit(1)
            else:
                functions.find_in_current_directory(sys.argv[2])
                exit(0)

    if sys.argv[1] == "--encrypt" or sys.argv[1] == "-e" or sys.argv[
            1] == "-er":
        functions.encrypt(sys.argv[1], sys.argv[2])
        exit(0)
    if sys.argv[1] == "--decrypt" or sys.argv[1] == "-d":
        functions.decrypt(sys.argv[2])
        exit(0)
    if sys.argv[1] == "--replace" or sys.argv[1] == "-r":
        functions.replace(sys.argv[2], sys.argv[3], sys.argv[4])
        exit(0)
    if sys.argv[1] == "-s":
        functions.file_statistics(sys.argv[2])
        exit(0)
    if sys.argv[1] not in tab:
        print("\033[1;31;40mBledne argumenty!")
        exit(1)
예제 #5
0
 def wrap(img):
     band = img.select(name).multiply(valor)
     return replace(name, band)(img)
def test_replace():
    storage = {22: [], 23: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    replace(storage, ["replace", "23", "in", "salary", "with", "1050"])
    assert get_value(storage, 23, 1) == 1050
예제 #7
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()
예제 #8
0
        print('Conversion succeed.')

        try:
            file = docx.Document(filename)
        except:
            print('Converting "' + filename + '" into "' + filename +
                  'x" file...')
            filename = doc2docx(filename)
            print('Conversion succeed.')
            file = docx.Document(filename)

        try:
            answer = docx.Document(answer_name)
        except:
            print('Converting "' + answer_name + '" into "' + answer_name +
                  'x" file...')
            answer_name = doc2docx(answer_name)
            print('Conversion succeed.')
            answer = docx.Document(answer_name)

        ws, wb, y, m, l = f.add_sheet(file.paragraphs[0].text, output_name)
        mark = f.check_type(filename)
        answer_list = f.read_answer(answer, ws)
        f.read(file, answer_list[-5:], ws, wb, y, m, l, mark, output_name)
        f.replace(ws, ['_', '_'], '<under2></under2>')
        wb.save(output_name)
        print('The database is successfully output to "' + output_name + '".')
        input('Press any key to exit')
    except Exception as e:
        print(traceback.format_exc())
예제 #9
0
 def test_replace(self):
     self.assertEqual(replace(''), 0)
     self.assertEqual(replace('abc'), 0)
     self.assertEqual(replace('123,45'), 123.45)
     self.assertEqual(replace('123.45'), 123.45)
     self.assertEqual(replace('123 456,78'), 123456.78)
     self.assertEqual(replace('+12'), 12)
     self.assertEqual(replace('+ 12'), 12)
     self.assertEqual(replace('-12'), -12)
     self.assertEqual(replace('- 12'), -12)
     self.assertEqual(replace(' 100 '), 100)
     self.assertEqual(replace('123zł'), 123)
     self.assertEqual(replace('123 zł'), 123)
     self.assertEqual(replace('123.456,78'), 123456.78)
     self.assertEqual(replace('123.456,78 zł'), 123456.78)
예제 #10
0
parser.add_argument("--situation", "-s", required=True, help="Situation")
args = parser.parse_args()

csv_dir = './../csv_files/latent_vectors/' + args.situation + "/"

if os.path.exists(csv_dir + args.output_dir) is False:
    print("対象のファイルが見つかりません。")
    exit()

original_data_path = csv_dir + args.old_dir + "/latent_vectors.csv"
parents_index_path = csv_dir + args.output_dir + "/parents_index.csv"
children_index_path = csv_dir + args.output_dir + "/children_index.csv"
children_path = csv_dir + args.output_dir + "/children.csv"

original_data = functions.read_csv(original_data_path)
parents_index = functions.read_csv(parents_index_path)
parents_index = functions.transform_to_int(parents_index)
parents_index = parents_index[0]
children_index = functions.read_csv(children_index_path)
children_index = functions.transform_to_int(children_index)
children_index = children_index[0]
children = functions.read_csv(children_path)
children = functions.transform_to_float(children)

new_data = functions.replace(original_data, children, parents_index,
                             children_index)

# 新しい潜在ベクトル群をcsvファイルに書き込む
functions.write_csv(csv_dir + args.output_dir + "/latent_vectors.csv",
                    new_data)
예제 #11
0
파일: start.py 프로젝트: Jnns3001/Python
def map(replacement):
    index = text.find("level-name=") + 11
    length = text.find("view-distance=") - index
    return f.replace(text, index, length, replacement)
예제 #12
0
파일: start.py 프로젝트: Jnns3001/Python
def onlineMode(replacement):
    index = text.find("online-mode=") + 12
    length = text.find("level-seed=") - index
    return f.replace(text, index, length, replacement)