#!/usr/bin/env python
# coding: utf-8

# In[1]:

from covid import Covid

# In[3]:

instance = Covid()

# In[4]:

instance.get_data()

# In[6]:

instance.get_status_by_country_name("India")

# In[ ]:
Exemple #2
0
# PYTHON 3.7
# BY XnuversXploitXen

from covid import Covid
import matplotlib.pyplot as pyplot
import time
from datetime import datetime
from datetime import date
import time

covid = Covid()

print('''
==============================================================================
__  __                              __  __      _       _ _  __  __          
\ \/ /_ __  _   ___   _____ _ __ ___\ \/ /_ __ | | ___ (_) |_\ \/ /___ _ __  
 \  /| '_ \| | | \ \ / / _ \ '__/ __|\  /| '_ \| |/ _ \| | __|\  // _ \ '_ \ 
 /  \| | | | |_| |\ V /  __/ |  \__ \/  \| |_) | | (_) | | |_ /  \  __/ | | |
/_/\_\_| |_|\__,_| \_/ \___|_|  |___/_/\_\ .__/|_|\___/|_|\__/_/\_\___|_| |_|
                                         |_|                                 
==============================================================================
''')

d = 'Hari (Day) = '
e = 'Bulan ke (Months) = '
f = 'Tahun (Year) = '

hari_ini = datetime.now()
tanggal = hari_ini.strftime(d + '%d, ' + e + '%m, ' + f + '%y')
print(tanggal)
Exemple #3
0
from flask import Flask, request, jsonify
from covid import Covid
from flask_cors import CORS
import json

c = Covid(source="worldometers")

app = Flask(__name__)
"""
This will provide the summary of all the available countries
"""


@app.route('/')
def get_status():
    data = c.get_data()

    data = [{
        'country':
        d['country'],
        'confirmed':
        d['confirmed'],
        'active':
        d['active'],
        'deaths':
        d['deaths'],
        'Recovery Rate':
        round(d['recovered'] / d['confirmed'], 4),
        'Percentage of Population Infected':
        round(d['confirmed'] / int(d['population']), 4)
    } for d in data if int(d['population']) > 0]
Exemple #4
0
def showdata():
    # importing matplotlib which will be used to show data graphically
    from matplotlib import pyplot as plt
    # to scale the data we are importing patches
    import matplotlib.patches as mpatches
    # importing covid library
    from covid import Covid
    # initializing covid library
    covid = Covid()
    # declaring empty lists to store different data sets
    cases = []
    confirmed = []
    active = []
    deaths = []
    recovered = []
    # using try and except to run program without errors
    try:
        # updating root
        root.update()
        # getting countries names entered by the user
        countries = data.get()
        # removing white spaces from the start and end of the string
        country_names = countries.strip()
        # replacing white spaces with commas inside the string
        country_names = country_names.replace(" ", ",")
        # splitting the string to store names of countries
        # as a list
        country_names = country_names.split(",")
        # for loop to get all countries data
        for x in country_names:
            # appending countries data one-by-one in cases list
            # here, the data will be stored as a dictionary
            # for one country i.e. for each country
            # there will be one dictionary in the list
            # which will contain the whole information
            # of that country
            cases.append(covid.get_status_by_country_name(x))
            # updating the root
            root.update()
        # for loop to get one country data stored as dict in list cases
        for y in cases:
            # storing every Country's confirmed cases in the confirmed list
            confirmed.append(y["confirmed"])
            # storing every Country's active cases in the active list
            active.append(y["active"])
            # storing every Country's deaths cases in the deaths list
            deaths.append(y["deaths"])
            # storing every Country's recovered cases in the recovered list
            recovered.append(y["recovered"])
        # marking the color information on scaleusing patches
        confirmed_patch = mpatches.Patch(color='green', label='confirmed')
        recovered_patch = mpatches.Patch(color='red', label='recovered')
        active_patch = mpatches.Patch(color='blue', label='active')
        deaths_patch = mpatches.Patch(color='black', label='deaths')
        # plotting the scale on graph using legend()
        plt.legend(handles=[
            confirmed_patch, recovered_patch, active_patch, deaths_patch
        ])
        # showing the data using graphs
        # this whole for loop section is related to matplotlib
        for x in range(len(country_names)):
            plt.bar(country_names[x], confirmed[x], color='green')
            if recovered[x] > active[x]:
                plt.bar(country_names[x], recovered[x], color='red')
                plt.bar(country_names[x], active[x], color='blue')
            else:
                plt.bar(country_names[x], active[x], color='blue')
                plt.bar(country_names[x], recovered[x], color='red')
            plt.bar(country_names[x], deaths[x], color='black')
        # setting the title of the graph
        plt.title('Current Covid Cases')
        # giving label to x direction of graph
        plt.xlabel('Country Name')
        # giving label to y direction of graph
        plt.ylabel('Cases(in millions)')
        # showing the full graph
        plt.show()
    except Exception as e:
        # asking user to enter correct details
        # during entering the country names on GUI
        # please differentiate the country names
        # with spaces or comma but not with both
        # otherwise you will come to this section
        data.set("Enter correct details again")
Exemple #5
0
import os
import sys

current_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.abspath(current_dir + "/../service"))

from covid import Covid

if __name__=="__main__":
    # print("Hello World!")
    obj_covid = Covid()
    var_meninggal = obj_covid.get_meninggal()
    print(var_meninggal)
from covid import Covid
c = Covid()
print(c.list_countries())