Created
February 1, 2021 17:03
-
-
Save luser/e68ab57a0ba0c66cb4d7e668d821e319 to your computer and use it in GitHub Desktop.
Canonicalize filename case in system Python 2.7 on macOS
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/python | |
from __future__ import print_function | |
from Carbon.File import FSPathMakeRef | |
import os | |
import sys | |
import unicodedata | |
def actual_path(path): | |
ref, _ = FSPathMakeRef(path) | |
out = unicodedata.normalize('NFC', ref.FSRefMakePath().decode('utf-8')) | |
if path.endswith(os.path.sep) and not out.endswith(os.path.sep): | |
return out + os.path.sep | |
return out | |
def main(): | |
for p in sys.argv[1:]: | |
print(actual_path(p)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment