Skip to content

Commit

Permalink
Merge pull request #86 from ParkenDD/allow-converter-intermediate-cla…
Browse files Browse the repository at this point in the history
…sses

Allow converter intermediate classes
  • Loading branch information
the-infinity authored Jan 31, 2024
2 parents f306f9d + 4642ce3 commit ab76cbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def register_converters(self):
# appending the base package dir gives converters the ability to work within their own module without relative paths
sys.path.append(str(base_package_dir))
# This import is based on the additional module path just added to sys
from common.base_converter import CsvConverter, JsonConverter, PullConverter, XlsxConverter, XmlConverter
from util import ScraperBase
from common.base_converter import PullConverter
from util import ScraperBase, SourceInfo

for source_dir in ['original', 'new', 'v3']:
package_dir = base_package_dir.joinpath(source_dir)
Expand All @@ -95,16 +95,10 @@ def register_converters(self):
self.legacy_pull_converters[attribute.POOL.id] = attribute()
continue

if (
not issubclass(attribute, XlsxConverter)
and not issubclass(attribute, XmlConverter)
and not issubclass(attribute, CsvConverter)
and not issubclass(attribute, JsonConverter)
and not issubclass(attribute, PullConverter)
):
continue
if attribute in [XlsxConverter, XmlConverter, CsvConverter, JsonConverter, PullConverter]:
# source_info is just set at actual final classes, so we ignore anything else
if not hasattr(attribute, 'source_info') or not isinstance(attribute.source_info, SourceInfo):
continue

# at this point we can be sure that attribute is a BaseConverter or PullConverter child, so we can initialize and
# register it
if issubclass(attribute, PullConverter):
Expand Down

0 comments on commit ab76cbf

Please sign in to comment.