Skip to content

Instantly share code, notes, and snippets.

@xx7y7xx
Last active December 2, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xx7y7xx/3b33a4d9e02c3e4a4e4a to your computer and use it in GitHub Desktop.
Save xx7y7xx/3b33a4d9e02c3e4a4e4a to your computer and use it in GitHub Desktop.
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)
print(path)
return path
if __name__ == '__main__':
uuid2path(sys.argv[1])
#!/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