Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more methods #8

Merged
merged 3 commits into from Feb 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions ansi_str.py
Expand Up @@ -32,6 +32,27 @@ def __len__(self, exclude_ansi=True):
return len(self[:])
return len(self.stripped)

def ljust(self, width):
return self.stripped.ljust(width).replace(self.stripped, self)

def rjust(self, width):
return self.stripped.rjust(width).replace(self.stripped, self)

def center(self, width):
return self.stripped.center(width).replace(self.stripped, self)

def lstrip(self):
return ansi_str(super(ansi_str, self).lstrip())

def rstrip(self):
return ansi_str(super(ansi_str, self).rstrip())

def strip(self):
return ansi_str(super(ansi_str, self).strip())

def splitlines(self):
return [ansi_str(s) for s in super(ansi_str, self).splitlines()]


if __name__ == '__main__':
# s = ansi_str('abc')
Expand Down