Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2019-05-17 22:25:33 +0300
committerVilem Duha <vilem.duha@gmail.com>2019-05-19 16:45:50 +0300
commitb0027289420fd8eaf7c2686e6a64ffe8b2e4419e (patch)
tree70c636f1268a77dc7369d5425e59143688dfd57e /blenderkit/categories.py
parentab57ec6a76cf344c6ae2c2d61b446a6e9bc4b0db (diff)
BlenderKit: Updated tooltip layout and finishing profile and OAuth
Diffstat (limited to 'blenderkit/categories.py')
-rw-r--r--blenderkit/categories.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/blenderkit/categories.py b/blenderkit/categories.py
index 794b15b1..c2b37dd1 100644
--- a/blenderkit/categories.py
+++ b/blenderkit/categories.py
@@ -1,7 +1,8 @@
import requests
import json
import os
-from blenderkit import paths,utils
+import bpy
+from blenderkit import paths, utils, tasks_queue
import shutil
import threading
@@ -18,6 +19,7 @@ def fix_category_counts(categories):
def filter_category(category):
+ ''' filter categories with no assets, so they aren't shown in search panel'''
if category['assetCount'] < 1:
return True
else:
@@ -57,6 +59,23 @@ def copy_categories():
print("couldn't copy categories file")
+def load_categories():
+ copy_categories()
+ tempdir = paths.get_temp_dir()
+ categories_filepath = os.path.join(tempdir, 'categories.json')
+
+ wm = bpy.context.window_manager
+ with open(categories_filepath, 'r') as catfile:
+ wm['bkit_categories'] = json.load(catfile)
+
+ wm['active_category'] = {
+ 'MODEL': ['model'],
+ 'SCENE': ['scene'],
+ 'MATERIAL': ['material'],
+ 'BRUSH': ['brush'],
+ }
+
+
def fetch_categories(API_key):
url = paths.get_api_url() + 'categories/'
@@ -73,8 +92,10 @@ def fetch_categories(API_key):
# filter_categories(categories) #TODO this should filter categories for search, but not for upload. by now off.
with open(categories_filepath, 'w') as s:
json.dump(categories, s, indent=4)
- except:
- # print('category fetching failed')
+ tasks_queue.add_task((load_categories, ()))
+ except Exception as e:
+ utils.p('category fetching failed')
+ utils.p(e)
if not os.path.exists(categories_filepath):
source_path = paths.get_addon_file(subpath='data' + os.sep + 'categories.json')
shutil.copy(source_path, categories_filepath)