Skip to content

Centralized Importer Class - #237

Open
krzywon wants to merge 9 commits into
refactor_24_231_io_reorgfrom
refactor_24_central_io_classes
Open

krzywon wants to merge 9 commits into
refactor_24_231_io_reorgfrom
refactor_24_central_io_classes

Conversation

@krzywon

@krzywon krzywon commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

This is the next step in the data import/export process. A central Importer class will look at the file mime type (for now) and infer the Importer based on that. Mime types are infallible, so a further check will be coming.

@krzywon
krzywon added this pull request to stack #238 September 18, 2026 13:53
codescene-access[bot]

This comment was marked as outdated.

@DrPaulSharp
DrPaulSharp self-requested a review September 18, 2026 14:31

@DrPaulSharp DrPaulSharp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, I've a couple of minor points.

pass
return []
return [], [f'File does not exist: "{file}"']
mime_type, encoding = mimetypes.guess_type(url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be mindful that guess_type has been soft deprecated in favour of guess_file_type in mimetypes. However, the refactoring branch is currently running on python version >=3.12 so we need to leave this as is for now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment here so we don't overlook it during the transition to later python versions.

imported.extend(file_list)
except Exception as e:
errors.append(f'Error accessing "{file}": {e}')
return imported, errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is errors a list given that it can only have zero or one elements? Is there a reason not to return a string instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess it makes two extend() lines in import_data which is neater. Is there anything else?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking longer term, like when #225 is fixed, there may be errors/warnings during file read that could be bundled into this list.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

See analysis details in CodeScene

Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants