mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
Working with local resources path
This commit is contained in:
@@ -1,17 +1,26 @@
|
|||||||
# used for AUR installation
|
# used for AUR installation
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
share_path = str(Path.home()) + '/.local/share'
|
||||||
|
local_resources_path = share_path + '/fpakman'
|
||||||
|
|
||||||
|
if os.path.exists(local_resources_path):
|
||||||
|
shutil.rmtree(local_resources_path)
|
||||||
|
|
||||||
|
os.mkdir(local_resources_path)
|
||||||
|
|
||||||
desktop_file = """
|
desktop_file = """
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type = Application
|
Type = Application
|
||||||
Name = fpakman
|
Name = fpakman
|
||||||
|
Categories=System;
|
||||||
Comment = Manage your Flatpak applications
|
Comment = Manage your Flatpak applications
|
||||||
Exec = /usr/bin/fpakman
|
Exec = /usr/bin/fpakman
|
||||||
Icon = /usr/lib/python{version}/site-packages/fpakman/resources/img/flathub_45.svg
|
Icon = {resource_path}/resources/img/flathub_45.svg
|
||||||
""".format(version="{}.{}".format(sys.version_info.major, sys.version_info.minor))
|
""".format(resource_path=local_resources_path)
|
||||||
|
|
||||||
apps_path = '{}/.local/share/applications'.format(str(Path.home()))
|
apps_path = '{}/.local/share/applications'.format(str(Path.home()))
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import os
|
import os
|
||||||
|
import getpass
|
||||||
|
|
||||||
|
local_resource_path = '/home/{}/.local/share/fpakman/resources'.format(getpass.getuser())
|
||||||
|
app_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
def get_path(resource_path):
|
def get_path(resource_path):
|
||||||
app_dir = get_app_dir()
|
|
||||||
return app_dir + '/resources/' + resource_path
|
|
||||||
|
|
||||||
|
if os.path.exists(local_resource_path):
|
||||||
def get_app_dir():
|
return local_resource_path + resource_path
|
||||||
return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
else:
|
||||||
|
return app_dir + '/resources/' + resource_path
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ def get_locale_keys():
|
|||||||
|
|
||||||
current_locale = locale.getdefaultlocale()
|
current_locale = locale.getdefaultlocale()
|
||||||
locale_path = None
|
locale_path = None
|
||||||
|
|
||||||
if current_locale:
|
if current_locale:
|
||||||
current_locale = current_locale[0]
|
current_locale = current_locale[0]
|
||||||
|
|
||||||
locale_dir = '{}/resources/locale'.format(resource.get_app_dir())
|
locale_dir = resource.get_path('/locale')
|
||||||
|
|
||||||
for locale_file in glob.glob(locale_dir + '/*'):
|
for locale_file in glob.glob(locale_dir + '/*'):
|
||||||
name = locale_file.split('/')[-1]
|
name = locale_file.split('/')[-1]
|
||||||
@@ -21,7 +22,7 @@ def get_locale_keys():
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not locale_path:
|
if not locale_path:
|
||||||
locale_path = '{}/resources/locale/en'.format(resource.get_app_dir())
|
locale_path = resource.get_path('locale/en')
|
||||||
|
|
||||||
with open(locale_path, 'r') as f:
|
with open(locale_path, 'r') as f:
|
||||||
locale_keys = f.readlines()
|
locale_keys = f.readlines()
|
||||||
|
|||||||
Reference in New Issue
Block a user