Skip to content

Commit

Permalink
Fix #1839
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Mar 9, 2016
1 parent 4d6d725 commit 21b6f14
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -12,6 +12,7 @@ Features
Bugfixes
--------

* Don't call sys.exit() from plugins if possible (Issue #1839)
* Fix a JSON conversion bug in the WordPress importer (Issue #2264)
* Don’t create download directories when not downloading WordPress
attachments (Issue #2260)
Expand Down
7 changes: 4 additions & 3 deletions nikola/plugins/task/galleries.py
Expand Up @@ -94,8 +94,8 @@ def set_site(self, site):
for source, dest in self.kw['gallery_folders'].items():
if source in appearing_paths or dest in appearing_paths:
problem = source if source in appearing_paths else dest
utils.LOGGER.error("The gallery input or output folder '{0}' appears in more than one entry in GALLERY_FOLDERS, exiting.".format(problem))
sys.exit(1)
utils.LOGGER.error("The gallery input or output folder '{0}' appears in more than one entry in GALLERY_FOLDERS, ignoring.".format(problem))
continue
appearing_paths.add(source)
appearing_paths.add(dest)

Expand All @@ -116,10 +116,11 @@ def _find_gallery_path(self, name):
if len(candidates) == 1:
return candidates[0]
self.logger.error("Gallery name '{0}' is not unique! Possible output paths: {1}".format(name, candidates))
raise RuntimeError("Gallery name '{0}' is not unique! Possible output paths: {1}".format(name, candidates))
else:
self.logger.error("Unknown gallery '{0}'!".format(name))
self.logger.info("Known galleries: " + str(list(self.proper_gallery_links.keys())))
sys.exit(1)
raise RuntimeError("Unknown gallery '{0}'!".format(name))

def gallery_path(self, name, lang):
"""Link to an image gallery's path.
Expand Down
6 changes: 3 additions & 3 deletions nikola/plugins/task/listings.py
Expand Up @@ -73,7 +73,7 @@ def set_site(self, site):
if source in appearing_paths or dest in appearing_paths:
problem = source if source in appearing_paths else dest
utils.LOGGER.error("The listings input or output folder '{0}' appears in more than one entry in LISTINGS_FOLDERS, exiting.".format(problem))
sys.exit(1)
continue
appearing_paths.add(source)
appearing_paths.add(dest)

Expand Down Expand Up @@ -275,14 +275,14 @@ def listing_path(self, namep, lang):
# ambiguities.
if len(self.improper_input_file_mapping[name]) > 1:
utils.LOGGER.error("Using non-unique listing name '{0}', which maps to more than one listing name ({1})!".format(name, str(self.improper_input_file_mapping[name])))
sys.exit(1)
return ["ERROR"]
if len(self.site.config['LISTINGS_FOLDERS']) > 1:
utils.LOGGER.notice("Using listings names in site.link() without input directory prefix while configuration's LISTINGS_FOLDERS has more than one entry.")
name = list(self.improper_input_file_mapping[name])[0]
break
else:
utils.LOGGER.error("Unknown listing name {0}!".format(namep))
sys.exit(1)
return ["ERROR"]
if not name.endswith(os.sep + self.site.config["INDEX_FILE"]):
name += '.html'
path_parts = name.split(os.sep)
Expand Down
7 changes: 3 additions & 4 deletions nikola/plugins/task/tags.py
Expand Up @@ -105,8 +105,7 @@ def gen_tasks(self):
intersect = set(tags.keys()) & set(categories.keys())
if len(intersect) > 0:
for slug in intersect:
utils.LOGGER.error("Category '{0}' and tag '{1}' both have the same slug '{2}'!".format('/'.join(categories[slug]), tags[slug], slug))
sys.exit(1)
utils.LOGGER.error("Category '{0}' and tag '{1}' both have the same slug '{2}'!".format(categories[slug], tags[slug], slug))

# Test for category slug clashes
categories = {}
Expand All @@ -115,13 +114,13 @@ def gen_tasks(self):
for part in slug:
if len(part) == 0:
utils.LOGGER.error("Category '{0}' yields invalid slug '{1}'!".format(category, '/'.join(slug)))
sys.exit(1)
raise RuntimeError("Category '{0}' yields invalid slug '{1}'!".format(category, '/'.join(slug)))
if slug in categories:
other_category = categories[slug]
utils.LOGGER.error('You have categories that are too similar: {0} and {1}'.format(category, other_category))
utils.LOGGER.error('Category {0} is used in: {1}'.format(category, ', '.join([p.source_path for p in self.site.posts_per_category[category]])))
utils.LOGGER.error('Category {0} is used in: {1}'.format(other_category, ', '.join([p.source_path for p in self.site.posts_per_category[other_category]])))
sys.exit(1)
raise RuntimeError("Category / Tag name collision.")
categories[slug] = category

tag_list = list(self.site.posts_per_tag.items())
Expand Down

0 comments on commit 21b6f14

Please sign in to comment.