Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

add __file__ attribute when load .py config file #333

Open
wants to merge 1 commit into
base: 0.9
Choose a base branch
from

Conversation

luoxiaohei
Copy link

Fix the exception when use __file__ attribute in .py config file.

eg:

import os
import dotenv

dotenv.load_dotenv(os.path.join(os.path.dirname(os.path.abspath(__file__)), '.env'))

databases = {
    'default': 'sql',
    'sql': {
        'driver': os.getenv('SQL_DRIVER'),
        'host': os.getenv('SQL_HOST'),
        'port': os.getenv('SQL_PORT'),
        'user': os.getenv('SQL_USER'),
        'password': os.getenv('SQL_PASSWORD'),
        'database': os.getenv('SQL_DATABASE')
    }
}

@mandarvaze
Copy link

@luoxiaohei Can you add a test case for _get_config function that you've fixed ?

I'm considering this PR for MasoniteFramework/orator fork

@luoxiaohei
Copy link
Author

@mandarvaze no problem!

@luoxiaohei luoxiaohei force-pushed the 0.9 branch 2 times, most recently from 1914e1a to da0ee60 Compare November 18, 2019 18:10
@luoxiaohei
Copy link
Author

@mandarvaze Hi, I have added test cases, but CI seems to have some problems. I don't think my code is causing CI to fail.

@mandarvaze
Copy link

I don't think my code is causing CI to fail.

It is failing because some of the existing files aren't formatted "correctly", via black formatter.

Can you run pre-commit run --all-files locally ? It should "fix" the files, including two of your files. Then you need to git add -u and run pre-commit run --all-files again. This time it should pass.

If you are having error running the command , look here

Finally, if you think it is too much, leave it. I can do it for you 😄

@luoxiaohei
Copy link
Author

@mandarvaze Thank you! Now seems that everything is right.

@mandarvaze
Copy link

Great. We are almost there. One last thing: Can you squash your 3 commits into a single commit, so that I can cherry pick the combined one.

Also, is this PR related to any open issue ? If yes, please mention.

@luoxiaohei
Copy link
Author

@mandarvaze I have squashed commits. There is no open issue related to it.

@mandarvaze
Copy link

@luoxiaohei Thanks for your contribution.

This PR is merged to MasoniteFramework/orator fork :
MasoniteFramework@d5b513c

@luoxiaohei
Copy link
Author

@josephmancuso Hi, Can you merge this PR? I want to create a new PR to fix the error occurred by source code installation.

@mandarvaze
Copy link

@luoxiaohei Feel free to create PR on MasoniteFramework/orator fork 😄

@luoxiaohei
Copy link
Author

@mandarvaze OK! 😄

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

Successfully merging this pull request may close these issues.

2 participants