-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert FEED setting from %s
to {slug}
-style strings
#2383
Conversation
@MinchinWeb: It appears Travis is reporting test failures. Could you take a look? |
@justinmayer Success! Flake8 issues have been fixed. I have Pandoc v2.1.3 install locally and so some test fail due to that. See issues #2255 and #2322, and WIP PR #2289. There are several other tests that fail locally (on Windows) for various reasons; some are things I haven't touched, so I'm leaving alone; some are due to 'symbolic link privilege not help'; some are due to Windows filepaths being written different than POSIX paths (these I skip now on Windows). These, as a whole, I'm ignoring. The other broken test was a simple typo. Fixed now! Python 3.7 has been released, but was failing to download on Travis; it can be added back at a later time. |
Would any @getpelican/reviewers be willing to take a moment and review this pull request? |
Yay, I personally welcome the change to CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' would now result in self.settings['CATEGORY_FEED_ATOM']).format(slug=category.slug).replace('%s', category.slug) And similarly elsewhere (maybe Besides that, the diff contains a lot of unnecessary formatting changes that make it very hard to review. Would it be possible to clean up the diff to not have them? Also, unrelated changes such as |
@mosra : I like you suggestion of how to support the two styles. I searched for examples of how to do this, and never did find anything useful... Regarding the "extra" pieces, some of the reformatting is from the different lengths of The Windows testing issues are similar (they could be pulled to a separate PR, and this one rebased on to it), but they were needed to get this far: when I first ran the test suite locally (on my Windows machine), a huge swatch of the tests failed, and so it was very hard to know what, if any, tests I had broken. Making the tests behave more sanely was the faster alternative to spamming Travis and crossing my fingers. |
@justinmayer @mosra : both old-style and new-style text substitutes are now supported!
|
pelican/generators.py
Outdated
@@ -400,7 +402,8 @@ def generate_feeds(self, writer): | |||
writer.write_feed( | |||
arts, | |||
self.context, | |||
self.settings['TAG_FEED_ATOM'].format(tag.slug), | |||
self.settings['TAG_FEED_ATOM'].replace('%s', '{slug}') | |||
.format(tag.slug), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not .format(slug=tag.slug)
here (and the two cases below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. It's been fixed!
91c9018
to
88fa66d
Compare
88fa66d
to
5be4b17
Compare
Sorry for late-ish response but, I don't really like the For one, it'd fail if you have >>> '%s'.replace('%s', '{slug}').format(slug='foo')
'foo'
>>> '{%s}'.replace('%s', '{slug}').format(slug='foo')
'{slug}'
>>> '{%s'.replace('%s', '{slug}').format(slug='foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Single '}' encountered in format string Second, I'd rather have these handled when the settings file is read (in And I'd propose throwing a warning and falling back to the default in case |
@avaris I like the idea of moving the conversion to the I'm not sure what to do about the errors you mention, and I haven't found an example online support both string styles at the same time. Do we throw an error on |
A check in for KEY in list_of_feed_setting_keys:
if '%s' in setting[KEY]:
logger.warning('%%s usage in %s is deprecated, use {name} instead. Falling back to default'. KEY)
setting[KEY] = DEFAULT_CONFIG[KEY] Very similar to this. |
39e2820
to
fba4c84
Compare
rather than trying to update them in place. Relies on the user to make the needed changes. Fallback is the default setting.
fba4c84
to
a3c0360
Compare
@avaris @mosra : I've moved to avaris' suggestion of complaining of old style settings when the settings are first loaded and falling back to the default in this case. I'm of slightly mixed feeling as it requires the user to actively update their settings to work with the new Pelican version, and doesn't support backwards-compatibility, but on the other hand it avoids a bunch of odd corner cases that are hard to detect and resolve automatically. But "explicit is better than implicit", so let's go with it. Does something in the documentation need to be added to explain this change? The failing test is due to a change in how Markdown v3 outputs HTML for footnotes. The fix has been submitted separately as PR #2417. |
@avaris / @mosra: Any further comments on @MinchinWeb's pull request? |
Stuff related to this PR is OK, but there are a lot of unrelated stuff (some unwarranted formatting changes, tox?? etc) attached to it. Is it possible to clean this up a bit? |
@MinchinWeb: I agree it's best to keep pull requests as discrete and digestible as possible. Could you take a look and perhaps move anything not directly related to issue 2106 into separate pull requests? |
It can be done, but it does seem like "busy work" rather than "fun work". And I don't understand what it adds. |
It's more about what it removes, which is the unrelated stuff reviewers have to go over otherwise. |
7 Pull Requests and 5 hours later, the pieces of this have all been split apart. #2432 is the core functionality I set out to add. I hope the various pull requests can be merged quickly and cleanly.
|
Since Pelican 4.0, `CATEGORY_FEED_ATOM` and `TAG_FEED_ATOM` are expected to use `{slug}`, not `%s`. Seems to have been introduced in getpelican/pelican#2383. This would cause the following error: ``` CRITICAL: TypeError: not all arguments converted during string formatting ``` This change allows for backwards and forward compatibility.
Since Pelican 4.0, `CATEGORY_FEED_ATOM` and `TAG_FEED_ATOM` are expected to use `{slug}`, not `%s`. Seems to have been introduced in getpelican/pelican#2383. This would cause the following error: ``` CRITICAL: TypeError: not all arguments converted during string formatting ``` This change allows for backwards and forward compatibility.
Since Pelican 4.0, `CATEGORY_FEED_ATOM` and `TAG_FEED_ATOM` are expected to use `{slug}`, not `%s`. Seems to have been introduced in getpelican/pelican#2383. This would cause the following error: ``` CRITICAL: TypeError: not all arguments converted during string formatting ``` This change allows for backwards and forward compatibility. Cherry picked from commit getpelican/pelican-themes@be0a410.
Closes #2106