All pastes #1567293 Raw Edit

Something

public python v1 · immutable
#1567293 ·published 2009-09-15 18:03 UTC
rendered paste body
# encoding: UTF-8from Tkinter import *import random, array, re, tkFontclass GeneratedDialog(Frame):	def __init__(self, beznotext, master=None):		Frame.__init__(self, master)		self.pack()		self.createWidgets(beznotext)		def createWidgets(self, beznotext):		self.label = Label(self, text="БЕЗН0ГNЙ Т3КСТ")		self.text = Message(self, text=beznotext)				self.label.pack({"side": "top"})		self.text.pack({"side": "bottom"})	class MainApplication(Frame):	def beznogify(self, x):		xynta = {}		xynta['xyntas'] = {}		xynta['items'] = ("chgletts", "inswords", "supwends", "symlower", "text")		for xynta['item'] in xynta['items']:			try:				xynta['xyntas'][xynta['item']] = x[xynta['item']]			except KeyError:				xynta['xyntas'][xynta['item']] = ""				rand = {}		rand['items'] = ("chgletts", "inswords", "supwends", "symlower")		rand['chgletts'] = (			{'a':'rb','b':6,'c':re.compile(u'Б'),'d': u'6'},			{'a':'gf','b':7,'c':re.compile(u'Г'),'d': u'F'},			{'a':'d' ,'b':4,'c':re.compile(u'Д'),'d': u'D'},			{'a':'e' ,'b':5,'c':re.compile(u'Е'),'d': u'3'},			{'a':'tz','b':7,'c':re.compile(u'З'),'d': u'Z'},			{'a':'rn','b':4,'c':re.compile(u'N'),'d': u'И'},			{'a':'n' ,'b':4,'c':re.compile(u'И'),'d': u'N'},			{'a':'ll','b':5,'c':re.compile(u'Л'),'d': u'L'},			{'a':'m' ,'b':7,'c':re.compile(u'М'),'d': u'W'},			{'a':'on','b':5,'c':re.compile(u'О'),'d': u'0'},			{'a':'ss','b':6,'c':re.compile(u'С'),'d': u'S'},			{'a':'y' ,'b':4,'c':re.compile(u'У'),'d': u'Y'},			{'a':'b' ,'b':6,'c':re.compile(u'Ь'),'d': u'Б'},			{'a':'bl','b':5,'c':re.compile(u'Ы'),'d':u'bl'},			{'a':'yu','b':6,'c':re.compile(u'Ю'),'d':u'IO'},			{'a':'r' ,'b':4,'c':re.compile(u'R'),'d': u'Я'},			{'a':'ya','b':4,'c':re.compile(u'Я'),'d': u'R'}		)		rand['inswords'] = (			{'a':'dosmot'  ,'b':25,'c':  u'ДОСМОТ'},			{'a':'ruki'    ,'b':26,'c':    u'РУКИ'},			{'a':'beznognm','b':28,'c':u'БЕЗНОГИМ'},		)		rand['supwends'] = (			{'a':'swoie'  ,'b':5,'c':    re.compile(u'О(Й|Е|И)$'),'d':'?'},			{'a':'swutb'  ,'b':7,'c':  re.compile(u'(У|Ю|И)ТЬ?$'),'d':'?'},			{'a':'swiaei' ,'b':8,'c':  re.compile(u'И(Я|Е|И|Й)$'),'d':'?'},			{'a':'swtsat' ,'b':6,'c':    re.compile(u'Т(Ь?CЯ)?$'),'d':'?'},			{'a':'sweogo' ,'b':5,'c':     re.compile(u'(Е|О)ГО$'),'d':'?'},			{'a':'swaeitm','b':6,'c':re.compile(u'(А|Е|И)(Т|М)$'),'d':'?'}		)		rand['symlower'] = (			{'a':'atlr' ,'b':5,'c':re.compile(u'А'),'d':u'а'},			{'a':'otlr' ,'b':6,'c':re.compile(u'О'),'d':u'о'},			{'a':'utlr' ,'b':8,'c':re.compile(u'У'),'d':u'у'},			{'a':'stlr' ,'b':7,'c':re.compile(u'С'),'d':u'с'},			{'a':'ttlr' ,'b':5,'c':re.compile(u'Т'),'d':u'т'},			{'a':'yutlr','b':6,'c':re.compile(u'Ю'),'d':u'ю'}		)		for rand['item'] in rand['items']:			for xyn in rand[rand['item']]:				rand[xyn['a']+"s"] = random.randrange(1, xyn['b'])				rand[xyn['a']] = 1				qarray = xynta['xyntas']['text'].upper().split(" ")		qout = u""		for qstring in qarray:			if (xynta['xyntas']['inswords'] == 'checked'):				for xyn in rand['inswords']:					if (rand[xyn['a']] == xyn['b']+1):						rand[xyn['a']] = 1					if (rand[xyn['a']] == rand[xyn['a']+"s"]):						qstring += u" "+xyn['c']					rand[xyn['a']] += 1			for xynx in ("supwends", "chgletts", "symlower"):				if (xynta['xyntas'][xynx] == 'checked'):					for xyn in rand[xynx]:						if (rand[xyn['a']] == xyn['b']+1):							rand[xyn['a']] = 1						if (rand[xyn['a']] == rand[xyn['a']+"s"]):							qstring = xyn['c'].sub(xyn['d'], qstring)						rand[xyn['a']] += 1			qout += qstring+u" "				return qout		def __init__(self, master=None):		Frame.__init__(self, master)		self.pack()		self.createWidgets()		def createBeznognm(self):		beznotext = self.beznogify({			"text": self.text.get("@0,0", "end"),			"chgletts": "checked",#self.chgletts["value"],			"inswords": "checked",#self.inswords["value"],			"supwends": "checked",#self.supwends["value"],			"symlower": "checked",#self.symlower["value"]		})		f_out = Tk()		beznoout = GeneratedDialog(beznotext, master=f_out)		beznoout.master.title("БЕЗН0ГNМ-генератор, результат генерации")		beznoout.mainloop()		def createWidgets(self):		self.text = Text(self, width=100, height=40)				self.generate = Button(self, text="ДОСМ0Т!", command=self.createBeznognm)		self.generate['font'] = tkFont.Font(family="Helvetica")				self.text.pack({"side": "top"})		self.generate.pack({"side": "bottom"})	f_in = Tk()app = MainApplication(master=f_in)app.master.title("БЕЗН0ГNМ-генератор")app.mainloop()