PK!ík@4÷÷cleanser/__init__.py"""Cleanser""" from cleanser.core.generic import Generic from cleanser.core.reddit import Reddit class Cleanser(Generic, Reddit): """Class does stuff""" def __init__(self, text: str): super().__init__() self.text = text PK!Ýh'**cleanser/core/__init__.py"""Common functions and classes for all core classes.""" class Base: """Base class for all cleansers""" def __init__(self): self._text = None @property def text(self): """Property for text that is being cleansed""" return self._text @text.setter def text(self, value: str): """Property setter for text that is being cleansed""" self._text = value def __repr__(self): return f"{self.__class__.__name__}({self.text!r})" def __str__(self): return f"{self.text}" PK!ÿíbè\\cleanser/core/generic.py"""Common generic methods for cleaning text.""" import re from cleanser.core import Base RE_WHITESPACE = re.compile(r"\s+") RE_EMOJI = re.compile(r"[\U00010000-\U0010ffff]", flags=re.UNICODE) URL_REGEX = re.compile( r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+" ) class Generic(Base): """Common generic methods for cleaning text.""" def whitespaces(self): """Removes extra spaces, tabs, and newlines from text.""" self.text = RE_WHITESPACE.sub(" ", self.text).strip() return self def emojis(self): """Removes emojis from text.""" self.text = RE_EMOJI.sub("", self.text) return self def urls(self): """Removes urls from text.""" self.text = URL_REGEX.sub("", self.text) return self def char(self, char: str): """Removes all occurences of char from text.""" if len(char) > 1: raise ValueError("char parameter can only be 1 character") self.text = self.text.replace(char, "") return self def double_punctuation(self): """Removes occurences of double punctuation with single instance of char""" punctuation = ".,?!:;*" for punc in punctuation: pattern = "\\" + punc + "{2,}" self.text = re.sub(pattern, punc, self.text) return self PK!K¶q//cleanser/core/reddit.py"""Utilities specifically for cleaning text from Reddit.""" import re from cleanser.core import Base REDDIT_MENTIONS = re.compile(r"/?u/\S+") REDDIT_SUBREDDITS = re.compile(r"/?r/\S+") REDDIT_QUOTES = re.compile(r"^\>.*$", flags=re.MULTILINE) REDDIT_BOLD_ITALICS = re.compile(r"\*+") REDDIT_CODE = re.compile(r"\`") REDDIT_SUPERSCRIPT = re.compile(r"\^") REDDIT_HEADERS = re.compile(r"\#+") REDDIT_STRIKETHROUGH = re.compile(r"~{2}.*~{2}") REDDIT_SPOILERS = re.compile(r">!|!<") # REDDIT_LINKS = re.compile(r"\[.*\]\(.*\)") class Reddit(Base): """Common methods for cleaning text from Reddit.""" def reddit_mentions(self): """Removes reddit user mentions from text.""" self.text = REDDIT_MENTIONS.sub("", self.text) return self def reddit_subreddits(self): """Removes reddit subreddit mentions from text.""" self.text = REDDIT_SUBREDDITS.sub("", self.text) return self def reddit_quotes(self): """Removes reddit quotes from text.""" self.text = REDDIT_QUOTES.sub("", self.text) return self def reddit_bold_italics(self): """Removes reddit bolding and italics from text.""" self.text = REDDIT_BOLD_ITALICS.sub("", self.text) return self def reddit_code(self): """Removes reddit code formatting from text.""" self.text = REDDIT_CODE.sub("", self.text) return self def reddit_superscript(self): """Removes reddit superscript formatting from text.""" self.text = REDDIT_SUPERSCRIPT.sub("", self.text) return self def reddit_headers(self): """Removes reddit header formatting from text.""" self.text = REDDIT_HEADERS.sub("", self.text) return self def reddit_strikethrough(self): """Removes reddit strikethrough formatted text.""" self.text = REDDIT_STRIKETHROUGH.sub("", self.text) return self def reddit_spoilers(self): """Removes reddit spoiler formatting from text.""" self.text = REDDIT_SPOILERS.sub("", self.text) return self PK!áDÞ33 cleanser-0.2.0.dist-info/LICENSEMIT License Copyright (c) 2019 Michael Holtzscher Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H€ÌÚ½TUcleanser-0.2.0.dist-info/WHEEL ÊA € н§ð#Z;/í"¢ÖŸd&F[xûzëwÜ@¡Z³p´Áy3¡©‰Fûšvë]\fi4WZ^EÉg´M_˜-]ÿì#±0(q7PK!H^ó¹P!cleanser-0.2.0.dist-info/METADATA•’Oo1ÅïþF•HÙÝ’VE²¥„C#R¨’À¥Bh²;Ù5øÏâ·,Ÿ»iRróî¼ù½?_!C Åg ¤½Sr\¾À¢’µAp„AìkÇå¸<Ëh-„AÉ•÷†äƇ­T»V2þäR\z‹Em‚tÌ=©ªj5wq]ÖÞV¶ó†QÝa¨ös]c:(y5[‰÷8ÜùÐÐn†Då)ÅEä·$ÒuhäåžôP*Ђ6Jn=ÞôÁ³wùWv üu@*®‡$N ½žœ”g£W§i«©"½Ñ˜ðÃH¥äÇåL^ô‰s‹MþNãíʵ\ß°6_Â\ÓöY¿uʧ“CõåÙÁ/ER}Ú‹O‹¹’ ì=iöaýwïê {NSï«¡OÉäl«”ü÷Æß9!ŽÈÍ“›·Q›F.8Ò—g;³?Ê[M ql´¿·ßµW_¡×T­3¡¢{¾VLgçë®îò›œX Æðü`ƒ-Û#ñyƒít^pÖLÆOÿÅ ñPK!HOØŠ°ƒgcleanser-0.2.0.dist-info/RECORD}ÎÉr¢@Ð{¾ k€ÃP6A@Y¼t‘¦Ñ–­!¯Ÿ¹8•JÍä^=X£¼Ñð nñ€ Y©ñ–sâÛ¯Ñ1\Ri1+T_—uN‹¥1dÈyl·ÚrÈXÎ’oÝ»óAq‚ôŸìô/0_L¹òì’òÄŸ—ͤFiÊ$AàÓžΚ`g2%ŠÂ7ðŠZ4`øÅ‹À§Zð§Û yy”Æ0nøCQFrvœ‚0fÙÚÞÆ#Åò÷ PQàÇfp"½t6t|½°p2•ÙQ°Üe´¸ ‘Hã܆ï6£–âEüëÑ̆Û0›·e÷êZšáEƾ“}j¦u3WŸ ‰sLEäì“á¿«EjIÌr»ÓäO”‘~€Ó0Ü';_”Éï“OÅkpÝYs:h<À:×›1õ%Z•¥ç–Š’@ÆIÕÕ“útIÕÚ!`H 4¹kÁÞ[Ëßäœ3 ¥Ý9ªårû–LéîLI û844?Ô)êå7PK!ík@4÷÷¤cleanser/__init__.pyPK!Ýh'**¤)cleanser/core/__init__.pyPK!ÿíbè\\¤Šcleanser/core/generic.pyPK!K¶q//¤ cleanser/core/reddit.pyPK!áDÞ33 ¤€cleanser-0.2.0.dist-info/LICENSEPK!H€ÌÚ½TU€ñcleanser-0.2.0.dist-info/WHEELPK!H^ó¹P!€cleanser-0.2.0.dist-info/METADATAPK!HOØŠ°ƒg€Mcleanser-0.2.0.dist-info/RECORDPKJ