add cookie stuff

This commit is contained in:
simon 2019-12-17 09:55:41 -05:00
parent 3e477c9f98
commit e5b5fa9c25
3 changed files with 37 additions and 5 deletions

35
hexlib/web.py Normal file
View File

@ -0,0 +1,35 @@
from http.cookiejar import Cookie
from dateutil.parser import parse
def cookie_from_string(text: str, domain: str) -> Cookie:
tokens = [t.strip() for t in text.split(";")]
name, value = tokens[0].split("=")
path = None
expires = None
for tok in tokens[1:]:
name, value = tok.split("=")
if name == "path":
path = value
if name == "expires":
expires = parse(value).timestamp()
return Cookie(
version=None,
name=name, value=value,
port=None, port_specified=False,
domain=domain, domain_specified=True, domain_initial_dot=False,
path=path, path_specified=path is not None,
secure=False,
expires=expires,
discard=None,
comment=None,
comment_url=None,
rest=None,
rfc2109=False
)

View File

@ -1,3 +0,0 @@
ImageHash
influxdb
siphash

View File

@ -2,12 +2,12 @@ from setuptools import setup
setup(
name="hexlib",
version="1.1",
version="1.2",
description="Misc utility methods",
author="simon987",
author_email="me@simon987.net",
packages=["hexlib"],
install_requires=[
"ImageHash", "influxdb", "siphash"
"ImageHash", "influxdb", "siphash", "python-dateutil"
]
)