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

[WIP] Add functions to work with metadata #182

Open
wants to merge 64 commits into
base: develop
Choose a base branch
from

Conversation

Heiss
Copy link

@Heiss Heiss commented Oct 23, 2020

This PR implements multiple methods to work with the projects within OSF.
Also it adds a new init parameter to specify a test instance of OSF.

Example for usage:

for project in OSF(token="ASFXXXXXXXXX", address="https://api.test.osf.io/v2").projects():
  print(project.metadata())
  project.delete()

Currently there is small rubbish from my first attempt to use OSFclient as an jsonld client for my work. I will remove it later (or do you want to use it maybe? On my workplace, we use jsonld as our format for distributed informations. It is a nice to have).

This PR adds the following methods to models:

OSF model:

  • projects(): Returns all projects for given session
  • project(id): Returns only the specified project with id
  • create_project(self, title, category=None, description=None, tags=None): create a project with given metadata (category defaults to "project")

Project model:

  • metadata(only_mutable=False, jsonld=False): returns the metadata of current project, can be used to get jsonld and filter to only mutable attributes.
  • update(json=None): updates the current project to the given json
  • delete(): deletes the current project

File model:

  • copyfileobj(): accepts now BytesIO object, because it uses now read(1) instead of peek(1), which is only implemented for buffered IO objects or file objects.

Currently, this changes are already used in my project.

@Heiss Heiss marked this pull request as ready for review December 17, 2020 17:08
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.

None yet

4 participants