Skip to content

Commit

Permalink
Added shortcuts to urlparse
Browse files Browse the repository at this point in the history
  • Loading branch information
dhondta committed Dec 29, 2020
1 parent 7fcfbdf commit d46f48d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ It also provides some other utility functions:
`ts.Timeout` | context manager for applying a timeout to a code block
`ts.TimeoutError` | custom exception for handling a timeout (as it is natively available in Python 3 but not in Python 2)
`ts.unpad` | String unpadding function (complementary of `ts.pad`)
`ts.urlparse` | Python2/3-compatible shortcut to `urlparse` (from module `urlparse` in Python 2 and `urllib` in Python 3)
`ts.urlparse_query` | Python2/3-compatible shortcut to `parse_qs` (from module `urlparse` in Python 2 and `urllib` in Python 3)
`ts.xor` | repeated XOR function, also allowing to apply an ordinal offset on XORed characters
`ts.xor_file` | XOR a file with a given key

Expand Down
7 changes: 6 additions & 1 deletion tinyscript/helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import os
from itertools import cycle
from string import printable
try: # Python 2
from urlparse import urlparse, parse_qs as urlparse_query
except ImportError: # Python 3
from urllib.parse import urlparse, parse_qs as urlparse_query

from .compat import b
from .constants import PYTHON3, WINDOWS


__all__ = __features__ = ["human_readable_size", "is_admin", "strings", "strings_from_file", "xor", "xor_file"]
__all__ = __features__ = ["human_readable_size", "is_admin", "strings", "strings_from_file", "urlparse",
"urlparse_query", "xor", "xor_file"]


def human_readable_size(size, precision=0):
Expand Down

0 comments on commit d46f48d

Please sign in to comment.