A tool for giving meaningful names to file and directory paths
Project description
# Onde
Onde ('OWN-jee') is a simple Python tool for naming and referencing file and directory paths meaningfully.
## Usage
Install Onde with pip:
`pip install onde`
To use Onde, create a YAML file named `paths.yml` in the root directory of your project that maps important files and directories to convenient aliases that you can use to refer to those files.
**paths.yml**
```yaml
- some_alias:
- "/some_absolute_path/some_file.txt"
- another_alias:
- "some_relative_path/another_file.txt"
- A third alias:
- "~/some_folder/a_file.txt"
```
You then use Onde by instantiating it and calling `paths`:
```python
>>> from onde import Onde
>>> onde = Onde()
>>> onde.path('some_alias')
'/some_absolute_path/some_file.txt'
>>> onde.path('another_alias')
'some_relative_path/another_file.txt'
>>> onde.path('A third alias')
'/Users/myusername/some_folder/a_file.txt'
```
Paths can include variables, which are wrapped in curly braces. When calling `paths()` you can fill in the variables:
**paths.yml**
```yaml
- my_alias:
- path:
- "/{my_directory}/{my_file}.txt"
```
```python
>>> from onde import Onde
>>> Onde().path('my_alias', 'hey_there', my_file='hows_it_going')
'/hey_there/hows_it_going.txt'
```
Directories can be nested, to make it easy to refer to represent multiple significant locations within a file system:
**paths.yml**
```yaml
- top_level:
- "some/folder"
- thing1:
- "path/to/child_1"
- thing2:
- "path/to/child_2"
- deeply_embedded_thing:
- "deeply/embedded/thing.txt"
```
```python
>>> from onde import Onde
>>> onde = Onde()
>>> onde.path('top_level')
'some/folder'
>>> onde.path('thing1')
'some/folder/path/to/child1'
>>> onde.path('thing2')
'some/folder/path/to/child2'
>>> onde.path('deeply_embedded_thing')
'some/folder/path/to/child2/deeply/embedded/thing.txt'
```
Aliases must be unique within the paths YAML file. Attempting to import a YAML file with duplicate aliases will raise an exception.
Path variables must also be unique for each path.
A well-formed Onde paths file should be in the format:
```yaml
- alias:
- 'path_segment'
- child_alias:
- 'path_segment'
- child_alias:
- 'path_segment'
```
Each mapping has a single alias as its key and a list as the value of that key. The first item in the list is a
## Contributing
Pull requests are welcome!
To install: `python setup.py install`
To run tests: `python setup.py test`
## License
Onde is written by Aaron Knight <iamaaronknight@gmail.com>. It is released
under the MIT license. See the LICENSE.txt file for more details.
Onde ('OWN-jee') is a simple Python tool for naming and referencing file and directory paths meaningfully.
## Usage
Install Onde with pip:
`pip install onde`
To use Onde, create a YAML file named `paths.yml` in the root directory of your project that maps important files and directories to convenient aliases that you can use to refer to those files.
**paths.yml**
```yaml
- some_alias:
- "/some_absolute_path/some_file.txt"
- another_alias:
- "some_relative_path/another_file.txt"
- A third alias:
- "~/some_folder/a_file.txt"
```
You then use Onde by instantiating it and calling `paths`:
```python
>>> from onde import Onde
>>> onde = Onde()
>>> onde.path('some_alias')
'/some_absolute_path/some_file.txt'
>>> onde.path('another_alias')
'some_relative_path/another_file.txt'
>>> onde.path('A third alias')
'/Users/myusername/some_folder/a_file.txt'
```
Paths can include variables, which are wrapped in curly braces. When calling `paths()` you can fill in the variables:
**paths.yml**
```yaml
- my_alias:
- path:
- "/{my_directory}/{my_file}.txt"
```
```python
>>> from onde import Onde
>>> Onde().path('my_alias', 'hey_there', my_file='hows_it_going')
'/hey_there/hows_it_going.txt'
```
Directories can be nested, to make it easy to refer to represent multiple significant locations within a file system:
**paths.yml**
```yaml
- top_level:
- "some/folder"
- thing1:
- "path/to/child_1"
- thing2:
- "path/to/child_2"
- deeply_embedded_thing:
- "deeply/embedded/thing.txt"
```
```python
>>> from onde import Onde
>>> onde = Onde()
>>> onde.path('top_level')
'some/folder'
>>> onde.path('thing1')
'some/folder/path/to/child1'
>>> onde.path('thing2')
'some/folder/path/to/child2'
>>> onde.path('deeply_embedded_thing')
'some/folder/path/to/child2/deeply/embedded/thing.txt'
```
Aliases must be unique within the paths YAML file. Attempting to import a YAML file with duplicate aliases will raise an exception.
Path variables must also be unique for each path.
A well-formed Onde paths file should be in the format:
```yaml
- alias:
- 'path_segment'
- child_alias:
- 'path_segment'
- child_alias:
- 'path_segment'
```
Each mapping has a single alias as its key and a list as the value of that key. The first item in the list is a
## Contributing
Pull requests are welcome!
To install: `python setup.py install`
To run tests: `python setup.py test`
## License
Onde is written by Aaron Knight <iamaaronknight@gmail.com>. It is released
under the MIT license. See the LICENSE.txt file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
onde-0.1.1.tar.gz
(4.9 kB
view details)
Built Distribution
onde-0.1.1-py3-none-any.whl
(5.9 kB
view details)
File details
Details for the file onde-0.1.1.tar.gz
.
File metadata
- Download URL: onde-0.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 175bbfa9f0a0b59f084f0cb423ed812c03d25c939d74b6b6a7a841ea5b61b9a4 |
|
MD5 | f7198cbb27f89cf2a3b13a2b65d5b2f2 |
|
BLAKE2b-256 | 09d693ff709dbc7628c6cef5f182f00c19cca9f20b185df22c3bc47ae3cf0cf2 |
File details
Details for the file onde-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: onde-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ad5c952bf465f55cd02e7a044a133651aaf45381d85214e75d7e0ac9ee07f1c |
|
MD5 | 934d5babe4aec4cb08875e7f8a28599a |
|
BLAKE2b-256 | 2c8b721182e24676eea9b0f2e654ead3d3b4bd9cbd8e9a4398e7dd93f2b12b42 |