Skip to content

Commit

Permalink
PyPI v0.1.2 3-Alpha Test Release
Browse files Browse the repository at this point in the history
Signed-off-by: vatsa287 <i.mnshreevatsa@gmail.com>
  • Loading branch information
vatsa287 committed Jul 29, 2020
1 parent 24a5d62 commit be85d00
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 12 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cli-weather command [-h] [-c COUNTRY] [-u UNITS] [-d] city_name/postal_code
Fork this repository
$ git clone "https://github.com/username/cli-weather"
$ cd cli_weather
$ pip install -r requirements.txt
$ pip install requests
$ python main.py [command] [options]
```
Expand All @@ -56,6 +56,14 @@ $ python main.py [command] [options]

GNU General Public License v3.0

**ver 0.1.2**

3 - Alpha Test Release
- Python2 and Python3 compatible
- Introductio of wheel distribution in binary
- Minor bug fixes in setup.py


**ver 0.1.1**

3 - Alpha Test Release
Expand All @@ -68,4 +76,4 @@ GNU General Public License v3.0
- Get weather by city
- Get weather by postalcode
- Change units according as you wish [Metric/Scientific/Farenheit]
- Only temparature by default, detailed information from snowfall to solar radiation
- Only temparature by default, detailed information from snowfall to solar radiation using -d
9 changes: 9 additions & 0 deletions build/lib.linux-x86_64-2.7/cli_weather/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
cli-weather
Get fast updates on weather-data right on the command line.
"""

__version__ = "0.1.0"
__author__ = 'Shree Vatsa N'

94 changes: 94 additions & 0 deletions build/lib.linux-x86_64-2.7/cli_weather/get_by_city.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from __future__ import print_function
import requests
import argparse

def get_by_city_args(subparsers):
city_parser = subparsers.add_parser('city',
formatter_class=argparse.RawTextHelpFormatter
)
city_parser.add_argument(
"city",
help="get weather by city name"
)
city_parser.add_argument(
"-c", "--country",
help="country of entered area",
default=""
)
city_parser.add_argument(
"-u", "--units",
help="M - [DEFAULT] Metric (Celcius, m/s, mm)\nS - Scientific (Kelvin, m/s, mm)\nI - Fahrenheit (F, mph, in)",
default="M"
)
city_parser.add_argument(
"-d","--detailed",
help="display detailed weather data",
action="store_true"
)

def city_parse(args):
city = args.city
country = "&" + args.country
units = args.units
API_KEY = "2a7db0585e7541018229c17efb2efa94"

if args.country == "":
API_URL = "https://api.weatherbit.io/v2.0/current?city="+city+"&key="
else:
API_URL = "https://api.weatherbit.io/v2.0/current?city="+city+country+"&key="

url = API_URL + API_KEY

querystring = {
"lang":"en",
"units":units
}

response = requests.request("GET", url, params=querystring)

try:
main_data = response.json()
# ValueError-unable to decode json, UnboundLocalError-used var before declaring
except (ValueError,UnboundLocalError) as err:
print("Invalid city")
print("Please use format ex: $ cli-weather bengaluru [-c country_name][-u S/M/F][-d]")
return

data = main_data['data']
weather = data[0]['weather']
# defalut metric values
degree = "celcius"
speed = "m/s"
distance = "mm"

if args.units == "S":
degree = "kelvin"
elif args.units == "F":
degree = "Fahrenheit"
speed = "mph"
distance = "in"

if args.detailed:
print("Have a nice day!\n")
print("city : {}".format(args.city.capitalize()))
print("temparature : {} {}".format(data[0]['temp'],degree))
print("summary : {}".format(weather['description']))
print("source station ID : {}".format(data[0]['station']))
print("latitude : {} degrees".format(data[0]['lat']))
print("longitude : {} degrees".format(data[0]['lon']))
print("timezone : {}".format(data[0]['timezone']))
print("last observation time : {}".format(data[0]['ob_time']))
print("sunrise : {}".format(data[0]['sunrise']))
print("sunset : {}".format(data[0]['sunset']))
print("pressure : {} mb".format(data[0]['pres']))
print("sea level pressure : {} mb".format(data[0]['slp']))
print("wind speed : {} {}".format(data[0]['wind_spd'],speed))
print("wind direction : {} degrees".format(data[0]['wind_dir']))
print("visibility : {} KM".format(data[0]['vis']))
print("relative humidity : {} %".format(data[0]['rh']))
print("snowfall : {} {}/hr".format(data[0]['snow'],distance))
print("estimated solar radiation: {} W/m^2".format(data[0]['solar_rad']))

elif args.detailed is False:
print("Current temparature in {} is {} {}" .format(city.capitalize(), data[0]['temp'], degree))

93 changes: 93 additions & 0 deletions build/lib.linux-x86_64-2.7/cli_weather/get_by_postalcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from __future__ import print_function
import requests
import argparse

def get_by_postalcode_args(subparsers):
postalcode_parser = subparsers.add_parser('postalcode',
formatter_class=argparse.RawTextHelpFormatter
)
postalcode_parser.add_argument(
"postalcode",
help="get weather by postal code"
)
postalcode_parser.add_argument(
"-c", "--country",
help="country of entered area",
default=""
)
postalcode_parser.add_argument(
"-u", "--units",
help="M - [DEFAULT] Metric (Celcius, m/s, mm)\nS - Scientific (Kelvin, m/s, mm)\nI - Fahrenheit (F, mph, in)",
default="M"
)
postalcode_parser.add_argument(
"-d","--detailed",
help="display sdetailed weather data",
action="store_true"
)

def postalcode_parse(args):
postalcode = args.postalcode
country = "&" + args.country
units = args.units
API_KEY = "2a7db0585e7541018229c17efb2efa94"

if args.country == "":
API_URL = "https://api.weatherbit.io/v2.0/current?postal_code="+postalcode+"&key="
else:
API_URL = "https://api.weatherbit.io/v2.0/current?postal_code="+postalcode+country+"&key="

url = API_URL + API_KEY

querystring = {
"lang":"en",
"units":units
}

response = requests.request("GET", url, params=querystring)

try:
main_data = response.json()
# ValueError-unable to decode json, UnboundLocalError-used var before declaring
except (ValueError,UnboundLocalError) as err:
print("Invalid postal-code")
print("Please use format ex: $ cli-weather postal-code 560032 [-c country_name][-u S/M/F][-d]")
return

data = main_data['data']
weather = data[0]['weather']
# defalut metric values
degree = "celcius"
speed = "m/s"
distance = "mm"

if args.units == "S":
degree = "kelvin"
elif args.units == "F":
degree = "Fahrenheit"
speed = "mph"
distance = "in"

if args.detailed:
print("Have a nice day!\n")
print("city : {}".format(data[0]['city_name'].capitalize()))
print("temparature : {} {}".format(data[0]['temp'],degree))
print("summary : {}".format(weather['description']))
print("source station ID : {}".format(data[0]['station']))
print("latitude : {} degrees".format(data[0]['lat']))
print("longitude : {} degrees".format(data[0]['lon']))
print("timezone : {}".format(data[0]['timezone']))
print("last observation time : {}".format(data[0]['ob_time']))
print("sunrise : {}".format(data[0]['sunrise']))
print("sunset : {}".format(data[0]['sunset']))
print("pressure : {} mb".format(data[0]['pres']))
print("sea level pressure : {} mb".format(data[0]['slp']))
print("wind speed : {} {}".format(data[0]['wind_spd'],speed))
print("wind direction : {} degrees".format(data[0]['wind_dir']))
print("visibility : {} KM".format(data[0]['vis']))
print("relative humidity : {} %".format(data[0]['rh']))
print("snowfall : {} {}/hr".format(data[0]['snow'],distance))
print("estimated solar radiation: {} W/m^2".format(data[0]['solar_rad']))
elif args.detailed is False:
print("Current temparature in {} is {} {}" .format(data[0]['city_name'].capitalize(), data[0]['temp'], degree))

29 changes: 29 additions & 0 deletions build/lib.linux-x86_64-2.7/cli_weather/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import print_function
import argparse

# handle ModuleNotFoundError python3 execution
try:
from cli_weather.get_by_city import get_by_city_args, city_parse
from cli_weather.get_by_postalcode import get_by_postalcode_args, postalcode_parse
except ModuleNotFoundError:
from get_by_city import get_by_city_args, city_parse
from get_by_postalcode import get_by_postalcode_args, postalcode_parse

def main():
parser = argparse.ArgumentParser('cli-weather')

# dest - name of the attribute under which sub-command name will be stored, defalut=None
subparsers = parser.add_subparsers(dest="selected_subparser")
get_by_city_args(subparsers)
get_by_postalcode_args(subparsers)
args = parser.parse_args()

# args.selected_subparser holds selectd subparser in <str>
if args.selected_subparser == "city":
city_parse(args)
elif args.selected_subparser == "postalcode":
postalcode_parse(args)

if __name__ == "__main__":
main()

14 changes: 11 additions & 3 deletions cli_weather.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: cli-weather
Version: 0.1.1
Version: 0.1.2
Summary: Lightweight command line app to get fast weather data right on the command line
Home-page: https://github.com/vatsa287/cli-weather
Author: Shree Vatsa N
Expand Down Expand Up @@ -55,7 +55,7 @@ Description: # cli-weather
Fork this repository
$ git clone "https://github.com/username/cli-weather"
$ cd cli_weather
$ pip install -r requirements.txt
$ pip install requests
$ python main.py [command] [options]

```
Expand All @@ -64,6 +64,14 @@ Description: # cli-weather

