Reduced cyclomatic complexity of BlockUsage.__init__()
This commit is contained in:
parent
a5bc52523d
commit
0d7bbb34f0
@ -34,13 +34,7 @@ class BlockUsage:
|
|||||||
if block_name:
|
if block_name:
|
||||||
self.block_name = block_name
|
self.block_name = block_name
|
||||||
else:
|
else:
|
||||||
try:
|
self.block_name = self.guess_block_name(block)
|
||||||
self.block_name = block[b'id', b'name']
|
|
||||||
except KeyError:
|
|
||||||
try:
|
|
||||||
self.block_name = block[b'name']
|
|
||||||
except KeyError:
|
|
||||||
self.block_name = b'-unnamed-'
|
|
||||||
|
|
||||||
assert isinstance(block, blendfile.BlendFileBlock)
|
assert isinstance(block, blendfile.BlendFileBlock)
|
||||||
assert isinstance(asset_path, (bytes, bpathlib.BlendPath)), \
|
assert isinstance(asset_path, (bytes, bpathlib.BlendPath)), \
|
||||||
@ -65,6 +59,18 @@ class BlockUsage:
|
|||||||
self.path_dir_field = path_dir_field
|
self.path_dir_field = path_dir_field
|
||||||
self.path_base_field = path_base_field
|
self.path_base_field = path_base_field
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def guess_block_name(block: blendfile.BlendFileBlock) -> bytes:
|
||||||
|
try:
|
||||||
|
return block[b'id', b'name']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
return block[b'name']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return b'-unnamed-'
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<BlockUsage name=%r type=%r field=%r asset=%r%s>' % (
|
return '<BlockUsage name=%r type=%r field=%r asset=%r%s>' % (
|
||||||
self.block_name, self.block.dna_type_name,
|
self.block_name, self.block.dna_type_name,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user