shopen


Nameshopen JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryProper implementation of os.startfile to launch a target file/URL
upload_time2024-09-22 03:07:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords os
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "shopen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "os",
    "author": null,
    "author_email": "David Barnett <david@mumind.me>",
    "download_url": "https://files.pythonhosted.org/packages/3d/6e/3bd9e1d801fce365962f3c9c71eed6154d9d97c7f73946cbce4371d2faff/shopen-0.2.2.tar.gz",
    "platform": null,
    "description": "# shopen\n\nshopen is a proper implementation of os.startfile to launch a target file/URL. Use it to launch the\npreferred system viewer for the user to view or edit a target file or URL.\n\n\"shopen\" is short for `shutil.open`, the [proposed builtin](\nhttps://github.com/python/cpython/issues/47427) it's intended to be a reference implementation for.\n\n[![PyPI - Version](https://img.shields.io/pypi/v/shopen.svg)](https://pypi.org/project/shopen)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/shopen.svg)](https://pypi.org/project/shopen)\n\n-----\n\n## Usage\n\nSimply install as a dependency of your project and then use it to launch an opener for a file or\nURL:\n\n```python\nimport pathlib, shopen\nshopen.open(\"https://zombo.com/\")  # Opens web browser\nshopen.open(pathlib.Path(\"~/somefile.txt\").expanduser())  # Opens file viewer\nshopen.open(pathlib.Path(\"./somefile.toml\"), \"edit\")  # Opens editor\n```\n\n## Why?\n\nPython's standard library provides nice cross-platform utilites for lots of different purposes, but\nso far no simple file/URL opener that would work on all platforms.\n\nOn Windows there's [os.startfile], but strangely that doesn't support any other platform.\n\nThe proposal [python/cpython#47427](https://github.com/python/cpython/issues/47427) to implement it\nas `shutil.open` was rejected for now. Python users keep [asking](\nhttps://stackoverflow.com/questions/434597/open-document-with-default-os-application-in-python-both-in-windows-and-mac-os)\nfor a decent way to do it, but the only answer had been brittle copypasta\u2026 until now!\n\nIdeally this can be added into stdlib after proving its usefulness and then only be needed as a\npolyfill for older versions of python.\n\n[os.startfile]: https://docs.python.org/3/library/os.html#os.startfile\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Proper implementation of os.startfile to launch a target file/URL",
    "version": "0.2.2",
    "project_urls": {
        "Documentation": "https://github.com/dbarnett/py-shopen#readme",
        "Issues": "https://github.com/dbarnett/py-shopen/issues",
        "Source": "https://github.com/dbarnett/py-shopen"
    },
    "split_keywords": [
        "os"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "01fd634b8d5a76af735988e28462d71056abb3e5087233b1166b453f2b522d81",
                "md5": "bd071f5aeb3ec9bd5113aac6ea4db689",
                "sha256": "d584291c76e64bda7f04ea168afb3314c2bfe194b5098f863d735753550ab373"
            },
            "downloads": -1,
            "filename": "shopen-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bd071f5aeb3ec9bd5113aac6ea4db689",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4236,
            "upload_time": "2024-09-22T03:07:50",
            "upload_time_iso_8601": "2024-09-22T03:07:50.178213Z",
            "url": "https://files.pythonhosted.org/packages/01/fd/634b8d5a76af735988e28462d71056abb3e5087233b1166b453f2b522d81/shopen-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d6e3bd9e1d801fce365962f3c9c71eed6154d9d97c7f73946cbce4371d2faff",
                "md5": "45209a8533fedaf0192a6d35a6d5a770",
                "sha256": "6e702c57616768856a86cf39cb780470196b6d96a20caa2b2703ae0334235edd"
            },
            "downloads": -1,
            "filename": "shopen-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "45209a8533fedaf0192a6d35a6d5a770",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5338,
            "upload_time": "2024-09-22T03:07:51",
            "upload_time_iso_8601": "2024-09-22T03:07:51.244536Z",
            "url": "https://files.pythonhosted.org/packages/3d/6e/3bd9e1d801fce365962f3c9c71eed6154d9d97c7f73946cbce4371d2faff/shopen-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-22 03:07:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dbarnett",
    "github_project": "py-shopen#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "shopen"
}
        
Elapsed time: 0.35297s