GNU General Public License v3.0

**ver 0.1.2**

3 - Alpha Test Release
- Python2 and Python3 compatible
- Introductio of wheel distribution in binary
- Minor bug fixes in setup.py


**ver 0.1.1**

3 - Alpha Test Release
Expand All @@ -76,7 +84,7 @@ Description: # cli-weather
- Get weather by city
- Get weather by postalcode
- Change units according as you wish [Metric/Scientific/Farenheit]
- Only temparature by default, detailed information from snowfall to solar radiation
- Only temparature by default, detailed information from snowfall to solar radiation using -d
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: Utilities
Expand Down
Binary file modified cli_weather/__pycache__/get_by_city.cpython-36.pyc
Binary file not shown.
Binary file modified cli_weather/__pycache__/get_by_postalcode.cpython-36.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions cli_weather/get_by_city.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import requests
import argparse

Expand Down
3 changes: 2 additions & 1 deletion cli_weather/get_by_postalcode.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import requests
import argparse

Expand Down Expand Up @@ -89,4 +90,4 @@ def postalcode_parse(args):
print("estimated solar radiation: {} W/m^2".format(data[0]['solar_rad']))
elif args.detailed is False:
print("Current temparature in {} is {} {}" .format(data[0]['city_name'].capitalize(), data[0]['temp'], degree))


