developer icon indicating copy to clipboard operation
developer copied to clipboard

error when writing inside folders

Open LukasMeine opened this issue 2 years ago • 4 comments

I'm getting this all the time. With and Without Modal

IsADirectoryError: [Errno 21] Is a directory: 'generated/src/'

It seems that smol is trying to write directly to the folder, instead to the appropriate file.

LukasMeine avatar May 19 '23 22:05 LukasMeine

hi! hmm. i think i understand - will fix this in the coming version of smol (i am working on #12 )

swyxio avatar May 22 '23 00:05 swyxio

nice! Thanks for the amazing work, your repo is great!

LukasMeine avatar May 22 '23 09:05 LukasMeine

Got the same error:

IsADirectoryError: [Errno 21] Is a directory: 'generated/app/'

jonnyhoff avatar May 31 '23 11:05 jonnyhoff

The fix

In the write_file function

Before:

      with open(file_path, "w") as file:
          # Write content to the file
          file.write(filecode)

After:

    if not file_path.endswith("/"):
        with open(file_path, "w") as file:
            # Write content to the file
            file.write(filecode)

jonnyhoff avatar May 31 '23 11:05 jonnyhoff