Within the last ~45 days, I've experienced an odd scoping / import issue with the rss_ogg plugin (disclaimer, I am the author of that plugin), how it imports/uses _encolsure from nikola.nikola vs the locally defined version of the same method, and how to correct the issue in the plugin.
The plugin has fairly standard nikola imports
from nikola import utils
from nikola.nikola import _enclosure
from nikola.plugin_categories import
and, later, defines its own version of _enclosure as such (which, I admit, is likely at least part of this error).
def _enclosure(self, post, lang):
"""Add an enclosure to RSS."""
enclosure = post.meta('ogg_enclosure', lang)
if enclosure:
try:
length = int(post.meta('ogg_enclosure_length', lang) or 0)
except KeyError:
length = 0
except ValueError:
utils.LOGGER.warn("Invalid enclosure length for post {0}".format(post.source_path))
length = 0
url = enclosure
mime = mimetypes.guess_type(url)[0]
return url, length, mime
This is using nikola.nikola._enclosure rather than self.enclosure to render the xml file (I've verified this because it uses the enclosure/media info defined for a non-ogg xml file). As a short term fix/test, I've removed the import of nikola.nikola._enclosure and updated the task to call self._enclosure, but it seems like at least one of those is redundant.
Is there some kind of new scoping change/issue? Does anyone have advice on how to correct this in a clean/coherent way that is going to be better long term?
Environment
Python Version: 3.9.0
Nikola Version: Nikola v8.2.2
Operating System: Windows 10 / Fedora 35
Description:
Within the last ~45 days, I've experienced an odd scoping / import issue with the rss_ogg plugin (disclaimer, I am the author of that plugin), how it imports/uses
_encolsure
fromnikola.nikola
vs the locally defined version of the same method, and how to correct the issue in the plugin.The plugin has fairly standard
nikola
importsand, later, defines its own version of
_enclosure
as such (which, I admit, is likely at least part of this error).further on, it defines its
task
like thisThis is using
nikola.nikola._enclosure
rather thanself.enclosure
to render the xml file (I've verified this because it uses the enclosure/media info defined for a non-ogg xml file). As a short term fix/test, I've removed the import ofnikola.nikola._enclosure
and updated the task to callself._enclosure
, but it seems like at least one of those is redundant.Is there some kind of new scoping change/issue? Does anyone have advice on how to correct this in a clean/coherent way that is going to be better long term?