forked from github/pelican
remove WRITE_SELECTED
Implementation is buggy and unreliable. Therefore, it is better to remove the functionality until a robust implementation is added.
This commit is contained in:
parent
0c5d63c69e
commit
86d6898517
8 changed files with 8 additions and 103 deletions
|
|
@ -434,15 +434,6 @@ def parse_arguments(argv=None):
|
|||
help="Ignore content cache " "from previous runs by not loading cache files.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-w",
|
||||
"--write-selected",
|
||||
type=str,
|
||||
dest="selected_paths",
|
||||
default=None,
|
||||
help="Comma separated list of selected paths to write",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--fatal",
|
||||
metavar="errors|warnings",
|
||||
|
|
@ -527,8 +518,6 @@ def get_config(args):
|
|||
config["LOAD_CONTENT_CACHE"] = False
|
||||
if args.cache_path:
|
||||
config["CACHE_PATH"] = args.cache_path
|
||||
if args.selected_paths:
|
||||
config["WRITE_SELECTED"] = args.selected_paths.split(",")
|
||||
if args.relative_paths:
|
||||
config["RELATIVE_URLS"] = args.relative_paths
|
||||
if args.port is not None:
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ DEFAULT_CONFIG = {
|
|||
"GZIP_CACHE": True,
|
||||
"CHECK_MODIFIED_METHOD": "mtime",
|
||||
"LOAD_CONTENT_CACHE": False,
|
||||
"WRITE_SELECTED": [],
|
||||
"FORMATTED_FIELDS": ["summary"],
|
||||
"PORT": 8000,
|
||||
"BIND": "127.0.0.1",
|
||||
|
|
@ -557,6 +556,13 @@ def handle_deprecated_settings(settings):
|
|||
)
|
||||
settings[old] = settings[new]
|
||||
|
||||
# Warn if removed WRITE_SELECTED is present
|
||||
if "WRITE_SELECTED" in settings:
|
||||
logger.warning(
|
||||
"WRITE_SELECTED is present in settings but this functionality was removed. "
|
||||
"It will have no effect."
|
||||
)
|
||||
|
||||
return settings
|
||||
|
||||
|
||||
|
|
@ -585,12 +591,6 @@ def configure_settings(settings):
|
|||
else:
|
||||
raise Exception("Could not find the theme %s" % settings["THEME"])
|
||||
|
||||
# make paths selected for writing absolute if necessary
|
||||
settings["WRITE_SELECTED"] = [
|
||||
os.path.abspath(path)
|
||||
for path in settings.get("WRITE_SELECTED", DEFAULT_CONFIG["WRITE_SELECTED"])
|
||||
]
|
||||
|
||||
# standardize strings to lowercase strings
|
||||
for key in ["DEFAULT_LANG"]:
|
||||
if key in settings:
|
||||
|
|
|
|||
|
|
@ -202,29 +202,6 @@ class TestPelican(LoggedTestCase):
|
|||
for file in ["a_stylesheet", "a_template"]:
|
||||
self.assertTrue(os.path.exists(os.path.join(theme_output, file)))
|
||||
|
||||
def test_write_only_selected(self):
|
||||
"""Test that only the selected files are written"""
|
||||
settings = read_settings(
|
||||
path=None,
|
||||
override={
|
||||
"PATH": INPUT_PATH,
|
||||
"OUTPUT_PATH": self.temp_path,
|
||||
"CACHE_PATH": self.temp_cache,
|
||||
"WRITE_SELECTED": [
|
||||
os.path.join(self.temp_path, "oh-yeah.html"),
|
||||
os.path.join(self.temp_path, "categories.html"),
|
||||
],
|
||||
"LOCALE": locale.normalize("en_US"),
|
||||
},
|
||||
)
|
||||
pelican = Pelican(settings=settings)
|
||||
logger = logging.getLogger()
|
||||
orig_level = logger.getEffectiveLevel()
|
||||
logger.setLevel(logging.INFO)
|
||||
mute(True)(pelican.run)()
|
||||
logger.setLevel(orig_level)
|
||||
self.assertLogCountEqual(count=2, msg="Writing .*", level=logging.INFO)
|
||||
|
||||
def test_cyclic_intersite_links_no_warnings(self):
|
||||
settings = read_settings(
|
||||
path=None,
|
||||
|
|
|
|||
|
|
@ -840,19 +840,6 @@ def split_all(path):
|
|||
)
|
||||
|
||||
|
||||
def is_selected_for_writing(settings, path):
|
||||
"""Check whether path is selected for writing
|
||||
according to the WRITE_SELECTED list
|
||||
|
||||
If WRITE_SELECTED is an empty list (default),
|
||||
any path is selected for writing.
|
||||
"""
|
||||
if settings["WRITE_SELECTED"]:
|
||||
return path in settings["WRITE_SELECTED"]
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def path_to_file_url(path):
|
||||
"""Convert file-system path to file:// URL"""
|
||||
return urllib.parse.urljoin("file://", urllib.request.pathname2url(path))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ from pelican.paginator import Paginator
|
|||
from pelican.plugins import signals
|
||||
from pelican.utils import (
|
||||
get_relative_path,
|
||||
is_selected_for_writing,
|
||||
path_to_url,
|
||||
sanitised_join,
|
||||
set_date_tzinfo,
|
||||
|
|
@ -145,9 +144,6 @@ class Writer:
|
|||
name should be skipped to keep that one)
|
||||
:param feed_title: the title of the feed.o
|
||||
"""
|
||||
if not is_selected_for_writing(self.settings, path):
|
||||
return
|
||||
|
||||
self.site_url = context.get("SITEURL", path_to_url(get_relative_path(path)))
|
||||
|
||||
self.feed_domain = context.get("FEED_DOMAIN")
|
||||
|
|
@ -203,13 +199,7 @@ class Writer:
|
|||
:param **kwargs: additional variables to pass to the templates
|
||||
"""
|
||||
|
||||
if (
|
||||
name is False
|
||||
or name == ""
|
||||
or not is_selected_for_writing(
|
||||
self.settings, os.path.join(self.output_path, name)
|
||||
)
|
||||
):
|
||||
if name is False or name == "":
|
||||
return
|
||||
elif not name:
|
||||
# other stuff, just return for now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue