eric6/DebugClients/Python/coverage/backward.py

branch
multi_processing
changeset 7802
eefe954f01e8
parent 7702
f8b97639deb5
equal deleted inserted replaced
7646:39e3db2b4936 7802:eefe954f01e8
6 # This file's purpose is to provide modules to be imported from here. 6 # This file's purpose is to provide modules to be imported from here.
7 # pylint: disable=unused-import 7 # pylint: disable=unused-import
8 8
9 import os 9 import os
10 import sys 10 import sys
11
12 from datetime import datetime
11 13
12 from coverage import env 14 from coverage import env
13 15
14 16
15 # Pythons 2 and 3 differ on where to get StringIO. 17 # Pythons 2 and 3 differ on where to get StringIO.
213 items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys) 215 items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys)
214 return "{}({})".format(type(self).__name__, ", ".join(items)) 216 return "{}({})".format(type(self).__name__, ", ".join(items))
215 217
216 def __eq__(self, other): 218 def __eq__(self, other):
217 return self.__dict__ == other.__dict__ 219 return self.__dict__ == other.__dict__
220
221
222 def format_local_datetime(dt):
223 """Return a string with local timezone representing the date.
224 If python version is lower than 3.6, the time zone is not included.
225 """
226 try:
227 return dt.astimezone().strftime('%Y-%m-%d %H:%M %z')
228 except (TypeError, ValueError):
229 # Datetime.astimezone in Python 3.5 can not handle naive datetime
230 return dt.strftime('%Y-%m-%d %H:%M')
218 231
219 232
220 def invalidate_import_caches(): 233 def invalidate_import_caches():
221 """Invalidate any import caches that may or may not exist.""" 234 """Invalidate any import caches that may or may not exist."""
222 if importlib and hasattr(importlib, "invalidate_caches"): 235 if importlib and hasattr(importlib, "invalidate_caches"):

eric ide

mercurial