{"id":21436738,"url":"https://github.com/bitnom/datafunc","last_synced_at":"2025-03-16T23:23:39.413Z","repository":{"id":62566622,"uuid":"313152957","full_name":"bitnom/datafunc","owner":"bitnom","description":"Python package of various functions for dict, list, and other data structures.","archived":false,"fork":false,"pushed_at":"2020-12-28T21:04:36.000Z","size":428,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-23T09:33:52.066Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bitnom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-16T00:35:39.000Z","updated_at":"2020-11-17T23:05:36.000Z","dependencies_parsed_at":"2022-11-03T16:30:25.260Z","dependency_job_id":null,"html_url":"https://github.com/bitnom/datafunc","commit_stats":null,"previous_names":["tensortom/datafunc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnom%2Fdatafunc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnom%2Fdatafunc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnom%2Fdatafunc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitnom%2Fdatafunc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitnom","download_url":"https://codeload.github.com/bitnom/datafunc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945755,"owners_count":20372926,"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":[],"created_at":"2024-11-23T00:14:25.821Z","updated_at":"2025-03-16T23:23:39.386Z","avatar_url":"https://github.com/bitnom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datafunc\n\nPython package of various functions for dict, list, and other data structures. Check out the\n[documentation](https://tensortom.github.io/datafunc/).\n\n[![Actively Maintained](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://gitHub.com/TensorTom/datafunc/graphs/commit-activity)\n[![MIT License](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/datafunc/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/ansicolortags.svg)](https://pypi.python.org/pypi/datafunc/)\n\n### Changelog\n- **11/17/2020 - 0.0.4** : Add missing type annotation. Generate docs.\n- **11/17/2020 - 0.0.3** : Added `duplicate()` and `add_sibling()` methods. Added some missing type declarations.\n- **11/15/2020 - 0.0.2** : Type annotations \u0026 minor refactors.\n- **11/15/2020 - 0.0.1** : Initial methods.\n\n## Reference\n\n#### flatten\n\n```python\nflatten(var: object) -\u003e Data\n```\n\nTraverse a dict-like object and return a new one with all\nthe same values but only one layer deep.\n\n**Arguments**:\n\n- `var`: Dict-like variable to flatten.\n\n**Returns**:\n\nA mo-dots dict-like Data object.\n\n\u003ca name=\"datafunc.iterable\"\u003e\u003c/a\u003e\n#### iterable\n\n```python\niterable(var: Any) -\u003e Boolean\n```\n\nDetermine whether or not the input variable is iterable.\n\n**Arguments**:\n\n- `var`: Any\n\n**Returns**:\n\nBoolean\n\n\u003ca name=\"datafunc.listlike\"\u003e\u003c/a\u003e\n#### listlike\n\n```python\nlistlike(var: Any) -\u003e Boolean\n```\n\nDetermine if the input variable is list-like\n(Not a str, not dict-like, but is iterable)\n\n**Arguments**:\n\n- `var`: Any\n\n**Returns**:\n\nBoolean\n\n\u003ca name=\"datafunc.mo_dotian\"\u003e\u003c/a\u003e\n#### mo\\_dotian\n\n```python\nmo_dotian(var: Any) -\u003e Boolean\n```\n\nDetermine whether or not the input var is a mo-dots type.\n\n**Arguments**:\n\n- `var`: Any\n\n**Returns**:\n\nBoolean\n\n\u003ca name=\"datafunc.apply_if\"\u003e\u003c/a\u003e\n#### apply\\_if\n\n```python\napply_if(func_to_apply: Callable, var: Any, condition: Callable, else_func: Callable = do_nothing) -\u003e Any\n```\n\nApply func_to_apply() to var if condiction() else apply else_func()\n\n**Arguments**:\n\n- `func_to_apply`: Callable to pass var to if condition(var) return true\n- `var`: Variable to test against condition and return through func_to_apply() or else_func()\n- `condition`: Callable to test var against. Should return a Boolean.\n- `else_func`: Callable to return var through if condition(var) returns False.\n\n**Returns**:\n\nfunc_to_apply(var) if condition(var) returns True, otherwise else_func(var)\n\n\u003ca name=\"datafunc.dictlike\"\u003e\u003c/a\u003e\n#### dictlike\n\n```python\ndictlike(var: Any) -\u003e Boolean\n```\n\nDetermine whether or not var is dict-like (Can\ncontain dict-like items).\n\n**Arguments**:\n\n- `var`: Any variable to check\n\n**Returns**:\n\nBoolean\n\n\u003ca name=\"datafunc.nestable\"\u003e\u003c/a\u003e\n#### nestable\n\n```python\nnestable(var: Any) -\u003e Boolean\n```\n\nWill return True if input var is either list-like or\ndict-like.\n\n**Arguments**:\n\n- `var`: Any input variable.\n\n**Returns**:\n\nBoolean\n\n\u003ca name=\"datafunc.jsonify_nestable_vals\"\u003e\u003c/a\u003e\n#### jsonify\\_nestable\\_vals\n\n```python\njsonify_nestable_vals(obj: object) -\u003e Data\n```\n\nConvert any nestable (Dict-like or list-like) to a dict-like mo-dots\nData object of obj's values as JSON strings.\n\n**Arguments**:\n\n- `obj`: Any nestable variable.\n\n**Returns**:\n\nA dict-like mo-dots Data object of obj's values as JSON strings.\n\n\u003ca name=\"datafunc.compare\"\u003e\u003c/a\u003e\n#### compare\n\n```python\ncompare(d1: object, d2: object) -\u003e Data\n```\n\nCompare dict-like variable d1 to dict-like variable d2\nand return a dict-like mo-dots Data object of what's\nbeen added, removed, modified, or remained equal in d2\n\n**Arguments**:\n\n- `d1`: Dict-like variable as the base variable.\n- `d2`: Dict-like variable to compare/contrast to d1\n\n**Returns**:\n\nDict-like mo-dots Data object of differences between d1 and d2.\n\n\u003ca name=\"datafunc.function_of\"\u003e\u003c/a\u003e\n#### function\\_of\n\n```python\nfunction_of(func: Callable, func_names: Tuple) -\u003e Boolean\n```\n\nDetermine whether or not a function's (func) name exists in tuple of strings\n(func_names).\n\n**Arguments**:\n\n- `func`: The callable function to test.\n- `func_names`: Tuple of function names as strings (\"func1\", \"func2\", \"func3,)\n\n**Returns**:\n\nBoolean True (func is of func_names) or False (func is not of func_names)\n\n\u003ca name=\"datafunc.basevals\"\u003e\u003c/a\u003e\n#### basevals\n\n```python\nbasevals(var: object, *attrs) -\u003e Any\n```\n\nThis method receives a dict and list of attributes\nto return the innermost value of the given dict-like\nvar. This function seems stupid and I don't recall\nwhat it was for.\n\n\u003ca name=\"datafunc.vivify\"\u003e\u003c/a\u003e\n#### vivify\n\n```python\nvivify(var: object, *attrs: str)\n```\n\nAdds the last attr variable passed to the dict-like \"var\"\nin the hierarchy mentioned via the prior *attrs\nFor ex:\nvivify(animals, \"cat\", \"leg\",\"fingers\", 4) is equivalent to animals[\"cat\"][\"leg\"][\"fingers\"]=4\nThis method creates necessary objects until it reaches the final depth\nThis behaviour is also known as autovivification and plenty of implementation are around\nThis implementation addresses the corner case of replacing existing primitives\nhttps://gist.github.com/hrldcpr/2012250#gistcomment-1779319\n\n\u003ca name=\"datafunc.duplicate\"\u003e\u003c/a\u003e\n#### duplicate\n\n```python\nduplicate(data: object) -\u003e object\n```\n\nConvenience method for copy.deepcopy()\n\n**Arguments**:\n\n- `data`: Any dict, mo-dots, or dotty object.\n\n**Returns**:\n\nA deep copy of the data.\n\n\u003ca name=\"datafunc.add_sibling\"\u003e\u003c/a\u003e\n#### add\\_sibling\n\n```python\nadd_sibling(data: object, node_path: List, new_key: str, new_data: Any, _i: int = 0)\n```\n\nTraversal-safe method to add a siblings data node.\n\n**Arguments**:\n\n- `data`: The data object you're traversing.\n- `node_path`: List of path segments pointing to the node you're creating a\nsibling of. Same as node_path of traverse()\n- `new_key`: The sibling key to create.\n- `new_data`: The new data to be stored at the key.\n- `_i`: Depth of node_path iterator.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnom%2Fdatafunc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitnom%2Fdatafunc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitnom%2Fdatafunc/lists"}