winregistry


Namewinregistry JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/shpaker/winregistry
SummaryLibrary aimed at working with Windows registry
upload_time2024-11-23 09:02:16
maintainerNone
docs_urlNone
authorAleksandr Shpak
requires_python>=3.8
licenseMIT
keywords windows registry regedit winreg
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WinRegistry

[![PyPI](https://img.shields.io/pypi/v/winregistry.svg)](https://pypi.python.org/pypi/winregistry)
[![PyPI](https://img.shields.io/pypi/dm/winregistry.svg)](https://pypi.python.org/pypi/winregistry)

Python package aimed at working with Windows Registry 

## Installation

Install via PyPI:

```bash
pip install winregistry
```

## Usage

```python
import winreg
from winregistry import open_key, open_value

# connect to registry and ensure sub-key
with open_key(
  winreg.HKEY_LOCAL_MACHINE,
  sub_key="SOFTWARE\_REMOVE_ME_",
) as key:
  ...

# also you can connect to registry with string key
with open_key(
  "HKLM\SOFTWARE\_REMOVE_ME_",
) as key:
  ...

# delete key
with open_key(
  winreg.HKEY_LOCAL_MACHINE,
  sub_key="SOFTWARE",
) as key:
  key.delete_key("_REMOVE_ME_")

# create value
with open_key(
  "HKLM\SOFTWARE\_REMOVE_ME_", 
  sub_key_ensure=True, 
  sub_key_access=winreg.KEY_SET_VALUE,
) as key:
    key.set_value("foo", "SZ")

# read value
with open_value(
  "HKLM\SOFTWARE\_REMOVE_ME_", 
  value_name="remove_me",
) as value:
  ...
```

## Usage with [Robot Testing Framework](https://robotframework.org/)

### Documentation

https://shpaker.github.io/winregistry/winregistry.robot

### Example

```robotframework
*** Variables ***
${ SUITE_KEY_NAME }       HKLM\\SOFTWARE\\_ROBOT_TESTS_
${ SHORT_CASE_KEY_NAME }  _CASE_KEY_
${ CASE_KEY_NAME }        ${ SUITE_KEY_NAME }\\${ SHORT_CASE_KEY_NAME }
${ VALUE_NAME }           some_testing_value

*** Settings ***
Library         Collections
Library         winregistry.robot
Suite Setup     Create Registry Key  ${ SUITE_KEY_NAME }
Suite Teardown  Delete Registry Key  ${ SUITE_KEY_NAME }

*** Test Cases ***
TEST REGISTRY KEYS
    [Teardown]  Delete Registry Key     ${ CASE_KEY_NAME }

    ${ items } =    Get Registry Key Sub Keys   ${ SUITE_KEY_NAME }
    List Should Not Contain Value   ${ items }  ${ SHORT_CASE_KEY_NAME }
    Registry Key Should Not Exist   ${ CASE_KEY_NAME }
    Create Registry Key             ${ CASE_KEY_NAME }
    Registry Key Should Exist       ${ CASE_KEY_NAME }
    ${ items } =    Get Registry Key Sub Keys   ${ SUITE_KEY_NAME }
    List Should Contain Value       ${ items }  ${ SHORT_CASE_KEY_NAME }


TEST REGISTRY VALUES
    [Setup]     Create Registry Key         ${ CASE_KEY_NAME }
    [Teardown]  Delete Registry Key         ${ CASE_KEY_NAME }

    ${ items } =    Get Registry Key Values Names   ${ CASE_KEY_NAME }
    List Should Not Contain Value           ${ items }          ${ VALUE_NAME }
    Registry Value Should Not Exist         ${ CASE_KEY_NAME }  ${ VALUE_NAME }
    Create Registry Value                   ${ CASE_KEY_NAME }  ${ VALUE_NAME }  SZ
    Registry Value Should Exist             ${ CASE_KEY_NAME }  ${ VALUE_NAME }
    ${ items } =    Get Registry Key Values Names   ${ CASE_KEY_NAME }
    List Should Contain Value               ${ items }          ${ VALUE_NAME }
    ${ value } =    Read Registry Value     ${ CASE_KEY_NAME }  ${ VALUE_NAME }
    Should Be Equal     ${ value.data }     ${ EMPTY }
    Set Registry Value                      ${ CASE_KEY_NAME }  ${ VALUE_NAME }  Remove me!
    ${ value } =    Read Registry Value     ${ CASE_KEY_NAME }  ${ VALUE_NAME }
    Should Be Equal     ${ value.data }     Remove me!
    Delete Registry Value                   ${ CASE_KEY_NAME }  ${ VALUE_NAME }
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/shpaker/winregistry",
    "name": "winregistry",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "windows, registry, regedit, winreg",
    "author": "Aleksandr Shpak",
    "author_email": "shpaker@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/29/34/a09f8b0458f2082f567f53419da7bc91d1de6887a5596d187623aac8d5a0/winregistry-2.0.1.tar.gz",
    "platform": null,
    "description": "# WinRegistry\n\n[![PyPI](https://img.shields.io/pypi/v/winregistry.svg)](https://pypi.python.org/pypi/winregistry)\n[![PyPI](https://img.shields.io/pypi/dm/winregistry.svg)](https://pypi.python.org/pypi/winregistry)\n\nPython package aimed at working with Windows Registry \n\n## Installation\n\nInstall via PyPI:\n\n```bash\npip install winregistry\n```\n\n## Usage\n\n```python\nimport winreg\nfrom winregistry import open_key, open_value\n\n# connect to registry and ensure sub-key\nwith open_key(\n  winreg.HKEY_LOCAL_MACHINE,\n  sub_key=\"SOFTWARE\\_REMOVE_ME_\",\n) as key:\n  ...\n\n# also you can connect to registry with string key\nwith open_key(\n  \"HKLM\\SOFTWARE\\_REMOVE_ME_\",\n) as key:\n  ...\n\n# delete key\nwith open_key(\n  winreg.HKEY_LOCAL_MACHINE,\n  sub_key=\"SOFTWARE\",\n) as key:\n  key.delete_key(\"_REMOVE_ME_\")\n\n# create value\nwith open_key(\n  \"HKLM\\SOFTWARE\\_REMOVE_ME_\", \n  sub_key_ensure=True, \n  sub_key_access=winreg.KEY_SET_VALUE,\n) as key:\n    key.set_value(\"foo\", \"SZ\")\n\n# read value\nwith open_value(\n  \"HKLM\\SOFTWARE\\_REMOVE_ME_\", \n  value_name=\"remove_me\",\n) as value:\n  ...\n```\n\n## Usage with [Robot Testing Framework](https://robotframework.org/)\n\n### Documentation\n\nhttps://shpaker.github.io/winregistry/winregistry.robot\n\n### Example\n\n```robotframework\n*** Variables ***\n${ SUITE_KEY_NAME }       HKLM\\\\SOFTWARE\\\\_ROBOT_TESTS_\n${ SHORT_CASE_KEY_NAME }  _CASE_KEY_\n${ CASE_KEY_NAME }        ${ SUITE_KEY_NAME }\\\\${ SHORT_CASE_KEY_NAME }\n${ VALUE_NAME }           some_testing_value\n\n*** Settings ***\nLibrary         Collections\nLibrary         winregistry.robot\nSuite Setup     Create Registry Key  ${ SUITE_KEY_NAME }\nSuite Teardown  Delete Registry Key  ${ SUITE_KEY_NAME }\n\n*** Test Cases ***\nTEST REGISTRY KEYS\n    [Teardown]  Delete Registry Key     ${ CASE_KEY_NAME }\n\n    ${ items } =    Get Registry Key Sub Keys   ${ SUITE_KEY_NAME }\n    List Should Not Contain Value   ${ items }  ${ SHORT_CASE_KEY_NAME }\n    Registry Key Should Not Exist   ${ CASE_KEY_NAME }\n    Create Registry Key             ${ CASE_KEY_NAME }\n    Registry Key Should Exist       ${ CASE_KEY_NAME }\n    ${ items } =    Get Registry Key Sub Keys   ${ SUITE_KEY_NAME }\n    List Should Contain Value       ${ items }  ${ SHORT_CASE_KEY_NAME }\n\n\nTEST REGISTRY VALUES\n    [Setup]     Create Registry Key         ${ CASE_KEY_NAME }\n    [Teardown]  Delete Registry Key         ${ CASE_KEY_NAME }\n\n    ${ items } =    Get Registry Key Values Names   ${ CASE_KEY_NAME }\n    List Should Not Contain Value           ${ items }          ${ VALUE_NAME }\n    Registry Value Should Not Exist         ${ CASE_KEY_NAME }  ${ VALUE_NAME }\n    Create Registry Value                   ${ CASE_KEY_NAME }  ${ VALUE_NAME }  SZ\n    Registry Value Should Exist             ${ CASE_KEY_NAME }  ${ VALUE_NAME }\n    ${ items } =    Get Registry Key Values Names   ${ CASE_KEY_NAME }\n    List Should Contain Value               ${ items }          ${ VALUE_NAME }\n    ${ value } =    Read Registry Value     ${ CASE_KEY_NAME }  ${ VALUE_NAME }\n    Should Be Equal     ${ value.data }     ${ EMPTY }\n    Set Registry Value                      ${ CASE_KEY_NAME }  ${ VALUE_NAME }  Remove me!\n    ${ value } =    Read Registry Value     ${ CASE_KEY_NAME }  ${ VALUE_NAME }\n    Should Be Equal     ${ value.data }     Remove me!\n    Delete Registry Value                   ${ CASE_KEY_NAME }  ${ VALUE_NAME }\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library aimed at working with Windows registry",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/shpaker/winregistry",
        "Repository": "https://github.com/shpaker/winregistry"
    },
    "split_keywords": [
        "windows",
        " registry",
        " regedit",
        " winreg"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfb02df03a38beead518e3c8ff88941bd849765f869f4de48fd827b0213cf724",
                "md5": "2bb606f4629f296c7bf1dd7cc90110d1",
                "sha256": "6401d65abc2cf52f55896559bfd915a6caf78c6032c8ff2d45f1e0df0592fc27"
            },
            "downloads": -1,
            "filename": "winregistry-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2bb606f4629f296c7bf1dd7cc90110d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5884,
            "upload_time": "2024-11-23T09:02:14",
            "upload_time_iso_8601": "2024-11-23T09:02:14.841221Z",
            "url": "https://files.pythonhosted.org/packages/cf/b0/2df03a38beead518e3c8ff88941bd849765f869f4de48fd827b0213cf724/winregistry-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2934a09f8b0458f2082f567f53419da7bc91d1de6887a5596d187623aac8d5a0",
                "md5": "6fb0259661d1a0a1b18b5ad37495b5df",
                "sha256": "02931655fb0421b65385990e8472b1f49a43c7c1ff96c2b2ad489e5627ee3363"
            },
            "downloads": -1,
            "filename": "winregistry-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6fb0259661d1a0a1b18b5ad37495b5df",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6214,
            "upload_time": "2024-11-23T09:02:16",
            "upload_time_iso_8601": "2024-11-23T09:02:16.391778Z",
            "url": "https://files.pythonhosted.org/packages/29/34/a09f8b0458f2082f567f53419da7bc91d1de6887a5596d187623aac8d5a0/winregistry-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-23 09:02:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shpaker",
    "github_project": "winregistry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "winregistry"
}
        
Elapsed time: 0.38004s