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

Feature/pycap 4 export project format #5

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pycaprio/core/adapters/http_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def delete_annotation(self, project_id: int, document_id: int, user_name: str):
allowed_statuses=(204, 200))
return True

def export_project(self, project_id: int) -> bytes:
response = self.client.get(f"/projects/{project_id}/export.zip", allowed_statuses=(200,))
def export_project(self, project_id: int, format: str = DocumentFormats.DEFAULT) -> bytes:
response = self.client.get(f"/projects/{project_id}/export.zip", allowed_statuses=(200,),
params={'format': format})
return response.content

def import_project(self, zip_stream: IO) -> Project:
Expand Down
9 changes: 6 additions & 3 deletions pycaprio/core/interfaces/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ def annotations(self, project_id: int, document_id: int) -> List[Annotation]:
pass # pragma: no cover

@abstractmethod
def annotation(self, project_id: int, document_id: int, annotation_id: int) -> bytes:
def annotation(self, project_id: int, document_id: int, annotation_id: int,
format: str = DocumentFormats.DEFAULT) -> bytes:
"""
Retrieves a Document
:param project_id: The project_id of the Project where the Annotation is located
:param document_id: The document_id of the Document where the Annotation is located
:param format: Format in which the annotation will be downloaded
:return: Content of the Annotation in bytes
"""
pass # pragma: no cover
Expand Down Expand Up @@ -98,7 +100,7 @@ def create_document(self, project_id: int, document_name: str, content: IO,

@abstractmethod
def create_annotation(self, project_id: int, document_id: int, user_name: str, content: IO,
annotation_format: str = DocumentFormats.DEFAULT, state: str = AnnotationStatus):
annotation_format: str = DocumentFormats.DEFAULT, state: str = AnnotationStatus.DEFAULT):
"""
Creates a Document
:param project_id: Id of the Project where the new Document will be created
Expand Down Expand Up @@ -139,10 +141,11 @@ def delete_annotation(self, project_id: int, document_id: int, user_name: str) -
pass # pragma: no cover

@abstractmethod
def export_project(self, project_id: int) -> bytes:
def export_project(self, project_id: int, format: str = DocumentFormats.DEFAULT) -> bytes:
"""
Exports a Project into a .zip file.
:param project_id: Project id.
:param format: Format in which the documents and annotations will be exported.
:return: Zip file in bytes.
"""
pass # pragma: no cover
Expand Down