(s)
| 281 | |
| 282 | # _delete_nonalpha = str.maketrans('', '', _nonalpha) |
| 283 | def sanitize_string(s): |
| 284 | # Translate non-ASCII character codes. |
| 285 | s = s.strip().encode('ascii', errors='ignore').decode() |
| 286 | if re.search(r'([0-9\.]*):([0-9]*)->([0-9\.]*):([0-9]*)',s): |
| 287 | # s = s.replace('/32','') |
| 288 | split_path = re.split('/|\.|,|:|-|>',s) |
| 289 | split_path = [item for item in filter(lambda x:x != '',split_path)] |
| 290 | split_path.pop(4) |
| 291 | split_path.pop(8) |
| 292 | return split_path |
| 293 | # Lower-case the string & strip non-alpha. |
| 294 | for i in s: |
| 295 | if i in string.punctuation: |
| 296 | s = s.replace(i," ") |
| 297 | |
| 298 | split_path = s.lower().split() |
| 299 | # split_path = [item for item in filter(lambda x:x != '',split_path)] |
| 300 | newline = [] |
| 301 | for item in split_path: |
| 302 | if len(item) < 2 or item.isdigit(): |
| 303 | continue |
| 304 | if len(item) <= 5 and len(item) >= 2: |
| 305 | newline.append(item) |
| 306 | else: |
| 307 | try: |
| 308 | if not nonsense(item): |
| 309 | newline.append(item) |
| 310 | else: |
| 311 | newline.append('hash') |
| 312 | except Exception as e: |
| 313 | print(s) |
| 314 | split_path = [item for item in filter(lambda x:x != '',newline)] |
| 315 | return split_path |
no outgoing calls
no test coverage detected