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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/modules')
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils.py4
-rw-r--r--release/scripts/modules/bl_i18n_utils/utils_cli.py10
-rw-r--r--release/scripts/modules/bl_keymap_utils/io.py11
-rw-r--r--release/scripts/modules/bpy_extras/__init__.py1
-rw-r--r--release/scripts/modules/bpy_extras/asset_utils.py63
5 files changed, 81 insertions, 8 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py
index 40b76b617b3..fd4488ecd73 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -185,9 +185,9 @@ def list_po_dir(root_path, settings):
"""
Generator. List given directory (expecting one sub-directory per languages)
and return all files matching languages listed in settings.
-
+
Yield tuples (can_use, uid, num_id, name, isocode, po_path)
-
+
Note that po_path may not actually exists.
"""
isocodes = ((e, os.path.join(root_path, e, e + ".po")) for e in os.listdir(root_path))
diff --git a/release/scripts/modules/bl_i18n_utils/utils_cli.py b/release/scripts/modules/bl_i18n_utils/utils_cli.py
index d38911c122d..76dd8a740c5 100644
--- a/release/scripts/modules/bl_i18n_utils/utils_cli.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_cli.py
@@ -103,22 +103,22 @@ def main():
sub_parsers = parser.add_subparsers()
sub_parser = sub_parsers.add_parser('update_po', help="Update a PO file from a given POT template file")
- sub_parser.add_argument('--template', metavar='template.pot', required=True,
+ sub_parser.add_argument('--template', metavar='template.pot', required=True,
help="The source pot file to use as template for the update.")
sub_parser.add_argument('--dst', metavar='dst.po', required=True, help="The destination po to update.")
- sub_parser.set_defaults(func=update_po)
+ sub_parser.set_defaults(func=update_po)
sub_parser = sub_parsers.add_parser('cleanup_po',
help="Cleanup a PO file (check for and fix some common errors, remove commented messages).")
sub_parser.add_argument('--src', metavar='src.po', required=True, help="The source po file to clean up.")
sub_parser.add_argument('--dst', metavar='dst.po', help="The destination po to write to.")
- sub_parser.set_defaults(func=cleanup_po)
+ sub_parser.set_defaults(func=cleanup_po)
sub_parser = sub_parsers.add_parser('strip_po',
help="Reduce all non-essential data from given PO file (reduce its size).")
sub_parser.add_argument('--src', metavar='src.po', required=True, help="The source po file to strip.")
sub_parser.add_argument('--dst', metavar='dst.po', help="The destination po to write to.")
- sub_parser.set_defaults(func=strip_po)
+ sub_parser.set_defaults(func=strip_po)
sub_parser = sub_parsers.add_parser('rtl_process_po',
help="Pre-process PO files for RTL languages.")
@@ -128,7 +128,7 @@ def main():
sub_parser = sub_parsers.add_parser('language_menu',
help="Generate the text file used by Blender to create its language menu.")
- sub_parser.set_defaults(func=language_menu)
+ sub_parser.set_defaults(func=language_menu)
args = parser.parse_args(sys.argv[1:])
diff --git a/release/scripts/modules/bl_keymap_utils/io.py b/release/scripts/modules/bl_keymap_utils/io.py
index 091cdbc2642..645a145f994 100644
--- a/release/scripts/modules/bl_keymap_utils/io.py
+++ b/release/scripts/modules/bl_keymap_utils/io.py
@@ -222,12 +222,21 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False):
fw("]\n")
fw("\n\n")
fw("if __name__ == \"__main__\":\n")
+
+ # We could remove this in the future, as loading new key-maps in older Blender versions
+ # makes less and less sense as Blender changes.
+ fw(" # Only add keywords that are supported.\n")
+ fw(" from bpy.app import version as blender_version\n")
+ fw(" keywords = {}\n")
+ fw(" if blender_version >= (2, 92, 0):\n")
+ fw(" keywords[\"keyconfig_version\"] = keyconfig_version\n")
+
fw(" import os\n")
fw(" from bl_keymap_utils.io import keyconfig_import_from_data\n")
fw(" keyconfig_import_from_data(\n")
fw(" os.path.splitext(os.path.basename(__file__))[0],\n")
fw(" keyconfig_data,\n")
- fw(" keyconfig_version=keyconfig_version,\n")
+ fw(" **keywords,\n")
fw(" )\n")
diff --git a/release/scripts/modules/bpy_extras/__init__.py b/release/scripts/modules/bpy_extras/__init__.py
index 1caef074d43..cb990b014a1 100644
--- a/release/scripts/modules/bpy_extras/__init__.py
+++ b/release/scripts/modules/bpy_extras/__init__.py
@@ -24,6 +24,7 @@ Utility modules associated with the bpy module.
__all__ = (
"anim_utils",
+ "asset_utils",
"object_utils",
"io_utils",
"image_utils",
diff --git a/release/scripts/modules/bpy_extras/asset_utils.py b/release/scripts/modules/bpy_extras/asset_utils.py
new file mode 100644
index 00000000000..db982e119d4
--- /dev/null
+++ b/release/scripts/modules/bpy_extras/asset_utils.py
@@ -0,0 +1,63 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+"""
+Helpers for asset management tasks.
+"""
+
+import bpy
+from bpy.types import (
+ Context,
+)
+
+__all__ = (
+ "SpaceAssetInfo",
+)
+
+class SpaceAssetInfo:
+ @classmethod
+ def is_asset_browser(cls, space_data: bpy.types.Space):
+ return space_data.type == 'FILE_BROWSER' and space_data.browse_mode == 'ASSETS'
+
+ @classmethod
+ def is_asset_browser_poll(cls, context: Context):
+ return cls.is_asset_browser(context.space_data)
+
+ @classmethod
+ def get_active_asset(cls, context: Context):
+ if hasattr(context, "active_file"):
+ active_file = context.active_file
+ return active_file.asset_data if active_file else None
+
+class AssetBrowserPanel:
+ bl_space_type = 'FILE_BROWSER'
+
+ @classmethod
+ def poll(cls, context):
+ return SpaceAssetInfo.is_asset_browser_poll(context)
+
+class AssetMetaDataPanel:
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'TOOL_PROPS'
+
+ @classmethod
+ def poll(cls, context):
+ active_file = context.active_file
+ return SpaceAssetInfo.is_asset_browser_poll(context) and active_file and active_file.asset_data