14 changes: 11 additions & 3 deletions cli_weather/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from __future__ import print_function
import argparse
from get_by_city import get_by_city_args, city_parse
from get_by_postalcode import get_by_postalcode_args, postalcode_parse

# handle ModuleNotFoundError python3 execution
try:
from cli_weather.get_by_city import get_by_city_args, city_parse
from cli_weather.get_by_postalcode import get_by_postalcode_args, postalcode_parse
except ModuleNotFoundError:
from get_by_city import get_by_city_args, city_parse
from get_by_postalcode import get_by_postalcode_args, postalcode_parse

def main():
parser = argparse.ArgumentParser('cli-weather')
Expand All @@ -18,4 +25,5 @@ def main():
postalcode_parse(args)

if __name__ == "__main__":
main()
main()

Binary file removed dist/cli-weather-0.1.1.tar.gz
Binary file not shown.
Binary file added dist/cli-weather-0.1.2.tar.gz
Binary file not shown.
Binary file added dist/cli_weather-0.1.2-py2.py3-none-any.whl
Binary file not shown.
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from setuptools import setup

long_description = open('/home/vatsa/cli-weather/PyPIDocumentation.md').read()
with open('README.md') as f:
long_description = f.read()

setup(
name='cli-weather',
version='0.1.1',
version='0.1.2',
description='Lightweight command line app to get fast weather data right on the command line',
long_description_content_type='text/markdown',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/vatsa287/cli-weather',
author='Shree Vatsa N',
author_email='i.mnshreevatsa@gmail.com',
Expand Down

0 comments on commit be85d00

Please sign in to comment.