Skip to content

Commit fd8b913

Browse files
committed
consistent use of get_addon_preferences() function
1 parent 0c35ce8 commit fd8b913

4 files changed

Lines changed: 11 additions & 22 deletions

File tree

operators/lol/add_local.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from os import listdir
3333
from os.path import basename, dirname, isfile, join, splitext, exists
3434
from ...utils.lol import utils as lol_utils
35+
from ...utils import get_addon_preferences
3536

3637
from mathutils import Vector
3738

@@ -77,9 +78,7 @@ def render_thumbnail(args):
7778
from ...utils.compatibility import run
7879
(context, assetfile, asset_type) = args
7980

80-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
81-
user_preferences = context.preferences.addons[name].preferences
82-
81+
user_preferences = get_addon_preferences(context)
8382

8483
if asset_type == 'MODEL':
8584
luxball = 'material_thumbnail.blend'
@@ -131,8 +130,7 @@ def execute(self, context):
131130
ui_props = scene.luxcoreOL.ui
132131
upload_props = scene.luxcoreOL.upload
133132

134-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
135-
user_preferences = context.preferences.addons[name].preferences
133+
user_preferences = get_addon_preferences(context)
136134

137135
if len(context.selected_objects) == 0:
138136
return {'CANCELLED'}
@@ -243,8 +241,7 @@ def execute(self, context):
243241
ui_props = scene.luxcoreOL.ui
244242
upload_props = scene.luxcoreOL.upload
245243

246-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
247-
user_preferences = context.preferences.addons[name].preferences
244+
user_preferences = get_addon_preferences(context)
248245
assetpath = join(user_preferences.global_dir, ui_props.asset_type.lower(), 'local')
249246

250247
files = [f for f in listdir(assetpath) if isfile(join(assetpath, f))]

operators/lol/update_ToC.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from bpy.types import Operator
2929
from ...utils.lol import utils as utils
30+
from ...utils import get_addon_preferences
3031

3132
class LOLUpdateTOC(Operator):
3233
bl_idname = 'scene.luxcore_ol_update_toc'
@@ -44,8 +45,7 @@ def execute(self, context):
4445
scene = context.scene
4546
ui_props = scene.luxcoreOL.ui
4647

47-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
48-
user_preferences = context.preferences.addons[name].preferences
48+
user_preferences = get_addon_preferences(context)
4949
LOL_HOST_URL = user_preferences.lol_host
5050
LOL_VERSION = user_preferences.lol_version
5151
LOL_HTTP_HOST = user_preferences.lol_http_host

scripts/LOL/render_thumbnail.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def calc_bbox(context, objects):
3939

4040
def render_material_thumbnail(assetname, blendfile, thumbnail, samples):
4141
context = bpy.context
42-
scene = context.scene
43-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
44-
user_preferences = context.preferences.addons[name].preferences
4542

4643
with bpy.data.libraries.load(blendfile, link=True) as (mat_from, mat_to):
4744
mat_to.materials = mat_from.materials
@@ -69,8 +66,6 @@ def render_material_thumbnail(assetname, blendfile, thumbnail, samples):
6966
def render_model_thumbnail(assetname, blendfile, thumbnail, samples):
7067
context = bpy.context
7168
scene = context.scene
72-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
73-
user_preferences = context.preferences.addons[name].preferences
7469

7570
with bpy.data.libraries.load(blendfile, link=True) as (data_from, data_to):
7671
data_to.objects = [name for name in data_from.objects]

utils/lol/utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def load_local_TOC(context, asset_type):
5050

5151
assets = []
5252

53-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
54-
user_preferences = context.preferences.addons[name].preferences
53+
user_preferences = get_addon_preferences(context)
54+
5555

5656
filepath = join(user_preferences.global_dir, 'local_assets_' + asset_type.lower() + '.json')
5757
if isfile(filepath):
@@ -68,8 +68,7 @@ def load_local_TOC(context, asset_type):
6868

6969

7070
def load_patreon_assets(context):
71-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
72-
user_preferences = context.preferences.addons[name].preferences
71+
user_preferences = get_addon_preferences(context)
7372
LOL_HOST_URL = user_preferences.lol_host
7473
LOL_VERSION = user_preferences.lol_version
7574
LOL_HTTP_HOST = user_preferences.lol_http_host
@@ -123,8 +122,7 @@ def download_table_of_contents(context):
123122
global bg_threads
124123
scene = context.scene
125124
ui_props = context.scene.luxcoreOL.ui
126-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
127-
user_preferences = context.preferences.addons[name].preferences
125+
user_preferences = get_addon_preferences(context)
128126
LOL_HOST_URL = user_preferences.lol_host
129127
LOL_VERSION = user_preferences.lol_version
130128
LOL_HTTP_HOST = user_preferences.lol_http_host
@@ -708,8 +706,7 @@ def bg_load_previews(context, asset_type):
708706
def bg_download_thumbnails(context, download_queue):
709707
import urllib.request
710708

711-
name = 'bl_ext.user_default.' + basename(dirname(dirname(dirname(__file__))))
712-
user_preferences = context.preferences.addons[name].preferences
709+
user_preferences = get_addon_preferences(context)
713710
LOL_HOST_URL = user_preferences.lol_host
714711
LOL_VERSION = user_preferences.lol_version
715712
LOL_HTTP_HOST = user_preferences.lol_http_host

0 commit comments

Comments
 (0)