Skip to content
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

File-like interface to remote resources #70

Merged
merged 8 commits into from
Sep 21, 2023
Merged

File-like interface to remote resources #70

merged 8 commits into from
Sep 21, 2023

Conversation

cmdoret
Copy link
Member

@cmdoret cmdoret commented Sep 21, 2023

Provides a common file-like interface for remote and local files. This will be needed for parsing tasks requiring access to contents of specific files (e.g. license matching).

This PR does the following:

  • Implement a file-like interface for remote and local files
  • Add placeholder methods list_files() to the extractor interface

The interface can be used as follows:

from gimie.io import LocalResource, RemoteResource
local = LocalResource("README.md")

url = "https://raw.githubusercontent.com/SDSC-ORD/gimie/main/README.md"
remote = RemoteResource("README.md", url)

def show_contents(resource: Resource):
  """I show what's in a resource, regardless of where it is"""
  print(resource.name + " contains:")
  with resource.open() as reader:
    print(reader.read())

show_contents(local)
show_contents(remote)

@cmdoret cmdoret added the enhancement New feature or request label Sep 21, 2023
@cmdoret cmdoret requested a review from marftn September 21, 2023 07:46
@cmdoret cmdoret self-assigned this Sep 21, 2023
@cmdoret cmdoret linked an issue Sep 21, 2023 that may be closed by this pull request
Copy link
Member

@marftn marftn left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@cmdoret cmdoret merged commit 9784457 into main Sep 21, 2023
6 checks passed
This was referenced Sep 21, 2023
@cmdoret cmdoret deleted the file-interface branch October 6, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provide generic file object
2 participants