Skip to content

Commit

Permalink
Merge branch 'gacou54:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ylemarechal authored Aug 30, 2023
2 parents 71639cb + beaba0e commit 26fb405
Show file tree
Hide file tree
Showing 24 changed files with 1,134 additions and 530 deletions.
30 changes: 20 additions & 10 deletions pyorthanc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pyorthanc.async_client import AsyncOrthanc
from pyorthanc.client import Orthanc
from pyorthanc.remote import RemoteModality
from pyorthanc.patient import Patient
from pyorthanc.study import Study
from pyorthanc.series import Series
from pyorthanc.instance import Instance
from pyorthanc.filtering import build_patient_forest, find, trim_patient, retrieve_and_write_patients
from pyorthanc.resources.study import Study
from .async_client import AsyncOrthanc
from .client import Orthanc
from .filtering import build_patient_forest, find, trim_patients
from .find import find_instances, find_patients, find_series, find_studies, query_orthanc
from .remote import RemoteModality
from .resources import Instance, Patient, Series, Study
from .retrieve import retrieve_and_write_instance, retrieve_and_write_patient, retrieve_and_write_patients, \
retrieve_and_write_series, retrieve_and_write_study


__all__ = [
Expand All @@ -17,7 +18,16 @@
'Series',
'Instance',
'build_patient_forest',
'trim_patient',
'retrieve_and_write_patients',
'trim_patients',
'find',
'find_patients',
'find_studies',
'find_series',
'find_instances',
'query_orthanc',
'retrieve_and_write_patients',
'retrieve_and_write_patient',
'retrieve_and_write_study',
'retrieve_and_write_series',
'retrieve_and_write_instance',
]
11 changes: 4 additions & 7 deletions pyorthanc/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AsyncOrthanc(httpx.AsyncClient):
"""

def __init__(self, url: str, username: Optional[str] = None, password: Optional[str] = None, headers: Optional[HeaderTypes] = None, return_raw_response: bool = False):
def __init__(self, url: str, username: Optional[str] = None, password: Optional[str] = None, return_raw_response: bool = False, *args, **kwargs):
"""
Parameters
----------
Expand All @@ -30,22 +30,19 @@ def __init__(self, url: str, username: Optional[str] = None, password: Optional[
Orthanc's username
password
Orthanc's password
headers
Headers that will be share in all requests
return_raw_response
All Orthanc's methods will return a raw httpx.Response rather than the serialized result
*args, **kwargs
Parameters passed to the httpx.Client (headers, timeout, etc.)
"""
super().__init__()
super().__init__(*args, **kwargs)
self.url = url
self.version = '1.12.1'
self.return_raw_response = return_raw_response

if username and password:
self.setup_credentials(username, password)

if headers is not None:
self.headers = headers

def setup_credentials(self, username: str, password: str) -> None:
"""Set credentials needed for HTTP requests"""
self._auth = httpx.BasicAuth(username, password)
Expand Down
11 changes: 4 additions & 7 deletions pyorthanc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Orthanc(httpx.Client):
"""

def __init__(self, url: str, username: Optional[str] = None, password: Optional[str] = None, headers: Optional[HeaderTypes] = None, return_raw_response: bool = False):
def __init__(self, url: str, username: Optional[str] = None, password: Optional[str] = None, return_raw_response: bool = False, *args, **kwargs):
"""
Parameters
----------
Expand All @@ -30,22 +30,19 @@ def __init__(self, url: str, username: Optional[str] = None, password: Optional[
Orthanc's username
password
Orthanc's password
headers
Headers that will be share in all requests
return_raw_response
All Orthanc's methods will return a raw httpx.Response rather than the serialized result
*args, **kwargs
Parameters passed to the httpx.Client (headers, timeout, etc.)
"""
super().__init__()
super().__init__(*args, **kwargs)
self.url = url
self.version = '1.12.1'
self.return_raw_response = return_raw_response

if username and password:
self.setup_credentials(username, password)

if headers is not None:
self.headers = headers

def setup_credentials(self, username: str, password: str) -> None:
"""Set credentials needed for HTTP requests"""
self._auth = httpx.BasicAuth(username, password)
Expand Down
Loading

0 comments on commit 26fb405

Please sign in to comment.