def _holidays_for_year(year, country='SG', api_key=os.environ['HOLIDAY_API_KEY']):
    hapi = holidayapi.v1(api_key)
    parameters = {
        'country': country,
        'year':    year,
    }
    time.sleep(5)
    return hapi.holidays(parameters)
示例#2
0
 def holiday(self, msg, year, month, day):
     if year == 0:
         year = int(datetime.now().strftime('%Y')) - int(
             os.getenv('YEAR_OFFSET'))
     if month == 0:
         month = datetime.now().strftime('%m')
     if day == 0:
         day = datetime.now().strftime('%d')
     holiday_api = holidayapi.v1(os.getenv('API_KEY'))
     holiday_parameters = {
         'country': 'US',
         'year': year,
         'month': month,
         'day': day
     }
     holidays = holiday_api.holidays(holiday_parameters)
     if 'holidays' in holidays:
         if len(holidays['holidays']) == 0:
             return 'No holidays for ' + str(year) + '-' + str(
                 month) + '-' + str(day)
         return holidays['holidays'][0]['name']
     return holidays
示例#3
0
from flask import Flask, render_template, jsonify, request
# from flask_cors import CORS, cross_origin
import holidayapi
import time
from datetime import datetime
import requests

hapi = holidayapi.v1('5605610e-feb0-490b-b32b-b32184c13c89')
app = Flask(__name__)


@app.route('/getWeatherData', methods=['POST'])
def getWeatherData():
    latitude, longitude, cityName = request.form.get(
        "latitude",
        None), request.form.get("longitude",
                                None), request.form.get("cityName", None)
    return "none"


@app.route('/getHolidayData', methods=['POST'])
def getHolidayData():
    countryCode = request.form.get("countryCode", None)
    parameters = {
        # Required
        'country': countryCode,
        'year': 2016,
        # Optional
        # 'month':    7,
        # 'day':      4,
        # 'previous': True,
示例#4
0
# -*- coding: utf-8 -*-

import holidayapi
import json
import time

# createa file w/ your API key

key = open('keys.txt', 'r').read()

hapi = holidayapi.v1(key)

countries = [
    'AU', 'CN', 'HK', 'IN', 'ID', 'JP', 'MY', 'NZ', 'PH', 'SG', 'KR', 'TH',
    'TW', 'VN'
]

years = range(2004, 2014 + 1)

parameters = {
    # Required
    'country': 'US',
    'year': 2016,
    # Optional
    # 'month':    7,
    # 'day':      4,
    # 'previous': True,
    # 'upcoming': True,
    # 'public':   True,
    # 'pretty':   True,
}
示例#5
0
from datetime import datetime, timedelta
import holidayapi

hapi = holidayapi.v1('11b227ec-f5ad-492e-b6a2-0588308b0c6c')

parameters = {
	# Required
	'country': 'GR',
	'year':    2017,
	# Optional
	# 'month':    7,
	# 'day':      4,
	# 'previous': True,
	# 'upcoming': True,
	# 'public':   True,
	# 'pretty':   True,
}

holidays = hapi.holidays(parameters)

startingDate1 = '24/11/2017'
startingDate2 = '24/11/2017'

endingDate1 = '30/01/2018'
endingDate2 = '15/12/2017'

#days = np.busday_count(date1, date2)

ed = 45

sdate1 = datetime.strptime(startingDate1, "%d/%m/%Y").date()
示例#6
0
from flask import Flask, request, render_template, url_for, redirect
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
from weather import Weather, Unit
from PyDictionary import PyDictionary
from datetime import date
import holidayapi
import wikipedia
import holidays
import pyjokes
import sys, os, time

app = Flask(__name__)
chatterbot = ChatBot("Iniya")
weather = Weather(unit=Unit.CELSIUS)
hapi = holidayapi.v1('da4e7a21-2b5e-42ad-9698-ee5721db8100')
dictionary = PyDictionary()


@app.route('/', methods=['POST', 'GET'])
def home():
    if request.method == 'GET':
        return render_template('chat.html')
    elif request.method == 'POST':
        user = request.form['you']
        if user == "let's ask":
            response = "Yeah!!! shoot your question...."
        elif user.find('iniya') == 0:
            response = wikipedia.summary(user[5:],
                                         sentences=1,
                                         auto_suggest=True,
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import holidayapi

hapi = holidayapi.v1('8172b8cc-45a2-4b5b-b5b3-1dd79030f5de')

parameters = {
	# Required
	'country': 'CO',
	'year':    2017,
	# Optional
	# 'month':    7,
	# 'day':      4,
	# 'previous': True,
	# 'upcoming': True,
	# 'public':   True,
	# 'pretty':   True,
}

holidays2017 = hapi.holidays(parameters)

holidays=holidays2011['holidays'].keys()+holidays2012['holidays'].keys()+holidays2013['holidays'].keys()+holidays2014['holidays'].keys()+holidays2015['holidays'].keys()+holidays2016['holidays'].keys()+holidays2017['holidays'].keys()

import numpy as np

np.savetxt("Holidays.csv", holidays, delimiter=",", fmt='%s')