Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/smart_open/__init__.py: 92%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#
2# Copyright (C) 2019 Radim Rehurek <me@radimrehurek.com>
3#
4# This code is distributed under the terms and conditions
5# from the MIT License (MIT).
6#
8"""Utilities for streaming to/from several file-like data storages.
10Supports S3 / HDFS / local filesystem / compressed files, and many more,
11using a simple, Pythonic API.
13The streaming makes heavy use of generators and pipes, to avoid loading
14full file contents into memory, allowing work with arbitrarily large files.
16The main functions are:
18* `open()`, which opens the given file for reading/writing
19* `parse_uri()`
20* `register_compressor()`, which registers callbacks for transparent compressor handling
22"""
24import contextlib
25import logging
26from importlib.metadata import PackageNotFoundError, version
28with contextlib.suppress(PackageNotFoundError):
29 __version__ = version("smart_open")
30#
31# Prevent regression of #474 and #475
32#
33logger = logging.getLogger(__name__)
34logger.addHandler(logging.NullHandler())
36from .compression import register_compressor # noqa: E402 # logger setup precedes imports (see #474)
37from .smart_open_lib import open, parse_uri # noqa: E402 # logger setup precedes imports (see #474)
39__all__ = [
40 "open",
41 "parse_uri",
42 "register_compressor",
43]