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

12 statements  

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# 

7 

8"""Utilities for streaming to/from several file-like data storages. 

9 

10Supports S3 / HDFS / local filesystem / compressed files, and many more, 

11using a simple, Pythonic API. 

12 

13The streaming makes heavy use of generators and pipes, to avoid loading 

14full file contents into memory, allowing work with arbitrarily large files. 

15 

16The main functions are: 

17 

18* `open()`, which opens the given file for reading/writing 

19* `parse_uri()` 

20* `register_compressor()`, which registers callbacks for transparent compressor handling 

21 

22""" 

23 

24import contextlib 

25import logging 

26from importlib.metadata import PackageNotFoundError, version 

27 

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()) 

35 

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) 

38 

39__all__ = [ 

40 "open", 

41 "parse_uri", 

42 "register_compressor", 

43]