Metadata-Version: 2.3
Name: shopen
Version: 0.2.2
Summary: Proper implementation of os.startfile to launch a target file/URL
Project-URL: Documentation, https://github.com/dbarnett/py-shopen#readme
Project-URL: Issues, https://github.com/dbarnett/py-shopen/issues
Project-URL: Source, https://github.com/dbarnett/py-shopen
Author-email: David Barnett <david@mumind.me>
License-Expression: MIT
License-File: LICENSE.txt
Keywords: os
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.8
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-mock; extra == 'dev'
Requires-Dist: pytest-subprocess; extra == 'dev'
Description-Content-Type: text/markdown

# shopen

shopen is a proper implementation of os.startfile to launch a target file/URL. Use it to launch the
preferred system viewer for the user to view or edit a target file or URL.

"shopen" is short for `shutil.open`, the [proposed builtin](
https://github.com/python/cpython/issues/47427) it's intended to be a reference implementation for.

[![PyPI - Version](https://img.shields.io/pypi/v/shopen.svg)](https://pypi.org/project/shopen)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/shopen.svg)](https://pypi.org/project/shopen)

-----

## Usage

Simply install as a dependency of your project and then use it to launch an opener for a file or
URL:

```python
import pathlib, shopen
shopen.open("https://zombo.com/")  # Opens web browser
shopen.open(pathlib.Path("~/somefile.txt").expanduser())  # Opens file viewer
shopen.open(pathlib.Path("./somefile.toml"), "edit")  # Opens editor
```

## Why?

Python's standard library provides nice cross-platform utilites for lots of different purposes, but
so far no simple file/URL opener that would work on all platforms.

On Windows there's [os.startfile], but strangely that doesn't support any other platform.

The proposal [python/cpython#47427](https://github.com/python/cpython/issues/47427) to implement it
as `shutil.open` was rejected for now. Python users keep [asking](
https://stackoverflow.com/questions/434597/open-document-with-default-os-application-in-python-both-in-windows-and-mac-os)
for a decent way to do it, but the only answer had been brittle copypasta… until now!

Ideally this can be added into stdlib after proving its usefulness and then only be needed as a
polyfill for older versions of python.

[os.startfile]: https://docs.python.org/3/library/os.html#os.startfile
