therepy


Nametherepy JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryTherapeutic filepath management for python data projects.
upload_time2023-06-22 08:03:55
maintainer
docs_urlNone
author
requires_python>=3.0
licenseMIT License Copyright (c) 2023 Hans Elliott Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords here paths
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # therepy
[![Documentation Status](https://readthedocs.org/projects/therepy/badge/?version=latest)](https://therepy.readthedocs.io/en/latest/?badge=latest)
[<img alt="GitHub" width="30px" src="https://raw.githubusercontent.com/edent/SuperTinyIcons/master/images/png/github.png" />](https://github.com/hans-elliott99/therepy)

A simple [r-lib/here](https://github.com/r-lib/here) for python, to make file path management less of a headache in project-oriented workflows.  

## Installation
```bash
pip install therepy
```

[See pypi for details](https://pypi.org/project/therepy/)

## Overview
R's here library uses the .Rproj file to identify the top-level or root directory in an R project, and all file paths are defined relative to this directory.  
Instead of looking for a specific file or file extension, the `therepy` module has the user define the root directory somewhere ("there", if you will):   

```python
from therepy import Here
here = Here("myproj")
```

Once initialized, the `Here` object allows you to specify file paths relative to the defined root directory (in this example, "myproj"), since it coverts them to absolute paths under the hood.  
For example, if I have a dataset in a subfolder, "myproj/database/data.csv", and I want to use it in a script, "myproj/analysis/viz.py", I can specify the path like so:  

```python
# -- viz.py -- 
fp = here.here("database", "data.csv")
print(fp)
#> PosixPath("/home/user/Documents/myproj/database/data.csv")
df = read_csv(fp)
```
The relative paths are expanded into absolute paths, so the returned file path will work even if "viz.py" gets moved around.

If you do not want to use your project's folder name to initialize `Here`, you can provide the name of a file that exists in your project's root or a [glob style expression](https://docs.python.org/3/library/glob.html) identifying such a file:  

```python
here = Here(".git")
here = Here("*.Rproj")
```

Here is built on [pathlib](https://docs.python.org/3/library/pathlib.html) and returns pathlib.Path instances by default (a PosixPath or WindowsPath depending on your system).  
This allows you to take advantage of pathlib's great features, like:  

```python
here = Here("myproj")
fp = here.here("database/data.csv")
if fp.exists():
    ... 
```

And since pathlib can resolve and join paths, you can easily define folders for reading and writing to:

```python
here = Here("myproj")
outputs = here.here("outputs")
print(outputs)
#> PosixPath("/home/user/Documents/myproj/outputs")
...

df.to_csv(here.here(outputs, "data.csv"))
```

`Here` will return strings if you ask it too:
```python
here = Here("myproj")
print(here.here(as_str=True))
#> "/home/user/Documents/myproj"
```


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "therepy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "here,paths",
    "author": "",
    "author_email": "Hans Elliott <hanselliott61@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/dc/dc/a33b9b4b694137688b3a50da3d4bf0ab6ca8a76b46b70ee45ff72d9348e7/therepy-0.0.1.tar.gz",
    "platform": null,
    "description": "# therepy\n[![Documentation Status](https://readthedocs.org/projects/therepy/badge/?version=latest)](https://therepy.readthedocs.io/en/latest/?badge=latest)\n[<img alt=\"GitHub\" width=\"30px\" src=\"https://raw.githubusercontent.com/edent/SuperTinyIcons/master/images/png/github.png\" />](https://github.com/hans-elliott99/therepy)\n\nA simple [r-lib/here](https://github.com/r-lib/here) for python, to make file path management less of a headache in project-oriented workflows.  \n\n## Installation\n```bash\npip install therepy\n```\n\n[See pypi for details](https://pypi.org/project/therepy/)\n\n## Overview\nR's here library uses the .Rproj file to identify the top-level or root directory in an R project, and all file paths are defined relative to this directory.  \nInstead of looking for a specific file or file extension, the `therepy` module has the user define the root directory somewhere (\"there\", if you will):   \n\n```python\nfrom therepy import Here\nhere = Here(\"myproj\")\n```\n\nOnce initialized, the `Here` object allows you to specify file paths relative to the defined root directory (in this example, \"myproj\"), since it coverts them to absolute paths under the hood.  \nFor example, if I have a dataset in a subfolder, \"myproj/database/data.csv\", and I want to use it in a script, \"myproj/analysis/viz.py\", I can specify the path like so:  \n\n```python\n# -- viz.py -- \nfp = here.here(\"database\", \"data.csv\")\nprint(fp)\n#> PosixPath(\"/home/user/Documents/myproj/database/data.csv\")\ndf = read_csv(fp)\n```\nThe relative paths are expanded into absolute paths, so the returned file path will work even if \"viz.py\" gets moved around.\n\nIf you do not want to use your project's folder name to initialize `Here`, you can provide the name of a file that exists in your project's root or a [glob style expression](https://docs.python.org/3/library/glob.html) identifying such a file:  \n\n```python\nhere = Here(\".git\")\nhere = Here(\"*.Rproj\")\n```\n\nHere is built on [pathlib](https://docs.python.org/3/library/pathlib.html) and returns pathlib.Path instances by default (a PosixPath or WindowsPath depending on your system).  \nThis allows you to take advantage of pathlib's great features, like:  \n\n```python\nhere = Here(\"myproj\")\nfp = here.here(\"database/data.csv\")\nif fp.exists():\n    ... \n```\n\nAnd since pathlib can resolve and join paths, you can easily define folders for reading and writing to:\n\n```python\nhere = Here(\"myproj\")\noutputs = here.here(\"outputs\")\nprint(outputs)\n#> PosixPath(\"/home/user/Documents/myproj/outputs\")\n...\n\ndf.to_csv(here.here(outputs, \"data.csv\"))\n```\n\n`Here` will return strings if you ask it too:\n```python\nhere = Here(\"myproj\")\nprint(here.here(as_str=True))\n#> \"/home/user/Documents/myproj\"\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Hans Elliott  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Therapeutic filepath management for python data projects.",
    "version": "0.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/hans-elliott99/therepy/issues",
        "Homepage": "https://github.com/hans-elliott99/therepy"
    },
    "split_keywords": [
        "here",
        "paths"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0688b53812211fa93a319ea03c477eb4c9495b1d2c2620e1ccfa3048296ff3b9",
                "md5": "10c03fa825b2233ab368ffde4bfaa4aa",
                "sha256": "c97ce92f9a2048fe50ac594562ed0f103c1d8005c375d5d7ee71324b0d7affb5"
            },
            "downloads": -1,
            "filename": "therepy-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "10c03fa825b2233ab368ffde4bfaa4aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 6203,
            "upload_time": "2023-06-22T08:03:53",
            "upload_time_iso_8601": "2023-06-22T08:03:53.634313Z",
            "url": "https://files.pythonhosted.org/packages/06/88/b53812211fa93a319ea03c477eb4c9495b1d2c2620e1ccfa3048296ff3b9/therepy-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dcdca33b9b4b694137688b3a50da3d4bf0ab6ca8a76b46b70ee45ff72d9348e7",
                "md5": "b2bdaf75832bdd6c59094f41da97cebe",
                "sha256": "d509bdec2bcb59a8267d1930cc96592e288367c3c1d8bcc9b2ff870137f87291"
            },
            "downloads": -1,
            "filename": "therepy-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b2bdaf75832bdd6c59094f41da97cebe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 6739,
            "upload_time": "2023-06-22T08:03:55",
            "upload_time_iso_8601": "2023-06-22T08:03:55.294510Z",
            "url": "https://files.pythonhosted.org/packages/dc/dc/a33b9b4b694137688b3a50da3d4bf0ab6ca8a76b46b70ee45ff72d9348e7/therepy-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-22 08:03:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hans-elliott99",
    "github_project": "therepy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "therepy"
}
        
Elapsed time: 0.09643s