Skip to content

Instantly share code, notes, and snippets.

@dave-tucker
Created September 29, 2015 14:40
Show Gist options
  • Save dave-tucker/6667991d2295ce9fe7ae to your computer and use it in GitHub Desktop.
Save dave-tucker/6667991d2295ce9fe7ae to your computer and use it in GitHub Desktop.
import os
import re
import unittest
TEST_PATH="C:\\Users\\Dave\\dev\\my-app\\redis\\data"
GOOD_PATH="/c/Users/Dave/dev/my-app/redis/data"
def unwindowize_path(path):
drive, path_parts = os.path.split(path)
parts = re.split("[\\\\]", path_parts)
new_path = "/".join(parts)
new_path = "/" + drive.rstip(":").lower() + new_path
return new_path
class Tests(unittest.TestCase):
def testPath(self):
result = unwindowize_path(TEST_PATH)
self.assertEqual(GOOD_PATH, result)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment