https://github.com/caltechlibrary/pairtree
A simple encoder/decoder for converting object identifiers into a Pair Tree Path (path)
https://github.com/caltechlibrary/pairtree
file-system-layout library-science pairtree
Last synced: about 1 year ago
JSON representation
A simple encoder/decoder for converting object identifiers into a Pair Tree Path (path)
- Host: GitHub
- URL: https://github.com/caltechlibrary/pairtree
- Owner: caltechlibrary
- License: other
- Created: 2018-06-26T21:50:55.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-08-29T23:07:03.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T15:29:13.930Z (about 1 year ago)
- Topics: file-system-layout, library-science, pairtree
- Language: JavaScript
- Homepage: https://caltechlibrary.github.io/pairtree
- Size: 296 KB
- Stars: 5
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
- Codemeta: codemeta.json
Awesome Lists containing this project
README
Pairtree
========
This is a library for translate a UTF-8 string to/from a pairtree
notation. This is typically used in storing things on disc (e.g. repository filesystems). This code is based on the specification found at https://confluence.ucop.edu/download/attachments/14254128/PairtreeSpec.pdf?version=2&modificationDate=1295552323000&api=v2 which is cited on the [OCFL](https://github.com/OCFL/spec/wiki) wiki.
Features
--------
- `Set()` will let you set the path separator
- `Separator` is a readonly value of the file separator used by `Encode()` and `Decode()`
- `Encode()` will encode the provided string as a pairtree path
- `Decode()` will decode a pairtree path returning the unencoded string
Example
-------
```
import (
"fmt"
"os"
"github.com/caltechlibrary/pairtree"
)
func main() {
key := "12mIEERD11"
fmt.Printf("Key: %q\n", key)
pairPath := pairtree.Encode(key)
fmt.Printf("Endoded key %q -> %q\n", key, pairPath)
key = Decode(pairPath)
fmt.Printf("Decoded path %q -> %q\n", pairPath, key)
}
```