def check_media(self): """Check media (will rebuild missing LaTeX files)""" with cd(self.col.media.dir()): click.echo('Checking media DB ... ', nl=False) output = self.col.media.check() click.echo('done!') if len(output.missing) + len(output.unused) == 0: click.secho('No unused or missing files found.', fg='white') return for file in output.missing: click.secho(f'Missing: {file}', fg='red') if len(output.missing) > 0 \ and click.confirm('Render missing LaTeX?'): out = self.col.media.render_all_latex() if out is not None: nid, _ = out click.secho(f'Error prosessing node: {nid}', fg='red') if click.confirm('Review note?'): note = Note(self, self.col.getNote(nid)) note.review() for file in output.unused: click.secho(f'Unused: {file}', fg='red') if len(output.unused) > 0 \ and click.confirm('Delete unused media?'): for file in output.unused: if os.path.isfile(file): os.remove(file)
def _add_note(self, fields, tags, markdown=True, deck=None): """Add new note to collection""" note = self.col.newNote(forDeck=False) if deck is not None: note.model()['did'] = self.deck_name_to_id[deck] if markdown: note.fields = [markdown_to_html(x) for x in fields] else: note.fields = [plain_to_html(x) for x in fields] tags = tags.strip().split() for tag in tags: note.addTag(tag) if not note.dupeOrEmpty(): self.col.addNote(note) self.modified = True else: click.secho('Dupe detected, note was not added!', fg='red') click.echo('Question:') click.echo(list(fields)[0]) return Note(self, note)
def find_notes(self, query): """Find notes in Collection and return Note objects""" return (Note(self, self.col.getNote(i)) for i in set(self.col.findNotes(query)))
def find_notes(self, query): """Find notes in Collection and return Note objects""" from apy.note import Note return (Note(self, self.col.getNote(i)) for i in self.col.findNotes(query))