本文整理汇总了Python中model.Tag.get方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.get方法的具体用法?Python Tag.get怎么用?Python Tag.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Tag
的用法示例。
在下文中一共展示了Tag.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTagsForUrl
# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import get [as 别名]
def getTagsForUrl(url):
try:
content = resource.get(url).decodeBody().lower()
except:
content = ""
soup = BeautifulSoup(content)
texts = soup.findAll(text=True)
def visible(element):
if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
return False
elif re.match('<!--.*-->', str(element)):
return False
return True
visible_texts = filter(visible, texts)
visibleText = " ".join(visible_texts)
result = getTagsProposalsForText(visibleText)
entry = Entry.all().filter("url =", url).fetch(1)
if len(entry) > 0:
entryStableTags = entry[0].tags
for t in entryStableTags:
found = False
name = Tag.get(t).name
for r in result:
if name == r:
found = True
if not found:
result.append(name)
return result
示例2: addTag
# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import get [as 别名]
def addTag(self, noteId, strTag):
count = Tag.select().where(Tag.tag == strTag).count()
if (count == 0):
dbTag = Tag()
dbTag.creationDate = dbTag.modificationDate = datetime.date.today()
dbTag.tag = strTag
dbTag.save()
else:
dbTag = Tag.get(Tag.tag == strTag)
note = Note.get(Note.id == noteId)
noteTag = NoteTag()
noteTag.note = note
noteTag.tag = dbTag
noteTag.creationDate = noteTag.modificationDate = datetime.date.today()
noteTag.save()
self.view.execute_script("notesMD.tags = " + RuntimeSettings.getTags())
示例3: removeTag
# 需要导入模块: from model import Tag [as 别名]
# 或者: from model.Tag import get [as 别名]
def removeTag(self, noteId, strTag):
tag = Tag.get(Tag.tag == strTag)
NoteTag.get(NoteTag.note == noteId, NoteTag.tag == tag.id).delete_instance()