本文整理汇总了Python中astral.Astral方法的典型用法代码示例。如果您正苦于以下问题:Python astral.Astral方法的具体用法?Python astral.Astral怎么用?Python astral.Astral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astral
的用法示例。
在下文中一共展示了astral.Astral方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_nightsky
# 需要导入模块: import astral [as 别名]
# 或者: from astral import Astral [as 别名]
def make_nightsky(self):
a = astral.Astral()
tomorrow = self.dt + timedelta(days = 1)
yesterday = self.dt - timedelta(days = 1)
if self.dt > self.loc.sunset(self.dt.date()):
moon_phase = a.moon_phase(self.dt.date())
night_length = self.loc.sunrise(tomorrow) - self.loc.sunset(self.dt.date())
night_so_far = self.dt - self.loc.sunset(self.dt.date())
elif self.dt < self.loc.sunrise(self.dt.date()):
moon_phase = a.moon_phase(yesterday.date())
night_length = self.loc.sunrise(self.dt.date()) - self.loc.sunset(yesterday)
night_so_far = self.dt - self.loc.sunset(yesterday)
if moon_phase == 0:
moon = MOONS[0]
elif moon_phase < 7:
moon = MOONS[1]
elif moon_phase < 14:
moon = MOONS[2]
elif moon_phase == 14:
moon = MOONS[3]
elif moon_phase < 21:
moon = MOONS[4]
else:
moon = MOONS[5]
moon_placement = 14 - int((night_so_far.seconds/night_length.seconds) * 15)
for _ in range(moon_placement):
self.sky += u"\u2800"
self.sky += moon + u"\uFE0F"
示例2: __init__
# 需要导入模块: import astral [as 别名]
# 或者: from astral import Astral [as 别名]
def __init__(self, config):
"""
Initializations for the startup of the weather forecast
"""
# Get plugin name (according to the folder, it is contained in)
self.name = os.path.dirname(__file__).split('/')[-1]
self.pretty_name = "Sunrise"
self.description = "Displays the current times of sunrise and sunset."
self.astral_at_location = Astral()[config.get('plugin_' + self.name, 'location')]
self.bg_color_index = 0 # default background color: black
self.word_color_index = 2 # default word color: warm white
self.minute_color_index = 2 # default minute color: warm white