{"id":16576401,"url":"https://github.com/kiwi0fruit/litereval","last_synced_at":"2026-05-29T06:31:08.271Z","repository":{"id":60722509,"uuid":"166063002","full_name":"kiwi0fruit/litereval","owner":"kiwi0fruit","description":"Wrapper around ast.literal_eval with additional {foo='bar', key=None} dict syntax. + Deep merge two dictionaries.","archived":false,"fork":false,"pushed_at":"2019-02-11T07:01:38.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-28T11:02:27.456Z","etag":null,"topics":["cli","eval","literal-eval","python","python-cli"],"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/kiwi0fruit.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}},"created_at":"2019-01-16T15:27:16.000Z","updated_at":"2023-02-17T00:47:49.000Z","dependencies_parsed_at":"2022-10-03T21:01:23.113Z","dependency_job_id":null,"html_url":"https://github.com/kiwi0fruit/litereval","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/kiwi0fruit/litereval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwi0fruit%2Flitereval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwi0fruit%2Flitereval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwi0fruit%2Flitereval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwi0fruit%2Flitereval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiwi0fruit","download_url":"https://codeload.github.com/kiwi0fruit/litereval/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwi0fruit%2Flitereval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33640627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","eval","literal-eval","python","python-cli"],"created_at":"2024-10-11T22:08:06.924Z","updated_at":"2026-05-29T06:31:08.253Z","avatar_url":"https://github.com/kiwi0fruit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# litereval\n\n`litereval` is wrapper around `ast.literal_eval` with new additional `{foo='bar', key=None}` `dict` syntax.\nPlus some helper tools to deep merge dictionaries, parse `ast.literal_eval` python data to `*args` and `**kwargs`.\n\nCan be used to create wrapper command line interfaces. See [pyppdf](https://github.com/kiwi0fruit/pyppdf).\n\n\n# Install\n\nNeeds python 3.6+\n\n```bash\nconda install -c defaults -c conda-forge litereval\n```\n\nor\n\n```bash\npip install litereval\n```\n\n\n# API\n\n### litereval\n\n```py\ndef litereval(string: str):\n    \"\"\"\n    Small extension of ``ast.literal_eval`` that also\n    accepts dict in a form of ``{key=100, foo='bar'}``\n\n    Returns\n    -------\n    ret :\n        ast.literal_eval(preprocess(string))\n    \"\"\"\n```\n\n### merge\n\n```py\ndef merge(source: dict, destination: dict,\n          copy: bool = False) -\u003e dict:\n    \"\"\"\n    Deep merge two dictionaries.\n    Overwrites in case of conflicts.\n    From https://stackoverflow.com/a/20666342\n    \"\"\"\n```\n\n### args_kwargs\n\n```py\ndef args_kwargs(args: Any) -\u003e Tuple[\n    Union[tuple, None], Union[dict, None]\n]:\n    \"\"\"\n    Parses ``args`` object to ``(*args, **kwargs)`` tuple.\n    Special case when ``args`` is ``None``: returns ``(None, None)``.\n    Otherwise tries to put not iterable object to tuple:\n    ``args`` to ``(args,)``. Examples:\n\n    * ``(1, 2)`` to ``(1, 2), {}``\n    * ``\"foo\"`` to ``(\"foo\",), {}``\n    * ``{(): ('a', 0), 'foo': None} to\n      ``('a', 0), {'foo': None}``\n\n    Returns\n    -------\n    ret :\n        tuple: *args, **kwargs\n    \"\"\"\n```\n\n### get_args\n\n```py\ndef get_args(name: str, args, default=None) -\u003e Args:\n    \"\"\"\n    Gets ``*args`` and ``**kwargs`` for a ``name`` function\n    from an ``args`` dict. Wrapper around ``args_kwargs`` function.\n\n    Returns ``NamedTuple`` ``Args``: ``(args: tuple, kwargs: dict)``\n    \"\"\"\n```\n\n### get\n\n```py\ndef get(key: str, dic, default=None):\n    \"\"\"Gets key even from not a dictionary.\"\"\"\n```\n\n### tuple\\_\n\n```py\ndef tuple_(obj: Any) -\u003e tuple:\n    \"\"\"Converts any object to tuple. ``string`` to ``(string,)``.\"\"\"\n```\n\n### validated\n\n```py\ndef validated(args: tuple, kwargs: dict) -\u003e Tuple[tuple, dict]:\n    \"\"\"Validates inputs and returns ``*args, **kwargs``.\"\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwi0fruit%2Flitereval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiwi0fruit%2Flitereval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwi0fruit%2Flitereval/lists"}