def get_note(id): note = Note() note_body = note.get_note(id) name = note_body["name"] body = note_body["body"] publishAt = note_body["publish_at"] publishAt = re.sub("-", "/", publishAt) eyecatch = note_body["eyecatch"] style = """<style type = "text/css" >.nav-item >a{color:#252525;} .nav-item>a:after{background-color:#252525;} </style>""" return render_template('note_body.html', name=name, body=body, publishAt=publishAt, eyecatch=eyecatch, style=style)
def test_note_get_note(self): name = '123' note = 3.5 test_object = Note(name, note) self.assertEqual(test_object.get_note(), note)
class MainScreen(Screen, WikikIRC): """Ecran principal""" info = StringProperty() volume = NumericProperty(1.0) f_size = NumericProperty(18) #36) def __init__(self, **kwargs): Screen.__init__(self, **kwargs) WikikIRC.__init__(self) self.info = "Patience et longueur de temps font plus que force ni que rage !" self.f_size = 18 #36 # Chargement des sons self.notes = {} for i in range(36): self.notes[i] = SoundLoader.load('./samples/' + str(i) + '.ogg') # Rafraichissement du jeu tempo = 0.03 self.event = Clock.schedule_interval(self.wikirc_update, tempo) print("Initialisation de MainScreen ok") def wikirc_update(self, dt): # Pour nouvel info info_old = self.info # Sortie IRC try: wo = self.bot.wiki_out if 600 < len(wo) <= 1000: self.f_size = 14 #28 ln = 50 elif 1000 < len(wo) <= 1400: self.f_size = 12 #24 ln = 60 elif 1400 < len(wo) <= 1800: self.f_size = 10 #20 ln = 70 elif 1800 < len(wo): self.f_size = 9 #18 ln = 80 else: self.f_size = 18 #36 ln = 40 except: self.info = "Patience et longueur de temps font plus que force ni que rage !" self.info = textwrap.fill(wo, ln) # Si un nouvel info, donc une seule fois par info if self.info != info_old: self.phrase_note = Note(self.info) n = self.phrase_note.get_note() self.volume = self.phrase_note.get_volume() if n: self.sound(n) def sound(self, n): """Joue la note n""" self.notes[n].volume = self.volume self.notes[n].play() def get_sm(self): return WikikircAndroidApp.get_running_app().sm