baf951bddf6b76b2d8672e7bd56e08bf22a674f1
1 from sys
import platform
2 from os
.path
import exists
3 from pathlib
import Path
4 from platform
import system
5 from panda3d
.core
import GraphicsWindow
, Filename
8 class class_property(property):
9 def __get__(self
, cls
, owner
):
10 return classmethod(self
.fget
).__get
__(None, owner
)()
16 def in_build(cls
): return not exists('main.py')
19 def windowed(cls
): return base
.win
and isinstance(base
.win
, GraphicsWindow
)
22 def is_appimage(app_name
):
23 parent_path
= str(Path(__file__
).parent
.absolute())
24 mounted
= parent_path
.startswith(LogicsTools
.appimage_path(app_name
))
25 return mounted
and parent_path
.endswith('/usr/bin')
28 def appimage_path(app_name
):
29 folder_mounted_appimage
= app_name
[:6].capitalize()
30 return f
'/tmp/.mount_{folder_mounted_appimage}'
33 def appdata_path(cls
):
34 appdata_path
= str(Filename
.get_user_appdata_directory())
35 home
= str(Path
.home()) # '/home/flavio' # we must force this for wine
36 if appdata_path
.startswith('/c/users/') and exists(home
+ '/.wine/'):
37 appdata_path
= home
+ '/.wine/drive_' + appdata_path
[1:]
41 def current_path(app_name
):
42 if not LogicsTools
.in_build
: return ''
43 if system() == 'Windows' or exists('main.py'): return ''
44 else: par_path
= str(Path(__file__
).parent
.absolute())
45 if LogicsTools
.is_appimage(app_name
):
46 par_path
= str(Path(par_path
).absolute())
50 def platform_specific_path(path
):
51 if LogicsTools
.__is
_windows
_not
_wine
():
52 path
= LogicsTools
.__linux
2windows
_path
(path
)
56 def __is_windows_not_wine():
57 home
= str(Path
.home())
58 return platform
== 'win32' and not exists(home
+ '/.wine/')
61 def __linux2windows_path(path
):
62 if path
.startswith('/'):
63 path
= path
[1] + ':\\' + path
[3:]
64 return path
.replace('/', '\\')