Browse Source

Fix StringMixIn's methods taking option arguments (thanks Sigma).

tags/v0.2
Ben Kurtovic 12 years ago
parent
commit
6881caf0bd
1 changed files with 33 additions and 7 deletions
  1. +33
    -7
      mwparserfromhell/string_mixin.py

+ 33
- 7
mwparserfromhell/string_mixin.py View File

@@ -125,19 +125,29 @@ class StringMixIn(object):


@inheritdoc @inheritdoc
def center(self, width, fillchar=None): def center(self, width, fillchar=None):
if fillchar is None:
return self.__unicode__().center(width)
return self.__unicode__().center(width, fillchar) return self.__unicode__().center(width, fillchar)


@inheritdoc @inheritdoc
def count(self, sub=None, start=None, end=None):
def count(self, sub, start=None, end=None):
return self.__unicode__().count(sub, start, end) return self.__unicode__().count(sub, start, end)


if not py3k: if not py3k:
@inheritdoc @inheritdoc
def decode(self, encoding=None, errors=None): def decode(self, encoding=None, errors=None):
if errors is None:
if encoding is None:
return self.__unicode__().decode()
return self.__unicode__().decode(encoding)
return self.__unicode__().decode(encoding, errors) return self.__unicode__().decode(encoding, errors)


@inheritdoc @inheritdoc
def encode(self, encoding=None, errors=None): def encode(self, encoding=None, errors=None):
if errors is None:
if encoding is None:
return self.__unicode__().encode()
return self.__unicode__().encode(encoding)
return self.__unicode__().encode(encoding, errors) return self.__unicode__().encode(encoding, errors)


@inheritdoc @inheritdoc
@@ -146,10 +156,12 @@ class StringMixIn(object):


@inheritdoc @inheritdoc
def expandtabs(self, tabsize=None): def expandtabs(self, tabsize=None):
if tabsize is None:
return self.__unicode__().expandtabs()
return self.__unicode__().expandtabs(tabsize) return self.__unicode__().expandtabs(tabsize)


@inheritdoc @inheritdoc
def find(self, sub=None, start=None, end=None):
def find(self, sub, start=None, end=None):
return self.__unicode__().find(sub, start, end) return self.__unicode__().find(sub, start, end)


@inheritdoc @inheritdoc
@@ -157,7 +169,7 @@ class StringMixIn(object):
return self.__unicode__().format(*args, **kwargs) return self.__unicode__().format(*args, **kwargs)


@inheritdoc @inheritdoc
def index(self, sub=None, start=None, end=None):
def index(self, sub, start=None, end=None):
return self.__unicode__().index(sub, start, end) return self.__unicode__().index(sub, start, end)


@inheritdoc @inheritdoc
@@ -202,6 +214,8 @@ class StringMixIn(object):


@inheritdoc @inheritdoc
def ljust(self, width, fillchar=None): def ljust(self, width, fillchar=None):
if fillchar is None:
return self.__unicode__().ljust(width)
return self.__unicode__().ljust(width, fillchar) return self.__unicode__().ljust(width, fillchar)


@inheritdoc @inheritdoc
@@ -221,15 +235,17 @@ class StringMixIn(object):
return self.__unicode__().replace(old, new, count) return self.__unicode__().replace(old, new, count)


@inheritdoc @inheritdoc
def rfind(self, sub=None, start=None, end=None):
def rfind(self, sub, start=None, end=None):
return self.__unicode__().rfind(sub, start, end) return self.__unicode__().rfind(sub, start, end)


@inheritdoc @inheritdoc
def rindex(self, sub=None, start=None, end=None):
def rindex(self, sub, start=None, end=None):
return self.__unicode__().rindex(sub, start, end) return self.__unicode__().rindex(sub, start, end)


@inheritdoc @inheritdoc
def rjust(self, width, fillchar=None): def rjust(self, width, fillchar=None):
if fillchar is None:
return self.__unicode__().rjust(width)
return self.__unicode__().rjust(width, fillchar) return self.__unicode__().rjust(width, fillchar)


@inheritdoc @inheritdoc
@@ -238,6 +254,10 @@ class StringMixIn(object):


@inheritdoc @inheritdoc
def rsplit(self, sep=None, maxsplit=None): def rsplit(self, sep=None, maxsplit=None):
if maxsplit is None:
if sep is None:
return self.__unicode__().rsplit()
return self.__unicode__().rsplit(sep)
return self.__unicode__().rsplit(sep, maxsplit) return self.__unicode__().rsplit(sep, maxsplit)


@inheritdoc @inheritdoc
@@ -246,10 +266,16 @@ class StringMixIn(object):


@inheritdoc @inheritdoc
def split(self, sep=None, maxsplit=None): def split(self, sep=None, maxsplit=None):
if maxsplit is None:
if sep is None:
return self.__unicode__().split()
return self.__unicode__().split(sep)
return self.__unicode__().split(sep, maxsplit) return self.__unicode__().split(sep, maxsplit)


@inheritdoc @inheritdoc
def splitlines(self, keepends=None): def splitlines(self, keepends=None):
if keepends is None:
return self.__unicode__().splitlines()
return self.__unicode__().splitlines(keepends) return self.__unicode__().splitlines(keepends)


@inheritdoc @inheritdoc
@@ -269,8 +295,8 @@ class StringMixIn(object):
return self.__unicode__().title() return self.__unicode__().title()


@inheritdoc @inheritdoc
def translate(self, table, deletechars=None):
return self.__unicode__().translate(table, deletechars)
def translate(self, table):
return self.__unicode__().translate(table)


@inheritdoc @inheritdoc
def upper(self): def upper(self):


Loading…
Cancel
Save