Path rewriting for sequences seems to be working too.

This commit is contained in:
Sybren A. Stüvel
2018-03-06 16:41:16 +01:00
parent 71dd5bc11b
commit e2123f8090
6 changed files with 56 additions and 34 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ def scene(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]
asset_path = bpathlib.BlendPath(dirname) / basename
is_sequence = seq_type not in single_asset_types
yield result.BlockUsage(seq, asset_path,
yield result.BlockUsage(seq_strip, asset_path,
is_sequence=is_sequence,
path_dir_field=dn_field,
path_base_field=bn_field)
+3 -5
View File
@@ -16,8 +16,8 @@ class DoesNotExist(OSError):
def expand_sequence(path: pathlib.Path) -> typing.Iterator[pathlib.Path]:
"""Expand a file sequence path into the actual file paths.
:param path: can be either a glob pattern (must contain a * character),
a directory, or the path of the first file in the sequence.
:param path: can be either a glob pattern (must contain a * character)
or the path of the first file in the sequence.
"""
if '*' in str(path): # assume it is a glob
@@ -31,9 +31,7 @@ def expand_sequence(path: pathlib.Path) -> typing.Iterator[pathlib.Path]:
raise DoesNotExist(path)
if path.is_dir():
log.debug('expanding directory %s', path)
yield from sorted(path.rglob('*'))
return
raise TypeError('path is a directory: %s' % path)
log.debug('expanding file sequence %s', path)
+9 -3
View File
@@ -16,8 +16,8 @@ class BlockUsage:
name of the block.
:ivar block:
:ivar asset_path: The path of the asset, if is_sequence=False. Otherwise
it can be either a glob pattern (must contain a * byte), a directory,
or the path of the first file in the sequence.
it can be either a glob pattern (must contain a * byte) or the path of
the first file in the sequence.
:ivar is_sequence: Indicates whether this file is alone (False), the
first of a sequence (True, and the path points to a file), or a
directory containing a sequence (True, and path points to a directory).
@@ -82,9 +82,15 @@ class BlockUsage:
return b'-unnamed-'
def __repr__(self):
if self.path_full_field is None:
field_name = self.path_dir_field.name.name_full.decode() + \
'/' + \
self.path_base_field.name.name_full.decode()
else:
field_name = self.path_full_field.name.name_full.decode()
return '<BlockUsage name=%r type=%r field=%r asset=%r%s>' % (
self.block_name, self.block.dna_type_name,
self.path_full_field.name.name_full.decode(), self.asset_path,
field_name, self.asset_path,
' sequence' if self.is_sequence else ''
)