當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。