本文整理汇总了Python中utility.Utility.epoch_to_iso8601方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.epoch_to_iso8601方法的具体用法?Python Utility.epoch_to_iso8601怎么用?Python Utility.epoch_to_iso8601使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utility.Utility
的用法示例。
在下文中一共展示了Utility.epoch_to_iso8601方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_newest_record_time
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import epoch_to_iso8601 [as 别名]
def set_newest_record_time(self, db_type, timestamp):
"""Set the newest record time.
Args:
timestamp (str): Epoch time to be written to file If not string,
will be coerced to string.
"""
record_file = "%s.%s" % (self.newest_record_file, db_type)
with open(record_file, 'w') as u_file:
print("FeedManager: Setting newest DB record to %s in %s" % (Utility.epoch_to_iso8601(timestamp), record_file)) # NOQA
u_file.write(str(timestamp).replace('.0', ''))
return
示例2: get_newest_record_time
# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import epoch_to_iso8601 [as 别名]
def get_newest_record_time(self, db_type):
"""Get the newest record time from file in feed dir."""
result = 0
rx = r'^\d{10}$'
target_file = "%s.%s" % (self.newest_record_file, db_type)
if not os.path.isfile(target_file):
print("FeedManager: No record of last update found at %s..." % target_file) # NOQA
return result
with open(target_file, 'r') as u_file:
first_line = u_file.readline().replace('\n', '').replace('.0', '')
if re.match(rx, first_line):
result = first_line
print("FeedManager: Newest DB record timestamp is %s" % Utility.epoch_to_iso8601(result)) # NOQA
else:
print("FeedManager: Unable to parse newest DB record timestamp: %s from %s" % (first_line, target_file)) # NOQA
return result