Created
          September 29, 2015 14:40 
        
      - 
      
- 
        Save dave-tucker/6667991d2295ce9fe7ae to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | 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