MCPcopy
hub / github.com/waditu/tushare / skipuntil

Method skipuntil

tushare/util/demjson.py:1718–1739  ·  view source on GitHub ↗

Advances the current position until a given predicate test function succeeds, or the end of the document is reached. Returns the actual number of characters skipped. The provided test function should take a single unicode character and return a boolean value, such a

( self, testfn )

Source from the content-addressed store, hash-verified

1716 return self.cpos - i
1717
1718 def skipuntil( self, testfn ):
1719 """Advances the current position until a given predicate test
1720 function succeeds, or the end of the document is reached.
1721
1722 Returns the actual number of characters skipped.
1723
1724 The provided test function should take a single unicode
1725 character and return a boolean value, such as:
1726
1727 lambda c : c == '.' # Skip to next period
1728
1729 See also methods: skipwhile() and popuntil()
1730
1731 """
1732 i = self.cpos
1733 while True:
1734 c = self.peek()
1735 if not c or testfn(c):
1736 break
1737 else:
1738 self.__pos.advance(c)
1739 return self.cpos - i
1740
1741 def skipwhile( self, testfn ):
1742 """Advances the current position until a given predicate test

Callers 2

skipwhileMethod · 0.95
recover_parserMethod · 0.80

Calls 2

peekMethod · 0.95
advanceMethod · 0.80

Tested by

no test coverage detected