• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dates.DateService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中semantic.dates.DateService的典型用法代码示例。如果您正苦于以下问题:Python DateService类的具体用法?Python DateService怎么用?Python DateService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: handle_read

def handle_read(text, mic, profile):
    mic.say(random.choice([
        "I am contacting Apple. Please stand by.",
        "Opening that file. Please wait."
    ]))
    api = app_utils.iCloud(profile)
    rem = api.reminders
    listname = find_list(text, profile, rem)
    if not listname:
        mic.say(random.choice([
            "I'm sorry, I couldn't find that list",
            "That list does not seem to be availble. Please check!"
        ]))
        return

    service = DateService()
    ans = random.choice([
        "I've found the following entries: ",
        "Your " + listname + " list contains ",
        "These are the entries of the " + listname + " list "
    ])
    for i in range(len(rem.lists[listname])):
        reminder = rem.lists[listname][i]
        ans += str(i+1) + ') ' + reminder['title']
        if reminder['due']:
            ans += ', due at ' + service.convertTime(reminder['due'])
        ans += '.'

    ans += random.choice([
        "",
        "That's it.",
        "There is nothing else on your list."
    ])
    mic.say(ans)
开发者ID:yannickulrich,项目名称:IRIS,代码行数:34,代码来源:reminders.py


示例2: handle

def handle(text, mic, profile):

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    mic.say("It is %s right now." % response)
开发者ID:jasonkuehl,项目名称:jasper-modules,代码行数:7,代码来源:Time.py


示例3: handle

def handle(text, mic, profile):

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    root = Tk()
    root.wm_title("Mirror")
    w, h = root.winfo_screenwidth(), root.winfo_screenheight()
    root.overrideredirect(1)
    root.geometry("%dx%d+0+0" % (w, h))
    root.focus_set()
    root.bind("1", root.quit())
    root.config(background="#000000")

    mainFrame = Frame(root, width=w, height=h)
    mainFrame.grid(row=0, column=0, padx=10, pady=2)
    mainFrame.config(background="#000000")
    customFont = tkFont.Font(family="Helvetica", size=60)

    timeVar = StringVar()
    timeVar.set(response)
    weatherVar = StringVar()
    weatherVar.set("76°")
    timeLabel = Label(mainFrame, textvariable=timeVar, font=customFont, fg="white", bg="black")
    weatherLabel = Label(mainFrame, textvariable=weatherVar, font=customFont, fg="white", bg="black")
    timeLabel.place(relx=1, x=-2, y=2, anchor=NE)
    weatherLabel.place(relx=0, x=-2, y=2, anchor=NW)
    root.mainloop()
开发者ID:jqk1032,项目名称:Reflekt,代码行数:29,代码来源:BootGUI.py


示例4: handle

def handle(text, mic, profile):
    """
        Responds to user-input, typically speech text, with a summary of
        the relevant weather for the requested date (typically, weather
        information will not be available for days beyond tomorrow).

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone number)
    """

    if not profile['location']:
        mic.say(
            "I'm sorry, I can't seem to access that information. Please make sure that you've set your location on the dashboard.")
        return

    tz = getTimezone(profile)

    service = DateService(tz=tz)
    date = service.parseDay(text)
    if not date:
        date = datetime.datetime.now(tz=tz)
    weekday = service.__daysOfWeek__[date.weekday()]

    if date.weekday() == datetime.datetime.now(tz=tz).weekday():
        date_keyword = "Today"
    elif date.weekday() == (
            datetime.datetime.now(tz=tz).weekday() + 1) % 7:
        date_keyword = "Tomorrow"
    else:
        date_keyword = "On " + weekday

    forecast = getForecast(profile)

    output = None

    for entry in forecast:
        try:
            date_desc = entry['title'].split()[0].strip().lower()

            weather_desc = entry['summary'].split('-')[1]

            if weekday == date_desc:
                output = date_keyword + \
                    ", the weather will be" + weather_desc + "."
                break
        except:
            continue

    if output:
        output = replaceAcronyms(output)
        mic.say(output)
    else:
        mic.say(
            "I'm sorry. I can't see that far ahead.")
开发者ID:Angrycrow,项目名称:jasper-client,代码行数:56,代码来源:Weather.py


示例5: handle

def handle(mic):
    c=datetime.datetime.now()
    con = mdb.connect('localhost', 'root', 'whyte', 'jarvis')
    cur=con.cursor()
    cur.execute("select * from notif where date > '"+str(c)+"' order by date limit 5")
    temp=cur.fetchall()
    service = DateService()
    
    for item in temp:
    	time = service.convertTime(item[2])
    	mic.say(str(item[1])+" on "+str(time))
    con.close()
开发者ID:sudhinsr,项目名称:jarvis,代码行数:12,代码来源:notifications.py


示例6: handle

    def handle(self, text, teller, mic, profile):
        """
            Reports the current time based on the user's timezone.

            Arguments:
            text -- user-input, typically transcribed speech
            mic -- used to interact with the user (input)
            profile -- contains information related to the user (e.g., phone number)
        """

        tz = getTimezone(profile)
        now = datetime.datetime.now(tz=tz)
        service = DateService()
        response = service.convertTime(now)
        teller.say("Il est %s." % response)
开发者ID:KenN7,项目名称:jasper-client,代码行数:15,代码来源:time.py


示例7: handle

def handle(text, sender, receiver, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    sender.say("It is %s right now." % response)
开发者ID:clusterfudge,项目名称:jasper-client,代码行数:15,代码来源:Time.py


示例8: handle

def handle(text, mic, profile):
    """
    Responds to user-input, typically speech text, with a summary of
    the relevant weather for the requested date (typically, weather
    information will not be available for days beyond tomorrow).

    Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """
    try:
        weather_client = yweather.Client()
        weather = weather_client.fetch_weather(profile["location"]["id"], metric=True)

        tz = getTimezone(profile)
        service = DateService(tz=tz)
        date = service.extractDate(text)
        if not date:
            date = datetime.datetime.now(tz=tz)

        weekday = service.__daysOfWeek__[date.weekday()]

        if date.weekday() == datetime.datetime.now(tz=tz).weekday():
            mic.say(
                ("Today, %s at %s degrees with wind speed" + " of %.1f metres per second")
                % (code2desc(weather["condition"]), weather["condition"]["temp"], float(weather["wind"]["speed"]) / 3.6)
            )
            return

        elif date.weekday() == (datetime.datetime.now(tz=tz).weekday() + 1) % 7:
            date_keyword = "Tomorrow"
        else:
            date_keyword = "On " + weekday

        weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        for fore in weather["forecast"]:
            if weekdays[date.weekday()] == fore["day"]:
                mic.say(
                    ("%s, %s with temperatures raging" + " from %s to %s degrees")
                    % (date_keyword, code2desc(fore), fore["low"], fore["high"])
                )
                break
        else:
            mic.say("I'm sorry. I can't see that far ahead.")
    except:
        mic.say("I'm sorry. I can't see that far ahead.")
开发者ID:yannickulrich,项目名称:IRIS,代码行数:48,代码来源:Weather.py


示例9: handle

def handle(text, mic, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    d = datetime.datetime.strptime(response, "%I:%M %p")
    response = d.strftime("%H:%M")
    response = re.sub(r'00:', 'minuit ', response)
    response = re.sub(r'12:', 'midi ', response)
    mic.say("Il est %s." % response)
开发者ID:overflOw11,项目名称:lola,代码行数:20,代码来源:Time.py


示例10: handle

def handle(text, mic, profile):
    """
        Reports the current date based on the user's location.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    day = (time.strftime("%A")) 
    month = (time.strftime("%B"))   
    num_day = (time.strftime("%d"))  
    message = "It is " + day + "the " + num_day + "today, get over karishma" 
    mic.say(message)
开发者ID:cpatchava,项目名称:brainiac,代码行数:20,代码来源:Alarm.py


示例11: handle

def handle(text, mic, profile, wxbot=None):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
        wxBot -- wechat robot
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)
    if "AM" in response:
        response = u"上午" + response.replace("AM", "")
    elif "PM" in response:
        response = u"下午" + response.replace("PM", "")
    mic.say(u"现在时间是 %s " % response)
开发者ID:jxgmy,项目名称:dingdang-robot,代码行数:21,代码来源:Time.py


示例12: handle

def handle(self, text, mic, profile):
    """
        Reports the current time based on the user's timezone.

        Arguments:
        text -- user-input, typically transcribed speech
        mic -- used to interact with the user (for both input and output)
        profile -- contains information related to the user (e.g., phone
                   number)
    """

    tz = getTimezone(profile)
    now = datetime.datetime.now(tz=tz)
    service = DateService()
    response = service.convertTime(now)

    self.blittxt(response, 150, white, black)


    
    mic.say("It is %s right now master." % response)
    time.sleep(1)    
开发者ID:DarthToker,项目名称:jasper-client,代码行数:22,代码来源:Time2.py


示例13: task

  def task(self):
    self.tz = getTimezone(self.profile)
    self.now = datetime.datetime.now(tz=self.tz)
    self.service = DateService()
    self.response = self.service.convertTime(self.now)
    self.timeVar.set(self.response)
    self.numFiles = len([name for name in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, name))])
    if self.numFiles > self.numFileHolder:
      self.showPicture()
      print ("OLD: " + str(self.numFileHolder) + "NEW: " + str(self.numFiles))
      self.numFileHolder = self.numFiles
    self.forecast = None
    if 'wmo_id' in self.profile:
      self.forecast = get_forcast_by_wmo_id(str(self.profile['wmo_id']))
    elif 'location' in self.profile:
      self.forecast = get_forecast_by_name(str(self.profile['location']))

    self.temp = self.forecast[0]['summary_detail']['value'][13:17] + unichr(176)
    self.weatherVar.set(self.temp) 
    self.root.after(2000, self.task)
开发者ID:jqk1032,项目名称:Reflekt,代码行数:20,代码来源:GUI.py


示例14: handle

def handle(text, speaker, requester, profile):
    """
    Responds to user-input, typically speech text, with a summary of
    the relevant weather for the requested date (typically, weather
    information will not be available for days beyond tomorrow).

    Arguments:
        text -- user-input, typically transcribed speech
		speaker -- used to interact with the user (output)
        requester -- used to interact with the user (input)
        profile -- contains information related to the user (e.g., phone
                   number)
    """
    forecast = None
    if 'wmo_id' in profile:
        forecast = get_forecast_by_wmo_id(str(profile['wmo_id']))
    elif 'location' in profile:
        forecast = get_forecast_by_name(str(profile['location']))

    if not forecast:
        speaker.clean_and_say("I'm sorry, I can't seem to access that information. Please " +
                "make sure that you've set your location on the dashboard.")
        return

    tz = getTimezone(profile)

    service = DateService(tz=tz)
    date = service.extractDay(text)
    if not date:
        date = datetime.datetime.now(tz=tz)
    weekday = service.__daysOfWeek__[date.weekday()]

    if date.weekday() == datetime.datetime.now(tz=tz).weekday():
        date_keyword = "Today"
    elif date.weekday() == (
            datetime.datetime.now(tz=tz).weekday() + 1) % 7:
        date_keyword = "Tomorrow"
    else:
        date_keyword = "On " + weekday

    output = None

    for entry in forecast:
        try:
            date_desc = entry['title'].split()[0].strip().lower()
            if date_desc == 'forecast':
                # For global forecasts
                date_desc = entry['title'].split()[2].strip().lower()
                weather_desc = entry['summary']
            elif date_desc == 'current':
                # For first item of global forecasts
                continue
            else:
                # US forecasts
                weather_desc = entry['summary'].split('-')[1]

            if weekday == date_desc:
                output = date_keyword + \
                    ", the weather will be " + weather_desc + "."
                break
        except:
            continue

    if output:
        output = replaceAcronyms(output)
        speaker.clean_and_say(output)
    else:
        speaker.clean_and_say(
            "I'm sorry. I can't see that far ahead.")
开发者ID:lowdev,项目名称:jasper-client,代码行数:69,代码来源:Weather.py


示例15: handle

def handle(mic):
    
    now = datetime.datetime.now()
    service = DateService()
    response = service.convertTime(now)
    mic.say("It is %s right now." % response)
开发者ID:sudhinsr,项目名称:jarvis,代码行数:6,代码来源:Time.py


示例16: compareTimes

 def compareTimes(self, input, targets):
     service = DateService()
     results = service.extractDates(input)
     for (result, target) in zip(results, targets):
         self.assertEqual(result.hour, target.hour)
         self.assertEqual(result.minute, target.minute)
开发者ID:caje731,项目名称:semantic,代码行数:6,代码来源:testDates.py


示例17: compareDate

 def compareDate(self, input, target):
     service = DateService()
     result = service.extractDate(input)
     self.assertEqual(result.month, target.month)
     self.assertEqual(result.day, target.day)
开发者ID:caje731,项目名称:semantic,代码行数:5,代码来源:testDates.py


示例18: compareDates

 def compareDates(self, input, targets):
     service = DateService()
     results = service.extractDates(input)
     for (result, target) in zip(results, targets):
         self.assertEqual(result.month, target.month)
         self.assertEqual(result.day, target.day)
开发者ID:caje731,项目名称:semantic,代码行数:6,代码来源:testDates.py


示例19: compareTime

 def compareTime(self, input, target):
     service = DateService()
     result = service.extractDate(input)
     self.assertEqual(result.hour, target.hour)
     self.assertEqual(result.minute, target.minute)
开发者ID:caje731,项目名称:semantic,代码行数:5,代码来源:testDates.py


示例20: GUI

class GUI(threading.Thread):

  def __init__(self):

    self.profile_path = jasperpath.config('profile.yml')
    if os.path.exists(self.profile_path):
      with open(self.profile_path, 'r') as f:
        self.profile = yaml.safe_load(f)

    threading.Thread.__init__(self)
    self.start()

  def callback(self):
    self.root.quit()

  def task(self):
    self.tz = getTimezone(self.profile)
    self.now = datetime.datetime.now(tz=self.tz)
    self.service = DateService()
    self.response = self.service.convertTime(self.now)
    self.timeVar.set(self.response)
    self.numFiles = len([name for name in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, name))])
    if self.numFiles > self.numFileHolder:
      self.showPicture()
      print ("OLD: " + str(self.numFileHolder) + "NEW: " + str(self.numFiles))
      self.numFileHolder = self.numFiles
    self.forecast = None
    if 'wmo_id' in self.profile:
      self.forecast = get_forcast_by_wmo_id(str(self.profile['wmo_id']))
    elif 'location' in self.profile:
      self.forecast = get_forecast_by_name(str(self.profile['location']))

    self.temp = self.forecast[0]['summary_detail']['value'][13:17] + unichr(176)
    self.weatherVar.set(self.temp) 
    self.root.after(2000, self.task)
  def showPicture(self):
    self.newest = max(glob.iglob('Pictures/*.jpg'), key = os.path.getctime)
    print ("NEWEST: " + self.newest)
    self.photo = ImageTk.PhotoImage(Image.open(self.newest))
    self.x = self.canvas.create_image(self.w/2, self.h/2, image=self.photo)
    self.canvas.itemconfigure(self.x, state=NORMAL)
    self.canvas.update_idletasks()
    time.sleep(3)
    self.canvas.itemconfigure(self.x, state=HIDDEN)
  def run(self):

    self.root = Tk()
    self.root.protocol("WM_DELETE_WINDOW", self.callback)
    self.w, self.h = self.root.winfo_screenwidth(), self.root.winfo_screenheight()
    #self.w, self.h = 500, 500
    self.root.overrideredirect(1)
    self.root.geometry("%dx%d+0+0" % (self.w, self.h))
    self.root.focus_set()
    self.root.bind("1", self.root.quit())
    self.root.config(background = "#000000")

    mainFrame = Frame(self.root, width=self.w, height=self.h)
    mainFrame.grid(row=0, column=0, padx=10, pady=2)
    mainFrame.config(background= "#000000")
    customFont = tkFont.Font(family="Helvetica", size=60)
    self.timeVar = StringVar()
    self.weatherVar = StringVar()
    self.canvas = Canvas(mainFrame, width=1080, height=1920, highlightthickness=0)
    timeLabel = Label(mainFrame, textvariable=self.timeVar, font=customFont, fg="white", bg="black")
    weatherLabel = Label(mainFrame, textvariable=self.weatherVar, font=customFont, fg="white", bg="black")
 
    self.canvas.config(background="#000000")
    self.canvas.place(relx=0.5, rely=0.5, anchor=CENTER)
    self.directory = '/home/pi/jasper/Pictures'
    self.numFileHolder = len([name for name in os.listdir(self.directory) if os.path.isfile(os.path.join(self.directory, name))])
    print "NUMFILEHOLDER: " + str(self.numFileHolder)
    timeLabel.place(relx=1, x=-2, y=2, anchor=NE)
    weatherLabel.place(relx=0, x=-2, y=2, anchor=NW)
    self.root.after(2000, self.task)
    self.root.mainloop()
开发者ID:jqk1032,项目名称:Reflekt,代码行数:75,代码来源:GUI.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python semver.compare函数代码示例发布时间:2022-05-27
下一篇:
Python common.Method类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap