MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / _replace_common_substr

Method _replace_common_substr

site-packages/matplotlib/dates.py:616–639  ·  view source on GitHub ↗

Helper function for replacing substrings sub1 and sub2 located at the same indexes in strings s1 and s2 respectively, with the string replacement. It is expected that sub1 and sub2 have the same length. Returns the pair s1, s2 after the substitutions.

(self, s1, s2, sub1, sub2, replacement)

Source from the content-addressed store, hash-verified

614
615 @cbook.deprecated("3.0")
616 def _replace_common_substr(self, s1, s2, sub1, sub2, replacement):
617 """Helper function for replacing substrings sub1 and sub2
618 located at the same indexes in strings s1 and s2 respectively,
619 with the string replacement. It is expected that sub1 and sub2
620 have the same length. Returns the pair s1, s2 after the
621 substitutions.
622 """
623 # Find common indexes of substrings sub1 in s1 and sub2 in s2
624 # and make substitutions inplace. Because this is inplace,
625 # it is okay if len(replacement) != len(sub1), len(sub2).
626 i = 0
627 while True:
628 j = s1.find(sub1, i)
629 if j == -1:
630 break
631
632 i = j + 1
633 if s2[j:j + len(sub2)] != sub2:
634 continue
635
636 s1 = s1[:j] + replacement + s1[j + len(sub1):]
637 s2 = s2[:j] + replacement + s2[j + len(sub2):]
638
639 return s1, s2
640
641 @cbook.deprecated("3.0")
642 def strftime_pre_1900(self, dt, fmt=None):

Callers 1

strftime_pre_1900Method · 0.95

Calls 1

findMethod · 0.45

Tested by

no test coverage detected