clip-util


Nameclip-util JSON
Version 0.1.26 PyPI version JSON
download
home_pageNone
SummaryClipboard utilities for use with Python.
upload_time2024-05-01 03:30:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright © 2022 Kyle L. Davis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords clipboard html rtf unicode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/pypi/v/clip-util?color=darkred)](https://pypi.org/project/clip-util/)
[![Read the Docs](https://img.shields.io/readthedocs/clip-util)](https://clip-util.readthedocs.io/en/latest/)
[![Tests](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml/badge.svg)](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml)

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/clip-util?label=Python%20Version&logo=python&logoColor=yellow)](https://pypi.org/project/clip-util/)
[![PyPI - License](https://img.shields.io/pypi/l/clip-util?color=green)](https://github.com/AceofSpades5757/clip-util/blob/main/LICENSE)

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# Description

Package for accessing the clipboard with Python.

# Installation

`pip install clip-util`

# Features

_Windows Only_

Allows you to set text, RTF, and HTML to the clipboard on Windows. Any other format can also be specified using the format type integer, specified by Windows.

## Supported Clipboard Formats

- Text
- HTML
- RTF

# Usage

## Clipboard

Will open and close every time the values are set, or retrieved. It's better to use a context manager.

```python
from clipboard import Clipboard


clipboard = Clipboard()

# Set Clipboard
clipboard["text"] = "Hello World!"
# OR
clipboard.set_clipboard("Hello World!")

# Get Clipboard
text = clipboard["text"]
# OR
text = clipboard.get_clipboard("text")

# Supports HTML
clipboard["html"] = "<h1>Hello World</h1>"
```


### Context Manager

```python
from clipboard import Clipboard


with Clipboard() as clipboard:

    # Set Clipboard
    clipboard["text"] = "Hello World!"
    # OR
    clipboard.set_clipboard("Hello World!")

    # Get Clipboard
    text = clipboard["text"]
    # OR
    text = clipboard.get_clipboard("text")

    # HTML
    clipboard["html"] = "<h1>Hello World</h1>"
```

## Clipboard Formats

You can use `clip-util` to access the clipboard formats directly.

`ClipboardFormat`: Enum for clipboard formats.

`ClipboardFormat.CF_HTML`: Represents HTML format.

`ClipboardFormat.CF_RTF`: Represents RTF format.

```python
from clipboard import Clipboard
from clipboard import ClipboardFormat
from clipboard import get_format_name


with Clipboard() as clipboard:

    # Get All Available Formats
    format_ids: list[int] = clipboard.available_formats()

    # Get Specific Format by ID
    # Use parentheses to access the format by ID
    formats: list[ClipboardFormat] = []
    format_id: int
    for format_id in format_ids:
        if format_id in ClipboardFormat:
            format: ClipboardFormat = ClipboardFormat(format_id)
            formats.append(format)
        else:
            # Format is not supported directly by this library
            pass

    # Get Specified Format by Name (directly)
    format_names: list[str] = []
    format_id: int
    for format_id in format_ids:
        name: str = get_format_name(format_id)
        format_names.append(name)

    # Get Specified Format by Name (using enum)
    # Use bracket notation to access the format
    #
    # Note: this method is not as robust as using `get_format_name`
    formats: list[ClipboardFormat] = []
    format_names: list[str] = []
    format_name: str
    for format_name in [f.name for f in formats]:
        if format_name in ClipboardFormat:
            format: ClipboardFormat = ClipboardFormat[format_name]
            name: str = format.name
            formats.append(format)
            format_names.append(name)
        else:
            # Format is not supported directly by this library
            pass
```

## Get All Supported Formats

You can even get the content of all available formats currently in the clipboard.

```python
from clipboard import get_available_formats
from clipboard import get_format_name
from clipboard import get_clipboard


available: list[int] = get_available_formats()
print(f"{available=}")

for format_id in available:
    name: str = get_format_name(format_id)
    content: str = get_clipboard(format_id)
    print(f"{format_id=}", f"{name=}, {content=}")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "clip-util",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "\"Kyle L. Davis\" <aceofspades5757.github@gmail.com>",
    "keywords": "clipboard, html, rtf, unicode",
    "author": null,
    "author_email": "\"Kyle L. Davis\" <aceofspades5757.github@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c3/ae/2cf78be18b343c5243ba262f2b30baea11f9ad1b209923ede0ac9bfd2e2e/clip_util-0.1.26.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/pypi/v/clip-util?color=darkred)](https://pypi.org/project/clip-util/)\r\n[![Read the Docs](https://img.shields.io/readthedocs/clip-util)](https://clip-util.readthedocs.io/en/latest/)\r\n[![Tests](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml/badge.svg)](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml)\r\n\r\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/clip-util?label=Python%20Version&logo=python&logoColor=yellow)](https://pypi.org/project/clip-util/)\r\n[![PyPI - License](https://img.shields.io/pypi/l/clip-util?color=green)](https://github.com/AceofSpades5757/clip-util/blob/main/LICENSE)\r\n\r\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n\r\n# Description\r\n\r\nPackage for accessing the clipboard with Python.\r\n\r\n# Installation\r\n\r\n`pip install clip-util`\r\n\r\n# Features\r\n\r\n_Windows Only_\r\n\r\nAllows you to set text, RTF, and HTML to the clipboard on Windows. Any other format can also be specified using the format type integer, specified by Windows.\r\n\r\n## Supported Clipboard Formats\r\n\r\n- Text\r\n- HTML\r\n- RTF\r\n\r\n# Usage\r\n\r\n## Clipboard\r\n\r\nWill open and close every time the values are set, or retrieved. It's better to use a context manager.\r\n\r\n```python\r\nfrom clipboard import Clipboard\r\n\r\n\r\nclipboard = Clipboard()\r\n\r\n# Set Clipboard\r\nclipboard[\"text\"] = \"Hello World!\"\r\n# OR\r\nclipboard.set_clipboard(\"Hello World!\")\r\n\r\n# Get Clipboard\r\ntext = clipboard[\"text\"]\r\n# OR\r\ntext = clipboard.get_clipboard(\"text\")\r\n\r\n# Supports HTML\r\nclipboard[\"html\"] = \"<h1>Hello World</h1>\"\r\n```\r\n\r\n\r\n### Context Manager\r\n\r\n```python\r\nfrom clipboard import Clipboard\r\n\r\n\r\nwith Clipboard() as clipboard:\r\n\r\n    # Set Clipboard\r\n    clipboard[\"text\"] = \"Hello World!\"\r\n    # OR\r\n    clipboard.set_clipboard(\"Hello World!\")\r\n\r\n    # Get Clipboard\r\n    text = clipboard[\"text\"]\r\n    # OR\r\n    text = clipboard.get_clipboard(\"text\")\r\n\r\n    # HTML\r\n    clipboard[\"html\"] = \"<h1>Hello World</h1>\"\r\n```\r\n\r\n## Clipboard Formats\r\n\r\nYou can use `clip-util` to access the clipboard formats directly.\r\n\r\n`ClipboardFormat`: Enum for clipboard formats.\r\n\r\n`ClipboardFormat.CF_HTML`: Represents HTML format.\r\n\r\n`ClipboardFormat.CF_RTF`: Represents RTF format.\r\n\r\n```python\r\nfrom clipboard import Clipboard\r\nfrom clipboard import ClipboardFormat\r\nfrom clipboard import get_format_name\r\n\r\n\r\nwith Clipboard() as clipboard:\r\n\r\n    # Get All Available Formats\r\n    format_ids: list[int] = clipboard.available_formats()\r\n\r\n    # Get Specific Format by ID\r\n    # Use parentheses to access the format by ID\r\n    formats: list[ClipboardFormat] = []\r\n    format_id: int\r\n    for format_id in format_ids:\r\n        if format_id in ClipboardFormat:\r\n            format: ClipboardFormat = ClipboardFormat(format_id)\r\n            formats.append(format)\r\n        else:\r\n            # Format is not supported directly by this library\r\n            pass\r\n\r\n    # Get Specified Format by Name (directly)\r\n    format_names: list[str] = []\r\n    format_id: int\r\n    for format_id in format_ids:\r\n        name: str = get_format_name(format_id)\r\n        format_names.append(name)\r\n\r\n    # Get Specified Format by Name (using enum)\r\n    # Use bracket notation to access the format\r\n    #\r\n    # Note: this method is not as robust as using `get_format_name`\r\n    formats: list[ClipboardFormat] = []\r\n    format_names: list[str] = []\r\n    format_name: str\r\n    for format_name in [f.name for f in formats]:\r\n        if format_name in ClipboardFormat:\r\n            format: ClipboardFormat = ClipboardFormat[format_name]\r\n            name: str = format.name\r\n            formats.append(format)\r\n            format_names.append(name)\r\n        else:\r\n            # Format is not supported directly by this library\r\n            pass\r\n```\r\n\r\n## Get All Supported Formats\r\n\r\nYou can even get the content of all available formats currently in the clipboard.\r\n\r\n```python\r\nfrom clipboard import get_available_formats\r\nfrom clipboard import get_format_name\r\nfrom clipboard import get_clipboard\r\n\r\n\r\navailable: list[int] = get_available_formats()\r\nprint(f\"{available=}\")\r\n\r\nfor format_id in available:\r\n    name: str = get_format_name(format_id)\r\n    content: str = get_clipboard(format_id)\r\n    print(f\"{format_id=}\", f\"{name=}, {content=}\")\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright \u00a9 2022 Kyle L. Davis  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Clipboard utilities for use with Python.",
    "version": "0.1.26",
    "project_urls": {
        "Author": "https://github.com/AceofSpades5757",
        "Documentation": "https://clip-util.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/AceofSpades5757/clip-util",
        "Issues": "https://github.com/AceofSpades5757/clip-util/issues",
        "Repository": "https://github.com/AceofSpades5757/clip-util"
    },
    "split_keywords": [
        "clipboard",
        " html",
        " rtf",
        " unicode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa2674a69a4a10697ffcc83367a465685734139f57dd1c6288135310a908c2ad",
                "md5": "1cc1a50a8b9556df92c40c97d7715047",
                "sha256": "b80b345e3bb909aea8d2a792881446051d95f80d74eef3a184c1cdefbe6d85f3"
            },
            "downloads": -1,
            "filename": "clip_util-0.1.26-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1cc1a50a8b9556df92c40c97d7715047",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13064,
            "upload_time": "2024-05-01T03:30:21",
            "upload_time_iso_8601": "2024-05-01T03:30:21.133036Z",
            "url": "https://files.pythonhosted.org/packages/aa/26/74a69a4a10697ffcc83367a465685734139f57dd1c6288135310a908c2ad/clip_util-0.1.26-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c3ae2cf78be18b343c5243ba262f2b30baea11f9ad1b209923ede0ac9bfd2e2e",
                "md5": "b8f06cddc04791e6407dcba1c02ebd36",
                "sha256": "0d3766d348d594a458076b98c7738e77f08c0f276787bab85ba444a6b9558875"
            },
            "downloads": -1,
            "filename": "clip_util-0.1.26.tar.gz",
            "has_sig": false,
            "md5_digest": "b8f06cddc04791e6407dcba1c02ebd36",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11301,
            "upload_time": "2024-05-01T03:30:22",
            "upload_time_iso_8601": "2024-05-01T03:30:22.833260Z",
            "url": "https://files.pythonhosted.org/packages/c3/ae/2cf78be18b343c5243ba262f2b30baea11f9ad1b209923ede0ac9bfd2e2e/clip_util-0.1.26.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-01 03:30:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AceofSpades5757",
    "github_project": "clip-util",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "clip-util"
}
        
Elapsed time: 2.93378s