{"id":26353659,"url":"https://github.com/aceofspades5757/clip-util","last_synced_at":"2025-03-16T11:19:33.650Z","repository":{"id":37938775,"uuid":"478390567","full_name":"AceofSpades5757/clip-util","owner":"AceofSpades5757","description":"Package for accessing the clipboard with Python, supporting HTML, RTF, and more.","archived":false,"fork":false,"pushed_at":"2025-03-03T20:50:50.000Z","size":386,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T19:51:46.032Z","etag":null,"topics":["clipboard","html","python","rtf","windows"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AceofSpades5757.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-06T03:36:39.000Z","updated_at":"2025-02-04T07:42:44.000Z","dependencies_parsed_at":"2023-01-31T19:45:20.025Z","dependency_job_id":"f1f0e953-5c1f-4f7d-99a3-88c1ae1d0c93","html_url":"https://github.com/AceofSpades5757/clip-util","commit_stats":{"total_commits":91,"total_committers":3,"mean_commits":"30.333333333333332","dds":"0.13186813186813184","last_synced_commit":"e775c91161385841da64f86ac9c95aaeb2085e0c"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fclip-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fclip-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fclip-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AceofSpades5757%2Fclip-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AceofSpades5757","download_url":"https://codeload.github.com/AceofSpades5757/clip-util/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858328,"owners_count":20359344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clipboard","html","python","rtf","windows"],"created_at":"2025-03-16T11:19:32.203Z","updated_at":"2025-03-16T11:19:33.640Z","avatar_url":"https://github.com/AceofSpades5757.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI](https://img.shields.io/pypi/v/clip-util?color=darkred)](https://pypi.org/project/clip-util/)\n[![Read the Docs](https://img.shields.io/readthedocs/clip-util)](https://clip-util.readthedocs.io/en/latest/)\n[![Tests](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml/badge.svg)](https://github.com/AceofSpades5757/clip-util/actions/workflows/test.yml)\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/clip-util?label=Python%20Version\u0026logo=python\u0026logoColor=yellow)](https://pypi.org/project/clip-util/)\n[![PyPI - License](https://img.shields.io/pypi/l/clip-util?color=green)](https://github.com/AceofSpades5757/clip-util/blob/main/LICENSE)\n\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# Description\n\nPackage for accessing the clipboard with Python.\n\n# Installation\n\n`pip install clip-util`\n\n# Features\n\n_Windows Only_\n\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.\n\n## Supported Clipboard Formats\n\n- Text\n- HTML\n- RTF\n\n# Usage\n\n## Clipboard\n\nWill open and close every time the values are set, or retrieved. It's better to use a context manager.\n\n```python\nfrom clipboard import Clipboard\n\n\nclipboard = Clipboard()\n\n# Set Clipboard\nclipboard[\"text\"] = \"Hello World!\"\n# OR\nclipboard.set_clipboard(\"Hello World!\")\n\n# Get Clipboard\ntext = clipboard[\"text\"]\n# OR\ntext = clipboard.get_clipboard(\"text\")\n\n# Supports HTML\nclipboard[\"html\"] = \"\u003ch1\u003eHello World\u003c/h1\u003e\"\n```\n\n\n### Context Manager\n\n```python\nfrom clipboard import Clipboard\n\n\nwith Clipboard() as clipboard:\n\n    # Set Clipboard\n    clipboard[\"text\"] = \"Hello World!\"\n    # OR\n    clipboard.set_clipboard(\"Hello World!\")\n\n    # Get Clipboard\n    text = clipboard[\"text\"]\n    # OR\n    text = clipboard.get_clipboard(\"text\")\n\n    # HTML\n    clipboard[\"html\"] = \"\u003ch1\u003eHello World\u003c/h1\u003e\"\n```\n\n## Clipboard Formats\n\nYou can use `clip-util` to access the clipboard formats directly.\n\n`ClipboardFormat`: Enum for clipboard formats.\n\n`ClipboardFormat.CF_HTML`: Represents HTML format.\n\n`ClipboardFormat.CF_RTF`: Represents RTF format.\n\n```python\nfrom clipboard import Clipboard\nfrom clipboard import ClipboardFormat\nfrom clipboard import get_format_name\n\n\nwith Clipboard() as clipboard:\n\n    # Get All Available Formats\n    format_ids: list[int] = clipboard.available_formats()\n\n    # Get Specific Format by ID\n    # Use parentheses to access the format by ID\n    formats: list[ClipboardFormat] = []\n    format_id: int\n    for format_id in format_ids:\n        if format_id in ClipboardFormat:\n            format_: ClipboardFormat = ClipboardFormat(format_id)\n            formats.append(format_)\n        else:\n            # Format is not supported directly by this library\n            pass\n\n    # Get Specified Format by Name (directly)\n    format_names: list[str] = []\n    format_id: int\n    for format_id in format_ids:\n        name: str = get_format_name(format_id)\n        format_names.append(name)\n\n    # Get Specified Format by Name (using enum)\n    # Use bracket notation to access the format\n    #\n    # Note: this method is not as robust as using `get_format_name`\n    formats: list[ClipboardFormat] = []\n    format_names: list[str] = []\n    format_name: str\n    for format_name in [f.name for f in formats]:\n        if format_name in ClipboardFormat:\n            format_: ClipboardFormat = ClipboardFormat[format_name]\n            name: str = format_.name\n            formats.append(format_)\n            format_names.append(name)\n        else:\n            # Format is not supported directly by this library\n            pass\n```\n\n## Get All Supported Formats\n\nYou can even get the content of all available formats currently in the clipboard.\n\n```python\nfrom clipboard import get_available_formats\nfrom clipboard import get_format_name\nfrom clipboard import get_clipboard\n\n\navailable: list[int] = get_available_formats()\nprint(f\"{available=}\")\n\nfor format_id in available:\n    name: str = get_format_name(format_id)\n    content: str = get_clipboard(format_id)\n    print(f\"{format_id=}\", f\"{name=}, {content=}\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceofspades5757%2Fclip-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faceofspades5757%2Fclip-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceofspades5757%2Fclip-util/lists"}