def _extract_progress(self, text): ''' Finds progress information in the text using the user-supplied regex and calculation instructions ''' # monad-ish dispatch to avoid the if/else soup find = partial(re.search, string=text.strip().decode(self.encoding)) regex = unit(self.progress_regex) match = bind(regex, find) result = bind(match, self._calculate_progress) return result