DanRuta / xVA-Synth

Machine learning based speech synthesis Electron app, with voices from specific characters from video games
GNU General Public License v3.0
590 stars 54 forks source link

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

Open GrumpyBen opened 1 year ago

GrumpyBen commented 1 year ago

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.

DanRuta commented 1 year ago

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