def file_sort(file_path, order, data_type): index_name = 0 input_file_path = [] with open(file_path, 'r') as file: latest = file.readline() current_chunk = open('current_chunk' + str(index_name), 'w') input_file_path.append('current_chunk' + str(index_name)) current_chunk.write(latest) while True: current = file.readline() if len(current) == 0: break if logic.comparison(order, data_type, latest, current): current_chunk.write(current) else: index_name += 1 current_chunk.close() current_chunk = open('current_chunk' + str(index_name), 'w') input_file_path.append('current_chunk' + str(index_name)) current_chunk.write(current) latest = current current_chunk.close() logic.logic({'order': order, 'type': data_type, 'output_file_path': file_path, 'input_file_path': input_file_path}) delete_temp_files(input_file_path)
def main(): input_parameters = comand_line.get_input_parameters() if not comand_line.is_correct_paths(input_parameters): easygui.msgbox( "Some paths isn't correct. We have to remove them, sorry.") input_parameters = comand_line.remove_invalid_file_paths( input_parameters) input_parameters['input_file_path'] = correct_file.check_for_correct_data( input_parameters) logic.logic(input_parameters)
def run(): cards = logic.cards() for i in range(0, cards): while True: interval = Label(fm3, text=str(logic.interval()) + ' Wiederholung(en) von', font=textFont) settings.Specs.next = False logic.logic() fm3.pack_forget() if settings.task1: label2.pack_forget() label3.pack_forget() label4.pack_forget() interval.pack() label1.pack() fm3.pack(expand=True) elif settings.task2: label1.pack_forget() label3.pack_forget() label4.pack_forget() interval.pack() label2.pack() fm3.pack(expand=True) elif settings.task3: label1.pack_forget() label2.pack_forget() label4.pack_forget() interval.pack() label3.pack() fm3.pack(expand=True) elif settings.task4: label1.pack_forget() label2.pack_forget() label3.pack_forget() interval.pack() label4.pack() fm3.pack(expand=True) break if i != cards: while True: if settings.Specs.next: interval.destroy() break label1.pack_forget() label2.pack_forget() label3.pack_forget() label4.pack_forget() startBT.pack_forget() nextBT.pack_forget() endeBT.pack(side=RIGHT, padx=20, pady=20)
async def ping(ctx, *item): await ctx.author.send("I will contact you in a minute!") goodAH = logic.logic(" ".join(item[:])) if goodAH != "no items or wrong name": await ctx.author.send("Good " + " ".join(item[:]) + " at /ah " + goodAH) else: await ctx.author.send("No items or wrong name")
def scheduler(numClasses=0, inFile="inFile", outFile="outFile"): inputFile = open(inFile, "r") fileText = inputFile.read() inputFile.close() outputFile = open(outFile, "w") initClassList = parse(fileText) imperativeList = initClassList[1] classList = convertTimesToInts(initClassList[0]) scheduleList = generateSchedules(fillScheduleWithClassList(classList), classList) # printScheduleList(scheduleList, numClasses, imperativeList) writeScheduleList(scheduleList, numClasses, imperativeList, outputFile) #timeList = getTimeList(classList) outputFile.close() logic()
async def receive(ws: websockets.WebSocketServerProtocol, client: Chat): global queues async for msg in ws: if msg == "EXIT": await ws.send("ACK_EXIT") break ret = logic(client.id, names.copy(), msg) for id, reply in ret.items(): await queues[id].put(reply) client.left = True clientname = client.name del queues[client.id] del names[client.id] ret = logic_client_disconnect(client.id, clientname, names.copy()) for id, reply in ret.items(): await queues[id].put(reply)
def postEmail(): if request.method == 'POST': data = json.loads(request.data)['email'] with sqlite3.connect("tinder.db") as conn: c = conn.cursor() c.execute("SELECT * FROM profile WHERE email=?", (data, )) rows = c.fetchall() if len(rows) == 0: return make_response({'data': None}, 400) filteredData = getMatch(parseDict(rows[0]), c) returnresult = [parseDict(rows[0])] returnresult += logic.logic(filteredData, parseDict(rows[0])) responses = returnresult return make_response({'data': responses}, 200) return make_response({'data': None}, 400)
def send_message(text, chat_id): command, parameter = get_command(text) http = urllib3.PoolManager() if command == "/start": reply = "Hello! I can tell you what time it is around the world! Just send me /time followed by a country code, a country name or a city name. For example /time it or /time Italy or /time Rome" url = URL + "sendMessage?text={}&chat_id={}".format(reply, chat_id) http.request('GET', url) elif command == "/help": reply = "Send /time followed by a country code, a country name or a city name. For example /time it or /time Italy or /time Rome" url = URL + "sendMessage?text={}&chat_id={}".format(reply, chat_id) http.request('GET', url) elif command == "/time": if parameter == '': reply = "Send /time followed by a country code, a country name or a city name. For example /time it or /time Italy or /time Rome" else: reply = logic(parameter) if reply == '': reply = "Unknown place :(" url = URL + "sendMessage?text={}&chat_id={}".format(reply, chat_id) http.request('GET', url)
def make_strategy_position_data(self): position_data = ['sell'] * len(self.profit_strategy_df.index) logic_data = logic.logic(self.profit_strategy_df) ## 포지션 데이터 설정 for i in range(max(config.optmizize_list), len(position_data) - 1): buy_signal = logic_data.buy_logic(i) sell_signal = logic_data.sell_logic(i) ## 매수 시그널 발생시 if buy_signal == 1 and sell_signal == 0: position_data[i] = 'buy' else: position_data[i] = 'sell' i += 1 self.profit_strategy_df['position'] = position_data return self.profit_strategy_df
from tkinter import * from logic import logicClass as logic import threading import time import ctypes master = Tk() logicC = logic() w = Canvas(master, width=300, height=300) w.pack() w.configure(background='white') gameover = None def createCircle(h, v): w.create_oval(5 + (h * 100), 95 + (v * 100), 95 + (h * 100), 5 + (v * 100), fill="white", outline="#000", width=4) def createX(h, v): w.create_line(95 + (h * 100), 95 + (v * 100), 5 + (h * 100), 5 + (v * 100),
def __init__(self): """ Initialize the logic class """ self.yt_app = logic()
def soln(): parent = logic.logic(src, obs_list, dest) for value in parent: but_list[value].config(bg='#b088f9') but_list[src].config(bg='#ffc7c7')
def game_loop(exit_state, game_data, questions, level, player): while not game_data.state.is_state(exit_state): game_data.dispatcher.handle_events(game_data, questions, level, player) logic(game_data, questions, level, player) render(game_data, questions, level, player)
def __init__(self, api, debug): self.api = api self.refresh_whitelist() self.predictorlogic = logic.logic() self.debug = debug
def addLogic(self, value, a, b): self.logics.append(logic.logic(value, a, b))
def tablechallan(self, b): global custname global custadd global billno global date custname = b.get_object("name").get_text() custadd = b.get_object("address").get_text() billno = b.get_object("invoice_no").get_text() date = b.get_object("sell_date").get_text() global sr1 sr1 = '' global sr2 sr2 = '' global sr3 sr3 = '' global sr4 sr4 = '' global sr5 sr5 = '' global sr6 sr6 = '' global sr7 sr7 = '' global sr8 sr8 = '' global sr9 sr9 = '' global sr10 sr10 = '' db = database() con = db.crsr() crsr = con.cursor() #arra = crsr.execute('SELECT sr_no from description where bill_no = ? ORDER BY sr_no',(int(billno),)) splitemp = b.get_object('item_no').get_text() arr = splitemp.split('\n') #for i in arra: #arr = arr + i try: if arr[0] is not None: sr1 = str(arr[0]) if arr[1] is not None: sr2 = str(arr[1]) if arr[2] is not None: sr3 = str(arr[2]) if arr[3] is not None: sr4 = str(arr[3]) if arr[4] is not None: sr5 = str(arr[4]) if arr[5] is not None: sr6 = str(arr[5]) if arr[6] is not None: sr7 = str(arr[6]) if arr[7] is not None: sr8 = str(arr[7]) if arr[8] is not None: sr9 = str(arr[8]) if arr[9] is not None: sr10 = str(arr[9]) except: a = 0 global par1 par1 = '' global par2 par2 = '' global par3 par3 = '' global par4 par4 = '' global par5 par5 = '' global par6 par6 = '' global par7 par7 = '' global par8 par8 = '' global par9 par9 = '' global par10 par10 = '' #arra = crsr.execute('SELECT item_name FROM item_list WHERE item_no IN (SELECT item_no FROM description WHERE bill_no = ? ORDER BY sr_no)',(int(billno),)) splitemp = b.get_object('item_name').get_text() arr = splitemp.split('\n') #for i in arra: #arr = arr + i try: if arr[0] is not None: par1 = str(arr[0]) if arr[1] is not None: par2 = str(arr[1]) if arr[2] is not None: par3 = str(arr[2]) if arr[3] is not None: par4 = str(arr[3]) if arr[4] is not None: par5 = str(arr[4]) if arr[5] is not None: par6 = str(arr[5]) if arr[6] is not None: par7 = str(arr[6]) if arr[7] is not None: par8 = str(arr[7]) if arr[8] is not None: par9 = str(arr[8]) if arr[9] is not None: par10 = str(arr[9]) except: a = 0 global no1 no1 = '' global no2 no2 = '' global no3 no3 = '' global no4 no4 = '' global no5 no5 = '' global no6 no6 = '' global no7 no7 = '' global no8 no8 = '' global no9 no9 = '' global no10 no10 = '' global w1 w1 = '' global w2 w2 = '' global w3 w3 = '' global w4 w4 = '' global w5 w5 = '' global w6 w6 = '' global w7 w7 = '' global w8 w8 = '' global w9 w9 = '' global w10 w10 = '' arra = crsr.execute( 'SELECT quantity, weight FROM description WHERE bill_no = ? ORDER BY sr_no', (int(billno), )) arr = () for i in arra: arr = arr + i try: if arr[0] is not None: no1 = str(arr[0]) if arr[1] is not None: w1 = str(arr[1]) if arr[2] is not None: no2 = str(arr[2]) if arr[3] is not None: w2 = str(arr[3]) if arr[4] is not None: no3 = str(arr[4]) if arr[5] is not None: w3 = str(arr[5]) if arr[6] is not None: no4 = str(arr[6]) if arr[7] is not None: w4 = str(arr[7]) if arr[8] is not None: no5 = str(arr[8]) if arr[9] is not None: w5 = str(arr[9]) if arr[10] is not None: no6 = str(arr[10]) if arr[11] is not None: w6 = str(arr[11]) if arr[12] is not None: no7 = str(arr[12]) if arr[13] is not None: w7 = str(arr[13]) if arr[14] is not None: no8 = str(arr[14]) if arr[15] is not None: w8 = str(arr[15]) if arr[16] is not None: no9 = str(arr[16]) if arr[17] is not None: w9 = str(arr[17]) if arr[18] is not None: no10 = str(arr[18]) if arr[19] is not None: w10 = str(arr[19]) except: a = 0 #arra = crsr.execute('SELECT item_rate FROM item_list WHERE item_no IN (SELECT item_no FROM description WHERE bill_no = ? ORDER BY sr_no)',(int(billno),)) arr = () arra = crsr.execute( 'SELECT item_list.item_rate FROM item_list,description WHERE item_list.item_no = description.item_no AND description.bill_no = ? ORDER BY description.sr_no', (int(billno), )) for i in arra: arr = arr + i global ra1 ra1 = '' global ra2 ra2 = '' global ra3 ra3 = '' global ra4 ra4 = '' global ra5 ra5 = '' global ra6 ra6 = '' global ra7 ra7 = '' global ra8 ra8 = '' global ra9 ra9 = '' global ra10 ra10 = '' try: if arr[0] is not None: ra1 = str(arr[0]) if arr[1] is not None: ra2 = str(arr[1]) if arr[2] is not None: ra3 = str(arr[2]) if arr[3] is not None: ra4 = str(arr[3]) if arr[4] is not None: ra5 = str(arr[4]) if arr[5] is not None: ra6 = str(arr[5]) if arr[6] is not None: ra7 = str(arr[6]) if arr[7] is not None: ra8 = str(arr[7]) if arr[8] is not None: ra9 = str(arr[8]) if arr[9] is not None: ra10 = str(arr[9]) except: a = 0 arra = crsr.execute( 'SELECT quantity FROM description WHERE bill_no = ? ORDER BY sr_no', (int(billno), )) q = () for i in arra: q = q + i global rs1, rp1 rs1 = '' rp1 = '' global rs2, rp2 rs2 = '' rp2 = '' global rs3, rp3 rs3 = '' rp3 = '' global rs4, rp4 rs4 = '' rp4 = '' global rs5, rp5 rs5 = '' rp5 = '' global rs6, rp6 rs6 = '' rp6 = '' global rs7, rp7 rs7 = '' rp7 = '' global rs8, rp8 rs8 = '' rp8 = '' global rs9, rp9 rs9 = '' rp9 = '' global rs10, rp10 rs10 = '' rp10 = '' amrp = 0.0 try: temp = str(float(arr[0]) * int(q[0])) if ra1 is not None: amrp = amrp + float(temp) rs1 = temp.split('.')[0] if temp.split('.')[1] == '0': rp1 = '00' else: rp1 = temp.split('.')[1] temp = str(float(arr[1]) * int(q[1])) if ra2 is not None: amrp = amrp + float(temp) rs2 = temp.split('.')[0] if temp.split('.')[1] == '0': rp2 = '00' else: rp2 = temp.split('.')[1] temp = str(float(arr[2]) * int(q[2])) if ra3 is not None: amrp = amrp + float(temp) rs3 = temp.split('.')[0] if temp.split('.')[1] == '0': rp3 = '00' else: rp3 = temp.split('.')[1] temp = str(float(arr[3]) * int(q[3])) if ra4 is not None: amrp = amrp + float(temp) rs4 = temp.split('.')[0] if temp.split('.')[1] == '0': rp4 = '00' else: rp4 = temp.split('.')[1] temp = str(float(arr[4]) * int(q[4])) if ra5 is not None: amrp = amrp + float(temp) rs5 = temp.split('.')[0] if temp.split('.')[1] == '0': rp5 = '00' else: rp5 = temp.split('.')[1] temp = str(float(arr[5]) * int(q[5])) if ra6 is not None: amrp = amrp + float(temp) rs6 = temp.split('.')[0] if temp.split('.')[1] == '0': rp6 = '00' else: rp6 = temp.split('.')[1] temp = str(float(arr[6]) * int(q[6])) if ra7 is not None: amrp = amrp + float(temp) rs7 = temp.split('.')[0] if temp.split('.')[1] == '0': rp7 = '00' else: rp7 = temp.split('.')[1] temp = str(float(arr[7]) * int(q[7])) if ra8 is not None: amrp = amrp + float(temp) rs8 = temp.split('.')[0] if temp.split('.')[1] == '0': rp8 = '00' else: rp8 = temp.split('.')[1] temp = str(float(arr[8]) * int(q[8])) if ra9 is not None: amrp = amrp + float(temp) rs9 = temp.split('.')[0] if temp.split('.')[1] == '0': rp9 = '00' else: rp9 = temp.split('.')[1] temp = str(float(arr[9]) * int(q[9])) if ra10 is not None: amrp = amrp + float(temp) rs10 = temp.split('.')[0] if temp.split('.')[1] == '0': rp10 = '00' else: rp10 = temp.split('.')[1] except: a = 0 global challanno challanno = b.get_object("invoice_no").get_text() global datech datech = b.get_object("sell_date").get_text() global rate rate = b.get_object("price").get_text() global grdtotal temp = b.get_object("grand_total").get_text() a = temp.split('.') grdtotal = a[0] import logic l = logic.logic() amntrp = amrp amnrp = str(amntrp) global vat vat = b.get_object("vat").get_text() global totalrs totalrs = amnrp.split('.')[0] global totalps if amnrp.split('.')[1] == '0': totalps = '00' else: totalps = amnrp.split('.')[1] vatrp = b.get_object("grand_total").get_text() temp = (float(vat) * float(amnrp)) / float(100) temp = str(temp) temp = temp.split('.') global vatrs vatrs = temp[0] global vatps if temp[1] == '0': vatps = '00' else: vatps = temp[1] tmp1 = b.get_object("other_charges").get_text() if tmp1.find('.') == -1: tmp1 = tmp1 + '.0' temp = tmp1.split('.') global roundoffrs roundoffrs = temp[0] global roundofps if temp[0] == '0': roundofps = '00' else: roundofps = temp[1] global word word = test.number_to_words(int(grdtotal)) + 'Only' flnm = '/home/john/fine_bill/' + billno + "challan.odt" renderer = Renderer('/home/john/Fine_contacts/fchallan.odt', globals(), flnm) renderer.run() flnm = '/home/john/fine_bill/' + billno + 'invoice.odt' renderer = Renderer('/home/john/Fine_contacts/finvoice.odt', globals(), flnm) renderer.run()
def main(conf_, difficulty): """Main function. This should be called to start the game. Arguments: *conf_* is settings, instance of :py:class:`settings.Settings`; *difficulty* - int between 0 and 2 (inclusive) - difficulty level (0 easy, 1 normal, 2 hard).""" global win_width, win_height, width, height, depth, w_depth, fps, fps_limit, log, conf, panx, pany, turbo, running global mouserot, mousepan, mouse_last_x, mouse_last_y, rotx, roty, zoom, menu_mode, xmenu, colors conf = conf_ reset_settings() # reset input state conf.get("key_bindings").input_state.reset() width, height, depth, w_depth = difficulty2dim[difficulty] gl_func_map() #pygame.init() pygame.joystick.init() conf.get("key_bindings").input_state.setup_joys() #set_mode(win_width, win_height) #pygame.display.set_caption("Blockout4D test") surf = pygame.display.get_surface() win_width, win_height = surf.get_size() pygame.event.post( pygame.event.Event(pygame.VIDEORESIZE, size=(win_width, win_height), w=win_width, h=win_height)) log = logic.logic(width, height, depth, w_depth, num_colors=len(colors)) log.SetGameOverCallback(gameover) log.SetBlockDroppedCallback(block_dropped) log.SetBlockRotatedCallback(block_rotated) gl_init() block_dropped() set_speed() pygame.time.set_timer(pygame.USEREVENT + 1, 200) menu_layout = _menu("*", [ _menu_entry("resume", None, menu_cbck_resume, None, None), _menu_entry("exit to os", None, menu_cbck_exit2os, None, None), _menu_entry("exit to menu", None, menu_cbck_exit2menu, None, None), _menu("settings", [ _menu("misc", [ _menu_entry("show fps", menu_cbck_misc_reset, menu_cbck_misc_enter, menu_cbck_misc_inc, menu_cbck_misc_dec), _menu_entry("speed", menu_cbck_misc_reset, None, menu_cbck_misc_inc, menu_cbck_misc_dec), ]), _menu("controls", [ _menu_entry(i, menu_cbck_controls_reset, menu_cbck_controls_enter, None, None) for i in key_num.labels ]), _menu_entry("save", None, menu_cbck_save, None, None), _menu_entry("reset", None, menu_cbck_reset, None, None) ]) ]) xmenu = Menu(menu_layout, conf) triggered_hold = [] triggered_once = [] triggered_timestamp = {} triggered_backoff = 300 triggered_norepeat = [20] while running: for ev in pygame.event.get(): if ev.type == pygame.QUIT: exit_2_os() elif ev.type == pygame.VIDEORESIZE: win_width, win_height = ev.w, ev.h print "Resizing to %d x %d" % (win_width, win_height) set_mode(win_width, win_height) reshape(win_width, win_height) set_fonts_sizes() else: if game_over_mode: if ev.type == pygame.KEYDOWN: if ev.key == pygame.K_ESCAPE: running = False else: if menu_mode: # we're in menu if ev.type == pygame.KEYDOWN: if ev.key == pygame.K_ESCAPE: if xmenu.path: xmenu.escape() else: menu_mode = False conf.get( "key_bindings").input_state.reset() elif ev.key == pygame.K_UP: xmenu.up() elif ev.key == pygame.K_DOWN: xmenu.down() elif ev.key == pygame.K_LEFT: xmenu.left() elif ev.key == pygame.K_RIGHT: xmenu.right() elif ev.key == pygame.K_RETURN: xmenu.enter() else: # we're not in menu conf.get("key_bindings").input_state.process_event(ev) triggered = conf.get("key_bindings").get_triggered() tmp = turbo turbo = (key_num.KEY_TURBO in triggered) if turbo != tmp: set_speed() log.AdvanceFall() triggered_new = remove_list(triggered, triggered_once) for i in triggered_new: triggered_timestamp[i] = pygame.time.get_ticks() execute_triggered(triggered_new) if ev.type == pygame.USEREVENT + 1: t = pygame.time.get_ticks() execute_triggered( filter( lambda x: (t - triggered_timestamp[x]) > triggered_backoff, triggered_once)) triggered_once = remove_list(triggered, triggered_norepeat) if ev.type == pygame.USEREVENT: log.AdvanceFall() """ elif ev.type == pygame.KEYDOWN: print "Key press: ", ev if ev.key == pygame.K_ESCAPE: menu_mode = True """ if ev.type == pygame.MOUSEBUTTONDOWN: if ev.button == 1: mouserot = True mouse_last_x = ev.pos[0] mouse_last_y = ev.pos[1] elif ev.button == 3: mousepan = True mouse_last_x = ev.pos[0] mouse_last_y = ev.pos[1] elif ev.button == 4: # scroll up zoom += 0.5 elif ev.button == 5: # scroll down zoom -= 0.5 elif ev.type == pygame.MOUSEBUTTONUP: if ev.button == 1: mouserot = False elif ev.button == 3: mousepan = False elif ev.type == pygame.MOUSEMOTION: x, y = ev.pos if mouserot: roty += (x - mouse_last_x) * 0.3 rotx += (y - mouse_last_y) * 0.3 mouse_last_x = x mouse_last_y = y elif mousepan: panx -= (x - mouse_last_x) * 0.005 * zoom pany += (y - mouse_last_y) * 0.005 * zoom mouse_last_x = x mouse_last_y = y display() clock.tick(fps_limit) fps = clock.get_fps() unload() return
matrix = initialize(m, n, matrix) #input in matrix as float or int type for i in range(m): for j in range(n): print('entry in row: ', i + 1, ' column: ', j + 1) #applying try and except if user gives an input other than prescribed type while True: try: matrix[i][j] = float(input()) break except ValueError: print( "no special characters are allowed \nplease enter valid float or integer type value" ) return matrix ''' calling all functions seperately from main as well from other files''' #calling entry1 m, n = entry1() #calling entry2 mat = entry2(m, n, matrix) #initialzing l2 and creating a deep copy of matrix in l2 l2 = intialize(m, n, l2) l2 = duplicate(m, n, mat, l2) ans = logic(m, n, l2) print(ans)
@author: Justin """ # test import logic.py as logic import RPi.GPIO as GPIO from board import SCL, SDA import busio import time from adafruit_seesaw.seesaw import Seesaw #create objects moisture_logic = logic() i2c_bus = busio.I2C(SCL, SDA) ss = Seesaw(i2c_bus, addr=0x36) #set up pi GPIO.cleanup() GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(17, GPIO.OUT) while True: touch = ss.moisture_read() shouldWater = logic.evaluate_logic(None, touch) print("Moisture: " + str(touch) + ". Should water?" + str(shouldWater))
def func1(self, event): # returns the x,y co-ordinates of the mouse pointer relative to the main board. cx = self.master.winfo_pointerx() - self.master.winfo_rootx() cy = self.master.winfo_pointery() - self.master.winfo_rooty() j = (cx - 320) // 80 i = (cy - 50) // 80 id_gui = 7 * j + i + 1 roll_num = self.roll_num p = 0 color_piece = \ logic.AddPlayer.turn_player_list_logic[Board.turn_player % len(logic.AddPlayer.turn_player_list_logic)][1] try: out = logic.logic(id_gui, color_piece, roll_num, p) target_id = out[0] color = out[1] killed_id_color = out[2] if color == "BLUE": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_blue[0].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "RED": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_red[0].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "GREEN": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_green[0].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "YELLOW": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_yellow[0].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) logic.win() except TypeError: print("------- Click on Proprite Label! -------") print(f"row is {i} and col is {j}", "id in gui is: ", id_gui)
#!/usr/bin/env python # -*- coding: utf-8 -*- import logic import storage import json l = logic.logic() print("answer "+l.getschicksalsjahre("12.2.2000")) print("answer "+l.getschicksalsjahre("12. januar 2000")) print("answer "+l.getschicksalsjahre("1.1.1987")) print("answer "+l.getschicksalsjahre("12. februar 2000")) print("answer "+l.getschicksalsjahre("12.4.1967")) print("answer "+l.getschicksalsjahre("20.2.2000")) print("answer "+l.getschicksalsjahre("6.sda3 33 sd84")) print("tenendenz "+l.getwochentendenz()) print("tenendenz "+l.getwochentendenz()) print("tenendenz "+l.getwochentendenz()) print(l.gettageswerte('Steinbock')) print(l.gettageswerte('stier')) print(l.gettageswerte('jungfrau')) print(l.gettageswerte('bär')) print(l.gettageshoroskop('Steinbock')) print(l.gettageshoroskop('stier')) print(l.gettageshoroskop('jungfrau')) print(l.gettageshoroskop('fische')) print(l.gettageshoroskop('zwillinge'))
def func4(self, event): try: cx = self.master.winfo_pointerx() - self.master.winfo_rootx() cy = self.master.winfo_pointery() - self.master.winfo_rooty() j = (cx - 320) // 80 i = (cy - 50) // 80 id_gui = 7 * j + i + 1 p = 3 roll_num = self.roll_num color_piece = \ logic.AddPlayer.turn_player_list_logic[Board.turn_player % len(logic.AddPlayer.turn_player_list_logic)][ 1] out = logic.logic(id_gui, color_piece, roll_num, p) target_id = out[0] color = out[1] killed_id_color = out[2] if color == "BLUE": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_blue[3].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "RED": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_red[3].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "GREEN": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_green[3].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) elif color == "YELLOW": if killed_id_color: for ii in killed_id_color: self.killed(ii[0], ii[1]) self.counter_lbl(ii[1]) self.counter_lbl(color) self.lbl_yellow[3].place(x=80 * (((target_id + 6) // 7) - 1) + 132, y=80 * ((target_id + 6) % 7) + 56) self.roll_turn(roll_num) logic.win() print(f"row is {i} and col is {j}", "id in gui is: ", id_gui) except TypeError: print("------- Click on Proprite Label! -------") except ZeroDivisionError: print("!======= Game Ended! =======!")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False database = SQLAlchemy(app) class user(database.Model): _id = database.Column("id", database.Integer, primary_key = True) name = database.Column(database.String(100)) score = database.Column(database.Integer) date = database.Column(database.String(100)) def __init__(self, name, score): self.name = name self.score = score self.date = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) logic = logic() #database.session.query(user).delete() #database.session.commit() @app.route("/", methods=["GET", "POST"]) def home(): if request.method == "GET": logic.prepare_game() return render_template("index.html", row = [1, 2, 3, 4, 5, 6, 7, 8], column = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'], highscores = sorted(user.query.all(), key = lambda x: (x.score, x.date))[0:50]) elif request.method == "POST": if "name" in request.form: if logc.get_steps >= 9: database.session.add(user(request.form["name"], logic.get_steps)) database.session.commit()
def tablechallan(self, b): global custname global custadd global billno global date custname = b.get_object("name").get_text() custadd = b.get_object("address").get_text() billno = b.get_object("invoice_no").get_text() date = b.get_object("sell_date").get_text() global sr1 sr1 = '' global sr2 sr2 = '' global sr3 sr3 = '' global sr4 sr4 = '' global sr5 sr5 = '' global sr6 sr6 = '' global sr7 sr7 = '' global sr8 sr8 = '' global sr9 sr9 = '' global sr10 sr10 = '' db = database() con = db.crsr() crsr = con.cursor() #arra = crsr.execute('SELECT sr_no from description where bill_no = ? ORDER BY sr_no',(int(billno),)) splitemp = b.get_object('item_no').get_text() arr = splitemp.split('\n') #for i in arra: #arr = arr + i try: if arr[0] is not None: sr1 = str(arr[0]) if arr[1] is not None: sr2 = str(arr[1]) if arr[2] is not None: sr3 = str(arr[2]) if arr[3] is not None: sr4 = str(arr[3]) if arr[4] is not None: sr5 = str(arr[4]) if arr[5] is not None: sr6 = str(arr[5]) if arr[6] is not None: sr7 = str(arr[6]) if arr[7] is not None: sr8 = str(arr[7]) if arr[8] is not None: sr9 = str(arr[8]) if arr[9] is not None: sr10 = str(arr[9]) except: a =0 global par1 par1 = '' global par2 par2 = '' global par3 par3 = '' global par4 par4 = '' global par5 par5 = '' global par6 par6 = '' global par7 par7 = '' global par8 par8 = '' global par9 par9 = '' global par10 par10 = '' #arra = crsr.execute('SELECT item_name FROM item_list WHERE item_no IN (SELECT item_no FROM description WHERE bill_no = ? ORDER BY sr_no)',(int(billno),)) splitemp = b.get_object('item_name').get_text() arr = splitemp.split('\n') #for i in arra: #arr = arr + i try: if arr[0] is not None: par1 = str(arr[0]) if arr[1] is not None: par2 = str(arr[1]) if arr[2] is not None: par3 = str(arr[2]) if arr[3] is not None: par4 = str(arr[3]) if arr[4] is not None: par5 = str(arr[4]) if arr[5] is not None: par6 = str(arr[5]) if arr[6] is not None: par7 = str(arr[6]) if arr[7] is not None: par8 = str(arr[7]) if arr[8] is not None: par9 = str(arr[8]) if arr[9] is not None: par10 = str(arr[9]) except: a = 0 global no1 no1 = '' global no2 no2 = '' global no3 no3 = '' global no4 no4 = '' global no5 no5 = '' global no6 no6 = '' global no7 no7 = '' global no8 no8 = '' global no9 no9 = '' global no10 no10 ='' global w1 w1 = '' global w2 w2 = '' global w3 w3 = '' global w4 w4 = '' global w5 w5 = '' global w6 w6 = '' global w7 w7 = '' global w8 w8 = '' global w9 w9 = '' global w10 w10 = '' arra = crsr.execute('SELECT quantity, weight FROM description WHERE bill_no = ? ORDER BY sr_no',(int(billno),)) arr = () for i in arra: arr = arr + i try: if arr[0] is not None: no1 = str(arr[0]) if arr[1] is not None: w1 = str(arr[1]) if arr[2] is not None: no2 = str(arr[2]) if arr[3] is not None: w2 = str(arr[3]) if arr[4] is not None: no3 = str(arr[4]) if arr[5] is not None: w3 = str(arr[5]) if arr[6] is not None: no4 = str(arr[6]) if arr[7] is not None: w4 = str(arr[7]) if arr[8] is not None: no5 = str(arr[8]) if arr[9] is not None: w5 = str(arr[9]) if arr[10] is not None: no6 = str(arr[10]) if arr[11] is not None: w6 = str(arr[11]) if arr[12] is not None: no7 = str(arr[12]) if arr[13] is not None: w7 = str(arr[13]) if arr[14] is not None: no8 = str(arr[14]) if arr[15] is not None: w8 = str(arr[15]) if arr[16] is not None: no9 = str(arr[16]) if arr[17] is not None: w9 = str(arr[17]) if arr[18] is not None: no10 = str(arr[18]) if arr[19] is not None: w10 = str(arr[19]) except: a = 0 #arra = crsr.execute('SELECT item_rate FROM item_list WHERE item_no IN (SELECT item_no FROM description WHERE bill_no = ? ORDER BY sr_no)',(int(billno),)) arr = () arra = crsr.execute('SELECT item_list.item_rate FROM item_list,description WHERE item_list.item_no = description.item_no AND description.bill_no = ? ORDER BY description.sr_no',(int(billno),)) for i in arra: arr = arr + i global ra1 ra1 = '' global ra2 ra2= '' global ra3 ra3 = '' global ra4 ra4 = '' global ra5 ra5 = '' global ra6 ra6 = '' global ra7 ra7 = '' global ra8 ra8 = '' global ra9 ra9 = '' global ra10 ra10 = '' try: if arr[0] is not None: ra1 = str(arr[0]) if arr[1] is not None: ra2 = str(arr[1]) if arr[2] is not None: ra3 = str(arr[2]) if arr[3] is not None: ra4 = str(arr[3]) if arr[4] is not None: ra5 = str(arr[4]) if arr[5] is not None: ra6 = str(arr[5]) if arr[6] is not None: ra7 = str(arr[6]) if arr[7] is not None: ra8 = str(arr[7]) if arr[8] is not None: ra9 = str(arr[8]) if arr[9] is not None: ra10 = str(arr[9]) except: a = 0 arra = crsr.execute('SELECT quantity FROM description WHERE bill_no = ? ORDER BY sr_no',(int(billno),)) q = () for i in arra: q = q + i global rs1, rp1 rs1 = '' rp1 = '' global rs2, rp2 rs2 = '' rp2 = '' global rs3, rp3 rs3 = '' rp3 = '' global rs4, rp4 rs4 = '' rp4 = '' global rs5, rp5 rs5 = '' rp5 = '' global rs6, rp6 rs6 = '' rp6 = '' global rs7, rp7 rs7 = '' rp7 = '' global rs8, rp8 rs8 = '' rp8 = '' global rs9, rp9 rs9 = '' rp9 = '' global rs10, rp10 rs10 = '' rp10 = '' amrp = 0.0 try: temp = str(float(arr[0]) * int(q[0])) if ra1 is not None: amrp = amrp + float(temp) rs1 = temp.split('.')[0] if temp.split('.')[1] == '0': rp1 = '00' else: rp1 = temp.split('.')[1] temp = str(float(arr[1]) * int(q[1])) if ra2 is not None: amrp = amrp + float(temp) rs2 = temp.split('.')[0] if temp.split('.')[1] == '0': rp2 = '00' else: rp2 = temp.split('.')[1] temp = str(float(arr[2]) * int(q[2])) if ra3 is not None: amrp = amrp + float(temp) rs3 = temp.split('.')[0] if temp.split('.')[1] == '0': rp3 = '00' else: rp3 = temp.split('.')[1] temp = str(float(arr[3]) * int(q[3])) if ra4 is not None: amrp = amrp + float(temp) rs4 = temp.split('.')[0] if temp.split('.')[1] == '0': rp4 = '00' else: rp4 = temp.split('.')[1] temp = str(float(arr[4]) * int(q[4])) if ra5 is not None: amrp = amrp + float(temp) rs5 = temp.split('.')[0] if temp.split('.')[1] == '0': rp5 = '00' else: rp5 = temp.split('.')[1] temp = str(float(arr[5]) * int(q[5])) if ra6 is not None: amrp = amrp + float(temp) rs6 = temp.split('.')[0] if temp.split('.')[1] == '0': rp6 = '00' else: rp6 = temp.split('.')[1] temp = str(float(arr[6]) * int(q[6])) if ra7 is not None: amrp = amrp + float(temp) rs7 = temp.split('.')[0] if temp.split('.')[1] == '0': rp7 = '00' else: rp7 = temp.split('.')[1] temp = str(float(arr[7]) * int(q[7])) if ra8 is not None: amrp = amrp + float(temp) rs8 = temp.split('.')[0] if temp.split('.')[1] == '0': rp8 = '00' else: rp8 = temp.split('.')[1] temp = str(float(arr[8]) * int(q[8])) if ra9 is not None: amrp = amrp + float(temp) rs9 = temp.split('.')[0] if temp.split('.')[1] == '0': rp9 = '00' else: rp9 = temp.split('.')[1] temp = str(float(arr[9]) * int(q[9])) if ra10 is not None: amrp = amrp + float(temp) rs10 = temp.split('.')[0] if temp.split('.')[1] == '0': rp10 = '00' else: rp10 = temp.split('.')[1] except: a = 0 global challanno challanno = b.get_object("invoice_no").get_text() global datech datech = b.get_object("sell_date").get_text() global rate rate = b.get_object("price").get_text() global grdtotal temp = b.get_object("grand_total").get_text() a = temp.split('.') grdtotal = a[0] import logic l = logic.logic() amntrp = amrp amnrp = str(amntrp) global vat vat = b.get_object("vat").get_text() global totalrs totalrs = amnrp.split('.')[0] global totalps if amnrp.split('.')[1] == '0': totalps = '00' else: totalps = amnrp.split('.')[1] vatrp = b.get_object("grand_total").get_text() temp = (float(vat) * float(amnrp))/float(100) temp = str(temp) temp = temp.split('.') global vatrs vatrs = temp[0] global vatps if temp[1] == '0': vatps = '00' else: vatps = temp[1] tmp1 = b.get_object("other_charges").get_text() if tmp1.find('.') == -1: tmp1 = tmp1 +'.0' temp = tmp1.split('.') global roundoffrs roundoffrs = temp[0] global roundofps if temp[0] == '0' : roundofps = '00' else: roundofps = temp[1] global word word = test.number_to_words(int(grdtotal)) + 'Only' flnm = '/home/john/fine_bill/' + billno + "challan.odt" renderer = Renderer('/home/john/Fine_contacts/fchallan.odt', globals(), flnm) renderer.run() flnm = '/home/john/fine_bill/' + billno +'invoice.odt' renderer = Renderer('/home/john/Fine_contacts/finvoice.odt', globals(), flnm) renderer.run()