Mercurial > libervia-backend
comparison sat/tools/utils.py @ 3860:e417c478b488
plugin XEP-0060, tools (utils): doc/type hints
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Jul 2022 17:18:17 +0200 |
parents | 0a87cae85746 |
children | 00212260f659 |
comparison
equal
deleted
inserted
replaced
3859:3ef988734869 | 3860:e417c478b488 |
---|---|
16 # You should have received a copy of the GNU Affero General Public License | 16 # You should have received a copy of the GNU Affero General Public License |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 """ various useful methods """ | 19 """ various useful methods """ |
20 | 20 |
21 from typing import Optional, Union | |
21 import unicodedata | 22 import unicodedata |
22 import os.path | 23 import os.path |
23 import datetime | 24 import datetime |
24 import subprocess | 25 import subprocess |
25 import time | 26 import time |
135 def wrapper(*args, **kwargs): | 136 def wrapper(*args, **kwargs): |
136 return defer.ensureDeferred(func(*args, **kwargs)) | 137 return defer.ensureDeferred(func(*args, **kwargs)) |
137 return wrapper | 138 return wrapper |
138 | 139 |
139 | 140 |
140 def xmpp_date(timestamp=None, with_time=True): | 141 def xmpp_date( |
142 timestamp: Optional[Union[float, int]] = None, | |
143 with_time: bool = True | |
144 ) -> str: | |
141 """Return date according to XEP-0082 specification | 145 """Return date according to XEP-0082 specification |
142 | 146 |
143 to avoid reveling the timezone, we always return UTC dates | 147 to avoid reveling the timezone, we always return UTC dates |
144 the string returned by this method is valid with RFC 3339 | 148 the string returned by this method is valid with RFC 3339 |
145 @param timestamp(None, float): posix timestamp. If None current time will be used | 149 @param timestamp(None, float): posix timestamp. If None current time will be used |