本文整理汇总了Python中note.Note.exists方法的典型用法代码示例。如果您正苦于以下问题:Python Note.exists方法的具体用法?Python Note.exists怎么用?Python Note.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NoteTest
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import exists [as 别名]
class NoteTest(unittest.TestCase):
def setUp(self):
self.path = file_dir + '/tmp'
self.ext = '.txt'
self.editor = 'subl'
self.note = Note(self.path, self.ext, self.editor)
def tearDown(self):
#if os.path.isdir(self.path): If its not there, something went wrong!
shutil.rmtree(self.path)
self.note = None
def test_empty_list(self):
"""
New Note, we don't have entries.
"""
self.failIf(self.note.list())
def test_new(self):
"""
Create a new Note.
"""
self.failUnless(self.note.new("TestNote", "LoremIpsumNote"))
def test_edit(self):
self.note.edit("TestNote", "LoremIpsumNote")
self.note.edit("TestNote", "MoreLoreMore")
def test_list(self):
self.failIf(self.note.list())
self.note.new("TestNote", "LoremIpsumNote")
self.failUnless(self.note.list() == "TestNote")
def test_exists(self):
self.note.list()
self.note.new("TestNote", "LoremIpsumNote")
self.failUnless(self.note.exists("TestNote"))
self.failIf(self.note.exists("DoesNotExist"))
def test_get_existing(self):
self.note.new("TestNote", "LoremIpsumNote")
self.failUnless(self.note.get("TestNote") == "LoremIpsumNote")
def test_get_non_existing(self):
self.failIf(self.note.get("NoneNote"))
def test_delete(self):
self.note.new("TestNote", "LoremIpsumNote")
self.failUnless(self.note.exists("TestNote"))
self.note.delete("TestNote")
self.failIf(self.note.exists("TestNote"))
#It should not crap out if the note does not exist.
self.note.delete("TestNote")
示例2: fetch_url
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import exists [as 别名]
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)