Skip to content

Instantly share code, notes, and snippets.

Last active Dec 2, 2015
What would you like to do?
Convert JCR UUID to filesystem path
#!/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)
return path
if __name__ == '__main__':
#!/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__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment