<commit_before>__author__ = 'patrick'
import psycopg2
import os
import yweather
import urllib
import hashlib
from xml.dom import minidom
from django.shortcuts import render

WEATHER_URLY = 'http://xml.weather.yahoo.com/forecastrss?w=%s&u=c'
WEATHER_NSY = 'http://xml.weather.yahoo.com/ns/rss/1.0'

client = yweather.Client()
woeid = client.fetch_woeid('Berlin')

url = WEATHER_URLY % woeid
dom = minidom.parse(urllib.urlopen(url))
forecasts = []
ycondition = dom.getElementsByTagNameNS(WEATHER_NSY, 'condition')[0]
yastronomy = dom.getElementsByTagNameNS(WEATHER_NSY, 'astronomy')[0]
ywind = dom.getElementsByTagNameNS(WEATHER_NSY, 'wind')[0]
yunits = dom.getElementsByTagNameNS(WEATHER_NSY, 'units')[0]

ywind.getAttribute('speed'),
ywind.getAttribute('direction'),
yunits.getAttribute('temperature'),
yastronomy.getAttribute('sunrise'),
ycondition.getAttribute('temp'),
yastronomy.getAttribute('sunset'),
ycondition.getAttribute('text'),
ycondition.getAttribute('temp'),
ycondition.getAttribute('code'),
forecasts,
dom.getElementsByTagName('title')[0].firstChild.data


connection = psycopg2.connect(os.environ['OPENSHIFT_APP_NAME'])
cursor = connection.cursor()
cursor.execute("INSERT INTO PythonWetter_weather (Datum, Stadt, Anbieter, Wetter, Tagestemperatur, Einheit, Kondition, Windgeschwindigkeit, Windrichtung) VALUES ('2014-10-21','Potsdam','Yahoo','test',10,'C',30,60,'SW'),",)
connection.commit()
connection.close()<commit_msg>Inputscript<commit_after>__author__ = 'patrick'
import psycopg2
import os
import yweather
import urllib
import hashlib
from xml.dom import minidom
from django.shortcuts import render

WEATHER_URLY = 'http://xml.weather.yahoo.com/forecastrss?w=%s&u=c'
WEATHER_NSY = 'http://xml.weather.yahoo.com/ns/rss/1.0'

client = yweather.Client()
woeid = client.fetch_woeid('Berlin')

url = WEATHER_URLY % woeid
dom = minidom.parse(urllib.urlopen(url))
forecasts = []
ycondition = dom.getElementsByTagNameNS(WEATHER_NSY, 'condition')[0]
yastronomy = dom.getElementsByTagNameNS(WEATHER_NSY, 'astronomy')[0]
ywind = dom.getElementsByTagNameNS(WEATHER_NSY, 'wind')[0]
yunits = dom.getElementsByTagNameNS(WEATHER_NSY, 'units')[0]

ywind.getAttribute('speed'),
ywind.getAttribute('direction'),
yunits.getAttribute('temperature'),
yastronomy.getAttribute('sunrise'),
ycondition.getAttribute('temp'),
yastronomy.getAttribute('sunset'),
ycondition.getAttribute('text'),
ycondition.getAttribute('temp'),
ycondition.getAttribute('code'),
forecasts,
dom.getElementsByTagName('title')[0].firstChild.data


connection = psycopg2.connect(database='pythonwetter', user=os.environ['OPENSHIFT_POSTGRESQL_DB_USERNAME'], password=os.environ['OPENSHIFT_POSTGRESQL_DB_PASSWORD'], host=os.environ['OPENSHIFT_POSTGRESQL_DB_HOST'], port=os.environ['OPENSHIFT_POSTGRESQL_DB_PORT'])
cursor = connection.cursor()
cursor.execute("INSERT INTO PythonWetter_weather (Datum, Stadt, Anbieter, Wetter, Tagestemperatur, Einheit, Kondition, Windgeschwindigkeit, Windrichtung) VALUES ('2014-10-21','Potsdam','Yahoo',%s,10,'C',30,60,'SW'),", ycondition.getAttribute('text'),)
connection.commit()
connection.close()
{'fraction_non_alphanumeric': 0.15054803352675694, 'fraction_numerical': 0.014829142488716958, 'mean_word_length': 9.483108108108109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1937152', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1108, 'n_words': 158}