adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.05k stars 167 forks source link

[checkoutlinesufo] FileNotFoundError when glyphs.com.adobe.type.processedglyphs is empty #1606

Open arialcrime opened 1 year ago

arialcrime commented 1 year ago

Within git I use the option to discard uncommitted changes quite a lot during font production work. While that’s super handy to get back to previous states of the files, it can also result in empty folders being left within UFOs.

One of these cases is when I run checkoutlinesufo -e path/to/ufo/file.ufo and discard those changes after. I don’t think an empty folder in a UFO is an issue in itself, but sadly it causes the following FileNotFoundError:

Traceback (most recent call last):
  File "/Users/benedikt/fdev/bin/checkoutlinesufo", line 8, in <module>
    sys.exit(main())
  File "/Users/benedikt/fdev/lib/python3.10/site-packages/afdko/checkoutlinesufo.py", line 1151, in main
    run(sys.argv[1:])
  File "/Users/benedikt/fdev/lib/python3.10/site-packages/afdko/checkoutlinesufo.py", line 1001, in run
    defcon_font = font_file.open(use_hash_map)
  File "/Users/benedikt/fdev/lib/python3.10/site-packages/afdko/checkoutlinesufo.py", line 68, in open
    ufotools.validateLayers(font_path)
  File "/Users/benedikt/fdev/lib/python3.10/site-packages/afdko/ufotools.py", line 1041, in validateLayers
    cleanUpGLIFFiles(defaultContentsFilePath, glyphDirPath, doWarning)
  File "/Users/benedikt/fdev/lib/python3.10/site-packages/afdko/ufotools.py", line 905, in cleanUpGLIFFiles
    with open(contentsFilePath, 'r', encoding='utf-8') as fp:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/benedikt/Desktop/TEMP/230130/checkoutlinesufo_test/font.ufo/glyphs.com.adobe.type.processedglyphs/contents.plist'

I’m not very familiar with how ufotools works, but I can imagine that a check if there is something in the folder could resolve this? Below you can find a zip with 2 files, one after running the checkoutlinesufo command from above, and the other after discarding the changes.

Let me know if you need anything else! checkoutlinesufo_test.zip

frankrolf commented 1 year ago

Did you try to use the --all option? It might be better to start fresh?

frankrolf commented 1 year ago

(doesn’t work). I agree an empty folder should not make the tool stumble, I’ll have a look.