| 1 |
#!/usr/bin/env python3 |
| 2 |
import os |
| 3 |
import sys |
| 4 |
|
| 5 |
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 6 |
|
| 7 |
from DisplayCAL import ICCProfile as iccp |
| 8 |
|
| 9 |
|
| 10 |
def set_profile_desc_to_basename_sans_ext(profile): |
| 11 |
if isinstance(profile, str): |
| 12 |
profile = iccp.ICCProfile(profile) |
| 13 |
if isinstance(profile, iccp.ICCProfile): |
| 14 |
name = os.path.splitext(os.path.basename(profile.fileName))[0] |
| 15 |
if isinstance(profile.tags.desc, iccp.TextDescriptionType): |
| 16 |
profile.tags.desc.ASCII = name.encode("ASCII", "asciize") |
| 17 |
profile.tags.desc.Unicode = name |
| 18 |
profile.tags.desc.Macintosh = name |
| 19 |
else: |
| 20 |
profile.tags.desc = iccp.MultiLocalizedUnicodeType() |
| 21 |
profile.tags.desc.add_localized_string("en", "US", name) |
| 22 |
profile.write() |
| 23 |
else: |
| 24 |
for item in profile: |
| 25 |
set_profile_desc_to_basename_sans_ext(item) |
| 26 |
|
| 27 |
|
| 28 |
if __name__ == "__main__": |
| 29 |
import sys |
| 30 |
|
| 31 |
set_profile_desc_to_basename_sans_ext(sys.argv[1:]) |