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


Python astral.Astral方法代码示例

本文整理汇总了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" 
开发者ID:thisisparker,项目名称:choochoobot,代码行数:35,代码来源:choochoogen.py

示例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 
开发者ID:bk1285,项目名称:rpi_wordclock,代码行数:16,代码来源:plugin.py


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