Skip to content

Deprecate: Item object #33

@uncojohnco

Description

@uncojohnco

Item object was originally implemented to resolve the characters representing the frame in a str via doing a comparisons str_parts and str_digits.

This behaviour has been superseded and exists in lss.util::find_matching_frame_substrings

class Item:
"""
A primitive class for defining an abstract representation of an item.
The purpose to be used to find the substring representing
a frame against another item.
Examples:
>>> item = Item('mario01_v003.rgb')
>>> item.name
'mario01_v003.rgb'
>>> item.str_parts
['mario', '_v', '.rgb']
>>> item.str_digits
['01', '003']
"""

def find_matching_frame_substrings(
str1: str, str2: str,
strict=True) -> Optional[SubstrMatch]:
"""
Diff between str1 and str2 to to resolve the frame representation
of each string.
Examples:
>>> find_matching_frame_substrings('file01_0040.rgb', 'file01_0041.rgb')
SubstrMatch(pos=SubstrPos(start=7, end=11), groups=('0040', '0041'))
>>> find_matching_frame_substrings('file1.03.rgb', 'file2.03.rgb')
SubstrMatch(pos=SubstrPos(start=4, end=5), groups=('1', '2'))
>>> bool(find_matching_frame_substrings('file02_0040.rgb', 'file01_0041.rgb'))
False
:param str1: The string object for comparison against.
:param str2: The string to compare to the object string.
:param strict: If True, the length of the digit padding
must be the same when comparing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions