def apply(self): # move doctest blocks out of blockquotes for node in self.document.traverse(nodes.block_quote): if all( isinstance(child, nodes.doctest_block) for child in node.children): node.replace_self(node.children)
def get_ratio(old, new): """Return a "similiarity ratio" (in percent) representing the similarity between the two strings where 0 is equal and anything above less than equal. """ if not all([old, new]): return VERSIONING_RATIO return levenshtein_distance(old, new) / (len(old) / 100.0)
def test_picklablility(): # we have to modify the doctree so we can pickle it copy = original.copy() copy.reporter = None copy.transformer = None copy.settings.warning_stream = None copy.settings.env = None copy.settings.record_dependencies = None for metanode in copy.traverse(MetaBody.meta): metanode.__class__ = addnodes.meta loaded = pickle.loads(pickle.dumps(copy, pickle.HIGHEST_PROTOCOL)) assert all(getattr(n, 'uid', False) for n in loaded.traverse(is_paragraph))
def apply(self): # move doctest blocks out of blockquotes for node in self.document.traverse(nodes.block_quote): if all(isinstance(child, nodes.doctest_block) for child in node.children): node.replace_self(node.children)