Add project root env fallback

1.3.4

- added: `PROJECT_ROOT` key is used if `ZIP_ROOT` is not specified. Fallback to initial property if neither exists
- added: checkbox to disable env variable check
main
Pullusb 2022-01-07 00:08:18 +01:00
parent dd82a38956
commit 85037c027a
3 changed files with 30 additions and 6 deletions

View File

@ -7,7 +7,9 @@ Modifications:
- Additional export **Zip pack - keep hierarchy**
Standard Bat pack is doing an "assembly", modifying file internal links. This zip pack leave the file untouched. Behavior description:
- The root folder for zipping use the environment variable `ZIP_ROOT` (accessed with `os.getenv('ZIP_ROOT')` if defined).
- If there is no such env variable, it fallback to path specified in addon preferences.
- if `ZIP_ROOT` is not defined, use `PROJECT_ROOT` variable.
- If there is no such env variables, it fallback to path specified in addon preferences.
- A checkbox allow to avoid the replacement of root properties with env variables.
- In the export browser window settings (sidebar), user can choose the packing root folder, prefilled by env or addon preference path
- If nothing specified, root will be automatically defined with the most upper folder covering the whole dependancies hierarchy.
@ -16,6 +18,11 @@ Standard Bat pack is doing an "assembly", modifying file internal links. This zi
### Changelog
1.3.4
- added: `PROJECT_ROOT` key is used if `ZIP_ROOT` is not specified. Fallback to initial property if neither exists
- added: checkbox to disable env variable check
1.3.3
- code: sys.module name corrected when addon folder isn't named `blender_asset_tracer` as expected

View File

@ -21,11 +21,12 @@
# <pep8 compliant>
__version__ = '1.3'
# branched from source BAT since 1.3.0
bl_info = {
"name": "Blender Asset Tracer",
"author": "Campbell Barton, Sybren A. Stüvel, Loïc Charrière and Clément Ducarteron",
"version": (1, 3, 3),
"version": (1, 3, 4),
"blender": (2, 80, 0),
"location": "File > External Data > BAT",
"description": "Utility for packing blend files",
@ -264,10 +265,19 @@ def menu_func(self, context):
layout.separator()
layout.operator(ExportBatPack.bl_idname)
filepath = layout.operator(BAT_OT_export_zip.bl_idname)
root_dir_env = os.getenv('ZIP_ROOT')
if not root_dir_env: # if no env use prefs instead
root_dir_env = preferences.get_addon_prefs().root_default
filepath.root_dir = '' if root_dir_env == None else root_dir_env #os.getenv('PROJECT_STORE')
prefs = preferences.get_addon_prefs()
root_dir_env = None
if prefs.use_env_root:
root_dir_env = os.getenv('ZIP_ROOT')
if not root_dir_env: # first fallback to PROJECT_ROOT
root_dir_env = os.getenv('PROJECT_ROOT')
if not root_dir_env: # if no env, use prefs instead
root_dir_env = prefs.root_default
filepath.root_dir = '' if root_dir_env == None else root_dir_env
classes = (

View File

@ -19,6 +19,12 @@ class myaddonPrefs(bpy.types.AddonPreferences):
subtype='DIR_PATH',
default='')
use_env_root : BoolProperty(
name="Use Environement Root",
description="Use root path specified by environnement keys at startup\nUsing key 'ZIP_ROOT' or 'PROJECT_ROOT' if exists (priority to key ZIP_ROOT if both are set)\nElse always use prefs.",
default=True,
)
def draw(self, context):
layout = self.layout
col = layout.column()
@ -28,6 +34,7 @@ class myaddonPrefs(bpy.types.AddonPreferences):
col = layout.column()
col.label(text='If specified, will be the default root folder path when using export to Zip')
col.label(text='Typically the root folder of the current project')
col.prop(self, 'use_env_root')