def _load_project_conf(self, parser):
try:
- self._name = parser.get('project', 'name')
- except _configparser.NoOptionError:
- pass
- try:
- vcs = parser.get('project', 'vcs')
- except _configparser.NoOptionError:
- pass
- else:
+ project = parser['project']
+ except KeyError:
+ project = {}
+ self._name = project.get('name')
+ vcs = project.get('vcs')
+ if vcs:
kwargs = {
'root': self._root,
'author_hacks': self._author_hacks,
def _load_copyright_conf(self, parser):
try:
- self._copyright = self._split_paragraphs(
- parser.get('copyright', 'long'))
- except _configparser.NoOptionError:
- pass
- try:
- self._short_copyright = self._split_paragraphs(
- parser.get('copyright', 'short'))
- except _configparser.NoOptionError:
- pass
+ copyright = parser['copyright']
+ except KeyError:
+ copyright = {}
+ if 'long' in copyright:
+ self._copyright = self._split_paragraphs(copyright['long'])
+ if 'short' in copyright:
+ self._short_copyright = self._split_paragraphs(copyright['short'])
def _split_paragraphs(self, text):
return [p.strip() for p in text.split('\n\n')]
def _load_files_conf(self, parser):
- try:
- self.with_authors = parser.getboolean('files', 'authors')
- except _configparser.NoOptionError:
- pass
- try:
- self.with_files = parser.getboolean('files', 'files')
- except _configparser.NoOptionError:
- pass
- try:
- ignored = parser.get('files', 'ignored')
- except _configparser.NoOptionError:
- pass
- else:
+ files = parser['files']
+ self.with_authors = files.getboolean('authors')
+ self.with_files = files.getboolean('files')
+ ignored = files.get('ignored')
+ if ignored:
self._ignored_paths = [pth.strip() for pth in ignored.split('|')]
- try:
- pyfile = parser.get('files', 'pyfile')
- except _configparser.NoOptionError:
- pass
- else:
+ pyfile = files.get('pyfile')
+ if pyfile:
self._pyfile = _os_path.join(self._root, pyfile)
def _load_author_hacks_conf(self, parser):
+ try:
+ section = parser['author-hacks']
+ except KeyError:
+ section = {}
author_hacks = {}
- for path in parser.options('author-hacks'):
- authors = parser.get('author-hacks', path)
+ for path, authors in section.items():
author_hacks[tuple(path.split('/'))] = set(
a.strip() for a in authors.split('|'))
self._author_hacks = author_hacks
self._vcs._author_hacks = self._author_hacks
def _load_year_hacks_conf(self, parser):
+ try:
+ section = parser['year-hacks']
+ except KeyError:
+ section = {}
year_hacks = {}
- for path in parser.options('year-hacks'):
- year = parser.get('year-hacks', path)
+ for path, year in section.items():
year_hacks[tuple(path.split('/'))] = int(year)
self._year_hacks = year_hacks
if self._vcs is not None:
self._vcs._year_hacks = self._year_hacks
def _load_aliases_conf(self, parser):
+ try:
+ section = parser['aliases']
+ except KeyError:
+ section = {}
aliases = {}
- for author in parser.options('aliases'):
- _aliases = parser.get('aliases', author)
+ for author, _aliases in section.items():
aliases[author] = set(
a.strip() for a in _aliases.split('|'))
self._aliases = aliases