def KeepGetNotes(searchWords=None, labels=None, archived=None, trashed=False, colors=None, pinned=None): notes = [] for gnote in gkeep.find(query=searchWords, labels=labels, colors=colors, pinned=pinned, archived=archived, trashed=trashed): note = Note(title=gnote.title, text=gnote.text, id=gnote.server_id) notes.append(note) return notes
def select_note_by_id(note_id: int, table: str = "Notes") \ -> Optional[Note]: try: c.execute("SELECT * FROM {} WHERE noteID = {}".format( table, note_id)) got: Tuple[int, str, int, date, str] = c.fetchone() if got is None: print("Table '{}' doesnt contain a record with id {}!".format( table, note_id)) return c.execute("SELECT * FROM Users where userID = {}".format(got[2])) user_got = c.fetchone() usr = User(user_got[1], user_got[2]) return Note(got[1], usr, got[3], got[4]) except ProgrammingError: print("Selection failed due to unknown error!") return
def __setitem__(self, item, value): """Enable the use of the [] notation on NoteContainers. This function accepts Notes and notes as string. Example: >>> n = NoteContainer(['C', 'E', 'G']) >>> n[0] = 'B' >>> n ['B-4', 'E-4', 'G-4'] """ if type(value) == str: n = Note(value) self.notes[item] = n else: self.notes[item] = value return self.notes
def read_pattern(bank_letter, pad_number): hex_data = get_hex_character_row_representation(bank_letter, pad_number) note_list = hex_data[:-2] pattern_length = int(str(hex_data[-1][2] + hex_data[-1][3]), base=16) pattern = Pattern(pattern_length) current_time = 0 for chunk_index, note in enumerate(note_list): #if str(note[2] + note[3]) != '80' or len(pattern.notes) == 0: if str(note[2] + note[3]) != '80': ticks_till_next_note = int(str(note[0] + note[1]), 16) velocity = int(str(note[8] + note[9]), 16) length_ticks = int(str(note[12] + note[13] + note[14] + note[15]), 16) pad, bank = gen_pad_bank(pad_code=str(note[2] + note[3]), bank_switch=note[5]) pattern.add_note(Note(bank=bank, pad=pad, velocity=velocity, length=length_ticks, start_tick=current_time)) current_time += ticks_till_next_note return pattern
def getAllNotes(self): self.connect() ret = self.cursor.execute("select * from %s" % self.mdTable) notes = [] for line in ret: name = line[0] filepath = line[1] mtime = line[2] ctime = line[3] atime = line[4] md5code = line[5] pdfpath = line[6] tags = parseStrSetString(line[7]) note = Note(name, filepath, mtime, ctime, atime, md5code, pdfpath, tags) notes.append(note) return notes
def open_event(self, row): if self.tableWidget.item(row, 0).text() not in self.notes_titles: if self.tableWidget.item(row, 1).text() == 'текстовая': self.note = Note() with open(r'texts\{}.txt'.format( self.tableWidget.item(row, 0).text()), mode='r', encoding='utf8') as file: self.note.plainTextEdit.setPlainText(file.read()) else: self.note = DrawNotepad() self.note.canvas_heart.setPixmap( QPixmap.fromImage( QImage(r'pictures\{}'.format( self.tableWidget.item(row, 0).text())))) self.note.setWindowTitle(self.tableWidget.item(row, 0).text()) self.notepad_final_step()
def __init__(self, SCALE): NOTES, FREQ_DICT = SCALE self.note = Note(NOTES, FREQ_DICT) self.rhythm = Rhythm() self.dynamics = Dynamics() self.equalizerFactor = {} self.equalizerFactor[-0.1] = 1.0 self.equalizerFactor[220] = 1.0 self.equalizerFactor[440] = 0.7 self.equalizerFactor[880] = 0.35 self.equalizerFactor[1760] = 0.15 self.equalizerFactor[3520] = 0.15 self.equalizerFactor[7040] = 0.15 self.equalizerFactor[14080] = 0.15 self.equalizerFactor[28160] = 0.15 self.equalizerFactor[56320] = 0.15 self.equalizerBreakPoints = [ -0.1, 220, 440, 880, 1760, 3520, 7040, 14080, 28160, 56320 ]
def update_note(self, note_id, score=None, note_text=None, image_data=None, weight=None): _note = Note(note_id) _note.update(score=score, note_text=note_text, image_data=image_data, weight=weight) if weight != None: if int(weight) < 0: self.update_note_selection_info(note_id=note_id, selector_id=None, selected_time=None, post_time=None) self.__reset_note_info_to_cache()
def new_note(initial_text=None): directory = user_configurations['TIXPATH'] new_filename = generate_filename() new_filepath = os.path.join(directory, new_filename) if initial_text: with open(new_filepath, 'w') as f: f.write(initial_text) open_file_in_editor(new_filepath) if not os.path.exists(new_filepath): return None with open(new_filepath, 'r') as f: note_content = f.read() if note_content.strip() == "": return None n = Note(new_filename, directory, note_content) return n
def ReadNotes(db, notes, source): '''Read Notestore.sqlite''' cursor = db.execute( "SELECT name FROM sqlite_master WHERE type='table' AND name='Z_12NOTES'" ) if cursor.fetchone() is None: ReadNotesHighSierra(db, notes, source) return try: query = " SELECT n.Z_12FOLDERS as folder_id , n.Z_9NOTES as note_id, d.ZDATA as data, " \ " c2.ZTITLE2 as folder, c2.ZDATEFORLASTTITLEMODIFICATION as folder_title_modified, " \ " c1.ZCREATIONDATE as created, c1.ZMODIFICATIONDATE1 as modified, c1.ZSNIPPET as snippet, c1.ZTITLE1 as title, c1.ZACCOUNT2 as acc_id, " \ " c5.ZACCOUNTTYPE as acc_type, c5.ZIDENTIFIER as acc_identifier, c5.ZNAME as acc_name, " \ " c3.ZMEDIA as media_id, c3.ZFILESIZE as att_filesize, c3.ZMODIFICATIONDATE as att_modified, c3.ZPREVIEWUPDATEDATE as att_previewed, c3.ZTITLE as att_title, c3.ZTYPEUTI, c3.ZIDENTIFIER as att_uuid, " \ " c4.ZFILENAME, c4.ZIDENTIFIER as media_uuid " \ " FROM Z_12NOTES as n " \ " LEFT JOIN ZICNOTEDATA as d ON d.ZNOTE = n.Z_9NOTES " \ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c1 ON c1.Z_PK = n.Z_9NOTES " \ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c2 ON c2.Z_PK = n.Z_12FOLDERS " \ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c3 ON c3.ZNOTE = n.Z_9NOTES " \ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c4 ON c3.ZMEDIA = c4.Z_PK " \ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c5 ON c5.Z_PK = c1.ZACCOUNT2 " \ " ORDER BY note_id " db.row_factory = sqlite3.Row cursor = db.execute(query) for row in cursor: try: att_path = '' if row['media_id'] != None: att_path = row['ZFILENAME'] data = GetUncompressedData(row['data']) text_content = ProcessNoteBodyBlob(data) note = Note(row['note_id'], row['folder'], row['title'], row['snippet'], text_content, row['att_uuid'], att_path, row['acc_name'], row['acc_identifier'], '', ReadMacAbsoluteTime(row['created']), ReadMacAbsoluteTime(row['modified']), 'NoteStore', source) notes.append(note) except: log.exception('Error fetching row data') except: log.exception('Query execution failed. Query was: ' + query)
def get_rudiments(): fill = [] obj = Rudiments() arr = obj.get_random_rudim() str = "" for l in arr: str += l arr = str[:16] + (str[16:] and "") arr = list(arr) for i in arr: hit = Note(16, 'snare') hit.add_hand(i) fill.append(hit) snare = notation.get_string(fill) filename = get_lilypond_drum_file(snare, "") subprocess.call(['lilypond', '-dbackend=eps', '-dno-gs-load-fonts', \ '-dinclude-eps-fonts', '--pdf', filename]) image = convert_from_path('rhytm.pdf') image[0].save('rhytm.png')
def input(self, key): # if self.dragging or not held_keys['control']: # super().input(key) if self.hovered: if key == 'left mouse down': # self.stop_dragging() x = (mouse.point[0] / self.end_button.x) * self.scale_x / self.loops # adjust for clicking in a loop x -= math.floor(mouse.point[0] * self.loops) * ( self.end_button.x * self.scale_x) y = math.floor(mouse.point[1] * self.height) + self.scroll x = round_to_closest(x, 1 / 16) # print('place note', x,y) self.current_note = Note(x, y) self.notes.append(self.current_note) self.draw_notes() if key == 'left mouse up': self.current_note = None if key in ('arrow up', 'arrow up hold', 'scroll up'): self.scroll += self.scroll_speed if key in ('arrow down', 'arrow down hold', 'scroll down'): self.scroll -= self.scroll_speed if key == 'left mouse down': if not self.hovered and not held_keys['control']: self.selected = False else: self.selected = True NoteSection.overlay_parent.parent = self if self.hovered and key == 'right mouse down': NoteSection.right_click_menu.note_section = self NoteSection.right_click_menu.position = self.position NoteSection.radial_play_button.on_click = self.play NoteSection.radial_instrument_button.on_click = self.open_instrument_menu NoteSection.radial_destroy_button.on_click = Func(destroy, self) NoteSection.right_click_menu.enabled = True
def parse(self): # remove beginning part of score that provides playing information array = self.score[7:] # split at measure lines - ! symbols in the font measures = array.split("!") # loop over each measure for i in range(len(measures)): # split the measure into notes individual_notes = measures[i].split("=") # loop through all notes for j in range(len(individual_notes)): # make sure no whitespace escaped the filter if individual_notes[j] != "" and individual_notes[j] != "\n": # send the excerpt into the note class to parse input note = Note(individual_notes[j]) # append note to list for playback self.notes.append(note)
def convert_to_mininote(note_metadata, note): """ Convert Evernote note to Mininote note :param NoteMetadata note_metadata: note metadata :param Note note: full note or None if not available """ if note: content = decode_note_text(note.content) else: if (len(note_metadata.title) >= 2 and note_metadata.title.startswith('"') and note_metadata.title.endswith('"')): content = note_metadata.title[1:-1] else: content = note_metadata.title return Note(text=content, updated_time=note_metadata.updated / 1000, created_time=note_metadata.created / 1000, guid=note_metadata.guid)
def getNoteByName(self, name): self.connect() ret = self.cursor.execute("select * from %s where name='%s'" % (self.mdTable, name)) notes = [] for line in ret: name = line[0] filepath = line[1] mtime = line[2] ctime = line[3] atime = line[4] md5code = line[5] pdfpath = line[6] tags = parseStrSetString(line[7]) note = Note(name, filepath, mtime, ctime, atime, md5code, pdfpath, tags) notes.append(note) if not notes: return None return notes[0]
def startElement(self, tag, attributes): ''' Called when a new element is found ''' self.CurrentData = tag if tag == "en-export": # First tag found in .enex file print("\n####%s####" % (lang("_export_started"))) elif tag == "note": # New note found self.note = Note() self.note.set_path(current_file) elif tag == "data": # Found an attachment self.attachment = Attachment() self.attachment.set_path(current_file) self.attachment.set_created_date(self.note.get_created_date()) self.attachment.set_filename(self.note.get_title()) self.attachment.set_uuid(self.note.get_uuid()) elif tag == "note-attributes": self.in_note_attributes = True elif tag == "resource-attributes": self.in_resource_attributes = True
def delete_note(): id = request.args.get('arg') conn = sqlite3.connect('Notes.db') c = conn.cursor() c.execute("SELECT username FROM users WHERE cookie = (?)", (request.cookies.get("cookie")[0:36], )) conn.commit() l = c.fetchall() usr = l[0][0] c.execute("DELETE FROM notes WHERE id = (?)", (id, )) conn.commit() c.execute("SELECT * FROM notes WHERE cookie = (?)", (request.cookies.get("cookie")[0:36], )) conn.commit() l = c.fetchall() nts = [] for n in l: nts.append(Note(n[1], n[2], n[3])) nts.reverse() return render_template("account.html", notes=nts, user=usr)
def deleteMD(self): if not self.detailNote: return box = QMessageBox(QMessageBox.Question, "注意", "您确定要从库中移除此文件吗?") yes = box.addButton("确定", QMessageBox.YesRole) no = box.addButton("取消", QMessageBox.NoRole) # box.setIcon(1) box.exec_() if box.clickedButton() == no: return elif box.clickedButton() == yes: self.db.deleteNote(self.detailNote.name) for note in self.curNotes: if note.name == self.detailNote.name: self.curNotes.remove(note) break note = Note() self.detailView.updateView(note) self.detailNote = None self.updateCurShow()
def execute(context, args): if context[consts.CONTEXT_SAFE_KEY] is None: print("No open safe") return context safe = context[consts.CONTEXT_SAFE_KEY] if not validate_args(args, safe): return context note_text = note_utils.open_edit_note() if note_text is not None: new_note = Note(args[0]) new_note.save(note_text, safe) note_text = "" safe.notes.append(new_note) return context
def play_theme(theTheme=0): themes = [[ 45, 57, 56, 57, 54, 57, 52, 57, 50, 57, 47, 57, 52, 57, 40, 57, 33, 45, 44, 45, 42, 45, 40, 45, 38, 45, 35, 45, 40, 45, 28, 45, 33 ], [33, 33, 47, 48, 38, 36, 38, 36, 33, 33, 47, 48, 43, 39, 38, 36, 33], [ 33, 33, 45, 33, 33, 45, 33, 45, 33, 45, 33, 33, 47, 48, 50, 51, 33, 45, 33, 36, 33, 45, 43, 45, 33, 33, 45, 33, 33, 39, 38, 36 ], [33, 28, 31, 32, 33, 39, 38, 36, 33, 39, 38, 36, 33, 28, 31, 32]] theme_audio = [] for n in themes[theTheme]: # create notes a_note = Note(all_notes[n][0], all_notes[n][2]) # calc audio theme_audio.append(a_note.calc_audio(.1)) # play audio for a in theme_audio: play(a)
def main(): candidate_database = CandidateDatabase() candidate = Candidate() candidate.name = "Alicia Toomtest" candidate.title = "Python Developer" candidate.address = "Gothenburg, Sweden" candidate.phone = "0722879879" candidate.email = "*****@*****.**" candidate.hobbies = "Gardening" candidate.education = [ Education(name="Education", school="School", level="Level"), Education(name="Education2", school="School2", level="Level2") ] candidate.experience = [ Experience(employer="Volvo", title="Python developer", responsibilities="code", duration_years="2018-present") ] candidate.note = Note() candidate.note.summary = "Gslf9ehdlsdfnjslsleofjfms," candidate.note.comment = "dki9eufsklwodudndjskwoeifjdk" # print_candidate(candidate) candidate_database.add_candidate(candidate) find_result = candidate_database.find_candidates("toom") if len(find_result) > 0: print_candidates(find_result) else: print("No result found") print_candidate(candidate) return
def ReadNotesHighSierra(db, notes, source): '''Read Notestore.sqlite''' try: query = " SELECT n.Z_PK, n.ZNOTE as note_id, n.ZDATA as data, " \ " c3.ZFILESIZE, "\ " c4.ZFILENAME, c4.ZIDENTIFIER as att_uuid, "\ " c1.ZTITLE1 as title, c1.ZSNIPPET as snippet, c1.ZIDENTIFIER as noteID, "\ " c1.ZCREATIONDATE1 as created, c1.ZLASTVIEWEDMODIFICATIONDATE, c1.ZMODIFICATIONDATE1 as modified, "\ " c2.ZACCOUNT3, c2.ZTITLE2 as folderName, c2.ZIDENTIFIER as folderID, "\ " c5.ZNAME as acc_name, c5.ZIDENTIFIER as acc_identifier, c5.ZACCOUNTTYPE "\ " FROM ZICNOTEDATA as n "\ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c1 ON c1.ZNOTEDATA = n.Z_PK "\ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c2 ON c2.Z_PK = c1.ZFOLDER "\ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c3 ON c3.ZNOTE= n.ZNOTE "\ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c4 ON c4.ZATTACHMENT1= c3.Z_PK "\ " LEFT JOIN ZICCLOUDSYNCINGOBJECT as c5 ON c5.Z_PK = c1.ZACCOUNT2 "\ " ORDER BY note_id " db.row_factory = sqlite3.Row cursor = db.execute(query) for row in cursor: try: att_path = '' if row['att_uuid'] != None: att_path = os.getenv( "HOME" ) + '/Library/Group Containers/group.com.apple.notes/Media/' + row[ 'att_uuid'] + '/' + row['ZFILENAME'] data = GetUncompressedData(row['data']) text_content = ProcessNoteBodyBlob(data) note = Note(row['note_id'], row['folderName'], row['title'], row['snippet'], text_content, row['att_uuid'], att_path, row['acc_name'], row['acc_identifier'], '', ReadMacAbsoluteTime(row['created']), ReadMacAbsoluteTime(row['modified']), 'NoteStore', source) notes.append(note) except: log.exception('Error fetching row data') except: log.exception('Query execution failed. Query was: ' + query)
def get_pitches(staff, lines_pos, notes_boxes, sharp_notes=None, flat_notes=None, duration=None): """ Return list of Note objects. :param lines_pos: y-coordinate of the lines :param notes_boxes: list of notes bounding boxes :param sharp_notes: list of sharps :param flat_notes: list of flats :param duration: duration of notes :return: list of Note objects """ if type(duration) is int or duration is None: duration = [duration] * len(notes_boxes) notes = [] gap_height = (lines_pos[1] - lines_pos[0]) / 2 middle = lines_pos[1] + gap_height for i, note_box in enumerate(notes_boxes): v = (note_box.middle[1] - middle) / gap_height note_ind = int((note_box.middle[1] - middle) / gap_height) if note_ind in Note.NOTES.keys(): label = Note.NOTES[note_ind][0] pitch = Note.NOTES[note_ind][1] if sharp_notes: if any(sharp.label[0] == label[0] for sharp in sharp_notes): label += '#' pitch += 1 if flat_notes: if any(flat.label[0] == label[0] for flat in flat_notes): label += 'b' pitch -= 1 notes.append(Note(label, pitch, duration[i], note_box)) return notes
def get_notes(self, sound, peaks, separation, max_pitch, stength_cutoff): """ Returns all notes found and their respective information such as pitch, octave, and alter (sharp, flat, normal). Input - sound: The numerical sound data (stored as list of numbers). - peaks: A list of the loudest regions found within the music. - separation: Peaks must be separated by this amount. (Same as "separation" variable in compile_music). - max_pitch: Disregards all frquencies higher than this amount. (Same as "max_pitch" variable in compile_music) - stength_cutoff: Output - notes: A Pandas DataFrame of the notes found (still needs more processing) """ notes = list() for peak, loudness in peaks: inspection_zone = sound[peak:peak + separation] fft_data = np.abs(fft(inspection_zone)) conversion_factor = self.sample_rate / len(fft_data) max_signal = max(fft_data) resonant_freqs = (-fft_data).argsort() timestamp = peak / self.sample_rate for freq in resonant_freqs: signal = fft_data[freq] if signal < stength_cutoff * max_signal: break if freq * conversion_factor < max_pitch: note = Note(freq * conversion_factor, signal, loudness, timestamp) notes.append(note.getInfo()) notes = pd.DataFrame(notes, columns=[ "time", "id", "signal", "pitch", "given_pitch", "loudness", "note", "octave", "alter" ]) return notes
def setup(self, restart=False): """ Set up the game here. Call this function to restart the game. """ self.note = Note(*NOTE_POS) self.button = Button(*BUTTON_POS) self.clock = Clock(*CLOCK_POS) self.strikes = Strikes(*STRIKES_POS) self.init_items() self.init_person() self.init_idcard() self.state = State.START_FADE_IN self.state_time = 0 self.day = 1 self.score = 0 self.guide_visible = False if not restart: self.sound_player = None arcade.play_sound(assets.sounds['elevator_music'], volume=0.03, looping=True) self.set_fullscreen(True) self.set_icon(pyglet.image.load("res/image/icon.png"))
def addNewNote(self): name = input("Name your note or press Enter\n") if not name: for entry in self.notes: if "Note" in entry.name and re.search(r'\d', entry.name): reg = re.compile("[^0-9]") last_id = int(reg.sub('', entry.name)) if last_id > self.note_id: self.note_id = last_id self.note_id += 1 name = f"Note{self.note_id}" else: # To avoid invalid input reg = re.compile("[^a-zA-Z][^0-9]") name = reg.sub('', name) tags = input("Add some tags or press enter\n") note = Note(self.note_id, name, tags.split()) try: print("\033[37;1m") # white text note.create() except FileExistsError: print(f"Note '{name}' already exists")
def removeNote(self): if not self.detailNote: return box = QMessageBox(QMessageBox.Warning, "警告", "您确定要从磁盘上中删除此文件吗?") yes = box.addButton("确定", QMessageBox.YesRole) no = box.addButton("取消", QMessageBox.NoRole) # box.setIcon(2) box.exec_() if box.clickedButton() == no: return elif box.clickedButton() == yes: if os.path.exists(self.detailNote.file_path): os.remove(self.detailNote.file_path) self.db.deleteNote(self.detailNote.name) for note in self.curNotes: if note.name == self.detailNote.name: self.curNotes.remove(note) break note = Note() self.detailView.updateView(note) self.detailNote = None self.updateCurShow()
def parse_midi(self, file_path): """Utility method to parse midi via midi_parser and set phrase. :param file_path: File path of midi file to parse :type file_path: String :return: None, modifys object in place :rtype: None """ try: f = open(file_path) f.close() except: print('File path "{}" incorrect.'.format(file_path)) self.handler.exit_program(self.phrase) notes = handler.parse_midi(file_path) for note in notes: self.append(note[3], Note(note=note[0], vel=note[1], length=note[2])) self.resize() self.normalize_offset()
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 fetch_url(random_url): """Return the decrypted note. Begin short destruction timer. Keyword arguments: random_url -- Random URL representing the encrypted note.""" note = Note(random_url) if not note.exists(): return render_template('404.html'), 404 elif not note.decrypt() and request.method != 'POST': return render_template('key.html', random=note.url) elif request.method == 'POST': passphrase = request.form['pass'] note.set_passphrase(passphrase) if passphrase == note.dkey: note.secure_remove() return render_template('note.html', text=utils.duress_text()) if note.decrypt(): note.secure_remove() return render_template('note.html', text=note.plaintext) else: return render_template('keyerror.html', random=note.url)