File tree 7 files changed +18
-16
lines changed
7 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 6
6
import json
7
7
import time
8
8
9
- import pyrfc3339
9
+ from backports . datetime_fromisoformat import datetime_fromisoformat
10
10
11
11
12
12
class GoCookieJar (cookiejar .FileCookieJar ):
@@ -52,7 +52,7 @@ def go_to_py_cookie(go_cookie):
52
52
"""Convert a Go-style JSON-unmarshaled cookie into a Python cookie"""
53
53
expires = None
54
54
if go_cookie .get ("Expires" ) is not None :
55
- t = pyrfc3339 . parse (go_cookie ["Expires" ])
55
+ t = datetime_fromisoformat (go_cookie ["Expires" ])
56
56
expires = t .timestamp ()
57
57
return cookiejar .Cookie (
58
58
version = 0 ,
@@ -101,8 +101,9 @@ def py_to_go_cookie(py_cookie):
101
101
if py_cookie .path_specified :
102
102
go_cookie ["Path" ] = py_cookie .path
103
103
if py_cookie .expires is not None :
104
- unix_time = datetime .datetime .fromtimestamp (py_cookie .expires )
105
104
# Note: fromtimestamp bizarrely produces a time without
106
105
# a time zone, so we need to use accept_naive.
107
- go_cookie ["Expires" ] = pyrfc3339 .generate (unix_time , accept_naive = True )
106
+ go_cookie ["Expires" ] = datetime .datetime .fromtimestamp (
107
+ py_cookie .expires
108
+ ).isoformat ()
108
109
return go_cookie
Original file line number Diff line number Diff line change 6
6
import logging
7
7
import typing
8
8
9
- import pyrfc3339
9
+ from backports . datetime_fromisoformat import datetime_fromisoformat
10
10
11
11
from juju .utils import block_until , juju_ssh_key_paths
12
12
@@ -239,7 +239,7 @@ def agent_status(self):
239
239
@property
240
240
def agent_status_since (self ):
241
241
"""Get the time when the `agent_status` was last updated."""
242
- return pyrfc3339 . parse (self .safe_data ["agent-status" ]["since" ])
242
+ return datetime_fromisoformat (self .safe_data ["agent-status" ]["since" ])
243
243
244
244
@property
245
245
def agent_version (self ):
@@ -266,7 +266,7 @@ def status_message(self):
266
266
@property
267
267
def status_since (self ):
268
268
"""Get the time when the `status` was last updated."""
269
- return pyrfc3339 . parse (self .safe_data ["instance-status" ]["since" ])
269
+ return datetime_fromisoformat (self .safe_data ["instance-status" ]["since" ])
270
270
271
271
@property
272
272
def dns_name (self ):
Original file line number Diff line number Diff line change 3
3
4
4
import logging
5
5
6
- import pyrfc3339
6
+ from backports . datetime_fromisoformat import datetime_fromisoformat
7
7
8
8
from juju .errors import JujuAPIError , JujuError
9
9
@@ -27,7 +27,7 @@ def agent_status(self):
27
27
@property
28
28
def agent_status_since (self ):
29
29
"""Get the time when the `agent_status` was last updated."""
30
- return pyrfc3339 . parse (self .safe_data ["agent-status" ]["since" ])
30
+ return datetime_fromisoformat (self .safe_data ["agent-status" ]["since" ])
31
31
32
32
@property
33
33
def is_subordinate (self ):
@@ -54,7 +54,7 @@ def workload_status(self):
54
54
@property
55
55
def workload_status_since (self ):
56
56
"""Get the time when the `workload_status` was last updated."""
57
- return pyrfc3339 . parse (self .safe_data ["workload-status" ]["since" ])
57
+ return datetime_fromisoformat (self .safe_data ["workload-status" ]["since" ])
58
58
59
59
@property
60
60
def workload_status_message (self ):
Original file line number Diff line number Diff line change 3
3
4
4
import logging
5
5
6
- import pyrfc3339
6
+ from backports . datetime_fromisoformat import datetime_fromisoformat
7
7
8
8
from . import errors , tag
9
9
from .client import client
@@ -31,7 +31,7 @@ def display_name(self):
31
31
32
32
@property
33
33
def last_connection (self ):
34
- return pyrfc3339 . parse (self ._user_info .last_connection )
34
+ return datetime_fromisoformat (self ._user_info .last_connection )
35
35
36
36
@property
37
37
def access (self ):
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ classifiers = [
23
23
]
24
24
dependencies = [
25
25
" macaroonbakery>=1.1,<2.0" ,
26
- " pyRFC3339>=1.0,<2.0" ,
27
26
" pyyaml>=5.1.2" ,
28
27
" websockets>=13.0.1" ,
29
28
" paramiko>=2.4.0" ,
@@ -35,6 +34,7 @@ dependencies = [
35
34
" packaging" ,
36
35
" typing-extensions>=4.5.0" ,
37
36
' backports.strenum>=1.3.1; python_version < "3.11"' ,
37
+ " backports-datetime-fromisoformat>=2.0.2" ,
38
38
]
39
39
[project .optional-dependencies ]
40
40
dev = [
Original file line number Diff line number Diff line change 21
21
package_data = {"juju" : ["py.typed" ]},
22
22
install_requires = [
23
23
"macaroonbakery>=1.1,<2.0" ,
24
- "pyRFC3339>=1.0,<2.0" ,
25
24
"pyyaml>=5.1.2" ,
26
25
"websockets>=13.0.1" ,
27
26
"paramiko>=2.4.0" ,
33
32
"packaging" ,
34
33
"typing-extensions>=4.5.0" ,
35
34
'backports.strenum>=1.3.1; python_version < "3.11"' ,
35
+ "backports-datetime-fromisoformat>=2.0.2" ,
36
36
],
37
37
extras_require = {
38
38
"dev" : [
Original file line number Diff line number Diff line change 8
8
import unittest
9
9
import urllib .request
10
10
11
- import pyrfc3339
11
+ from backports . datetime_fromisoformat import datetime_fromisoformat
12
12
13
13
from juju .client .gocookies import GoCookieJar
14
14
15
15
# cookie_content holds the JSON contents of a Go-produced
16
16
# cookie file (reformatted so it's not all on one line but
17
17
# otherwise unchanged).
18
+
18
19
cookie_content = """
19
20
[
20
21
{
@@ -223,7 +224,7 @@ def test_expiry_time(self):
223
224
]"""
224
225
jar = self .load_jar (content )
225
226
got_expires = tuple (jar )[0 ].expires
226
- want_expires = int (pyrfc3339 . parse ("2345-11-15T18:16:08Z" ).timestamp ())
227
+ want_expires = int (datetime_fromisoformat ("2345-11-15T18:16:08Z" ).timestamp ())
227
228
self .assertEqual (got_expires , want_expires )
228
229
229
230
def load_jar (self , content ):
You can’t perform that action at this time.
0 commit comments