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

File access relative to current working directory throughout code, make it hard to use code in library #35

Open
GrumpyBen opened this issue Aug 28, 2022 · 1 comment

Comments

@GrumpyBen
Copy link

GrumpyBen commented Aug 28, 2022

Throughout the code base, to figure out location of resource files, the following code pattern is used:

f'{"./resources/app" if self.PROD else "."}/some/path'

This creates a dependency on the current working directory, and makes the code harder to reuse outside of xVA-Synth - to package it in a library for example.

As the PROD attribute is propagated throughout the code base, it could as well be a path prefix, call it ROOT, instead of a boolean. The code pattern would become simpler and more flexible than current usage:

f'{self.ROOT}/some/path'

Plus dependency on current working directory - which can change due to many factors, e.g. how a Windows shortcut is configured - is removed.

@GrumpyBen GrumpyBen changed the title File access relative to current working directory throughout code, make it hard to use cideb File access relative to current working directory throughout code, make it hard to use code in library Aug 28, 2022
@DanRuta
Copy link
Owner

DanRuta commented Sep 6, 2022

Yeah, this is maybe not the best design. That's a good idea, to use a root path instead of a PROD flag, thank you! Though the flag is I think sometimes used for things other than the path, so I'll possibly add a second variable for this, or something, instead

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

No branches or pull requests

2 participants