You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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
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 itROOT
, 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.
The text was updated successfully, but these errors were encountered: