From 86d689851793e61b0cee1fe0bf72c8ebc991b6c1 Mon Sep 17 00:00:00 2001 From: Deniz Turgut Date: Sun, 12 Nov 2023 19:43:26 +0300 Subject: [PATCH] remove WRITE_SELECTED Implementation is buggy and unreliable. Therefore, it is better to remove the functionality until a robust implementation is added. --- docs/faq.rst | 4 ---- docs/publish.rst | 12 ------------ docs/settings.rst | 22 ---------------------- pelican/__init__.py | 11 ----------- pelican/settings.py | 14 +++++++------- pelican/tests/test_pelican.py | 23 ----------------------- pelican/utils.py | 13 ------------- pelican/writers.py | 12 +----------- 8 files changed, 8 insertions(+), 103 deletions(-) diff --git a/docs/faq.rst b/docs/faq.rst index c065b4ed8..cecc11575 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -217,10 +217,6 @@ changed. A simple solution is to make ``rsync`` use the ``--checksum`` option, which will make it compare the file checksums in a much faster way than Pelican would. -When only several specific output files are of interest (e.g. when working on -some specific page or the theme templates), the ``WRITE_SELECTED`` option may -help, see :ref:`writing_only_selected_content`. - How to process only a subset of all articles? ============================================= diff --git a/docs/publish.rst b/docs/publish.rst index f5ebfff56..e687b65af 100644 --- a/docs/publish.rst +++ b/docs/publish.rst @@ -18,18 +18,6 @@ folder, using the default theme to produce a simple site. The default theme consists of very simple HTML without styling and is provided so folks may use it as a basis for creating their own themes. -When working on a single article or page, it is possible to generate only the -file that corresponds to that content. To do this, use the ``--write-selected`` -argument, like so:: - - pelican --write-selected output/posts/my-post-title.html - -Note that you must specify the path to the generated *output* file — not the -source content. To determine the output file name and location, use the -``--debug`` flag. If desired, ``--write-selected`` can take a comma-separated -list of paths or can be configured as a setting. (See: -:ref:`writing_only_selected_content`) - You can also tell Pelican to watch for your modifications, instead of manually re-running it every time you want to see your changes. To enable this, run the ``pelican`` command with the ``-r`` or ``--autoreload`` option. On non-Windows diff --git a/docs/settings.rst b/docs/settings.rst index 88a32d239..e9edffde0 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -362,13 +362,6 @@ Basic settings If ``True``, load unmodified content from caches. -.. data:: WRITE_SELECTED = [] - - If this list is not empty, **only** output files with their paths in this - list are written. Paths should be either absolute or relative to the current - Pelican working directory. For possible use cases see - :ref:`writing_only_selected_content`. - .. data:: FORMATTED_FIELDS = ['summary'] A list of metadata fields containing reST/Markdown content to be parsed and @@ -1400,21 +1393,6 @@ modification times of the generated ``*.html`` files will always change. Therefore, ``rsync``-based uploading may benefit from the ``--checksum`` option. -.. _writing_only_selected_content: - - -Writing only selected content -============================= - -When only working on a single article or page, or making tweaks to your theme, -it is often desirable to generate and review your work as quickly as possible. -In such cases, generating and writing the entire site output is often -unnecessary. By specifying only the desired files as output paths in the -``WRITE_SELECTED`` list, **only** those files will be written. This list can be -also specified on the command line using the ``--write-selected`` option, which -accepts a comma-separated list of output file paths. By default this list is -empty, so all output is written. See :ref:`site_generation` for more details. - Example settings ================ diff --git a/pelican/__init__.py b/pelican/__init__.py index 25c493b93..a25f5624b 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -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: diff --git a/pelican/settings.py b/pelican/settings.py index 4a4f29012..33ec210a3 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -169,7 +169,6 @@ def load_source(name, path): "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: diff --git a/pelican/tests/test_pelican.py b/pelican/tests/test_pelican.py index 3c0c05722..075f55ebe 100644 --- a/pelican/tests/test_pelican.py +++ b/pelican/tests/test_pelican.py @@ -202,29 +202,6 @@ def test_theme_static_paths_copy_single_file(self): 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, diff --git a/pelican/utils.py b/pelican/utils.py index 02ffb9d16..eda53d3f5 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -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)) diff --git a/pelican/writers.py b/pelican/writers.py index ec12d1257..d405fc889 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -11,7 +11,6 @@ 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 @@ def write_feed( 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 @@ def write_file( :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