Skip to content
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
17 changes: 8 additions & 9 deletions fhir_pyrate/dicom_downloader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ctypes
import hashlib
import io
import logging
Expand All @@ -12,6 +13,7 @@
import traceback
import warnings
from contextlib import contextmanager
from ctypes.util import find_library
from functools import partial
from types import TracebackType
from typing import (
Expand Down Expand Up @@ -45,15 +47,12 @@
# https://stackoverflow.com/questions/64674495/how-to-catch-simpleitk-warnings
# https://github.com/hankcs/HanLP/blob/doc-zh/hanlp/utils/io_util.py
try:
import ctypes
from ctypes.util import find_library
except ImportError:
libc = None
else:
try:
libc = ctypes.cdll.msvcrt # Windows
except OSError:
libc = ctypes.cdll.LoadLibrary(find_library("c")) # type: ignore
# Windows succeeds, POSIX raises
libc: Optional[ctypes.CDLL] = ctypes.cdll.msvcrt # Windows
except (OSError, AttributeError):
# POSIX fallback — "libc.so.*" on Linux, "libc.dylib" on macOS
c_name = find_library("c")
libc = ctypes.CDLL(c_name) if c_name else None


def flush(stream: TextIO) -> None:
Expand Down
Loading
Loading