Commit Graph

238 Commits

Author SHA1 Message Date
Campbell Barton
73b34ad06b PyAPI: tweak to ensure_ext don't lower entire path 2015-09-03 21:58:11 +10:00
Sybren A. Stüvel
8383a2d4cc Fix: Made bpy.path.ensure_ext compatible with compound extensions.
Extensions such as ".tar.gz" are now also supported. Before this patch,
ensure_ext('demo.tar.gz', '.tar.gz') would return 'demo.tar.tar.gz'.

This results in issues with the `ExportHelper` mix-in class; clicking
an existing file in the file dialogue warns about overwriting it
(highlighting the input box in red), but then saves to a different
file.

Also added a unit test for the new behaviour.

Reviewers: mont29, campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1498
2015-09-03 13:09:16 +02:00
Campbell Barton
62c8f46ab6 Docs: comment functions in BLI & Py API 2015-08-05 02:09:03 +10:00
Campbell Barton
88d63905a8 Fix T45644: bpy.utils.smpte_from_frame drops frame
D1444 by @lichtwerk, with minor fix & docstring updates
2015-08-03 14:01:24 +10:00
Campbell Barton
1c81bcffde addon_utils default mismatch /w enable/disable
default_set argument is now False for both.
2015-06-14 05:14:43 +10:00
Campbell Barton
60ddaf045a Python API: use cached translation tables
bpy.path.clean_name() and AddPresetBase.as_filename() were doing
inefficient search-replace of individual characters.

Use cached replacement table instead.
2015-06-13 19:47:32 +10:00
Campbell Barton
99fba34b8d rename wiki -> manual 2015-06-08 11:34:07 +10:00
Campbell Barton
f51fef63aa Fix own error deleting previews 2015-05-17 17:26:01 +10:00
Campbell Barton
847ec075eb Cleanup: pep8 2015-05-17 17:26:01 +10:00
Campbell Barton
20e561dd6a PyAPI: Remove release method, just use delitem 2015-05-12 18:43:30 +10:00
Campbell Barton
34c78a659b Doc: add bpy.utils.previews
Updated sphinx_doc_gen.py to better handle pure py-classes.
2015-05-12 18:24:32 +10:00
Bastien Montagne
d30f664c04 Expose PreviewImage & custom icons to py API.
This commit mainly:

* Exposes PreviewImage struct in RNA, including ways for user to set images data.
* Adds a new kind of PreviewImage, using a file path and IMB_thumb to get image.
* Adds a new kind of custom icon using PreviewImage, unrelated to ID previews system.
* Adds a python API (utils.previews) to allow python scripts to access those custom previews/icons.

Note that loading image from files' thumbnails is done when needed (deferred loading), not
when defining the custom preview/icon.

WARNING: for release addons who would want to use this, please keep it to a strict minimum, really needed level.
We do not want our UI to explode under hundreds of different flashy icons!

For more info, see also the release notes of Blender 2.75 (http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.75/Addons)
and the example/templates featured with Blender.

Patch by Campbell (ideasman42), Inês (brita) and Bastien (mont29).

Differential Revision: https://developer.blender.org/D1255
2015-05-11 16:37:15 +02:00
Bastien Montagne
929c9de3dc Turn bpy.utils into a package, so that we can easily add submodules to it. 2015-05-02 10:38:51 +02:00
Campbell Barton
b87eaef1f7 Fix T44137: bpy.path.is_subdir fails
`bpy.path.is_subdir("/abc/def/ghi","/abc/de")` incorrectly returned True
2015-03-26 16:32:16 +11:00
Campbell Barton
e17c6f79a5 cleanup: py imports 2015-01-28 16:50:51 +11:00
Campbell Barton
7733bd5efc PyAPI: avoid scanning all addons on startup
Gives small speedup
2015-01-23 16:38:29 +11:00
Campbell Barton
3e8c0027a3 Cleanup: replace deprecated imp -> importlib 2015-01-23 12:37:58 +11:00
Campbell Barton
f0f1c7995b PyAPI: disallow assigning members to 'bpy.ops' 2014-12-18 13:52:31 +01:00
Campbell Barton
b2b1d8e290 Cleanup: remove redundant 'object' parent class 2014-10-28 18:42:06 +01:00
Campbell Barton
0a48cf08da Correct docstrings 2014-08-26 10:57:21 +10:00
Campbell Barton
679046743f Fix T41584: bpy.utils.time_from_frame out by a day
Fix from retroj
2014-08-26 09:18:54 +10:00
Bastien Montagne
3a58c4679a Fix addon crash when trying listdir a directory we have no permission to. 2014-07-30 15:35:19 +02:00
Bastien Montagne
f94b87bbb8 New python API for units handling.
Exposes all supported unit systems & types, and to_value()/to_string() functions.

Reviewed and enhanced by CampbellBarton, many thanks!

Differential Revision: https://developer.blender.org/D416
2014-06-17 16:03:40 +02:00
Campbell Barton
a2489e29f6 Code cleanup: style, unused import 2014-04-28 00:19:15 +10:00
Campbell Barton
ea610e655c Style cleanup: C & pep8 2014-04-15 13:11:48 +10:00
Bastien Montagne
0c6e74436f Fix T39158: Help > Operator Cheat Sheet causes a python recursive loop.
Core issue exists since ages - the thing you get from bpy.types.YOUR_OT_operator is fuzzy, and may change,
due to the fact that both Operator and OperatorProperties share the same name...
Would be cool to get rid of this issue one day, but for now it's safer to use rna acessor...

This commit is to be backported to 2.70.
2014-03-13 17:37:19 +01:00
Campbell Barton
18f6bb04fa Fix for custom property editor when property id's contained quotes
Adds bpy.utils.escape_identifier()
2014-02-25 16:19:57 +11:00
Campbell Barton
dea4bcdf67 PyAPI: bpy.ops was showing 'module' in autocomplete output 2014-02-19 13:41:41 +11:00
Campbell Barton
2a9e33fba5 Keymap: load/save improvements
- avoid passing redundant operator name to keymap property set function.
- avoid double attr lookups when setting each property.
- handle exceptions on value type mismatch.
- avoid resource warning on failed load.
2014-02-19 10:32:23 +11:00
Campbell Barton
1ea47c9af9 Code Cleanup: style, spelling and pep8 edits 2013-11-20 03:40:10 +11:00
Campbell Barton
ecf2eeef23 style cleanup 2013-10-16 04:08:20 +00:00
Campbell Barton
b20c3f97a4 rename presets not to use '+' character, also some typo fixes. 2013-10-05 14:19:39 +00:00
Campbell Barton
b6631b8be7 fixes for python api docs.
also move foreach_get/set examples into their own py example files (prefer not to have example code built into blenders binary).
2013-09-18 05:20:43 +00:00
Campbell Barton
4fbe426151 bpy.path.reduce_dirs() - new utility function to de-duplicate and remove nested paths before doing a recursive search. 2013-08-12 07:44:38 +00:00
Campbell Barton
2085a42e52 pep8 cleanup 2013-06-27 03:05:19 +00:00
Campbell Barton
c8f30bc7f0 fix [#35574] Export Key Map issue
problem was the keymap failed to import but didnt give any feedback, now it displays error message.
2013-06-11 15:11:55 +00:00
Campbell Barton
63d523336f freestyle lineset tag attribute was defined but not used, also some code cleanup. 2013-04-07 01:38:03 +00:00
Campbell Barton
98752a1f30 py api additions needed for fixing [#34864].
- add rna property 'as_bytes' method so you can get a string property as python bytes (bypass encoding).
- make bpy.path.abspath/relpath compatible with bytes.
- add 'relpath' option to bpy_extras.image_utils.load_image(), so you can load an image relative to a path.
2013-04-05 00:30:32 +00:00
Bastien Montagne
2c348d003e Big i18n tools update, I/II.
Notes:
* Everything is still a bit raw and sometimes hackish.
* Not every feature implemented yet.
* A bunch of cleanup is still needed.
* Doc needs to be updated too!
2013-02-24 08:50:55 +00:00
Campbell Barton
3b8a0f3d67 use import rather then assignment for loading '_' into scripts. 2013-02-10 09:56:05 +00:00
Campbell Barton
97d62f0183 style cleanup 2013-01-15 23:15:32 +00:00
Campbell Barton
9dbe85c17e expose common extensions for image/movie/audio types, since python scripts had to do this internally.
- bpy.path.extensions_image
- bpy.path.extensions_movie
- bpy.path.extensions_audio

eg:

  if os.path.splitext(filename)[1].lower() in bpy.path.extensions_image:
      ... we have an image ...
2013-01-04 03:47:37 +00:00
Campbell Barton
423994bf39 py api: add restrict state context manager (thats python's context not blenders context),
which restricts bpy.context and bpy.data.

enable this for loading scripts in 'startup' too.
2012-12-20 03:56:22 +00:00
Campbell Barton
ef665b3d18 dissallow access to the context while addons import and register.
Since the window manager is needed for keymaps this is kept as an exception.

some addons will need updating, but in every case I've seen addons should not be accessing the context while registering.
(bad stuff! - declaring the scene as a global variable - which crashes when the users loads a new file, manipulating the active object or scene... tsk tsk)
2012-12-19 07:27:23 +00:00
Campbell Barton
7c2e4e28ba bpy.ops module/caller classes incorrectly had __keys__ rather then __slots__.
also added comments about texface drawing when theres no origindex.
2012-12-06 03:09:06 +00:00
Campbell Barton
7c3db355b1 remove ifdef'd bevel code, current bevel works better then the previous code.
reduce strlen check in texttool_suggest_add()
use 'del list[:]' rather then 'list[:] = []' in python scripts which clear lists.
2012-11-14 09:45:15 +00:00
Campbell Barton
9fa36b12cc style cleanup: pep8 2012-10-08 08:28:05 +00:00
Campbell Barton
8a51d235e6 pep8 cleanup 2012-09-26 21:19:51 +00:00
Campbell Barton
6b1582c012 better handle sizes by default for mask mode, now ignore image width/height 2012-08-25 14:18:54 +00:00
Campbell Barton
a7ec09aef9 ability to register your own online manual callbacks - useful for 3rd party addon developers, who may want to link to their own URL's. 2012-08-25 14:07:51 +00:00