Example #1
0
 def get_user(self, name):
     if name in self._users:
         return self._users[name]
     elif name in self._users_canon:
         return self._users[self._users_canon[name]]
     else:
         raise PlagError('No such user: ' + name)
Example #2
0
 def get_plag(self, name):
     if name in self._plags:
         return self._plags[name]
     elif name in self._plags_canon:
         return self._plags[self._plags_canon[name]]
     else:
         raise PlagError('No such plag: ' + name)
Example #3
0
 def _parse_pages(name, text):
     # Allowed page range inclusion settings:
     #   include - include in statistics
     #   exclude - do not include in statistics
     # Allowed page categories:
     #   frontmatter - title page, colophon, dedication, and similar
     #                 (anything in the front that is not covered by
     #                 more specific categories)
     #   toc         - table of contents
     #   foreword    - a foreword written by someone else than the author
     #                 of the work
     #   preface     - a preface written by the author of the work
     #   text        - the main text body
     #   appendix    - generic appendix page (e.g. an afterword,
     #                 data (in engineering) or detailed proofs (in math))
     #   references  - a formal bibliography section
     #   glossary    - list of terms (or acronyms) and their definitions
     #   index       - list of terms (or acronyms, or people, etc.) and
     #                 for each term a list of pages where it is used
     #   list        - anything else list-like, e.g. a list of tables or
     #                 a list of figures
     #   backmatter  - anything else in the back that is not directly
     #                 related to the main subject matter, e.g. a résumé of
     #                 the author or a colophon that is located at the end
     #   other       - no category system can be exhaustive, so here you are
     #   empty       - an empty page; this should only be used between
     #                 pages of two different types; in particular, do
     #                 not use it between chapters of the main text.
     pages = []
     allowed_include_pages = ('include', 'exclude')
     allowed_page_categories = ('frontmatter', 'toc', 'foreword', 'preface', 'text', 'appendix', 'references', 'glossary', 'index', 'list', 'backmatter', 'other', 'empty')
     for row in csv_to_list(text):
         if len(row) != 3:
             raise PlagError('Plag '+name+': row in pages field has '+len(row)+' columns, but 3 are expected: '+repr(row))
         pagerange = PageRange.parse(row[0])
         if row[1].lower() in allowed_include_pages:
             include_pages = (row[1].lower() == 'include')
         else:
             raise PlagError('Plag '+name+': invalid value \'' + row[1] + '\' for second column in pages field, must be one of: ' + ' '.join(allowed_include_pages))
         if row[2].lower() in allowed_page_categories:
             page_category = row[2].lower()
         else:
             raise PlagError('Plag '+name+': invalid value \'' + row[2] + '\' for third column in pages field, must be one of: ' + ' '.join(allowed_page_categories))
         pages.append((pagerange, include_pages, page_category))
     return tuple(pages)
Example #4
0
 def _parse_chapters(name, text):
     # Allowed chapter types:
     #   chapter
     #   section
     #   TODO: define more, such as subsection, subsubsection, or part
     chapters = []
     allowed_chapter_types = ('chapter', 'section')
     for row in csv_to_list(text):
         if len(row) != 3:
             raise PlagError('Plag '+name+': row in chapters field has '+len(row)+' columns, but 3 are expected: '+repr(row))
         if row[0].lower() in allowed_chapter_types:
             chapter_type = row[0].lower()
         else:
             raise PlagError('Plag '+name+': invalid value \'' + row[0] + '\' for first column in chapters field, must be one of: ' + ' '.join(allowed_chapter_types))
         chapter_first_page = row[1]
         chapter_title = row[2]
         chapters.append((chapter_type, chapter_first_page, chapter_title))
     return tuple(chapters)
Example #5
0
 def verify_config(self):
     if not self.name:
         raise PlagError('PlagWiki with no name!')
     if not self.fullname:
         raise PlagError('PlagWiki '+self.name+': No full name defined!')
     if not self.language:
         raise PlagError('PlagWiki '+self.name+': No language defined!')
     if not self.wiki:
         raise PlagError('PlagWiki '+self.name+': No wiki URL defined!')
     if not self.api:
         raise PlagError('PlagWiki '+self.name+': No API URL defined!')
     if not self.software:
         raise PlagError('PlagWiki '+self.name+': No wiki software defined!')
     if self.software == 'MediaWiki':
         if self.ask:
             raise PlagError('PlagWiki '+self.name+': Ask URL defined, but wiki software is MediaWiki (expected MediaWiki+SMW)!')
     elif self.software == 'MediaWiki+SMW':
         if not self.ask:
             raise PlagError('PlagWiki '+self.name+': No Ask URL defined!')
     else:
         raise PlagError('PlagWiki '+self.name+': Unknown wiki software: '+self.software+' (should be MediaWiki or MediaWiki+SMW)')
Example #6
0
 def verify_config(self):
     if not self.name:
         raise PlagError('Plag with no name!')
     if not self.author:
         raise PlagError('Plag '+self.name+': No author defined!')
     if not self.title:
         raise PlagError('Plag '+self.name+': No title defined!')
     if self.subtitle is None:
         raise PlagError('Plag '+self.name+': No subtitle defined!')
     if not self.thesistype:
         raise PlagError('Plag '+self.name+': No thesis type defined!')
     if self.pages is None:
         raise PlagError('Plag '+self.name+': No pages defined!')
     if self.chapters is None:
         raise PlagError('Plag '+self.name+': No chapters defined!')
     if not self.wiki:
         raise PlagError('Plag '+self.name+': No wiki defined!')
     if not self.overviewpage:
         raise PlagError('Plag '+self.name+': No overview page defined!')
     if not self.fragmentprefix:
         raise PlagError('Plag '+self.name+': No fragment prefix defined!')
     if self.pagesprefix is None:
         raise PlagError('Plag '+self.name+': No pages prefix defined!')
     if not self.fragmentcategory:
         raise PlagError('Plag '+self.name+': No fragment category defined!')
     if not self.sourcecategory:
         raise PlagError('Plag '+self.name+': No source category defined!')
     if not self.typescategory:
         raise PlagError('Plag '+self.name+': No types category defined!')
     if self.barcode is None:
         raise PlagError('Plag '+self.name+': No barcode page defined!')
     if self.options is None:
         raise PlagError('Plag '+self.name+': No options defined!')
     if self.pdf is None:
         raise PlagError('Plag '+self.name+': No PDF file name defined!')