commit: 2cdf26dbb2bed60fd21194433fbc6dc314e03c96 Author: Florian Schmaus <flow <AT> gentoo <DOT> org> AuthorDate: Sun Jun 22 09:11:53 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Thu Sep 11 20:37:56 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2cdf26db
util/_urlopen: Mark timestamp_to_http and http_to_timestamp as public We will want to call http_to_timestamp from another module in a later commit. But mark both functions are public for symmetry. Signed-off-by: Florian Schmaus <flow <AT> gentoo.org> Part-of: https://github.com/gentoo/portage/pull/1447 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/portage/util/_urlopen.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/portage/util/_urlopen.py b/lib/portage/util/_urlopen.py index d451a94a89..1f27bbe76f 100644 --- a/lib/portage/util/_urlopen.py +++ b/lib/portage/util/_urlopen.py @@ -48,7 +48,7 @@ def urlopen(url, timeout=10, if_modified_since=None, headers={}, proxies=None): for key in headers: request.add_header(key, headers[key]) if if_modified_since: - request.add_header("If-Modified-Since", _timestamp_to_http(if_modified_since)) + request.add_header("If-Modified-Since", timestamp_to_http(if_modified_since)) if parse_result.username is not None: password_manager.add_password( None, url, parse_result.username, parse_result.password @@ -66,17 +66,17 @@ def urlopen(url, timeout=10, if_modified_since=None, headers={}, proxies=None): except AttributeError: # Python 2 add_header = hdl.headers.addheader - add_header("timestamp", _http_to_timestamp(hdl.headers.get("last-modified"))) + add_header("timestamp", http_to_timestamp(hdl.headers.get("last-modified"))) return hdl -def _timestamp_to_http(timestamp): +def timestamp_to_http(timestamp): dt = datetime.fromtimestamp(float(int(timestamp) + TIMESTAMP_TOLERANCE)) stamp = mktime(dt.timetuple()) return formatdate(timeval=stamp, localtime=False, usegmt=True) -def _http_to_timestamp(http_datetime_string): +def http_to_timestamp(http_datetime_string): timestamp = mktime(parsedate(http_datetime_string)) return str(int(timestamp))
