Path resolver
Project description
Pathmap
========
[![Build Status](https://travis-ci.org/codecov/pathmap.svg?branch=master)](https://travis-ci.org/codecov/pathmap)
[![codecov](https://codecov.io/gh/codecov/pathmap/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/pathmap)
Pathmap is a library for resolving paths. Example
```
>>> from pathmap import resolve_paths
>>> toc = ',a/b/c,'
>>> paths = ['b/c']
>>> list(resolve_paths(toc, paths))
['a/b/c']
```
### Case sensitivity
Pathmap searches for paths using lower case keys only but it stores the original value
of each path added to the tree. This way we can search for two identical paths with
different casing
```
>>> from pathmap import resolve_paths
>>> toc = ',a/b/C,A/B/c,'
>>> paths = ['A/b/C','a/B/c']
>>> list(resolve_paths(toc, paths))
['a/b/C', 'A/B/c']
```
### Resolving shorter/longer paths
When resolving paths it may happen that we get a partial path. For example searching for the path "two/three.py" in a tree that contains the path "dist/one/two/three.py".
Pathmap will continue searhing for a possible match until it hits the end of the current sequence but only if there is a single possible result.
For example if we add to our example
```
toc = '''
dist/one/two/three.py
dist/another/two/three.py
'''
```
With this toc we would construct a tree that looks something like this
```
three.py
|
two
| |
one another
| |
dist dist
```
Now when we hit the branch containing the key "two" we have two possible options, either
we resolve the path to "dist/one/two/three.py" or "dist/another/two/three.py".
In this case pathmap will not resolve the path and simply return None.
### Local development
Dependencies are listed in the requirements_dev.txt file
pip install -r requirements_dev.txt
### Testing
pytest is used for testing. Run tests with
py.test
========
[![Build Status](https://travis-ci.org/codecov/pathmap.svg?branch=master)](https://travis-ci.org/codecov/pathmap)
[![codecov](https://codecov.io/gh/codecov/pathmap/branch/master/graph/badge.svg)](https://codecov.io/gh/codecov/pathmap)
Pathmap is a library for resolving paths. Example
```
>>> from pathmap import resolve_paths
>>> toc = ',a/b/c,'
>>> paths = ['b/c']
>>> list(resolve_paths(toc, paths))
['a/b/c']
```
### Case sensitivity
Pathmap searches for paths using lower case keys only but it stores the original value
of each path added to the tree. This way we can search for two identical paths with
different casing
```
>>> from pathmap import resolve_paths
>>> toc = ',a/b/C,A/B/c,'
>>> paths = ['A/b/C','a/B/c']
>>> list(resolve_paths(toc, paths))
['a/b/C', 'A/B/c']
```
### Resolving shorter/longer paths
When resolving paths it may happen that we get a partial path. For example searching for the path "two/three.py" in a tree that contains the path "dist/one/two/three.py".
Pathmap will continue searhing for a possible match until it hits the end of the current sequence but only if there is a single possible result.
For example if we add to our example
```
toc = '''
dist/one/two/three.py
dist/another/two/three.py
'''
```
With this toc we would construct a tree that looks something like this
```
three.py
|
two
| |
one another
| |
dist dist
```
Now when we hit the branch containing the key "two" we have two possible options, either
we resolve the path to "dist/one/two/three.py" or "dist/another/two/three.py".
In this case pathmap will not resolve the path and simply return None.
### Local development
Dependencies are listed in the requirements_dev.txt file
pip install -r requirements_dev.txt
### Testing
pytest is used for testing. Run tests with
py.test
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pathmap-0.1.2.tar.gz
(527.4 kB
view hashes)
Built Distribution
Close
Hashes for pathmap-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26ce7501306bab39d1f0252d6427ddc5c4e2813029f8f4397e75babb103b5c7f |
|
MD5 | 9f1df3ec8da619a8d5e44c2feca4fa8f |
|
BLAKE2b-256 | 558c9fb14f65695fa179fc618b57890b0ec617afaeba68baae5054d1abf2d18f |