Examples



Correct Usage Examples

No config object usage is required to use the default settings:
1from yfrake import client
2
3@client.session
4def main():
5    # do stuff
6
7main()
Assigning a custom config file in the Current Working Directory.
If the file doesn’t exist, it will be created with the default settings.
1from yfrake import client, config
2
3config.file = config.HERE
4
5@client.session
6def main():
7    # do stuff
8
9main()

Assigning a custom config file in the specified path:

1from yfrake import client, config
2
3config.file = "C:/Users/username/Projects/Project Name/yfrake_settings.ini"
4
5@client.session
6def main():
7    # do stuff
8
9main()

Reading the currently loaded configuration settings:

1from yfrake import client, config
2
3settings = config.settings  # correct
4
5@client.session
6def main():
7    settings = config.settings  # also correct
8
9main()

Assigning a custom config file before the server is started:

1from yfrake import server, config
2
3config.file = Path("C:/Users/username/Projects/Project Name/yfrake_settings.ini")
4server.start()
5
6# defined behaviour
7
8server.stop()


Incorrect Usage Examples

Trying to assign a custom config file in the Current Working Directory.

1from yfrake import client, config
2
3@client.session
4def main():
5    config.file = config.HERE
6
7    # will raise an exception
8
9main()

Trying to assign a custom custom config file in the specified path:

1from yfrake import client, config
2
3@client.session
4def main():
5    config.file = "C:/Users/username/Projects/Project Name/yfrake_settings.ini"
6
7    # will raise an exception
8
9main()

Assigning a custom config file after the server has started:

1from yfrake import server, config
2
3server.start()
4config.file = Path("C:/Users/username/Projects/Project Name/yfrake_settings.ini")
5
6# undefined behaviour
7
8server.stop()