本文整理汇总了Python中document.documentFields.DocumentFields.setField方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentFields.setField方法的具体用法?Python DocumentFields.setField怎么用?Python DocumentFields.setField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document.documentFields.DocumentFields
的用法示例。
在下文中一共展示了DocumentFields.setField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: descAll
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descAll(self):
d = DocumentFields()
d.setField("title", "document about internet")
d.setField("year", "2014")
d.setField("author", "John Bruf, Tommy Bamo")
d.setField("keywords", "Computer science, Photography")
d.setField("journal", "Journal of Computer Science")
notes = Notes(d)
notes.createAllContent()
content = notes.getDocumentContent()
expectedContent = "document about internet\n\n"
expectedContent += Notes.TABLE_HEADER
expectedContent += "Annee = 2014\n"
expectedContent += "Auteurs = John Bruf, Tommy Bamo\n"
expectedContent += "Mots-cles = Computer science, Photography\n"
expectedContent += "Journal = Journal of Computer Science\n"
expectedContent += Notes.TABLE_END
# contentLines = content.splitlines()
# expLines = expectedContent.splitlines()
# d = difflib.Differ()
# diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例2: organize
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def organize(self):
fields = DocumentFields()
fields.setField("title", "document about internet")
fields.setField("year", "2014")
fields.setField("authors", "John Bruf, Tommy Bamo")
fields.setField("keywords", "Computer science, Photography")
fields.setField("journal", "Journal of Computer Science")
dir = Directory("document_about_internet")
dir.removeDir()
d = DocumentFolder()
d.setDocFields(fields)
d.create()
assert(not d.hasVideoFolder())
assert(not d.hasImageFolder())
assert(not d.hasNotesFolder())
assert(not d.hasDescFolder())
d.organize()
assert(d.hasVideoFolder())
assert(d.hasImageFolder())
assert(d.hasNotesFolder())
assert(d.hasDescFolder())
notesPath = d.getNotesFilePath()
print notesPath
assert(File(notesPath).exists())
d.delete()
示例3: test_changeField
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def test_changeField(self):
a = DocumentFields()
a.setField("title", "bc")
a.setField("title", "Other")
self.assertEqual (a.getNbFields(), 1)
self.assertTrue(a.hasField("title"))
self.assertEqual(a.getField("title"), "Other")
示例4: test_organizeWithFiles
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def test_organizeWithFiles(self):
fields = DocumentFields()
fields.setField("title", "document about internet")
d = DocumentFolder()
d.setDocFields(fields)
bibfile = File("bibfile.bib")
bibfile.createFile()
pdffilename = "pdffile.pdf"
pdffile = File(pdffilename)
pdffile.createFile()
fileList = [bibfile, pdffilename]
d.create()
d.organize(fileList)
self.assertFalse(File("bibfile.bib").exists())
self.assertFalse(File("pdffile.pdf").exists())
folderPath = d.getDir().getPath().getAbsolutePath()
newbibfile = File(folderPath + "/" + "bibfile.bib")
newpdffile = File(folderPath + "/" + "pdffile.pdf")
self.assertTrue(newbibfile.exists())
self.assertTrue(newpdffile.exists())
d.delete()
示例5: internFolders
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def internFolders(self):
a = DocumentFields()
a.setField("title", "document")
d = DocumentFolder()
d.setDocFields(a)
d.create()
assert(d.getDir().exists())
assert(not d.hasVideoFolder())
assert(not d.hasImageFolder())
assert(not d.hasNotesFolder())
assert(not d.hasDescFolder())
d.createVideoFolder()
d.createImageFolder()
d.createNotesFolder()
d.createDescFolder()
assert(d.hasVideoFolder())
assert(d.hasImageFolder())
assert(d.hasNotesFolder())
assert(d.hasDescFolder())
d.delete()
示例6: descTableAll
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableAll(self):
d = DocumentFields()
d.setField("title", "document about internet")
d.setField("year", "2014")
d.setField("author", "Bruf, John and Bamo, Tomy")
d.setField("keywords", "Computer science, Photography")
d.setField("journal", "Journal of Computer Science")
notes = WikiNotes(d)
notes.createTitle()
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = WikiNotes.TABLE_HEADER
expectedContent += ("|Annee :\n"
"| \'\'\'2014\'\'\'\n"
"|-\n"
"|Auteurs :\n"
"| \'\'\'John Bruf, Tomy Bamo\'\'\'\n"
"|-\n"
"|Mots-cles :\n"
"| \'\'\'Computer science, Photography\'\'\'\n"
"|-\n"
"|Journal :\n"
"| \'\'\'Journal of Computer Science\'\'\'\n"
"|-\n")
expectedContent += WikiNotes.TABLE_END
# contentLines = content.splitlines()
# expLines = expectedContent.splitlines()
# d = difflib.Differ()
# diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例7: titleContent
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def titleContent(self):
d = DocumentFields()
d.setField("title", "document about internet")
notes = Notes(d)
notes.createTitle()
content = notes.getDocumentContent()
expectedContent = "document about internet\n\n"
# print content
# print expectedContent
assert(content == expectedContent)
示例8: folderName
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def folderName(self):
a = DocumentFields()
a.setField("title", "document")
d = DocumentFolder()
d.setDocFields(a)
for i, title in enumerate(self.titles):
a.setField("title", title)
name = d.computeFolderName()
assert(name == self.folderNames[i])
示例9: titleContent
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def titleContent(self):
d = DocumentFields()
d.setField("title", "document about internet")
notes = LatexNotes(d)
notes.createTitle()
content = notes.getDocumentContent()
expectedContent = LatexNotes.HEADER
expectedContent += "\\title{document about internet}\n"
expectedContent += "\\maketitle\n"
expectedContent += "\n"
expectedContent += "\\end{document}\n"
# print content
# print expectedContent
assert(content == expectedContent)
示例10: descTableKeywords
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableKeywords(self):
d = DocumentFields()
d.setField("keywords", "Computer science, Photography")
notes = Notes(d)
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = Notes.TABLE_HEADER
expectedContent += "Mots-cles = Computer science, Photography\n"
expectedContent += Notes.TABLE_END
# contentLines = content.splitlines()
# expLines = expectedContent.splitlines()
# d = difflib.Differ()
# diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例11: descTableJournal
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableJournal(self):
d = DocumentFields()
d.setField("journal", "Journal of Computer Science")
notes = Notes(d)
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = Notes.TABLE_HEADER
expectedContent += "Journal = Journal of Computer Science\n"
expectedContent += Notes.TABLE_END
# contentLines = content.splitlines()
# expLines = expectedContent.splitlines()
# d = difflib.Differ()
# diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例12: descTableYear
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableYear(self):
d = DocumentFields()
d.setField("year", "2014")
notes = Notes(d)
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = Notes.TABLE_HEADER
expectedContent += "Annee = 2014\n"
expectedContent += Notes.TABLE_END
# contentLines = content.splitlines()
# expLines = expectedContent.splitlines()
# d = difflib.Differ()
# diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例13: descTableAuthors
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableAuthors(self):
d = DocumentFields()
d.setField("author", "John Bruf, Tommy Bamo")
notes = Notes(d)
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = Notes.TABLE_HEADER
expectedContent += "Auteurs = John Bruf, Tommy Bamo\n"
expectedContent += Notes.TABLE_END
contentLines = content.splitlines()
expLines = expectedContent.splitlines()
d = difflib.Differ()
diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)
示例14: read
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def read(self):
fields = DocumentFields()
with open(self.path.path) as bibtex_file:
bibtex_str = bibtex_file.read()
bib_database = bibtexparser.loads(bibtex_str)
for entry in bib_database.entries:
for field, value in entry.items():
if (field == "ENTRYTYPE"):
docType = strToDocType(value)
fields.setDocType(docType)
elif (field != "ID"):
fields.setField(field, value)
return fields
示例15: descTableAuthors
# 需要导入模块: from document.documentFields import DocumentFields [as 别名]
# 或者: from document.documentFields.DocumentFields import setField [as 别名]
def descTableAuthors(self):
d = DocumentFields()
d.setField("author", "Bruf, John and Bamo, Tomy")
notes = WikiNotes(d)
notes.createDescriptionTable()
content = notes.getDocumentContent()
expectedContent = WikiNotes.TABLE_HEADER
expectedContent += ( "|Auteurs :\n"
"| \'\'\'John Bruf, Tomy Bamo\'\'\'\n"
"|-\n")
expectedContent += WikiNotes.TABLE_END
contentLines = content.splitlines()
expLines = expectedContent.splitlines()
d = difflib.Differ()
diff = d.compare(contentLines, expLines)
# print "\n".join(diff)
assert(content == expectedContent)