clique.DIGITS_PATTERN = '(?P<index>(?P<padding>0*)\\d+)'

Pattern for matching an index with optional padding.

clique.PATTERNS = {'frames': '\\.(?P<index>(?P<padding>0*)\\d+)\\.\\D+\\d?$', 'versions': 'v(?P<index>(?P<padding>0*)\\d+)'}

Common patterns that can be passed to assemble().

clique.assemble(iterable, patterns=None, minimum_items=2, case_sensitive=True)[source]

Assemble items in iterable into discreet collections.

patterns may be specified as a list of regular expressions to limit the returned collection possibilities. Use this when interested in collections that only match specific patterns. Each pattern must contain the expression from DIGITS_PATTERN exactly once.

A selection of common expressions are available in PATTERNS.


If a pattern is supplied as a string it will be automatically compiled to a re.RegexObject instance for convenience.

When patterns is not specified, collections are formed by examining all possible groupings of the items in iterable based around common numerical components.

minimum_items dictates the minimum number of items a collection must have in order to be included in the result. The default is 2, filtering out single item collections.

If case_sensitive is False, then items will be treated as part of the same collection when they only differ in casing. To avoid ambiguity, the resulting collection will always be lowercase. For example, “item.0001.dpx” and “Item.0002.dpx” would be part of the same collection, “item.%04d.dpx”.


Any compiled patterns will also respect the set case sensitivity.

Return tuple of two lists (collections, remainder) where ‘collections’ is a list of assembled Collection instances and ‘remainder’ is a list of items that did not belong to any collection.

clique.parse(value, pattern='{head}{padding}{tail} [{ranges}]')[source]

Parse value into a Collection.

Use pattern to extract information from value. It may make use of the following keys:

  • head - Common leading part of the collection.
  • tail - Common trailing part of the collection.
  • padding - Padding value in %0d format.
  • range - Total range in the form start-end.
  • ranges - Comma separated ranges of indexes.
  • holes - Comma separated ranges of missing indexes.


holes only makes sense if range or ranges is also present.