{"id":21207326,"url":"https://github.com/cacilhas/objectproxy","last_synced_at":"2025-03-14T23:23:48.020Z","repository":{"id":119028614,"uuid":"164506385","full_name":"cacilhas/ObjectProxy","owner":"cacilhas","description":"This module provides a way to build lazy proxies to any kind of Python entity.","archived":false,"fork":false,"pushed_at":"2019-01-07T22:24:22.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T15:49:45.513Z","etag":null,"topics":["lazyload","poc","python","utils"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cacilhas.png","metadata":{"files":{"readme":"README","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":"2019-01-07T22:24:00.000Z","updated_at":"2020-04-23T05:16:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddc28312-e740-4070-9fd4-ef1a81b8e49d","html_url":"https://github.com/cacilhas/ObjectProxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cacilhas%2FObjectProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cacilhas%2FObjectProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cacilhas%2FObjectProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cacilhas%2FObjectProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cacilhas","download_url":"https://codeload.github.com/cacilhas/ObjectProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243659433,"owners_count":20326672,"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":["lazyload","poc","python","utils"],"created_at":"2024-11-20T20:58:25.881Z","updated_at":"2025-03-14T23:23:48.007Z","avatar_url":"https://github.com/cacilhas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. _BSD New: http://opensource.org/licenses/BSD-3-Clause\n.. _GitHUB: https://github.com/Montegasppa/ObjectProxy\n.. _mail me: mailto:batalema@cacilhas.info\n.. _project issues: https://github.com/Montegasppa/ObjectProxy/issues\n\n\n=============\n ObjectProxy\n=============\n\nThis module provides a way to build lazy proxies to any kind of Python\nentity.\n\n\nUse\n===\n\n\nLazy proxy\n----------\n\nTo make a proxy to a module, instanciate the ``Proxy`` class with a\nstring representing the import name of the module as parameter::\n\n    from object_proxy.lazy import LazyProxy\n\n    path = LazyProxy('os.path')\n\n\nOnly when the proxy is used for the first time, the target module is\nimported.\n\nTo make a proxy to an object or a class, use the colon (``:``) syntax::\n\n    environ = LazyProxy('os:environ')\n\n\nWhen the proxy is used, it’s equivalent to::\n\n    from os import environ\n\n\nNote\n~~~~\n\nThe functions ``repr()`` and ``id()`` are **not** proxied to target.\n\n\nContext-dependent proxy\n-----------------------\n\nThe proxy can be context-dependent.\n\nYou must instanciate a context::\n\n    from object_proxy.lazy import LazyProxy\n    from object_proxy.context import Context\n\n    gevent_context = Context('gevent')\n    eventlet_context = Context('eventlet')\n\n    patch = LazyProxy('gevent.monkey:patch_all', context=gevent_context)\n    eventlet_context.register(patch, 'eventlet:monkey_patch')\n\n    # Run monkey patch from gevent\n    Context.activate('gevent')\n    # Or: Context.activate(gevent_context)\n    # Or: gevent_context.activate()\n    patch()\n\n    # Run monkey patch from eventlet\n    Context.activate('eventlet')\n    # Identical to the previous\n    patch()\n\n\nYou can know whether a proxy belongs to a context using ``id()`` and\n``in``::\n\n    \u003e\u003e\u003e id(patch) in gevent_context\n    True\n\n\nTo discover which contexts a proxy belongs::\n\n    \u003e\u003e\u003e Context.find_proxy(patch)\n    [('gevent', 'gevent.monkey:patch_all'), ('eventlet', 'eventlet:monkey_patch')]\n\n\nContexts can get children::\n\n    \u003e\u003e\u003e context = gevent_context.get_child('with_path')\n    \u003e\u003e\u003e context.name\n    'gevent.with_path'\n    \u003e\u003e\u003e path = LazyProxy('os.path', context=context)\n    \u003e\u003e\u003e context.activate()\n    \u003e\u003e\u003e path\n    \u003cmodule 'posixpath' from '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'\u003e\n    \u003e\u003e\u003e patch\n    \u003cfunction patch_all at 0x109b1a848\u003e\n\n\nThe function ``patch()`` is inherited from super context.\n\n\nDownload and install\n====================\n\nObjectProxy can be downloaded from GitHUB_ or installed using ``pip``::\n\n    pip install ObjectProxy\n\n\nTODO\n----\n\nThere’s a lot work to do. You can `mail me`_ with suggestions or see the\n`project issues`_.\n\n\nLicense\n=======\n\nObjectProxy is licensed under `BSD New`_. See ``LICENSE`` file.\n\n\nAuthor\n------\n\nRodrigo Cacilhας \u003cbatalema@cacilhas.info\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcacilhas%2Fobjectproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcacilhas%2Fobjectproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcacilhas%2Fobjectproxy/lists"}