Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when writing inside folders #26

Open
LukasMeine opened this issue May 19, 2023 · 4 comments · May be fixed by #80
Open

error when writing inside folders #26

LukasMeine opened this issue May 19, 2023 · 4 comments · May be fixed by #80

Comments

@LukasMeine
Copy link
Contributor

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 LukasMeine changed the title error when writing to folders error when writing inside folders May 19, 2023
@swyxio
Copy link
Contributor

swyxio commented May 22, 2023

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

@LukasMeine
Copy link
Contributor Author

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

@jonnyhoff
Copy link

Got the same error:

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

@jonnyhoff
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants