本文整理匯總了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