Last active
December 2, 2015 07:09
-
-
Save xx7y7xx/3b33a4d9e02c3e4a4e4a to your computer and use it in GitHub Desktop.
Convert JCR UUID to filesystem path
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import textwrap | |
def uuid2path(uuid): | |
uuid2 = uuid.replace("-", "") | |
list = textwrap.wrap(uuid2, 4) | |
path = "/".join(list) | |
print(path) | |
return path | |
if __name__ == '__main__': | |
uuid2path(sys.argv[1]) |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import unittest | |
from uuid2path import uuid2path | |
class TestUUID2Path(unittest.TestCase): | |
def test_result(self): | |
self.assertEqual(uuid2path("3f48daaa-d787-424b-9a53-24515c2b9b66"), "3f48/daaa/d787/424b/9a53/2451/5c2b/9b66") | |
self.assertEqual(uuid2path("c2befb20-b8d0-48b0-8bb5-f0beac989c4a"), "c2be/fb20/b8d0/48b0/8bb5/f0be/ac98/9c4a") | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment