Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-dev-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-dev-tools
Commits
2afbb8ec
Commit
2afbb8ec
authored
6 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
blender_theme_as_c: support DNA member renaming
parent
3ee979c1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/blender_theme_as_c.py
+44
-4
44 additions, 4 deletions
utils/blender_theme_as_c.py
with
44 additions
and
4 deletions
utils/blender_theme_as_c.py
+
44
−
4
View file @
2afbb8ec
...
...
@@ -188,18 +188,56 @@ sys.path.append(os.path.join(
"
..
"
,
"
..
"
,
"
..
"
,
"
release
"
,
"
scripts
"
,
"
addons
"
,
"
io_blend_utils
"
,
"
blend
"
,
))
del
sys
source_dst
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
..
"
,
"
..
"
,
"
..
"
,
"
release
"
,
"
datafiles
"
,
"
userdef
"
,
"
userdef_default_theme.c
"
)
del
sys
dna_rename_defs_h
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
..
"
,
"
..
"
,
"
..
"
,
"
source
"
,
"
blender
"
,
"
makesdna
"
,
"
intern
"
,
"
dna_rename_defs.h
"
)
def
dna_rename_defs
(
blend
):
"""
"""
from
blendfile
import
DNAName
import
re
re_dna_struct_rename_elem
=
re
.
compile
(
r
'
DNA_STRUCT_RENAME_ELEM+\(
'
r
'
([a-zA-Z0-9_]+)
'
'
,\s*
'
r
'
([a-zA-Z0-9_]+)
'
'
,\s*
'
r
'
([a-zA-Z0-9_]+)
'
'
\)
'
,
)
with
open
(
dna_rename_defs_h
,
'
r
'
,
encoding
=
'
utf-8
'
)
as
fh
:
data
=
fh
.
read
()
for
l
in
data
.
split
(
'
\n
'
):
m
=
re_dna_struct_rename_elem
.
match
(
l
)
if
m
is
not
None
:
struct_name
,
member_storage
,
member_runtime
=
m
.
groups
()
struct_name
=
struct_name
.
encode
(
'
utf-8
'
)
member_storage
=
member_storage
.
encode
(
'
utf-8
'
)
member_runtime
=
member_runtime
.
encode
(
'
utf-8
'
)
dna_struct
=
blend
.
structs
[
blend
.
sdna_index_from_id
[
struct_name
]]
for
field
in
dna_struct
.
fields
:
dna_name
=
field
.
dna_name
if
member_storage
==
dna_name
.
name_only
:
field
.
dna_name
=
dna_name
=
DNAName
(
dna_name
.
name_full
)
del
dna_struct
.
field_from_name
[
dna_name
.
name_only
]
dna_name
.
name_full
=
dna_name
.
name_full
.
replace
(
member_storage
,
member_runtime
)
dna_name
.
name_only
=
member_runtime
dna_struct
.
field_from_name
[
dna_name
.
name_only
]
=
field
def
theme_data
(
userpref_filename
):
import
blendfile
blend
=
blendfile
.
open_blend
(
userpref_filename
)
dna_rename_defs
(
blend
)
u
=
next
((
c
for
c
in
blend
.
blocks
if
c
.
code
==
b
'
USER
'
),
None
)
# theme_type = b.sdna_index_from_id[b'bTheme']
t
=
u
.
get_pointer
((
b
'
themes
'
,
b
'
first
'
))
...
...
@@ -208,9 +246,7 @@ def theme_data(userpref_filename):
def
is_ignore_dna_name
(
name
):
if
name
.
startswith
(
b
'
_
'
)
or
name
==
b
'
pad
'
:
return
True
elif
name
.
startswith
(
b
'
pad
'
)
and
name
[
3
:].
isdigit
():
if
name
.
startswith
(
b
'
_
'
):
return
True
elif
name
in
{
b
'
active_theme_area
'
,
...
...
@@ -322,6 +358,10 @@ def file_remove_empty_braces(source_dst):
r
'
\s+\.[a-zA-Z_0-9]+\s+=\s+\{\s*\},
'
,
key_replace
,
data
,
re
.
MULTILINE
)
# Use two spaces instead of tabs.
data
=
data
.
replace
(
'
\t
'
,
'
'
)
with
open
(
source_dst
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
fh
:
fh
.
write
(
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment