PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/stubs/re.py

https://github.com/SRiikonen/mypy-py
Python | 85 lines | 55 code | 14 blank | 16 comment | 2 complexity | 43546a0ee961f6ecda4b4be5365f1cdf MD5 | raw file
Possible License(s): MIT
  1. # Stubs for re
  2. # Ron Murawski <ron@horizonchess.com>
  3. # based on: http://docs.python.org/3.2/library/re.html
  4. # and http://hg.python.org/cpython/file/618ea5612e83/Lib/re.py
  5. # ----- re variables and constants -----
  6. int A
  7. int ASCII
  8. int DEBUG
  9. int I
  10. int IGNORECASE
  11. int L
  12. int LOCALE
  13. int M
  14. int MULTILINE
  15. int S
  16. int DOTALL
  17. int X
  18. int VERBOSE
  19. class error(Exception): pass
  20. # TODO functions and classes that work on bytes objects
  21. # ----- re classes -----
  22. class Pattern:
  23. int flags, groupindex, groups
  24. str pattern
  25. Match search(self, str string, int pos=0, int endpos=-1): pass
  26. Match match(self, str string, int pos=0, int endpos=-1): pass
  27. list<str> split(self, str string, int maxsplit=0): pass
  28. list<str> findall(self, str string, int pos=0, int endpos=-1): pass
  29. Iterator<Match> finditer(self, str string, int pos=0, int endpos=-1): pass
  30. str sub(self, str repl, str string, int count=0): pass
  31. str sub(self, func<str(Match)> repl, str string, int count=0): pass
  32. tuple<str, int> subn(self, str repl, str string, int count=0): pass
  33. tuple<str, int> subn(self, func<str(Match)> repl, str string,
  34. int count=0): pass
  35. class Match:
  36. int pos, endpos, lastindex
  37. str lastgroup, string
  38. # The regular expression object whose match() or search() method produced
  39. # this match instance.
  40. Pattern re
  41. str expand(self, str template): pass
  42. str group(self): pass
  43. str group(self, int group1): pass
  44. # TODO group(...) with multiple groups
  45. # if there are multiple arguments, the result is a tuple with one item per
  46. # argument
  47. list<str> group(self, list<int> group1): pass # not quite correct! ???
  48. tuple<str, str> groups(self, str default=None): pass
  49. dict<str, str> groupdict(self, str default=None): pass
  50. int start(self, int group=0): pass
  51. int end(self, int group=0): pass
  52. tuple<int, int> span(self, int group=0): pass
  53. Pattern compile(str pattern, int flags=0): pass
  54. Match search(str pattern, str string, int flags=0): pass
  55. Match match(str pattern, str string, int flags=0): pass
  56. list<str> split(str pattern, str string, int maxsplit=0, int flags=0): pass
  57. list<str> findall(str pattern, str string, int flags=0): pass
  58. # Return an iterator yielding match objects over all non-overlapping matches
  59. # for the RE pattern in string. The string is scanned left-to-right, and
  60. # matches are returned in the order found. Empty matches are included in the
  61. # result unless they touch the beginning of another match.
  62. Iterator<Match> finditer(str pattern, str string, int flags=0): pass
  63. str sub(str pattern, str repl, str string, int count=0, int flags=0): pass
  64. str sub(str pattern, func<str(Match)> repl, str string, int count=0,
  65. int flags=0): pass
  66. tuple<str, int> subn(str pattern, str repl, str string, int count=0,
  67. int flags=0): pass
  68. tuple<str, int> subn(str pattern, func<str(Match)> repl, str string,
  69. int count=0, int flags=0): pass
  70. str escape(str string): pass
  71. void purge(): pass