Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
| Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | def class_blacklist(): | ||||
| #~ if prop.type == 'COLLECTION': | #~ if prop.type == 'COLLECTION': | ||||
| #~ prop_cls = prop.srna | #~ prop_cls = prop.srna | ||||
| #~ if prop_cls is not None: | #~ if prop_cls is not None: | ||||
| #~ blacklist_rna_class.add(prop_cls.__class__) | #~ blacklist_rna_class.add(prop_cls.__class__) | ||||
| # Now here is the *ugly* hack! | # Now here is the *ugly* hack! | ||||
| # Unfortunately, all classes we want to access are not available from bpy.types (OperatorProperties subclasses | # Unfortunately, all classes we want to access are not available from bpy.types (OperatorProperties subclasses | ||||
| # are not here, as they have the same name as matching Operator ones :( ). So we use __subclasses__() calls | # are not here, as they have the same name as matching Operator ones :( ). So we use __subclasses__() calls | ||||
| # to walk through all rna hierachy. | # to walk through all rna hierarchy. | ||||
| # But unregistered classes remain listed by relevant __subclasses__() calls (be it a Py or BPY/RNA bug), | # But unregistered classes remain listed by relevant __subclasses__() calls (be it a Py or BPY/RNA bug), | ||||
| # and obviously the matching RNA struct exists no more, so trying to access their data (even the identifier) | # and obviously the matching RNA struct exists no more, so trying to access their data (even the identifier) | ||||
| # quickly leads to segfault! | # quickly leads to segfault! | ||||
| # To address this, we have to blacklist classes which __name__ does not match any __name__ from bpy.types | # To address this, we have to blacklist classes which __name__ does not match any __name__ from bpy.types | ||||
| # (we can't use only RNA identifiers, as some py-defined classes has a different name that rna id, | # (we can't use only RNA identifiers, as some py-defined classes has a different name that rna id, | ||||
| # and we can't use class object themselves, because OperatorProperties subclasses are not in bpy.types!)... | # and we can't use class object themselves, because OperatorProperties subclasses are not in bpy.types!)... | ||||
| _rna_clss_ids = {cls.__name__ for cls in _rna} | {cls.bl_rna.identifier for cls in _rna} | _rna_clss_ids = {cls.__name__ for cls in _rna} | {cls.bl_rna.identifier for cls in _rna} | ||||
| ▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | def extract_strings(node): | ||||
| estr_ls.append(estr) | estr_ls.append(estr) | ||||
| nds_ls.extend(nds) | nds_ls.extend(nds) | ||||
| ret = _extract_string_merge(estr_ls, nds_ls) | ret = _extract_string_merge(estr_ls, nds_ls) | ||||
| return ret | return ret | ||||
| def extract_strings_split(node): | def extract_strings_split(node): | ||||
| """ | """ | ||||
| Returns a list args as returned by 'extract_strings()', but split into groups based on separate_nodes, this way | Returns a list args as returned by 'extract_strings()', but split into groups based on separate_nodes, this way | ||||
| expressions like ("A" if test else "B") wont be merged but "A" + "B" will. | expressions like ("A" if test else "B") won't be merged but "A" + "B" will. | ||||
| """ | """ | ||||
| estr_ls = [] | estr_ls = [] | ||||
| nds_ls = [] | nds_ls = [] | ||||
| bag = [] | bag = [] | ||||
| for is_split, estr, nds in extract_strings_ex(node): | for is_split, estr, nds in extract_strings_ex(node): | ||||
| if is_split: | if is_split: | ||||
| bag.append((estr_ls, nds_ls)) | bag.append((estr_ls, nds_ls)) | ||||
| estr_ls = [] | estr_ls = [] | ||||
| ▲ Show 20 Lines • Show All 491 Lines • Show Last 20 Lines | |||||