This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from seatgeek/pr/20
Pull Request #20 Augmented With force_ascii parameter
- Loading branch information
Showing
6 changed files
with
234 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import re | ||
import string | ||
import unicodedata | ||
|
||
class StringProcessor(object): | ||
""" | ||
This class defines method to process strings in the most | ||
efficient way. Ideally all the methods below use unicode strings | ||
for both input and output. | ||
""" | ||
|
||
@classmethod | ||
def replace_non_lettters_non_numbers_with_whitespace(cls, a_string): | ||
""" | ||
This function replaces any sequence of non letters and non numbers with a single white space. | ||
""" | ||
regex = re.compile(r"(?ui)[\W]+") | ||
return regex.sub(u" ", a_string) | ||
|
||
@classmethod | ||
def strip(cls, a_string): | ||
""" | ||
This function strips leading and trailing white space. | ||
""" | ||
|
||
return a_string.strip() | ||
|
||
@classmethod | ||
def to_lower_case(cls, a_string): | ||
""" | ||
This function returns the lower-cased version of the string given. | ||
""" | ||
return a_string.lower() | ||
|
||
@classmethod | ||
def to_upper_case(cls, a_string): | ||
""" | ||
This function returns the upper-cased version of the string given. | ||
""" | ||
return a_string.upper() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.