Last active
March 12, 2025 17:16
-
-
Save aelkiss/199a9771d3f50750d67a07d9b51002ce to your computer and use it in GitHub Desktop.
Make pairtree links from volume ids (for dataset)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pairtree import id_encode | |
import sys | |
import os.path | |
def topath(ident): | |
encodedid = id_encode(ident) | |
filepath = [] while encodedid: | |
filepath.append(encodedid[:2]) | |
encodedid = encodedid[2:] | |
return os.path.join(*filepath) | |
for line in sys.stdin: | |
(namespace,objid) = line.strip().split('.',1) | |
pt_objid = id_encode(objid) | |
path = f"obj/{namespace}/pairtree_root/{topath(objid)}" | |
# for pairtree structure | |
print(f"mkdir -p $DATASET_HOME/'{path}'") | |
print(f"ln -s '/sdr1/{path}/{pt_objid}' $DATASET_HOME/'{path}/{pt_objid}'") | |
# alternate for flat structure | |
# print(f"ln -s '/sdr1/{path}/{pt_objid}' $DATASET_HOME/'{namespace}.{pt_objid}'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment