本文整理汇总了Python中document.documentFields.DocumentFields类的典型用法代码示例。如果您正苦于以下问题:Python DocumentFields类的具体用法?Python DocumentFields怎么用?Python DocumentFields使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocumentFields类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: internFolders
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()
示例2: test_organizeWithFiles
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()
示例3: titleContent
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)
示例4: folderName
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])
示例5: titleContent
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)
示例6: test_changeField
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")
示例7: descTableYear
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)
示例8: descTableAuthors
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)
示例9: descTableKeywords
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)
示例10: descTableJournal
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)
示例11: read
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
示例12: test_create
def test_create(self):
a = DocumentFields()
a.setField("title", "document")
d = DocumentFolder()
d.setDocFields(a)
# Creation in local folder
for title in self.titles:
a.setField("title", title)
d.create()
self.assertTrue(d.getDir().exists())
d.delete()
self.assertFalse(d.getDir().exists())
dir = Directory("documents")
dir.createDir()
# Creaton in another folder
for title in self.titles:
a.setField("title", title)
d.create(dir.getPath().getAbsolutePath())
self.assertTrue(d.getDir().exists())
d.delete()
self.assertFalse(d.getDir().exists())
dir.removeDir()
示例13: create
def create(self):
a = DocumentFields()
a.setField("title", "document")
d = DocumentFolder()
d.setDocFields(a)
for title in self.titles:
a.setField("title", title)
d.create()
assert(d.getDir().exists())
d.delete()
assert(not d.getDir().exists())
dir = Directory("documents")
dir.createDir()
for title in self.titles:
a.setField("title", title)
d.create(dir.getPath().getAbsolutePath())
assert(d.getDir().exists())
d.delete()
assert(not d.getDir().exists())
dir.removeDir()
示例14: descTableAuthors
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)
示例15: setType
def setType(self):
a = DocumentFields()
for t in DocumentFields.TYPES:
a.setDocType(t)
assert (a.getDocType() == t)
a.setDocType(DocumentFields.OTHER)
assert (a.getDocType() == DocumentFields.OTHER)