def delegate(conn, user_in): user_in = user_in.lower() if user_in == "create": print("\n") return Create.Create(conn) elif user_in == "read": print("\n") return Read.Read(conn) elif user_in == "update": print("\n") return Update.Update(conn) elif user_in == "delete": print("\n") return Delete.Delete(conn) else: raise Exception("Invalid User input: " + user_in)
def showDlgCreateDB(self): self.dlg = QtWidgets.QDialog() self.dlg_ui = Create.Ui_Dialog() self.dlg_ui.setupUi(self.dlg) self.dlg_ui.buttonBox.accepted.connect(self.create_db) self.dlg_ui.buttonBox.rejected.connect(self.dlg.close) self.dlg_ui.tableWidget.setHorizontalHeaderLabels( ('Имя атрибута', 'Тип')) for row in range(self.dlg_ui.tableWidget.rowCount()): combo = QtWidgets.QComboBox(self.dlg) combo.addItem("INT") combo.addItem("REAL") combo.addItem("TEXT") combo.addItem("TIME") combo.addItem("DATE") self.dlg_ui.tableWidget.setCellWidget(row, 1, combo) self.dlg.show()
def test_createAssetLibStubFiles(self, os_stub, shutil_mock, makeDir_mock, getAnimDir_stub): #------------------------ Arrange project = 'testing' assetPath = '/temp/AssetLib/testing' name = 'Asset_01' typ = 'character' os_stub.path.isdir.return_value = False os_stub.path.join.return_value = 'path' getAnimDir_stub.return_value = 'path' # Act inst = Create.Create() result = inst.createAssetLibStubFiles(project=project, assetPath=assetPath, name=name, typ=typ) # Assert self.assertTrue(result) self.assertTrue( call(path='path', dirName='model') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='rig') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='texture') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='concept') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='fbx') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='meta') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='reference') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='notes') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='reports') in makeDir_mock.mock_calls) self.assertTrue( call(path='path', dirName='unity_proj') in makeDir_mock.mock_calls)
def test_createMetaDataFiles_1(self, getAnimDirs_stub, create_file_stub): #------------------------ Arrange project = 'testing' unityPath = '/temp/testing/unityDir' assetLibPath = '/temp/testing/AssetLib' user = '******' name = 'Asset_01' description = 'A test asset.' typ = 'character' subType = 'main' create_file_stub.return_value = True getAnimDirs_stub.return_value = True # Act inst = Create.Create() result = inst.createMetaDataFiles(project=project, assetLibPath=assetLibPath, name=name, typ=typ) # Assert self.assertEqual(result, True)
def test_main_3(self, meta_stub, unity_stub, assetLib_stub): successMsg = 'Created asset successfully.' failMsg = 'Failed to create asset.' #------------------------ Arrange project = 'testing' unityPath = '/temp/testing/dir' assetLibPath = '/temp/testing/unityDir' user = '******' name = 'Ass' # Name too short test description = 'A test asset.' typ = 'character' subType = 'main' meta_stub.return_value = False unity_stub.return_value = False assetLib_stub.return_value = False # Act inst = Create.Create() result = inst.main(project=project, unityPath=unityPath, assetLibPath=assetLibPath, user=user, name=name, description=description, typ=typ, subType=subType) # Assert self.assertEqual( result, { 'AssetLibStubs': failMsg, 'UnityLibStubs': failMsg, 'MetaData': failMsg })
def test_getAnimDir(self): project = 'testing' typ = 'biped_animcycle' name = 'Anim_01' inst = Create.Create() path = '/repos/AssetLib' result = inst._getAnimDir(project=project, path=path, typ=typ, name=name) self.assertEqual( result, '/repos/AssetLib/testing/animation/biped/library/cycle/Anim_01') path = '/repos/UnityProject/Assets/art' result = inst._getAnimDir(unity=True, project=project, path=path, typ=typ, name=name) self.assertEqual(result, '/repos/UnityProject/Assets/art/animation/Anim_01')
import sys import Create if not Create.check_argc(len(sys.argv)): sys.exit(1) Zco = [] if not Create.read_file(str(sys.argv[1]), Zco): sys.exit(1) if len(Zco) < 2: print("Not enough data!") sys.exit(1) print("Creating " + str(sys.argv[2])) print(" 1.Creating Triangles") Triangles = [] Create.create_triangles(Zco, Triangles) print(" 2.Creating Output File") Outputstr = [] Create.create_output(Triangles, Create.calculate_coeff(Zco), Outputstr) Create.create_STL(str(sys.argv[2]), Outputstr) print("Done!")
file = open("answers", 'w') while (True): print("\n1. Create and populate a database") print("2. Retrieve records with a given key") print("3. Retrieve records with a given data") print("4. Retrieve records with a given range of key values") print("5. Destroy the database") print("6. Quit \n") selection = input("Please select your program number:\n") try: digit = int(selection) if digit == 1: Create.dbOpen(option) elif digit == 2: if (option == "btree"): btree.keySearch_Btree(file) elif (option == "hash"): hashTree.keySearch_Hashtree(file) else: pass elif digit == 3: if (option == "btree"): btree.valueSearch_Btree(file) elif (option == "hash"): hashTree.valueSearch_Hashtree(file) else:
__author__ = 'ADM_Skullie' import Create print "specimen creation . . . " reproduction = "provide method of reproduction:" locomotion = "provide method of movement:" energy = "provide method of attaining energy:" specimen = Create.specimen(reproduction, locomotion, energy) print len(specimen.specimens)
"""After checking symmetry, remove shift here z_list = [row[2] for row in new_atom_list] z_shift = (max(z_list)+min(z_list))/2 for row in new_atom_list: row[2] -= z_shift """ return new_atom_list if __name__ == '__main__': import Create create = Create.Create(2, 3) deform = Deform() atom_list = create.trigonal() new_atom_list = deform.rolling(atom_list) y_list = [row[1] for row in new_atom_list] z_list = [row[2] for row in new_atom_list] y_shift = (max(y_list) + min(y_list)) / 2 z_shift = (max(z_list) + min(z_list)) / 2 print("Check of Symmetry: \n") print("y shift = " + str(y_shift)) print("z shift = " + str(z_shift) + "\n")
#!/usr/bin/python3 import sys, List, Create, Delete, Run, Info from colorama import init, Fore, Style if (__name__ == "__main__"): init() if (len(sys.argv) == 1): print( Fore.RED + "Invalid argument. Available arguments are:\n-run\n-list\n-create\n-delete\n-info" + Style.RESET_ALL) exit(0) if (sys.argv[1] == "list"): List.listInstances() elif (sys.argv[1] == "create"): Create.createInstance() elif (sys.argv[1] == "delete"): Delete.deleteInstance() elif (sys.argv[1] == "run"): Run.runInstance() elif (sys.argv[1] == "info"): Info.showInfo() else: print( Fore.RED + "Invalid argument. Available arguments are:\n-run\n-list\n-create\n-delete\n-info" + Style.RESET_ALL)
file = open("answers", 'w') while(True): print("\n1. Create and populate a database") print("2. Retrieve records with a given key") print("3. Retrieve records with a given data") print("4. Retrieve records with a given range of key values") print("5. Destroy the database") print("6. Quit \n") selection = input("Please select your program number:\n") try: digit = int(selection) if digit == 1: Create.dbOpen(option) elif digit == 2: if(option == "btree"): btree.keySearch_Btree(file) elif(option == "hash"): hashTree.keySearch_Hashtree(file) else: pass elif digit == 3: if(option == "btree"): btree.valueSearch_Btree(file) elif(option == "hash"): hashTree.valueSearch_Hashtree(file) else:
#!python3 #encoding:utf-8 # configで指定したディレクトリにDBがない場合、作成する import configparser import os.path import Create config = configparser.ConfigParser() config.read('./config.ini') print(config['Path']['DB']) print(os.path.abspath(config['Path']['DB'])) creator = Create.InitializeMasterDbCreator( os.path.abspath(config['Path']['DB'])) creator.Run()
from flask import render_template, url_for, redirect, request, session from Forms import RegistrationForm, LoginForm, SearchForm, GifForm, FilterForm from flask_bootstrap import Bootstrap from flask_login import login_user, login_required, logout_user, current_user from Models import User, UserGif, db from flask_bcrypt import Bcrypt import GiphyServices import Create # Configure the application with necessary settings app = Create.create_app() # Create the login manager login_manager = Create.create_login_manager(app) # Init Bcrypt and Bootstrap extensions bcrypt = Bcrypt(app) Bootstrap(app) # returns a user object when reloading a user from the session @login_manager.user_loader def load_user(username): return User.query.get(username) @app.route('/') def index(): return redirect(url_for('login'))
in_range_keys = [] keys = db.keys() for i in range(len(db)): if keys[i] >= lower and keys[i] <= upper: in_range_keys.append(keys[i]) print("Retrieved record: ", len(in_range_keys)) # record ending time end_time = time.time() # compute time consumed print("Time used on BTREE key search is", end_time - start_time) for i in range(len(in_range_keys) ): key = in_range_keys[i].decode(encoding = 'UTF-8') value = db[in_range_keys[i]].decode(encoding = 'UTF-8') f.write(key + "\n" + value+ "\n\n") # IMPORTANT: CLOSE THE DATABASE try: db.close() except Exception as e: print (e) if __name__ == "__main__": f = open("answers.txt", 'w') Create.bTree() keySearch_Btree(f) valueSearch_Btree(f) rangeSearch_Btree(f)
def main(): conn = Create.createConnection( "C:\\Users\LAB\Desktop\Project1\healthcare.db") if conn == False: return cur = conn.cursor() if cur == False: return cur.execute("PRAGMA foreign_keys = ON") ##To turn on foreign keys flag = Create.createTable( cur, """create table if not exists Login( Subscriber_ID varchar Primary Key, Password varchar, Sec_Q varchar, Sec_A varchar) """) if flag == False: return flag = Create.createTable( cur, """create table if not exists Member( Member_ID varchar Primary Key, Member_CD varchar, Name varchar, DOB date, ZIP_CD int, SID varchar, PID varchar, Foreign Key (SID) references Login(Subscriber_ID), Foreign Key (PID) references Provider(Provider_ID) ) """) if flag == False: return flag = Create.createTable( cur, """create table if not exists Provider( Provider_ID varchar Primary Key, Provider_Name varchar, ZIP_CD int ) """) if flag == False: return # ############# Add records to Provider ################ # data1 = ('P345',"ABC", 1007) # data2 = ('P897',"DEF", 1008) # data3 = ('P762', "GHI", 1008) # data4 = ('P845', "ZXC", 1009) # # changeTable.insertRecord(cur,data1,"Provider") # changeTable.insertRecord(cur, data2, "Provider") # changeTable.insertRecord(cur, data3, "Provider") # changeTable.insertRecord(cur, data4, "Provider") ######################################################## command = "select * from Member" cur.execute(command) data = cur.fetchall() for i in data: print(i) #######################Input From User########################## inp = int(input("1.Login\n2.Sign Up\n")) if inp == 1: SID = Login.login(cur) else: SID = Login.newMember(cur) if SID == False: return print("\nSelect an option : \n") option = int( input( "1.Member Enroll\n2.Member Update\n3.Member Delete\n4.Member Enquiry\n" )) if option == 1: Member.enroll(cur, SID) elif option == 2: Member.update(cur, SID) elif option == 3: Member.delete(cur, SID) else: Member.enquire(cur, SID) #changeTable.readTable(cur,"Login") conn.commit() print() command = "select * from Member" cur.execute(command) data = cur.fetchall() for i in data: print(i)
def add_command(): Create.create() view_command()
# -*- coding: utf-8 -*- """ Created on Fri Jul 22 10:41:10 2016 @author: Lina492375qW1188 """ import Create, Deform, Interaction, Construct #----------------- Number of atom ------------------# xmax = 150 # num of atoms in x-dir = (2*xmax+1, 2*xmax) ymax = 50 # num of atoms in y-dir = ymax*4 #----------------- Initialization ------------------# create = Create.Create(xmax,ymax) deform = Deform.Deform() interaction = Interaction.Interaction(create.ymax) infile='data.unknown' construct = Construct.Construct(infile) #---------- Rolling, Set bond and angle ------------# # action choices: (a)create plane (b)create paper roll. action = '(b)' if action == '(a)': coord1 = create.trigonal() elif action == '(b)': coord1 = deform.rolling(create.trigonal()) bond1 = interaction.bond(coord1) angle1 = interaction.angle(coord1)
z_shift = (max(z_list)+min(z_list))/2 for row in new_atom_list: row[2] -= z_shift """ return new_atom_list if __name__ == '__main__': #-------------- initialization ----------------# import Create xmax = 2 ymax = 3 create = Create.Create(xmax, ymax) # create plane lattice. deform = Deform() #-------------- print lattices ----------------# atom_list = create.trigonal() new_atom_list = deform.rolling(atom_list) print("lattice coord = {}\n".format(new_atom_list)) #-------------- check symmetry ----------------# y_list = [row[1] for row in new_atom_list] z_list = [row[2] for row in new_atom_list] y_shift = (max(y_list) + min(y_list)) / 2 z_shift = (max(z_list) + min(z_list)) / 2 print("Check the center of cross section: \n")
keys = db.keys() for i in range(len(db)): if keys[i] >= lower and keys[i] <= upper: in_range_keys.append(keys[i]) print("Retrieved record: ", len(in_range_keys)) # record ending time end_time = time.time() # compute time consumed print("Time used on BTREE key search is", end_time - start_time) for i in range(len(in_range_keys)): key = in_range_keys[i].decode(encoding='UTF-8') value = db[in_range_keys[i]].decode(encoding='UTF-8') f.write(key + "\n" + value + "\n\n") # IMPORTANT: CLOSE THE DATABASE try: db.close() except Exception as e: print(e) if __name__ == "__main__": f = open("answers.txt", 'w') Create.bTree() keySearch_Btree(f) valueSearch_Btree(f) rangeSearch_Btree(f)
import Create import Function Process = [] n, r1, r2, r3 = 20, 40, 40, 20 Process = Create.create(n, r1, r2, r3) print('ProcessName\tArrivalTime\tBurstTime') for i in range(len(Process)): print(Process[i][0], '\t\t', Process[i][1], '\t\t', Process[i][2]) print(' ') Function.FCFS(Process, n) print('---------------------------') Function.SJF(Process, n) print('---------------------------') Function.RR(Process, n, 4) print('---------------------------')