コード例 #1
0
def assistant(command):

	if "how are you" in command:
		speak("i am well")
	elif "open " in command:
		reg_ex = re.search("open (.*)", command)
		chrome.open(reg_ex)
	elif "set up my desktop" in command:
		chrome.setupDesktop()
	elif "what date is today" in command:
		date.date()
	elif "what time is it" in command:
		date.time()
	elif "application" in command:
		reg_ex = re.search("application (.*)", command)
		application = reg_ex.group(1)
		aplication.open(application)
	elif "hello" in command:
		date.welcome()
	elif "help me" in command:
		help()
	elif "make a joke" in command:
		joke.makeJoke()
	elif "tell me about" in command:
		reg_ex = re.search('tell me about (.*)', command)
		chrome.about(reg_ex)
	elif "shut down" in command:
		speak('Bye bye Sir. Have a nice day')
		sys.exit()					
	elif "what is the weather in" in command:
		reg_ex = re.search('what is the weather in(.*)', command)
		weather.tellWeather(reg_ex)
	elif "i go outside" in command:
		speak("don't be idiot and stay at home")
コード例 #2
0
def test_given_full_date_then_prints_all_fields(capsys):
    fields = {
        '%Y': TIMESTAMP.year,
        '%m': TIMESTAMP.month,
        '%d': TIMESTAMP.day,
        '%H': TIMESTAMP.hour,
        '%M': TIMESTAMP.minute,
        '%S': TIMESTAMP.second
    }

    for fmt, field in fields.items():
        date(TIMESTAMP, fmt)

        out, err = capsys.readouterr()
        assert str(field) in out
コード例 #3
0
def update_record(rid, distance):
    day = date.date()
    now = date.now()
    condition = cond({'rid': rid, 'date': day})
    table = 'record'
    return update_or_insert(table, ['rid', 'date', 'time', 'distance'],
                            [rid, day, now, distance], condition)
コード例 #4
0
 def test_a_31_31(self):
     f = open(path.join(self.test_dir, 'test.txt'), 'w')
     f.write('a/31/31')
     f.close()
     f = open(path.join(self.test_dir, 'test.txt'))
     self.assertEqual(date(f.name), None)
     f.close()
コード例 #5
0
 def test_31_31_31(self):
     f = open(path.join(self.test_dir, 'test.txt'), 'w')
     f.write('31/31/31')
     f.close()
     f = open(path.join(self.test_dir, 'test.txt'))
     self.assertEqual(date(f.name), '31/31/31 is illegal')
     f.close()
コード例 #6
0
 def test_12_10_01(self):
     f = open(path.join(self.test_dir, 'test.txt'), 'w')
     f.write('12/10/01')
     f.close()
     f = open(path.join(self.test_dir, 'test.txt'))
     self.assertEqual(date(f.name), '2001-10-12')
     f.close()
コード例 #7
0
 def test_31_0_1(self):
     f = open(path.join(self.test_dir, 'test.txt'), 'w')
     f.write('31/0/1')
     f.close()
     f = open(path.join(self.test_dir, 'test.txt'))
     self.assertEqual(date(f.name), '2000-01-31')
     f.close()
コード例 #8
0
def req_URLs(date1, date2):
    """Returns the requested parent URL's for speeches and remarks in a 
	given date range. Date1 = "YYYY/MM" Date2 = "YYYY/MM"""

    a = date(date1)
    b = date(date2)

    if a == b:
        print '\n'.join(map(str, read_parentURLs(a)))

    elif a != b:
        f = open('requested_parentURLs.csv', 'w')
        for URL in range(a, b + 1):
            requested_URL = '\n'.join(map(str, read_parentURLs(URL)))
            f.write(u'%s\n' % (requested_URL))
        f.close()
コード例 #9
0
def req_URLs(date1, date2):
	"""Returns the requested parent URL's for speeches and remarks in a 
	given date range. Date1 = "YYYY/MM" Date2 = "YYYY/MM"""

	a = date(date1)
	b = date(date2)

	if a==b:
		print '\n'.join(map(str, read_parentURLs(a)))

	elif a != b:
		f = open('requested_parentURLs.csv', 'w')
		for URL in range(a, b+1):
			requested_URL = '\n'.join(map(str, read_parentURLs(URL)))
			f.write(u'%s\n' % (requested_URL))
		f.close()
コード例 #10
0
 def testDayOfWeek(self):
     # Compare to the datetime.date value to make it locale independent
     expected = date(2000, 6, 16).strftime('%A')
     # strftime() used to always be passed a day of week of 0
     dt = DateTime('2000/6/16')
     s = dt.strftime('%A')
     self.assertEqual(s, expected, (dt, s))
コード例 #11
0
def header():
    day = date.date()
    month = date.month()

    head = '{} {}\n\n'.format(day, room)
    head = head + '{}\n\n'.format(motto())
    head = head + '日跑量/{}月累计/{}月计划\n'.format(month, month)

    return head
コード例 #12
0
def test_given_percent_a_then_prints_full_week_day(capsys):
    #days in the month of january 2000
    days = {
        2: 'Sunday',
        3: 'Monday',
        4: 'Tuesday',
        5: 'Wednesday',
        6: 'Thursday',
        7: 'Friday',
        8: 'Saturday',
    }

    for number, name in days.items():
        timestamp = datetime.datetime(2000, 1, number, 0, 0, 0)
        date(timestamp, '%B')

        out, err = capsys.readouterr()
        assert name in out
コード例 #13
0
def delete_record(rid):
    table = 'record'
    day = date.date()
    condition = cond({'rid': rid, 'date': day})

    old = store.value(table, 'distance', condition=condition)
    if not none_or_empty(old):
        update_total(rid, old * (-1), add=True)
        store.delete(table, condition=condition)
コード例 #14
0
 def test_interfaces(self):
     verifyObject(ITimeDelta, timedelta(minutes=20))
     verifyObject(IDate, date(2000, 1, 2))
     verifyObject(IDateTime, datetime(2000, 1, 2, 10, 20))
     verifyObject(ITime, time(20, 30, 15, 1234))
     verifyObject(ITZInfo, tzinfo())
     verifyClass(ITimeDeltaClass, timedelta)
     verifyClass(IDateClass, date)
     verifyClass(IDateTimeClass, datetime)
     verifyClass(ITimeClass, time)
コード例 #15
0
def test_given_percent_b_then_prints_full_month_name(capsys):
    months = {
        1: 'January',
        2: 'Febuary',
        3: 'March',
        4: 'April',
        5: 'May',
        6: 'June',
        7: 'July',
        8: 'August',
        9: 'September',
        10: 'October',
        11: 'November',
        12: 'December'
    }

    for number, name in months.items():
        timestamp = datetime.datetime(2000, number, 1, 0, 0, 0)
        date(timestamp, '%A')

        out, err = capsys.readouterr()
        assert name in out
コード例 #16
0
def motto_reply(display, text):
    if none_or_empty(text):
        return None

    if len(text.split('\n')) > 4:
        global error
        error = '箴言最多4行'
        return None

    id, name, nick = runner(display)
    store.insert('motto', ['rid', 'content', 'date'],
                 [[id, text, date.date()]])
    return '已添加,将随机展示'
コード例 #17
0
    def Image_Download(self, TimeUTC):

        date = dt.date()

        link = "https://weather.gc.ca/data/prog/regional/" + date + "00/" + date + "00_054_R1_north@america@northwest_I_ASTRO_nt_0" + str(
            TimeUTC).zfill(2) + ".png"
        dowloadPic = "Images/Image" + str(TimeUTC) + ".jpg"
        print TimeUTC
        try:
            urllib2.urlopen(link)
            urllib.urlretrieve(link, dowloadPic)
            return 1
        except:
            return 0
コード例 #18
0
def rank(order='time', reverse=False):
    table_runner = 'runner'
    table_record = 'record'
    table_plan = 'plan'

    day = date.date()
    year = date.year()
    month = date.month()

    condition = cond({'date': day})

    records = store.query(table_record, ['rid', 'distance', 'time'],
                          condition=condition)
    marks = []
    for record in records:
        id = record[0]
        distance = record[1]
        time = record[2]
        name = store.value(table_runner, 'name', condition=cond({'id': id}))
        total = 0
        plan = 0
        plans = store.query(table_plan, ['plan', 'total'],
                            condition=cond({
                                'rid': id,
                                'year': year,
                                'month': month
                            }))
        if plans and len(plans) > 0:
            plans = plans[0]

        if plans:
            plan = plans[0]
            total = plans[1]

        mark = {
            'name': name,
            'distance': distance,
            'total': total,
            'plan': plan,
            'time': date.toTime(time)
        }
        marks.append(mark)

    marks.sort(reverse=reverse, key=lambda mark: mark[order])
    return marks
コード例 #19
0
def _load_date(val):
    microsecond = 0
    tz = None
    try:
        if len(val) > 19:
            if val[19] == '.':
                if val[-1].upper() == 'Z':
                    subsecondval = val[20:-1]
                    tzval = "Z"
                else:
                    subsecondvalandtz = val[20:]
                    if '+' in subsecondvalandtz:
                        splitpoint = subsecondvalandtz.index('+')
                        subsecondval = subsecondvalandtz[:splitpoint]
                        tzval = subsecondvalandtz[splitpoint:]
                    elif '-' in subsecondvalandtz:
                        splitpoint = subsecondvalandtz.index('-')
                        subsecondval = subsecondvalandtz[:splitpoint]
                        tzval = subsecondvalandtz[splitpoint:]
                    else:
                        tzval = None
                        subsecondval = subsecondvalandtz
                if tzval is not None:
                    tz = TomlTz(tzval)
                microsecond = int(
                    int(subsecondval) * (10**(6 - len(subsecondval))))
            else:
                tz = TomlTz(val[19:])
    except ValueError:
        tz = None
    if "-" not in val[1:]:
        return None
    try:
        if len(val) == 10:
            d = date.date(int(val[:4]), int(val[5:7]), int(val[8:10]))
        else:
            d = date.datetime(int(val[:4]), int(val[5:7]), int(val[8:10]),
                              int(val[11:13]), int(val[14:16]),
                              int(val[17:19]), microsecond, tz)
    except ValueError:
        return None
    return d
コード例 #20
0
import requests
import pandas as pd
from bs4 import BeautifulSoup
import csv as csv
from date import date
a = date()


def songs():
    df = pd.DataFrame({"Fake": [0]})
    df = df.drop(columns="Fake")
    df = df.drop([0])
    df2 = df
    for it in a:
        print(it)
        url = "https://www.billboard.com/charts/hot-100/" + str(it)
        source_code = requests.get(url)
        plain_text = source_code.text
        soup = BeautifulSoup(plain_text, "html5lib")

        i = 1
        for (link, link12) in zip(
                soup.findAll("span", {"class": "chart-list-item__title-text"}),
                soup.findAll("div", {"class": "chart-list-item__artist"})
        ):  # zip method helps us perform multiple pararllel for loops .
            href = link.string  #song name
            href1 = href.split()
            word1 = combine(href1)
            x0 = combine2(href1)
            url1 = "https://en.wikipedia.org/wiki/" + str(word1)
            href12 = link12.string
コード例 #21
0
def test_given_format_with_text_then_prints_text(capsys):
    date(TIMESTAMP, 'abc 123')

    out, err = capsys.readouterr()
    assert out == 'abc 123\n'
コード例 #22
0
from wks import wks
from title import title
from bat import bat
from bri import bri
from date import date
from vol import vol
from ntw import ntw

from fmt import left, center, right

bar = [
    left,
    wks(),
    ' ',
    title(),
    center,
    date(),
    right,
    ntw(),
    '  ',
    bri(),
    '  ',
    vol(),
    '  ',
    bat(),
    ' ',
]
コード例 #23
0
def test_given_no_format_then_prints_newline(capsys):
    date(TIMESTAMP, '')

    out, err = capsys.readouterr()
    assert out == '\n'
コード例 #24
0
def test_given_format_with_double_percent_then_prints_percent(capsys):
    date(TIMESTAMP, '%%')

    out, err = capsys.readouterr()
    assert out == '%\n'
コード例 #25
0
ファイル: connection.py プロジェクト: natanaelfelix/Estudos
    assert_fingerprint,
    create_urllib3_context,
    ssl_wrap_socket,
)

from .util import connection

from ._collections import HTTPHeaderDict

log = logging.getLogger(__name__)

port_by_scheme = {"http": 80, "https": 443}

# When it comes time to update this value as a part of regular maintenance
# (ie test_recent_date is failing) update it to ~6 months before the current date.
RECENT_DATE = date.date(2019, 1, 1)

_CONTAINS_CONTROL_CHAR_RE = re.compile(r"[^-!#$%&'*+.^_`|~0-9a-zA-Z]")


class DummyConnection(object):
    """Used to detect a failed ConnectionCls import."""

    pass


class HTTPConnection(_HTTPConnection, object):
    """
    Based on httplib.HTTPConnection but provides an extra constructor
    backwards-compatibility layer between older and newer Pythons.
コード例 #26
0
ファイル: datetime.py プロジェクト: natanaelfelix/Estudos
def today_is_later_than(year, month, day):
    # type: (int, int, int) -> bool
    today = date.date.today()
    given = date.date(year, month, day)

    return today > given
コード例 #27
0
ファイル: client.py プロジェクト: skandavc18/OOPerl
# !/usr/local/bin/perl -w -I C:\Users\Rachana\Desktop\try\perl\

import date
d=date.date(15,8,1947)
d.dispdate()
コード例 #28
0
#Тренировки
import arithmetic
import is_year_leap
import square
import season
import bank
import is_prime
import date
import XOR_cipher

print(is_year_leap.is_year_leap(2004))
print(square.square(5))
print(arithmetic.arithmetic(4, 3, '+'))
print(season.season(13))
print(bank.bank(1000, 3))
print(is_prime.is_prime(47))
print(date.date(29, 2, 2000))
print(XOR_cipher.XOR_cipher('help', '3'))
コード例 #29
0
ファイル: Bite074.py プロジェクト: ryancheley/PyBites
import calendar
from date import date


def weekday_of_birth_date(date):
    """Takes a date object and returns the corresponding weekday string"""
    results = calendar.day_name[date.weekday()]
    return results


t = weekday_of_birth_date(date=date(1974, 11, 11))
print(t)
コード例 #30
0
ファイル: fn.py プロジェクト: F0xedb/futurenetCalculator
    _money = float(args.money)
    days = int(args.days)

    # calculate the given profit with the money.money you earned
    money.money(args).profit(args.profit, _money, days)

    # count command line parameter
    countmoney = money.counter(args.count).calculate()

    if args.count:
        money.money(args).profit(args.countprofit, countmoney, len(args.count))

    # predict adpack amount in x days
    packs = adpack.adpacks(args.adpacks, args.balance, 0.0, 60.0,
                           float(args.course), args, date)
    packs.predictAdpacks()

    packs.predictTime()

    if args.adpackprofit:
        packs.AdpackProfit()

    packs.targetProfit()
    file.file(args).TotalEarnings()


if __name__ == '__main__':
    g_date = date.date()
    argument = argparser.argparser(g_date.date)
    init(argument, g_date)
コード例 #31
0
 def today(self): # known case of datetime.date.today
     """ Current date or datetime:  same as self.__class__.fromtimestamp(time.time()). """
     return date(1, 1, 1)
コード例 #32
0
 def replace(self, year=None, month=None, day=None): # known case of datetime.date.replace
     """ Return date with new specified fields. """
     return date(1,1,1)
コード例 #33
0
 def fromtimestamp(cls, timestamp): # known case of datetime.date.fromtimestamp
     """ timestamp -> local date from a POSIX timestamp (like time.time()). """
     return date(1,1,1)
コード例 #34
0
 def fromordinal(cls, ordinal): # known case of datetime.date.fromordinal
     """ int -> date corresponding to a proleptic Gregorian ordinal. """
     return date(1,1,1)
コード例 #35
0
ファイル: calendarhandler.py プロジェクト: jonprairie/cts
 def InitDateList(self):
     current_date_ordinal = self.current_date.toordinal()
     for day in range(default_options["game_length"]):
         temp_date = datetime.date.fromordinal(current_date_ordinal + day)
         temp_date = date.date(date = temp_date)
         self.date_list.append(temp_date)