Commit 1ffa5166 authored by Matthieu Boileau's avatar Matthieu Boileau

Do not reset output directory if just listing rubrique tree

parent 83d90bfa
......@@ -395,6 +395,8 @@ class Website:
return yaml.load(remove_null_date(strip_invalid(yml_file)))
def __init__(self, reset_output_dir=True):
self.reset_output_dir = reset_output_dir
self.category_index = {}
self.article_index = {}
self.doc_index = {}
......@@ -433,9 +435,6 @@ class Website:
else:
logger.critical(f"Error in {config_filename}: {pelican_category}: {spip_rubrique}")
if reset_output_dir:
self._reset_output_directories()
def _reset_output_directories(self):
"""Erase existing output files and create empty output directories"""
if os.path.exists("content"):
......@@ -491,15 +490,14 @@ class Website:
parent = self.rubrique_nodes[parent_name]
self.rubrique_nodes[node_name] = anytree.AnyNode(name=node_name, id=node_id, count=0, parent=parent)
self.labels[0] = "root" # Root node label
self.labels[0] = "root" # Add root node label
for node_id in self.parents:
insert_node(node_id)
self.rubrique_tree = self.rubrique_nodes[get_label(0)] # rubrique_tree is the root node
# Count the number of articles for each rubriques
# Count the number of pages for each rubrique
for article in self.articles:
#if article.type != 'rubrique': # Do not count rubriques themselves
rubrique_node = anytree.search.find_by_attr(self.rubrique_tree, article.rubrique, name="id")
rubrique_node.count += 1
......@@ -535,9 +533,7 @@ class Website:
self.author_index[art_id] = author_name_index[author_id]
def _build_articles(self):
"""
Instanciate a list of Article objects
"""
"""Instanciate a list of Article objects"""
def add_articles(filename, spip_type):
"""Add article or rubrique to website.articles and website.article_index"""
......@@ -568,6 +564,10 @@ class Website:
logger.debug("-------")
logger.debug("Exporting to Pelican")
if self.reset_output_dir:
self._reset_output_directories()
processed = []
for article in self.articles:
skip_reason = article.export_to_pelican()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment