当前位置: 首页>>代码示例>>Python>>正文


Python Commons.format_time_delta方法代码示例

本文整理汇总了Python中inc.Commons.Commons.format_time_delta方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.format_time_delta方法的具体用法?Python Commons.format_time_delta怎么用?Python Commons.format_time_delta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inc.Commons.Commons的用法示例。


在下文中一共展示了Commons.format_time_delta方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_format_time_delta

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_time_delta [as 别名]
 def test_format_time_delta(self):
     delta1 = timedelta(5, 5)
     assert Commons.format_time_delta(delta1) == "P5T5S"
     delta2 = timedelta(0, 50)
     assert Commons.format_time_delta(delta2) == "P0T50S"
     delta3 = timedelta(3, 0, 0, 0, 1)
     assert Commons.format_time_delta(delta3) == "P3T60S"
     delta4 = timedelta(2, 0, 0, 0, 0, 1)
     assert Commons.format_time_delta(delta4) == "P2T3600S"
     delta5 = timedelta(0, 0, 0, 0, 0, 0, 1)
     assert Commons.format_time_delta(delta5) == "P7T0S"
开发者ID:joshcoales,项目名称:Hallo,代码行数:13,代码来源:testCommons.py

示例2: to_xml_string

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_time_delta [as 别名]
 def to_xml_string(self):
     """
     Saves this E621 subscription
     :rtype: str
     """
     # Create root element
     root = ElementTree.Element("e621_sub")
     # Create search element
     search = ElementTree.SubElement(root, "search")
     search.text = self.search
     # Create server name element
     server = ElementTree.SubElement(root, "server")
     server.text = self.server_name
     # Create channel name element, if applicable
     if self.channel_name is not None:
         channel = ElementTree.SubElement(root, "channel")
         channel.text = self.channel_name
     # Create user name element, if applicable
     if self.user_name is not None:
         user = ElementTree.SubElement(root, "user")
         user.text = self.user_name
     # Create latest id elements
     for latest_id in self.latest_ten_ids:
         latest_id_elem = ElementTree.SubElement(root, "latest_id")
         latest_id_elem.text = str(latest_id)
     # Create last check element
     if self.last_check is not None:
         last_check = ElementTree.SubElement(root, "last_check")
         last_check.text = self.last_check.isoformat()
     # Create update frequency element
     update_frequency = ElementTree.SubElement(root, "update_frequency")
     update_frequency.text = Commons.format_time_delta(self.update_frequency)
     # Return xml string
     return ElementTree.tostring(root)
开发者ID:,项目名称:,代码行数:36,代码来源:

示例3: to_json

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_time_delta [as 别名]
 def to_json(self):
     """
     :rtype: dict
     """
     json_obj = dict()
     json_obj["server_name"] = self.server.name
     if isinstance(self.destination, Channel):
         json_obj["channel_address"] = self.destination.address
     if isinstance(self.destination, User):
         json_obj["user_address"] = self.destination.address
     if self.last_check is not None:
         json_obj["last_check"] = self.last_check.isoformat()
     json_obj["update_frequency"] = Commons.format_time_delta(self.update_frequency)
     if self.last_update is not None:
         json_obj["last_update"] = self.last_update.isoformat()
     return json_obj
开发者ID:joshcoales,项目名称:Hallo,代码行数:18,代码来源:Subscriptions.py


注:本文中的inc.Commons.Commons.format_time_delta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。