Skip to main content

openfile is a trivial Python module that implements a single convenience function openfile(filename, mode="rt", **kwargs) wich delegates the real work to one of the following standard library functions:

  • gzip.open(filename, mode, **kwargs) if the file ends with suffix .gz;

  • bz2.open(filename, mode, **kwargs) if the file ends with suffix .bz2;

  • lzma.open(filename, mode, **kwargs) if the file ends with suffix .xz or .lzma;

  • open(filename, mode, **kwargs) if the file does not end with any suffix mentioned above.

If the filename is a single dash - then sys.stdin or sys.stdout is returned, depending on mode being r or w, respectively.

The following keyword arguments are used by openfile:

  • expanduser=True will cause openfile to call os.path.expanduser for filename.

  • expandvars=True will cause openfile to call os.path.expandvars for filename.

  • makedirs=True will cause openfile to call os.makedirs for the parent directory os.path.dirname(filename) if it does not exist and mode contains either "w" or "a".

All other keyword arguments passed to openfile will be passed down to the open functions listed above.

Metadata

Release files for openfile 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfile 0.0.7
File Size Uploaded
openfile-0.0.7.tar.gz 2.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openfile 0.0.7
File Interpreter ABI Platform
openfile-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 kB

Release files / openfile-0.0.7.tar.gz

Download URL openfile-0.0.7.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea4e8f19112049f578ec161b12f70c1113144988c0a488ab173a138b50f37479
BLAKE2b-256 checksum
How to use checksums
16466c8b936e55ace50a6d9ea722dd4b11a4996d58cff41690636a0d6f6f6718
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.23.2 CPython/3.6.4

Release files / openfile-0.0.7-py3-none-any.whl

Download URL openfile-0.0.7-py3-none-any.whl
Size 2.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d21b69dba1306c9dd397a44fd8f4fa8a83812f1d935c409085e8a25c411d16ec
BLAKE2b-256 checksum
How to use checksums
93e6805db6867faacb488b44ba8e0829ef4de151dd0499f3c5da5f4ad11698a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.23.2 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

1 release file

0.0.5

1 release file

0.0.3

1 release file

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page