def check(e): ## structures.check(e) ## enumerations.check(e) ## unions.check(e) # trailings(e.code) # columns(e.code) error = classes.c_error(e.parser.old_contents) errors.open(e, error) if (e.parser.windows_style): errors.add(e, error, errors.ERRORS_STYLE, "This file contains \\r at end of lines !\n") columns(e, error) trailings(e, error) errors.close(e, error) errors.commit(e, error) types.check(e) #print "types done" globals.check(e) #print "globals done" comments.check(e) #print "comments done" macros.check(e) #print "macros done" functions.check(e) #print "func done" prototypes.check(e) #print "proto done" contents.check(e)
def __init__(self, uniq, age, name): checkParam = [check(age, False), check(uniq, True), check(name, True)] if True not in checkParam: print('err') return self.uniq = uniq self.age = age self.name = name
def main(): if len(sys.argv) != 2: print( "\n **************USAGE ERROR************\n please have a carefull look at the usage of the program. \n" ) print( "the usage of {} using the make file is : make hash='your hash' run. TIPS: do not put any sapce between the equal and your hash string\n" .format(sys.argv[0])) exit(-1) print( "***************DEBUT DE LA RECHERCHE DANS LA RAINBOW TABLE**************** \n\n", " \t HEURE DE DEBUT :", functions.get_time()) #******import the parameters******* my_hash = str(sys.argv[1]) data_base = params.data_base P = params.P i = P - 1 print("Searching the password corresponding to the hash : \n", my_hash, "\n") #*******start the search in the ranbow table*********** flag, returned_password = functions.check(my_hash, data_base) while i >= 0 and flag == False: j = i while j <= P: nom = functions.reduce_hash_to_pass(my_hash, j) my_hash = functions.sha256(nom) j += 1 flag, returned_password = functions.check(my_hash, data_base) i -= 1 #*******cherk the result of the search*********** if flag == True: print("Le mot de passe provient de : ", returned_password, " de la rainbow table, on applique : ", P - i + 1, " transformations de hachage et reduction") for j in range(i + 1): my_hash = functions.sha256(returned_password) returned_password = functions.reduce_hash_to_pass(my_hash, j) print("le mot de passe en clair est : ", returned_password) if flag == False: print("le mot de passe n existe pas dans notre base de donnée ") print("\tHEURE DE FIN ", functions.get_time(), "\n") print("***************FIN DE LA RECHERCHE.***************") print("\nMERCI D AVOIR UTILISE NOTRE APP !!!")
def __init__(self, pdb, inputs): self.pdb = os.path.abspath(pdb) self.abspath = os.path.abspath(pdb) partes = self.abspath.split("/") self.name = partes[-1][:-4] self.path = "/".join(partes[:-1] + ["", ]) self.original_lines = [] #check if pdb file exist!!! functions.check(self.pdb)
def home(): content = {'question':'','confidence':'','response_title':'','response_content':''} content['infected_count'] = functions.getInfectedCount() content['recovered_count'] = functions.getCuredCount() content['death_count'] = functions.getDeathCount() content['mortality_rate'] = functions.getMortalityRate() content['recovery_rate'] = functions.getRecoveryRate() if request.method == 'POST': question = request.form['question'] #get question from form print(question) content['question'] = question question = functions.check(question) print('corrected question: ' + question) qtn = vectorizer.transform([question]) #transform to a vector qtn = qtn.toarray() #transform to array prediction = virtual_agent_model.predict(qtn) print("confidence: " + str(np.amax(prediction[0]))) content['confidence'] = str(np.amax(prediction[0])) print(responses.class_names[np.argmax(prediction[0])]) content['response_title'] = responses.class_names[np.argmax(prediction[0])] content['response_content'] = responses.class_responses[np.argmax(prediction[0])] return render_template('index.html', content=content)
async def clear(self, ctx, amount=100, member: discord.Member=None): if not functions.check(ctx, "admin", "clear"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `admin.clear`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) if amount > 1000: return await ctx.send("Limit to `1000`") def check(m): return m.author == member if member: await ctx.message.delete() try: await ctx.channel.purge(limit=amount, check=check) except discord.Forbidden: return await ctx.send("Bot nie ma uprawnień") return await ctx.send(f"Usunięto `{amount}` wiadomości użytkownika `{member.name}`.", delete_after=5) try: await ctx.channel.purge(limit=amount + 1) except discord.Forbidden: return await ctx.send("Bot nie ma uprawnień") await ctx.send(f"Usunięto `{amount}` wiadomości.", delete_after=5)
async def serverinfo(self, ctx): if not functions.check(ctx, "admin", "serverinfo"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `admin.serverinfo`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) b = 0 for member in ctx.guild.members: if member.bot: b += 1 osoby = len(ctx.guild.members) - b time = str(ctx.message.guild.created_at).split(" ")[0] embed = discord.Embed( colour = discord.Colour.red() ) embed.set_author(name=f'Informacje o serwerze {ctx.guild}') embed.add_field(name='Właściciel:', value=f'{ctx.guild.owner.mention} ({ctx.guild.owner.id})', inline=False) embed.add_field(name='ID Serwera:', value=ctx.message.guild.id, inline=False) embed.add_field(name='Ilość osób:', value=osoby, inline=False) embed.add_field(name='Ilość botów:', value=b, inline=False) embed.add_field(name='Ilość kanałów:', value=len(ctx.guild.channels), inline=False) embed.add_field(name='Ilość ról:', value=len(ctx.guild.roles), inline=False) embed.add_field(name='Ilość emotek:', value=len(ctx.guild.emojis), inline=False) embed.set_thumbnail(url=ctx.guild.icon_url) embed.set_footer(text=f'Serwer został stworzony dnia {time}') await ctx.send(embed=embed)
async def leavemsg(self, ctx, channel: discord.TextChannel, *, arg): if not functions.check(ctx, "admin", "set"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `admin.set`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) with open("bay.json", "r") as f: w = json.load(f) if not str(ctx.guild.id) in w: w[str(ctx.guild.id)] = ctx.guild.id w[str(ctx.guild.id)] = {} if not str(channel.id) in w: w[str(ctx.guild.id)]['channel'] = channel.id w[str(ctx.guild.id)]['msg'] = arg w[str(ctx.guild.id)] = ctx.guild.id w[str(ctx.guild.id)] = {} w[str(ctx.guild.id)]['channel'] = channel.id w[str(ctx.guild.id)]['msg'] = arg with open("bay.json", "w") as f: json.dump(w, f, indent=4) await ctx.send(f"Ustawiono `{arg}` jako wiadomość pożegnalna na kanał {channel.mention}.")
async def achievement(self, ctx, *, arg): if not functions.check(ctx, "fun", "achievement"): e = discord.Embed( title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.achievement`", color=discord.Color.red()) e.set_footer( text= "Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)" ) return await ctx.send(embed=e) if len(arg) > 23: return await ctx.send( "Wiadomość przekroczyła limit znaków (`limit 23`)") async with ctx.typing(): arg = arg.replace(" ", "+").replace("ś", "s").replace( "ę", "e").replace("ż", "z").replace("ź", "z").replace( "ł", "l").replace("ó", "o").replace("ą", "a").replace( "ć", "c").replace("Ś", "S").replace("Ę", "E").replace( "Ż", "Z").replace("Ź", "Z").replace("Ł", "L").replace( "Ó", "O").replace("Ą", "A").replace("Ć", "C") img = requests.get( f"https://minecraftskinstealer.com/achievement/{random.randint(1, 40)}/Achievement+Get%21/{arg}" ).content open("achievement.png", "wb").write(img) await ctx.send(file=File("achievement.png")) os.remove("achievement.png")
async def levels(self, ctx): if not functions.check(ctx, "level", "levels"): e = discord.Embed( title="Nie masz uprawnień", description="Nie posiadasz uprawnień `level.levels`", color=discord.Color.red()) e.set_footer( text= "Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)" ) return await ctx.send(embed=e) with open("osoby.json", "r") as f: lvl = json.load(f) e = discord.Embed( title="Levele:", description="\n".join([ f"{m.name} : `{lvl[str(ctx.guild.id)][str(m.id)]['level']}` (`{lvl[str(ctx.guild.id)][str(m.id)]['exp']}` / `{lvl[str(ctx.guild.id)][str(m.id)]['level'] * 125}`)" for m in [ self.bot.get_user(int(m)) for m in lvl[str(ctx.guild.id)] if lvl[str(ctx.guild.id)][m]["level"] > 1 if m in [str(i.id) for i in ctx.guild.members] ] ]), color=discord.Color.red()) await ctx.send(embed=e)
async def level(self, ctx, member: discord.Member = None): if not functions.check(ctx, "level", "level"): e = discord.Embed( title="Nie masz uprawnień", description="Nie posiadasz uprawnień `level.level`", color=discord.Color.red()) e.set_footer( text= "Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)" ) return await ctx.send(embed=e) if not member: member = ctx.author with open("osoby.json", "r") as f: lvl = json.load(f) exp = lvl[str(ctx.guild.id)][str(member.id)]["exp"] level = lvl[str(ctx.guild.id)][str(member.id)]["level"] with open("profil.json", "r") as f: glvl = json.load(f) gexp = glvl[str(member.id)]["global_levels"]["exp"] glevel = glvl[str(member.id)]["global_levels"]["level"] e = discord.Embed( title=f"Levele użytkownika {member.name}:", description= f"**Serwerowy level:**\nLevel: `{level}`\nExp: `{exp}` / `{level * 125}`\n\n**Globalny level:**\nLevel: `{glevel}`\nExp: `{gexp}` / `{glevel * 125}`", color=discord.Color.red()) e.set_thumbnail(url=str(member.avatar_url)) await ctx.send(embed=e)
def postdata(): global cursor if request.method == 'POST': try: data = request.get_json(force = True) except Exception as e: return"Enter correctly formatted json\n" if(check(data)): db.employee.insert_one(data)#insertion top mongodb id1=data["Id"] name=data["Name"] dept=data["Department"] des=data["Designation"] sal=data["Salary"] try: cursor.execute("insert into employee values(%s,%s,%s,%s,%s)",(id1,name,dept,sal,des,)) connection.commit() except Exception as err: print(err) deldict = {} deldict["Id"] = id1 db.employee.delete_one(deldict) return str(err)+"\n" return "Pushed Data succesfully\n" else: return "Enter data related to the employee collection\n"
def blog(): #variables que se usan en la página context = {'title': 'Blog'} chain = dbconfig.db_users.Main.find({}) message = "" #si se hace submit se ejecuta el siguiente código if request.method == 'POST': if 'guardar' in request.form: col = [] counter = 0 for x in users: col.append(str(x.username)) # col=['francisco','adrian','melissa','joshua','victor','main'] n = dbconfig.db_users.Main.count() if n > 0: collection = dbconfig.db_users.Main ahash = "" cursor = collection.find({'_id': n - 1}, {'hash': 1}) for x in cursor: ahash = x['hash'] mensaje = request.form.get('mensaje') hs_non = functions.hashear(mensaje + ahash) now = datetime.now() tiempo = now.strftime("%H:%M:%S") user = g.user.username for x in col: dbconfig.db_users[x].insert_one({ '_id': n, 'usuario': user, 'hora': tiempo, 'hash': hs_non[0], 'nonce': hs_non[1], 'ahash': ahash, 'mensaje': mensaje }) else: mensaje = request.form.get('mensaje') hs_non = functions.hashear(mensaje) now = datetime.now() tiempo = now.strftime("%H:%M:%S") user = g.user.username for x in col: dbconfig.db_users[x].insert_one({ '_id': n, 'usuario': user, 'hora': tiempo, 'hash': hs_non[0], 'nonce': hs_non[1], 'mensaje': mensaje }) elif 'check' in request.form: uchain = dbconfig.db_users[g.user.username].find({}) message = functions.check(chain, uchain) chain = uchain #template que se va usar y variables que va a usar return render_template('home.html', **context, blockchain=chain, mensaje=message)
async def ascii(self, ctx, *, arg): if not functions.check(ctx, "fun", "ascii"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.ascii`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) await ctx.send("```" + Figlet().renderText(arg) + "```")
async def _add(self, ctx, cmd: str, *, arg): if not functions.check(ctx, "inne", "cmd"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `inne.cmd`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje d o różnych ról (komenda perm)") return await ctx.send(embed=e) with open("customcmd.json", "r") as f: c = json.load(f) if not str(ctx.guild.id) in c: c[str(ctx.guild.id)] = {} if not cmd in c: c[str(ctx.guild.id)][cmd] = {} c[str(ctx.guild.id)][cmd]['komenda'] = cmd c[str(ctx.guild.id)][cmd]['msg'] = arg c[str(ctx.guild.id)][cmd]['author_name'] = str(ctx.author) c[str(ctx.guild.id)][cmd]['author_id'] = str(ctx.author.id) c[str(ctx.guild.id)][cmd]['komenda'] = cmd c[str(ctx.guild.id)][cmd]['msg'] = arg c[str(ctx.guild.id)][cmd]['author_name'] = str(ctx.author) c[str(ctx.guild.id)][cmd]['author_id'] = str(ctx.author.id) with open("customcmd.json","w") as f: json.dump(c, f, indent=4) await ctx.send("Dodano komende.")
def home(): content = {'question':'','confidence':'','response_title':'','response_content':''} data = functions.getData() content['infected_count'] = data['infected'] content['recovered_count'] = data['recovered'] content['death_count'] = data['deaths'] content['death_rate'] = data['death_rate'] content['recovery_rate'] = data['recovery_rate'] content['datetime'] = data['datetime'] if request.method == 'POST': question = request.form['question'] #get question from form print(question) content['question'] = question question = functions.check(question) print('corrected question: ' + question) qtn = vectorizer.transform([question]) #transform to a vector qtn = qtn.toarray() #transform to array prediction = virtual_agent_model.predict(qtn) print(responses.class_names[np.argmax(prediction[0])]) content['response_title'] = responses.class_names[prediction[0]] content['response_content'] = responses.class_responses[prediction[0]] return render_template('index.html', content=content)
async def love(self, ctx, m: discord.User, me: discord.User=None): if not functions.check(ctx, "fun", "love"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.love`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) los = random.randint(0,100) me = me or ctx.author los = random.randint(0, 100) async with ctx.typing(): open("member1.png", "wb").write(requests.get(m.avatar_url).content) open("member2.png", "wb").write(requests.get(me.avatar_url).content) para = Image.open("para.png") member1 = Image.open("member1.png") member2 = Image.open("member2.png") member1.thumbnail((300, 300)) member2.thumbnail((300, 300)) para.paste(member1, (360, 250)) para.paste(member2, (890, 180)) para.save("ship.png") await ctx.send(f"**{m.name}** + **{me.name}** = **{m.name[:round(len(m.name) / 2)].lower()}{me.name[round(len(me.name) / 2):].lower()}**\nIch miłość jest równa **{los}%**!", file=discord.File("ship.png")) os.remove("member1.png") os.remove("member2.png") os.remove("ship.png")
async def _8ball(self, ctx, *, arg): if not functions.check(ctx, "fun", "8ball"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.8ball`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) answer = random.choice("Tak, Nie, Możliwe że tak, Możliwe że nie, Możliwe lecz nie wiem, Raczej tak, Raczej nie, Oczywiście że tak, Oczywiście że nie, Na pewno tak, Na pewno nie".split(", ")) await ctx.send(f":8ball: | **{answer}**")
async def rnumber(self, ctx, a: int, b: int): if not functions.check(ctx, "fun", "rnumber"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.rnumber`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) los = random.randint(a, b) await ctx.send(los)
async def coinflip(self, ctx): if not functions.check(ctx, "fun", "coinflip"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.coinflip`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) choices = ["Orzeł", "Reszka"] los = random.choice(choices) await ctx.send(los)
async def howgay(self, ctx, member: discord.User=None): if not functions.check(ctx, "fun", "howgay"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.howgay`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) member = member or ctx.author await ctx.send(f"{member.name} jest gejem w {random.randint(0, 100)}%!")
def run(self): response = functions.booking(s=self.session, date=self.dic['date'], seat=self.dic['seat'], start=self.dic['start'], end=self.dic['end']) state, target = functions.check(response) self.signal.emit(state, target) while (1): response = functions.booking(s=self.session, date=self.dic['date'], seat=self.dic['seat'], start=self.dic['start'], end=self.dic['end']) state, target = functions.check(response) if (state == 1): self.signal.emit(state, target) break
async def cleverbot(self, ctx, *, arg): if not functions.check(ctx, "fun", "cleverbot"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.cleverbot`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) cb = ac.Cleverbot(config.cleverbot) async with ctx.typing(): response = await cb.ask(arg) await ctx.send(response.text)
async def cmd(self, ctx): if not functions.check(ctx, "inne", "cmd"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `inne.cmd`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) e=discord.Embed(title="Komendy cmd:", description="> `cmd add (nazwa komendy) (tekst)`, `cmd remove (nazwa komendy)`, `cmd info (nazwa komendy)`, `cmd list`", color=discord.Color.red()) e.set_footer(text="<> = nazwa użytkownika, [] = wzmianka") await ctx.send(embed=e)
async def set(self, ctx): if not functions.check(ctx, "admin", "set"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `admin.set`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) e = discord.Embed(title="Komendy set:", description="> `set prefix (prefix)`, `set welcomemsg (kanał) (wiadomość)`, `set offwelcomemsg`, `set leavemsg (kanał) (wiadomość)`, `set offleavemsg`, `set autorole (rola)`, `set offautorole`, `set offbadwords`, `set onbadwords`, `set offinvites`, `set oninvites`, `set cleverbot (kanał)`, `set offcleverbot`", colour=discord.Colour.red()) e.set_footer(text="<> = nick osoby, [] = wzmianka, {} = licznik osób") await ctx.send(embed=e)
def send_user_his_message(message): if check(message.chat.username): msg = bot.send_message(message.chat.id, send(message), reply_markup=markups.my_message_markup) bot.register_next_step_handler(msg, process_my_message) else: bot.send_message( message.chat.id, "У вас ещё не созданного сообщения. Для того, чтобы его создать введите " "\"Добавить сообщение\".")
async def rchoice(self, ctx, *, arg): if not functions.check(ctx, "fun", "rchoice"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.rchoice`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) wybory = arg.split(" | ") los = random.choice(wybory) e = discord.Embed(description=los, color=discord.Color.red()) e.set_footer(text=f"Wywołane przez {ctx.author.id}") await ctx.send(embed=e)
async def servericon(self, ctx): if not functions.check(ctx, "fun", "servericon"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.servericon`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) async with ctx.typing(): icon = requests.get(f"{ctx.author.guild.icon_url}?height=100&width=100").content open("icon.png", "wb").write(icon) await ctx.send(file=File("icon.png")) os.remove("icon.png")
def create_new_message(message): if not check(message.chat.username): msg = bot.send_message( message.chat.id, "Пожалуйста, введите сообщение, которое вы хотите добавить.") bot.register_next_step_handler(msg, process_create_new_message) else: bot.send_message( message.chat.id, "У вас уже создано сообщение. Для просмотра его статистики наберите \"Моё сообщение\"." )
async def hug(self, ctx, member: discord.User): if not functions.check(ctx, "fun", "hug"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `fun.hug`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) async with ctx.typing(): img1 = requests.get("https://nekos.life/api/hug").json() img2 = requests.get(img1["url"]).content open("hug.gif", "wb").write(img2) await ctx.send(f"**{ctx.author.name}** przytulił **{member.name}**!", file=File("hug.gif")) os.remove("hug.gif")
async def warns(self, ctx, member: discord.Member=None): if not functions.check(ctx, "admin", "warns"): e = discord.Embed(title="Nie masz uprawnień", description="Nie posiadasz uprawnień `admin.warns`", color=discord.Color.red()) e.set_footer(text="Uprawnienie administratora może edytować permisje do różnych ról (komenda perm)") return await ctx.send(embed=e) member = member or ctx.author with open("warns.json", "r") as f: warns = json.load(f) e = discord.Embed(title=f"Warny użytkownika {member.name}:", description="\n".join([f"{warn}. {warns[str(ctx.guild.id)][str(member.id)][warn]}" for warn in warns[str(ctx.guild.id)][str(member.id)]]), color=discord.Color.red()) await ctx.send(embed=e)
def register(): if request.method=="GET": return render_template('register.html', message = "",logged=None) button = request.form["b"] if button == "Register": password = request.form["password"] confirm = request.form["confirm_password"] username = request.form["username"] name = request.form["name"] if password=="" or confirm=="" or username=="" or name=="": return render_template('register.html', message = "Please complete all fields.",logged=None) if (password != confirm): return render_template('register.html', message = "Passwords don't match.", logged=None) if functions.check(username): return render_template('register.html', message = "Sorry, that username is already taken.",logged=None) functions.add_user(username, name, password) session['username']=username session['name']=name return redirect('home')
superposition_pairs = [] # list of PDB objects pairs that must be superposed # if -l flag is given, then we use superposition pairs given in the file if inputs.superpositions_list: functions.add_superposition_pairs(inputs, superposition_pairs) else: # if not, then use pdb1 and pdb2 superposition_pairs.append((PDB.PDB(inputs.pdb1, inputs), PDB.PDB(inputs.pdb2, inputs))) results = [] # first we generate all modfiles for mobile, target in superposition_pairs: if functions.check(mobile.pdb) and functions.check(target.pdb): # creating modified pdb files according the table # functions.modifyPDBAtoms(flags, mobile, inputs.d_table, inputs.d_pdbResnumTable) # functions.modifyPDBAtoms(flags, target, inputs.d_table, inputs.d_pdbResnumTable) mobile.modifyPDBAtoms(inputs) target.modifyPDBAtoms(inputs) # functions.modifyPDBAtoms2(inputs, mobile, fullpdb=None, pdbname=None,) # functions.modifyPDBAtoms2(inputs, target, fullpdb=None, pdbname=None,) # if -p flag is given then try parallel python if inputs.p: # with this flag we try to run parallel python try: import pp except: print "No pp module in python library\n"
def __saveAndCheckInputs(self, args): """With this function we iterate for all args and saves the inputs""" # creating inputs object # inputs = Inputs() # superposition_pairs = [] # list of all superposition pairs par = [] # var use for save pdb inputs # first iterate fdor all argv and recopilate flag information for j, i in enumerate(args): # save pdf file if exist if i.strip()[-4:] == '.pdb': if self.pdb1 == None: self.pdb1 = i.strip() # par.append(i.strip()) else: self.pdb2 = i.strip() # checking parameters file if i.strip() == '-i': try: self.i = True self.parameters = args[j + 1] except: print "No Parameters file indicated" errorSentence() # checking table file if i.strip() == '-t': try: self.tablefile = args[j + 1] except: print "No table file indicated" errorSentence() # checking pdb_resnum_table if i.strip() == '-f': try: self.f = True self.pdb_resnum_table = args[j + 1] except: print "No PDB_resnum_table file indicated" errorSentence() # checking superposition list if i.strip() == '-l': try: self.superpositions_list = args[j + 1] except: print "No superpositions list file indicated" errorSentence() # checking parallel python nCPUs if i.strip() == '-p': self.p = True try: if args[j + 1].isdigit(): self.numCPUs = int(args[j + 1]) except: pass # checking if output file name is given if i.strip() == '-o': try: self.o = True self.output = args[j + 1].strip() except: pass # check -s flag. If true, click runs with -s flag if i.strip() == '-s': self.s = True # check -m flag. If true, mantains *.clique file if i.strip() == '-m': self.m = True # cheking if the files exists if not len(par) in (0, 2): print "two pdf files are necessary as minimum or a list of superposition pairs." errorSentence() # if par and par[0] and par[1]: if self.pdb1 and self.pdb2: # if user gives two pdb files if not functions.check(self.pdb1): print "%s does'n exist, please try a real pdb file." % self.pdb1 errorSentence() if not functions.check(self.pdb2): print "%s does'n exist, please try a real pdb file." % self.pdb2 errorSentence() else: # if no list of superposition is given if not '-l' in args: print "Click needs two pdb files." errorSentence() # if check if not functions.check(self.parameters): print "%s does'n exist, please try a real parameters file." % self.parameters errorSentence() if not self.tablefile: print "modclick needs a table file." errorSentence() else: if not functions.check(self.tablefile): print "%s does'n exist, please try a real table file." % self.tablefile errorSentence() if not functions.check(self.pdb_resnum_table_file): print "%s does'n exist, please try a real PDB_resnum_table file." % self.pdb_resnum_table_file errorSentence() # checking superpsition list file if not functions.check(self.superpositions_list): print "%s does'n exist, please try a real superposition list." % self.superpositions_list errorSentence() # checking Parameters.inp file if not functions.check("Parameters.inp"): print "Parameters.inp does'n exist." sys.exit(1)
def quartett(): #Deckerstellung deck = create_deck() #KI-Hilfskomponenten ki_comparelist = deck.copy() #Ausführung des Programms #Namen und Anzahl der Spieler rl_namelist = [] cp_namelist = [] full_namelist = [] num_rl = ask_num_rl() num_cp = ask_num_cp(num_rl) num_full = num_rl + num_cp quartett_counter = [] for i in range(num_rl): rl_namequestion = "Wie heißt Spieler "+str(i+1)+"? " rl_name_temp = restart(input(rl_namequestion)) while rl_name_temp == " ": rl_name_temp = restart(input("Keine gültige Eingabe! Bitte geben Sie einen Namen ein: ")) while rl_name_temp in rl_namelist: rl_name_temp = restart(input("Der Spielername ist vergeben! Bitte wähle einen anderen Namen: ")) rl_namelist.append(rl_name_temp) full_namelist.append(rl_name_temp) for i in range(num_cp): cp_name_temp = "CP"+str(i+1) cp_namelist.append(cp_name_temp) full_namelist.append(cp_name_temp) horizont() print("Spielteilnehmer:") for i in range(len(full_namelist)): print(full_namelist[i]) for i in range(num_full): quartett_counter.append([]) #Verteilen der Karten hands = [] for i in range(num_full): hands.append([]) if num_full == 2: for i in range(2): for j in range(10): curr_card = deck[randint(0,len(deck) - 1)] deck.remove(curr_card) hands[i-1].append(curr_card) else: curr_player_index = 0 while len(deck) > 0: curr_card = deck[randint(0,len(deck) - 1)] deck.remove(curr_card) hands[curr_player_index].append(curr_card) curr_player_index += 1 if curr_player_index == num_full: curr_player_index = 0 else: pass #Spielablauf curr_index = 0 game = 0 horizont() print("Das Spiel fängt an!") horizont() while game == 0: curr_name = full_namelist[curr_index] curr_hand = sort_cards(hands[curr_index]) print(curr_name,"ist dran!") restart(input("Drücke eine Taste um fortzufahren.")) if curr_name in rl_namelist: clear() horizont() print("Deine Hand:", print_cards(curr_hand)) curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) game += win(hands, full_namelist, quartett_counter) while game == 0: if num_full == 2: enemy_index = curr_index + 1 if enemy_index == 2: enemy_index = 0 for i in range(len(hands)): print(full_namelist[i],"hat",len(hands[i]),"Karten und", len(quartett_counter[i]) // 4, "Quartetten.") else: enemy_index = ask_enemy(curr_name, full_namelist, hands, quartett_counter) enemy_hand = hands[enemy_index] wished_card = ask_card() wished_card = check(wished_card, enemy_hand) if wished_card == 0: if len(deck) > 0: card_draw = deck.pop() curr_hand.append(card_draw) print("Du hast",print_cards([card_draw]),"gezogen.") curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) game += win(hands, full_namelist, quartett_counter) break else: curr_hand.append(wished_card) enemy_hand.remove(wished_card) curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) game += win(hands, full_namelist, quartett_counter) if game != 0: break horizont() print("Deine Hand:", print_cards(sort_cards(curr_hand))) if game != 0: break input("Drücke eine Taste um Zug zu beenden.") clear() else: horizont() curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) win(hands, full_namelist, quartett_counter) if num_full == 2: enemy_index = curr_index + 1 if enemy_index == 2: enemy_index = 0 else: enemy_index = ask_enemy_cp(full_namelist, hands) enemy_hand = hands[enemy_index] enemy_name = full_namelist[enemy_index] while game == 0: wished_card = check_cp(curr_name, curr_hand, enemy_name, enemy_hand) if wished_card == 0: if len(deck) > 0: card_draw = deck.pop() curr_hand.append(card_draw) print(curr_name, "hat eine Karte gezogen.") curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) game += win(hands, full_namelist, quartett_counter) break else: curr_hand.append(wished_card) enemy_hand.remove(wished_card) curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter) game += win(hands, full_namelist, quartett_counter) if game != 0: break if game != 0: break curr_index += 1 if curr_index == len(full_namelist): curr_index = 0