kopia lustrzana https://github.com/sq9atk/sr0wx
Applied 2to3; added requirements.txt
rodzic
e4ec0b31d1
commit
cd82f95db4
|
@ -20,7 +20,7 @@ import base64
|
|||
import logging
|
||||
import json
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
|
||||
from sr0wx_module import SR0WXModule
|
||||
|
||||
|
@ -81,8 +81,8 @@ Parameters:
|
|||
|
||||
|
||||
try:
|
||||
request = urllib2.Request(url)
|
||||
webFile = urllib2.urlopen(request, None, 5)
|
||||
request = urllib.request.Request(url)
|
||||
webFile = urllib.request.urlopen(request, None, 5)
|
||||
response = webFile.read()
|
||||
|
||||
if response == 'OK':
|
||||
|
@ -92,10 +92,10 @@ Parameters:
|
|||
self.__logger.error(log, url, response)
|
||||
return dict()
|
||||
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import logging
|
||||
import json
|
||||
import socket
|
||||
|
@ -31,12 +31,12 @@ class AirPollutionSq9atk(SR0WXModule):
|
|||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
|
||||
try:
|
||||
data = urllib2.urlopen(url, None, 45)
|
||||
data = urllib.request.urlopen(url, None, 45)
|
||||
return json.load(data)
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
|
||||
return {}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class AirPollutionSq9atk(SR0WXModule):
|
|||
value = self.getSensorValue(row['id'])
|
||||
if(value[1]>1): # czasem tu schodzi none
|
||||
qualityIndexName = self.mbstr2asci(value[0]) + "IndexLevel"
|
||||
if levelIndexArray.has_key(qualityIndexName):
|
||||
if qualityIndexName in levelIndexArray:
|
||||
index = levelIndexArray[qualityIndexName]['indexLevelName']
|
||||
else:
|
||||
index = 'empty'
|
||||
|
@ -119,7 +119,7 @@ class AirPollutionSq9atk(SR0WXModule):
|
|||
message = " _ informacja_o_skaz_eniu_powietrza _ "
|
||||
message += " stacja_pomiarowa " + self.mbstr2asci(self.getStationName()) + " _ "
|
||||
message += valuesMessage
|
||||
print "\n"
|
||||
print("\n")
|
||||
return {
|
||||
"message": message,
|
||||
"source": "powietrze_malopolska_pl",
|
||||
|
@ -128,12 +128,12 @@ class AirPollutionSq9atk(SR0WXModule):
|
|||
def mbstr2asci(self, string):
|
||||
"""Zwraca "bezpieczną" nazwę dla wyrazu z polskimi znakami diakrytycznymi"""
|
||||
return string.lower().\
|
||||
replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'x_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'').replace(u'.',u'').\
|
||||
replace(u',',u'')
|
||||
replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','x_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','').replace('.','').\
|
||||
replace(',','')
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import json as JSON
|
||||
|
@ -86,14 +86,14 @@ class AirlySq9atk(SR0WXModule):
|
|||
|
||||
|
||||
def getAirlyData(self, url):
|
||||
request = urllib2.Request(url, headers={'Accept': 'application/json', 'apikey': self.__api_key})
|
||||
request = urllib.request.Request(url, headers={'Accept': 'application/json', 'apikey': self.__api_key})
|
||||
try:
|
||||
webFile = urllib2.urlopen(request, None, 30)
|
||||
webFile = urllib.request.urlopen(request, None, 30)
|
||||
return webFile.read()
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
return ""
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import re
|
||||
import logging
|
||||
import pytz
|
||||
|
@ -23,12 +23,12 @@ class CalendarSq9atk(SR0WXModule):
|
|||
def downloadFile(self, url):
|
||||
try:
|
||||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
webFile = urllib2.urlopen(url, None, 30)
|
||||
webFile = urllib.request.urlopen(url, None, 30)
|
||||
return webFile.read()
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
return ""
|
||||
|
||||
def getSunsetSunrise(self):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging, re, subprocess
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import time
|
||||
from pprint import pprint
|
||||
|
||||
|
@ -36,11 +36,11 @@ class GeoMagneticSq9atk(SR0WXModule):
|
|||
|
||||
def downloadDataFromUrl(self, url):
|
||||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
opener = urllib2.build_opener()
|
||||
opener = urllib.request.build_opener()
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 5.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1',
|
||||
}
|
||||
opener.addheaders = headers.items()
|
||||
opener.addheaders = list(headers.items())
|
||||
response = opener.open(url)
|
||||
|
||||
return response.read()
|
||||
|
@ -81,14 +81,14 @@ class GeoMagneticSq9atk(SR0WXModule):
|
|||
'value':0,
|
||||
'at':0,
|
||||
}
|
||||
for key, row in data.iteritems():
|
||||
for key, row in data.items():
|
||||
if row > maxValue['value']:
|
||||
maxValue['value'] = row
|
||||
maxValue['at'] = key
|
||||
return maxValue
|
||||
|
||||
def getDailyFluctuation(self, data):
|
||||
values = data.values()
|
||||
values = list(data.values())
|
||||
return int(max(values)) - int(min(values))
|
||||
|
||||
def get_data(self):
|
||||
|
@ -98,7 +98,7 @@ class GeoMagneticSq9atk(SR0WXModule):
|
|||
message = ' _ sytuacja_geomagnetyczna_w_regionie ';
|
||||
|
||||
self.__logger.info("::: Przetwarzam dane...\n")
|
||||
for d, day in daysValues.iteritems():
|
||||
for d, day in daysValues.items():
|
||||
|
||||
if len(day) > 0:
|
||||
a=1
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import re
|
||||
import json
|
||||
import logging
|
||||
|
@ -48,14 +48,14 @@ class ImgwPodestSq9atk(SR0WXModule):
|
|||
s.__logger.info("Nie udało się pobrać danych o wodowskazach!")
|
||||
|
||||
def bezpiecznaNazwa(s, nazwa):
|
||||
return unicode(nazwa, 'utf-8').lower().\
|
||||
replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'z_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'')
|
||||
return str(nazwa, 'utf-8').lower().\
|
||||
replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','z_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','')
|
||||
|
||||
def pobierzDaneWodowskazu(s, wodowskaz):
|
||||
global wodowskazy
|
||||
|
@ -119,7 +119,7 @@ class ImgwPodestSq9atk(SR0WXModule):
|
|||
|
||||
if w['przekroczenieStanu'] == 'ostrzegawczy':
|
||||
s.__logger.info("::: Stan ostrzegawczy: " + wodowskaz + " - " + rzeka + ' - ' + w['nazwa_org'])
|
||||
if not stanyOstrzegawcze.has_key(w['rzeka']):
|
||||
if w['rzeka'] not in stanyOstrzegawcze:
|
||||
stanyOstrzegawcze[w['rzeka']] = [w['nazwa']+ ' ' + w['tendencja'] + ' _ ']
|
||||
|
||||
else:
|
||||
|
@ -127,7 +127,7 @@ class ImgwPodestSq9atk(SR0WXModule):
|
|||
|
||||
elif w['przekroczenieStanu'] == 'alarmowy':
|
||||
s.__logger.info("::: Stan alarmowy: "+ wodowskaz+" - " + rzeka + ' - ' + w['nazwa_org'])
|
||||
if not stanyAlarmowe.has_key(w['rzeka']):
|
||||
if w['rzeka'] not in stanyAlarmowe:
|
||||
stanyAlarmowe[w['rzeka']] = [w['nazwa']+ ' ' + w['tendencja'] + ' _ ']
|
||||
|
||||
else:
|
||||
|
|
|
@ -528,5 +528,5 @@ class Sun:
|
|||
if __name__ == "__main__":
|
||||
|
||||
k = Sun()
|
||||
print k.get_max_solar_flux(46.2, 2004, 01, 30)
|
||||
print(k.get_max_solar_flux(46.2, 2004, 0o1, 30))
|
||||
# print k.sunRiseSet(2002, 3, 22, 25.42, 62.15)
|
||||
|
|
|
@ -46,9 +46,9 @@ def main():
|
|||
pygame.mixer.pre_init(44100,-16,2,1024)
|
||||
pygame.mixer.init(44100,-16,2,1024)
|
||||
#pygame.init()
|
||||
print "Testing CTCSS capability"
|
||||
print("Testing CTCSS capability")
|
||||
for tone in sorted(CTCSSTones.keys()):
|
||||
print "Tone %s, %s Hz..."%(tone,CTCSSTones[tone])
|
||||
print("Tone %s, %s Hz..."%(tone,CTCSSTones[tone]))
|
||||
s= pygame.sndarray.make_sound(getCTCSS(CTCSSTones[tone]))
|
||||
c=s.play(300)
|
||||
while c.get_busy():
|
||||
|
|
|
@ -114,11 +114,11 @@ def cw(text, wpm=25, farnsworth=None, weight=None, pitch=600, volume=0.1, sample
|
|||
if letter in morse:
|
||||
for beep in morse[letter]:
|
||||
if beep==".":
|
||||
if letters.has_key(letter):
|
||||
if letter in letters:
|
||||
letters[letter]=Numeric.concatenate( (letters[letter],dit) )
|
||||
else: letters[letter]=dit
|
||||
else:
|
||||
if letters.has_key(letter):
|
||||
if letter in letters:
|
||||
letters[letter]=Numeric.concatenate( (letters[letter],dah) )
|
||||
else: letters[letter]=dah
|
||||
letters[letter]=Numeric.concatenate( (letters[letter],interLetter) )
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import re
|
||||
import datetime
|
||||
|
||||
|
@ -29,7 +29,7 @@ class imgw_prognoza:
|
|||
|
||||
|
||||
def downloadFile(self, url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import fpformat
|
||||
import math
|
||||
import re
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
|
||||
__author__ = "klausman-pymetar@schwarzvogel.de"
|
||||
|
||||
|
@ -759,8 +759,7 @@ class ReportParser:
|
|||
parsed values filled in. Note: This function edits the
|
||||
WeatherReport object you supply!"""
|
||||
if self.Report is None and MetarReport is None:
|
||||
raise EmptyReportException, \
|
||||
"No report given on init and ParseReport()."
|
||||
raise EmptyReportException("No report given on init and ParseReport().")
|
||||
elif MetarReport is not None:
|
||||
self.Report = MetarReport
|
||||
|
||||
|
@ -957,8 +956,7 @@ class ReportFetcher:
|
|||
is inspected. If it isn't set, a direct connection is tried.
|
||||
"""
|
||||
if self.stationid is None and StationCode is None:
|
||||
raise EmptyIDException, \
|
||||
"No ID given on init and FetchReport()."
|
||||
raise EmptyIDException("No ID given on init and FetchReport().")
|
||||
elif StationCode is not None:
|
||||
self.stationid = StationCode
|
||||
|
||||
|
@ -967,23 +965,23 @@ class ReportFetcher:
|
|||
|
||||
if proxy:
|
||||
p_dict = {'http': proxy}
|
||||
p_handler = urllib2.ProxyHandler(p_dict)
|
||||
opener = urllib2.build_opener(p_handler, urllib2.HTTPHandler)
|
||||
urllib2.install_opener(opener)
|
||||
p_handler = urllib.request.ProxyHandler(p_dict)
|
||||
opener = urllib.request.build_opener(p_handler, urllib.request.HTTPHandler)
|
||||
urllib.request.install_opener(opener)
|
||||
else:
|
||||
urllib2.install_opener(
|
||||
urllib2.build_opener(urllib2.ProxyHandler, urllib2.HTTPHandler))
|
||||
urllib.request.install_opener(
|
||||
urllib.request.build_opener(urllib.request.ProxyHandler, urllib.request.HTTPHandler))
|
||||
|
||||
try:
|
||||
fn = urllib2.urlopen(self.reporturl)
|
||||
except urllib2.HTTPError, why:
|
||||
raise NetworkException, why
|
||||
fn = urllib.request.urlopen(self.reporturl)
|
||||
except urllib.error.HTTPError as why:
|
||||
raise NetworkException(why)
|
||||
|
||||
# Dump entire report in a variable
|
||||
self.fullreport = fn.read()
|
||||
|
||||
if fn.info().status:
|
||||
raise NetworkException, "Could not fetch METAR report"
|
||||
raise NetworkException("Could not fetch METAR report")
|
||||
|
||||
report = WeatherReport(self.stationid)
|
||||
report.reporturl = self.reporturl
|
||||
|
|
|
@ -28,5 +28,5 @@ for word in dictionary.download_list:
|
|||
replace("ź","z").replace("ż","z")
|
||||
|
||||
if not os.path.exists("%s.ogg"%filename):
|
||||
print "%s;%s"%(filename,word[0])
|
||||
print("%s;%s"%(filename,word[0]))
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ def log(moduleName, message, buglevel=0):
|
|||
message = prefix + message.replace("\n","".join( ("\r\n",prefix) ))
|
||||
|
||||
if buglevel>=config.showLevel:
|
||||
print message
|
||||
print(message)
|
||||
if buglevel>=config.writeLevel:
|
||||
filename = dt.strftime("%y-%m-%d")+".log"
|
||||
if not os.path.exists(filename):
|
||||
|
@ -47,7 +47,7 @@ def log(moduleName, message, buglevel=0):
|
|||
try:
|
||||
logfile.write(message + '\n')
|
||||
except:
|
||||
print dt.strftime("%x %X UTC")+" [DEBUG]:\tCan't write to file!"
|
||||
print(dt.strftime("%x %X UTC")+" [DEBUG]:\tCan't write to file!")
|
||||
finally:
|
||||
logfile.close()
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class debug():
|
|||
|
||||
if buglevel>=config.showLevel:
|
||||
self.msgs = self.msgs + message
|
||||
print formattedMessage
|
||||
print(formattedMessage)
|
||||
if buglevel>=config.writeLevel:
|
||||
try:
|
||||
if not os.path.exists(self.filename):
|
||||
|
@ -80,7 +80,7 @@ class debug():
|
|||
logfile = open(self.filename, 'a+')
|
||||
logfile.write(formattedMessage + '\n')
|
||||
except:
|
||||
print dt.strftime("%x %X UTC")+" [DEBUG]:\tCan't write to file!"
|
||||
print(dt.strftime("%x %X UTC")+" [DEBUG]:\tCan't write to file!")
|
||||
finally:
|
||||
logfile.close()
|
||||
|
||||
|
@ -88,14 +88,14 @@ class debug():
|
|||
# run gether(). Both functions do the same except
|
||||
def gather(self):
|
||||
if not self.logGathered:
|
||||
print "\n\nHash of traceback is %s. Hope it helps in debugging. You can find whole log at %s ."%\
|
||||
('%X'%(self.msgs.__hash__()+int('ffffffff',16)), "".join( (config.baseURI, self.filename) ) )
|
||||
print("\n\nHash of traceback is %s. Hope it helps in debugging. You can find whole log at %s ."%\
|
||||
('%X'%(self.msgs.__hash__()+int('ffffffff',16)), "".join( (config.baseURI, self.filename) ) ))
|
||||
self.logGathered = True
|
||||
|
||||
def __del__(self):
|
||||
if not self.logGathered:
|
||||
print "\n\nHash of traceback is %s. Hope it helps in debugging. You can find whole log at %s ."%\
|
||||
('%X'%(self.msgs.__hash__()+int('ffffffff',16)), "".join( (config.baseURI, self.filename) ) )
|
||||
print("\n\nHash of traceback is %s. Hope it helps in debugging. You can find whole log at %s ."%\
|
||||
('%X'%(self.msgs.__hash__()+int('ffffffff',16)), "".join( (config.baseURI, self.filename) ) ))
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# This file is ugly, dirty, and probably useless when downloading
|
||||
# other samples than polish. But I will fix it one day.
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import os, sys
|
||||
import subprocess
|
||||
|
||||
|
@ -49,7 +49,7 @@ for word in dictionary.download_list:
|
|||
|
||||
#url = "\"http://translate.google.com/translate_tts?tl=pl&q=%s\""%urllib.quote_plus(phrase+" .")
|
||||
#os.system("wget -q -U \"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6\" -O %s.mp3 %s"%(filename,url))
|
||||
url = u"\"http://translate.google.com/translate_tts?tl=%s&q=%s&total=1&idx=0&client=t\"" % (dictionary.LANGUAGE, urllib.quote_plus(phrase + " ."))
|
||||
url = "\"http://translate.google.com/translate_tts?tl=%s&q=%s&total=1&idx=0&client=t\"" % (dictionary.LANGUAGE, urllib.parse.quote_plus(phrase + " ."))
|
||||
os.system("wget -q -U 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36' -O %s.mp3 %s" % (filename, url))
|
||||
|
||||
os.system("lame --decode %s.mp3 %s.wav"%(filename,filename))
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
#
|
||||
|
||||
import re
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
|
||||
from config import gopr_lawiny as config
|
||||
import datetime
|
||||
lang=None
|
||||
|
||||
def downloadFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
def my_import(name):
|
||||
|
@ -98,5 +98,5 @@ def getData(l):
|
|||
|
||||
if __name__ == '__main__':
|
||||
lang = 'pl'
|
||||
print getData(lang)
|
||||
print(getData(lang))
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
#
|
||||
|
||||
import re
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
|
||||
from config import hscr_laviny as config
|
||||
import datetime
|
||||
lang=None
|
||||
|
||||
def downloadFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
def my_import(name):
|
||||
|
@ -45,7 +45,7 @@ def getAwareness(region):
|
|||
url = "http://www.horskasluzba.cz/laviny/"
|
||||
|
||||
# We'll have to find link to the most actual info for the specified region:
|
||||
r = u'id\=(\d{4,}).{10,}Lavinov.{5,}'+region # UGLY, but \" doesn't work...
|
||||
r = 'id\=(\d{4,}).{10,}Lavinov.{5,}'+region # UGLY, but \" doesn't work...
|
||||
_id = re.compile(r)
|
||||
|
||||
for line in downloadFile(url).split('\n'):
|
||||
|
@ -66,7 +66,7 @@ def getAwareness(region):
|
|||
level, tendention, exposition, date = False,False,False,False
|
||||
|
||||
for line in downloadFile(url).split('\n'):
|
||||
line = unicode(line, "cp1250")
|
||||
line = str(line, "cp1250")
|
||||
level = level or last(_level.findall(line))
|
||||
tendention = tendention or last(_tendention.findall(line))
|
||||
exposition = exposition or last(_exposition.findall(line))
|
||||
|
@ -114,5 +114,5 @@ def getData(l):
|
|||
|
||||
if __name__ == '__main__':
|
||||
lang = 'pl'
|
||||
print getData('pl')
|
||||
print(getData('pl'))
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import pygame
|
||||
import datetime
|
||||
import re
|
||||
|
@ -25,7 +25,7 @@ from config import ibles as config
|
|||
lang=None
|
||||
|
||||
def downloadFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
def my_import(name):
|
||||
|
@ -88,7 +88,7 @@ def get_forecast_url():
|
|||
now = datetime.datetime.now()
|
||||
year, month, day, hour = now.year, now.month, now.day, now.hour
|
||||
|
||||
if month not in range(4,10):
|
||||
if month not in list(range(4,10)):
|
||||
return None
|
||||
else:
|
||||
webfile = downloadFile('http://bazapozarow.ibles.pl/zagrozenie/')
|
||||
|
@ -118,7 +118,7 @@ def getData(l):
|
|||
zagrozenie=max(zagrozenie, poziomy[kolor])
|
||||
|
||||
if zagrozenie>0:
|
||||
print zagrozenie
|
||||
print(zagrozenie)
|
||||
data['data']=' '.join( ('w_lasach_wystepuje ',
|
||||
poziomy_nazwy[zagrozenie],
|
||||
'zagrozenie_pozarowe',))
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# TODO: sprawdzanie, dla których wodowskazów możemy czytać komunikaty
|
||||
|
||||
import os
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import re
|
||||
|
||||
def format(s):
|
||||
|
@ -29,20 +29,20 @@ def format(s):
|
|||
rzeka Ślęza jak i Ślęża oznaczany jest każdy niełaciński
|
||||
znak"""
|
||||
if str(s.__class__)=="<type 'str'>":
|
||||
s=unicode(s, 'utf-8')
|
||||
return s.lower().replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'x_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'')
|
||||
s=str(s, 'utf-8')
|
||||
return s.lower().replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','x_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','')
|
||||
|
||||
|
||||
wodowskazy={}
|
||||
|
||||
_wodowskaz=re.compile('Stacja\:\ (.{1,}?)\<')
|
||||
_rzeka=re.compile(u"""Rzeka\:\ (.{1,}?)\<|(Jezioro\ .{1,}?)\<|(Zalew\ .{1,}?)|(Morze\ Ba..tyckie)""", re.MULTILINE)
|
||||
_rzeka=re.compile("""Rzeka\:\ (.{1,}?)\<|(Jezioro\ .{1,}?)\<|(Zalew\ .{1,}?)|(Morze\ Ba..tyckie)""", re.MULTILINE)
|
||||
_stan=re.compile('Stan\ Wody\ H\ \[cm\]\:\ (.{1,}?)\<')
|
||||
_nnw=re.compile('NNW\:(\d{1,})')
|
||||
_ssw=re.compile('SSW\:(\d{1,})')
|
||||
|
@ -54,7 +54,7 @@ _przekroczenieStanu=re.compile('stan\ (ostrzegawczy|alarmowy)')
|
|||
_przekroczenieStanuStan=re.compile('stan\ (?:ostrzegawczy|alarmowy)\</b\>\ \((\d{1,})cm\)')
|
||||
|
||||
def getFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
contents = webFile.read()
|
||||
webFile.close()
|
||||
return contents
|
||||
|
@ -142,12 +142,12 @@ def getData(l):
|
|||
w['nazwa']=bezpiecznaNazwa(w['nazwa'])
|
||||
|
||||
if w['przekroczenieStanu']=='ostrzegawczy':
|
||||
if not stanyOstrzegawcze.has_key(w['rzeka']):
|
||||
if w['rzeka'] not in stanyOstrzegawcze:
|
||||
stanyOstrzegawcze[w['rzeka']]=[w['nazwa']]
|
||||
else:
|
||||
stanyOstrzegawcze[w['rzeka']].append(w['nazwa'])
|
||||
elif w['przekroczenieStanu']=='alarmowy':
|
||||
if not stanyAlarmowe.has_key(w['rzeka']):
|
||||
if w['rzeka'] not in stanyAlarmowe:
|
||||
stanyAlarmowe[w['rzeka']]=[w['nazwa']]
|
||||
else:
|
||||
stanyAlarmowe[w['rzeka']].append(w['nazwa'])
|
||||
|
@ -178,7 +178,7 @@ def getData(l):
|
|||
return data
|
||||
|
||||
def show_help():
|
||||
print u"""
|
||||
print("""
|
||||
Lista wodowskazów danej zlewni dostępna po podaniu parametru:
|
||||
|
||||
1. Zlewnia Sanu
|
||||
|
@ -197,24 +197,24 @@ Lista wodowskazów danej zlewni dostępna po podaniu parametru:
|
|||
14. Zlewnia dolnej Odry do Kostrzynia i zalewu Szczecińskiego
|
||||
|
||||
Mapę zlewni można zobaczyć na stronie:
|
||||
http://www.pogodynka.pl/polska/podest/"""
|
||||
http://www.pogodynka.pl/polska/podest/""")
|
||||
|
||||
def bezpiecznaNazwa(s):
|
||||
"""Zwraca "bezpieczną" nazwę dla nazwy danej rzeki/danego
|
||||
wodowskazu. Ze względu na to, że w Polsce zarówno płynie
|
||||
rzeka Ślęza jak i Ślęża oznaczany jest każdy niełaciński
|
||||
znak"""
|
||||
return unicode(s, 'utf-8').lower().replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'x_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'')
|
||||
return str(s, 'utf-8').lower().replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','x_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','')
|
||||
|
||||
def podajListeWodowskazow(region):
|
||||
rv = []
|
||||
for wodowskaz in wodowskazy.keys():
|
||||
for wodowskaz in list(wodowskazy.keys()):
|
||||
try:
|
||||
w = pobierzDaneWodowskazu(wodowskaz)
|
||||
rv.append(w)
|
||||
|
@ -237,7 +237,7 @@ if __name__ == '__main__':
|
|||
# generowanie listy słów słownika; ostatnie słowo (rozielone spacją)
|
||||
# jest nazwą pliku docelowego
|
||||
|
||||
print """#!/usr/bin/python
|
||||
print("""#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Caution! I am not responsible for using these samples. Use at your own risk
|
||||
|
@ -253,14 +253,14 @@ END_MARKER = ' k'
|
|||
CUT_START = 0.9
|
||||
CUT_END=0.7
|
||||
|
||||
download_list = [ """
|
||||
frazy = [u'komunikat hydrologiczny imgw',
|
||||
u'przekroczenia stanów ostrzegawczych',
|
||||
u'przekroczenia stanów alarmowych', u'rzeka', u'wodowskaz']
|
||||
download_list = [ """)
|
||||
frazy = ['komunikat hydrologiczny imgw',
|
||||
'przekroczenia stanów ostrzegawczych',
|
||||
'przekroczenia stanów alarmowych', 'rzeka', 'wodowskaz']
|
||||
for fraza in set(frazy):
|
||||
#print fraza.encode('utf-8')
|
||||
print "\t['%s', '%s'],"%(fraza.encode('utf-8'),
|
||||
format(fraza).encode('utf-8'),)
|
||||
print("\t['%s', '%s'],"%(fraza.encode('utf-8'),
|
||||
format(fraza).encode('utf-8'),))
|
||||
|
||||
frazy=[]
|
||||
zaladujRegion(int(region))
|
||||
|
@ -268,16 +268,16 @@ download_list = [ """
|
|||
frazy.append(w['rzeka'])
|
||||
frazy.append(w['nazwa'])
|
||||
for fraza in set(frazy):
|
||||
print "\t['ę. %s', '%s'],"%(fraza, str(bezpiecznaNazwa(fraza)),)
|
||||
print ']'
|
||||
print("\t['ę. %s', '%s'],"%(fraza, str(bezpiecznaNazwa(fraza)),))
|
||||
print(']')
|
||||
elif len(sys.argv)==2 and int(sys.argv[1]) in range(1,14+1):
|
||||
# podaje listę wodowskazów w danym regionie (danej zlewni)
|
||||
region = sys.argv[1]
|
||||
zaladujRegion(int(region))
|
||||
for w in podajListeWodowskazow(int(region)):
|
||||
print "'%s.%s', # Nazwa: %s, rzeka: %s"%(region, w['numer'], w['nazwa'], w['rzeka'])
|
||||
print("'%s.%s', # Nazwa: %s, rzeka: %s"%(region, w['numer'], w['nazwa'], w['rzeka']))
|
||||
else:
|
||||
show_help()
|
||||
else:
|
||||
import debug
|
||||
from . import debug
|
||||
from config import imgw_podest as config
|
||||
|
|
|
@ -196,13 +196,13 @@ def bezpiecznaNazwa(s):
|
|||
wodowskazu. Ze względu na to, że w Polsce zarówno płynie
|
||||
rzeka Ślęza jak i Ślęża oznaczany jest każdy niełaciński
|
||||
znak"""
|
||||
return unicode(s, 'utf-8').lower().replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'x_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'')
|
||||
return str(s, 'utf-8').lower().replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','x_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','')
|
||||
|
||||
imgw_podest_sq9atk = [
|
||||
['ę. ' + fraza, bezpiecznaNazwa(fraza)]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
imieniny = {
|
||||
'01-01':'Mieczysław Mieszko Maria Mieczysława Masław Odyseusz Wilhelm',
|
||||
'01-02':'Abel Bazyli Narcyz Grzegorz Izydor Makary Odylon',
|
||||
'01-03':'Arleta Daniel Danuta Enoch Genowefa Piotr',
|
||||
|
@ -366,3 +367,4 @@
|
|||
'12-30':'Dawida Sewer Anizja Irmina Eugeniusz Rajner Sabin Katarzyna Dionizy Uniedrog Dawid',
|
||||
'12-31':'Korneliusz Sylwester Donata Mariusz Melania Saturnina Sebastian Tworzysław',
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ def getData(l):
|
|||
def getAwareness(region, tomorrow=False):
|
||||
# tommorow = False -- awareness for today
|
||||
# tommorow = True -- awareness for tommorow
|
||||
r = re.compile('pictures/aw(\d[01]?)([0234]).jpg')
|
||||
r = re.compile(r'pictures/aw(\d[01]?)([0234]).jpg')
|
||||
url = "http://www.meteoalarm.eu/index3.php?area=%s&day=%s&lang=EN"\ %(str(region),str(int(tomorrow)))
|
||||
|
||||
|
||||
|
|
|
@ -73,20 +73,20 @@
|
|||
#
|
||||
# This dictionary is used by all SR0WX modules.
|
||||
|
||||
fake_gettext = lambda(s): s
|
||||
fake_gettext = lambda s: s
|
||||
_ = fake_gettext
|
||||
|
||||
# Units and grammar cases
|
||||
hrs = ["","godziny","godzin"]
|
||||
hPa = ["hektopaskal", "hektopaskale", "hektopaskali"]
|
||||
percent = [u"procent",u"procent",u"procent"]
|
||||
percent = ["procent","procent","procent"]
|
||||
mPs = ["metr_na_sekunde", "metry_na_sekunde", "metrow_na_sekunde"]
|
||||
kmPh = ["kilometr_na_godzine", "kilometry_na_godzine", "kilometrow_na_godzine"]
|
||||
MiPh = ["", "", ""] # miles per hour -- not used
|
||||
windStrength = "sila_wiatru"
|
||||
deg = [u"stopien","stopnie","stopni"]
|
||||
deg = ["stopien","stopnie","stopni"]
|
||||
C = ["stopien_celsjusza", "stopnie_celsjusza", "stopni_celsjusza"]
|
||||
km = ["kilometr", "kilometry", u"kilometrow"]
|
||||
km = ["kilometr", "kilometry", "kilometrow"]
|
||||
mns = ["minuta","minuty","minut"]
|
||||
tendention = ['tendencja_spadkowa','', 'tendencja_wzrostowa']
|
||||
|
||||
|
@ -99,16 +99,16 @@ directions = { "N": ("północno ", "północny"),
|
|||
"S": ("południowo ", "południowy") }
|
||||
|
||||
# numbers
|
||||
jednostkiM = [u""] + u"jeden dwa trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
jednostkiF = [u""] + u"jedną dwie trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
dziesiatki = [u""] + u"""dziesięć dwadzieścia trzydzieści czterdzieści
|
||||
jednostkiM = [""] + "jeden dwa trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
jednostkiF = [""] + "jedną dwie trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
dziesiatki = [""] + """dziesięć dwadzieścia trzydzieści czterdzieści
|
||||
pięćdziesiąt sześćdziesiąt siedemdziesiąt osiemdziesiąt dziewięćdziesiąt""".split()
|
||||
nastki = u"""dziesięć jedenaście dwanaście trzynaście czternaście piętnaście
|
||||
nastki = """dziesięć jedenaście dwanaście trzynaście czternaście piętnaście
|
||||
szesnaście siedemnaście osiemnaście dziewiętnaście""".split()
|
||||
setki = [u""]+ u"""sto dwieście trzysta czterysta pięćset sześćset siedemset osiemset
|
||||
setki = [""]+ """sto dwieście trzysta czterysta pięćset sześćset siedemset osiemset
|
||||
dziewięćset""".split()
|
||||
|
||||
ws=u"""x x x
|
||||
ws="""x x x
|
||||
tysiąc tysiące tysięcy
|
||||
milion miliony milionów
|
||||
miliard miliardy miliardów
|
||||
|
@ -163,7 +163,7 @@ def lslownie(liczba, plec='M'):
|
|||
"""Liczba całkowita słownie"""
|
||||
trojki = []
|
||||
if liczba==0:
|
||||
return u'zero'
|
||||
return 'zero'
|
||||
while liczba>0:
|
||||
trojki.append(liczba % 1000)
|
||||
liczba = liczba // 1000
|
||||
|
@ -173,7 +173,7 @@ def lslownie(liczba, plec='M'):
|
|||
if i>0:
|
||||
p = _przypadek(n)
|
||||
w = wielkie[i][p]
|
||||
slowa.append(_slownie3cyfry(n, plec)+u" "+w)
|
||||
slowa.append(_slownie3cyfry(n, plec)+" "+w)
|
||||
else:
|
||||
slowa.append(_slownie3cyfry(n, plec))
|
||||
slowa.reverse()
|
||||
|
@ -206,13 +206,13 @@ def cosslownie(liczba,cos, plec='M'):
|
|||
# As you remember, ``cardinal()`` must be defined, this is the function which
|
||||
# will be used by SR0WX modules. This functions was also written by dowgrid,
|
||||
# modified by me. (Is function's name proper?)
|
||||
def cardinal(no, units=[u"",u"",u""], gender='M'):
|
||||
def cardinal(no, units=["","",""], gender='M'):
|
||||
"""Zamienia liczbę zapisaną cyframi na zapis słowny, opcjonalnie z jednostkami
|
||||
w odpowiednim przypadku. Obsługuje liczby ujemne."""
|
||||
if no<0:
|
||||
return (u"minus " + cosslownie(-no, units, plec=gender)).replace(u"jeden tysiąc", u"tysiąc",1).encode("utf-8")
|
||||
return ("minus " + cosslownie(-no, units, plec=gender)).replace("jeden tysiąc", "tysiąc",1).encode("utf-8")
|
||||
else:
|
||||
return cosslownie(no, units, plec=gender).replace(u"jeden tysiąc", u"tysiąc",1).encode("utf-8")
|
||||
return cosslownie(no, units, plec=gender).replace("jeden tysiąc", "tysiąc",1).encode("utf-8")
|
||||
|
||||
# This one tiny simply removes diactrics (lower case only). This function
|
||||
# must be defined even if your language doesn't use diactrics (like English),
|
||||
|
|
|
@ -73,20 +73,20 @@
|
|||
#
|
||||
# This dictionary is used by all SR0WX modules.
|
||||
|
||||
fake_gettext = lambda(s): s
|
||||
fake_gettext = lambda s: s
|
||||
_ = fake_gettext
|
||||
|
||||
# Units and grammar cases
|
||||
hrs = ["","godziny","godzin"]
|
||||
hPa = ["hektopaskal", "hektopaskale", "hektopaskali"]
|
||||
percent = [u"procent",u"procent",u"procent"]
|
||||
percent = ["procent","procent","procent"]
|
||||
mPs = ["metr_na_sekunde", "metry_na_sekunde", "metrow_na_sekunde"]
|
||||
kmPh = ["kilometr_na_godzine", "kilometry_na_godzine", "kilometrow_na_godzine"]
|
||||
MiPh = ["", "", ""] # miles per hour -- not used
|
||||
windStrength = "sila_wiatru"
|
||||
deg = [u"stopien","stopnie","stopni"]
|
||||
deg = ["stopien","stopnie","stopni"]
|
||||
C = ["stopien_celsjusza", "stopnie_celsjusza", "stopni_celsjusza"]
|
||||
km = ["kilometr", "kilometry", u"kilometrow"]
|
||||
km = ["kilometr", "kilometry", "kilometrow"]
|
||||
mns = ["minuta","minuty","minut"]
|
||||
tendention = ['tendencja_spadkowa','', 'tendencja_wzrostowa']
|
||||
|
||||
|
@ -99,16 +99,16 @@ directions = { "N": ("północno ", "północny"),
|
|||
"S": ("południowo ", "południowy") }
|
||||
|
||||
# numbers
|
||||
jednostkiM = [u""] + u"jeden dwa trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
jednostkiF = [u""] + u"jedną dwie trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
dziesiatki = [u""] + u"""dziesięć dwadzieścia trzydzieści czterdzieści
|
||||
jednostkiM = [""] + "jeden dwa trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
jednostkiF = [""] + "jedną dwie trzy cztery pięć sześć siedem osiem dziewięć".split()
|
||||
dziesiatki = [""] + """dziesięć dwadzieścia trzydzieści czterdzieści
|
||||
pięćdziesiąt sześćdziesiąt siedemdziesiąt osiemdziesiąt dziewięćdziesiąt""".split()
|
||||
nastki = u"""dziesięć jedenaście dwanaście trzynaście czternaście piętnaście
|
||||
nastki = """dziesięć jedenaście dwanaście trzynaście czternaście piętnaście
|
||||
szesnaście siedemnaście osiemnaście dziewiętnaście""".split()
|
||||
setki = [u""]+ u"""sto dwieście trzysta czterysta pięćset sześćset siedemset osiemset
|
||||
setki = [""]+ """sto dwieście trzysta czterysta pięćset sześćset siedemset osiemset
|
||||
dziewięćset""".split()
|
||||
|
||||
ws=u"""x x x
|
||||
ws="""x x x
|
||||
tysiąc tysiące tysięcy
|
||||
milion miliony milionów
|
||||
miliard miliardy miliardów
|
||||
|
@ -163,7 +163,7 @@ def lslownie(liczba, plec='M'):
|
|||
"""Liczba całkowita słownie"""
|
||||
trojki = []
|
||||
if liczba==0:
|
||||
return u'zero'
|
||||
return 'zero'
|
||||
while liczba>0:
|
||||
trojki.append(liczba % 1000)
|
||||
liczba = liczba // 1000
|
||||
|
@ -173,7 +173,7 @@ def lslownie(liczba, plec='M'):
|
|||
if i>0:
|
||||
p = _przypadek(n)
|
||||
w = wielkie[i][p]
|
||||
slowa.append(_slownie3cyfry(n, plec)+u" "+w)
|
||||
slowa.append(_slownie3cyfry(n, plec)+" "+w)
|
||||
else:
|
||||
slowa.append(_slownie3cyfry(n, plec))
|
||||
slowa.reverse()
|
||||
|
@ -206,13 +206,13 @@ def cosslownie(liczba,cos, plec='M'):
|
|||
# As you remember, ``cardinal()`` must be defined, this is the function which
|
||||
# will be used by SR0WX modules. This functions was also written by dowgrid,
|
||||
# modified by me. (Is function's name proper?)
|
||||
def cardinal(no, units=[u"",u"",u""], gender='M'):
|
||||
def cardinal(no, units=["","",""], gender='M'):
|
||||
"""Zamienia liczbę zapisaną cyframi na zapis słowny, opcjonalnie z jednostkami
|
||||
w odpowiednim przypadku. Obsługuje liczby ujemne."""
|
||||
if no<0:
|
||||
return (u"minus " + cosslownie(-no, units, plec=gender)).replace(u"jeden tysiąc", u"tysiąc",1).encode("utf-8")
|
||||
return ("minus " + cosslownie(-no, units, plec=gender)).replace("jeden tysiąc", "tysiąc",1).encode("utf-8")
|
||||
else:
|
||||
return cosslownie(no, units, plec=gender).replace(u"jeden tysiąc", u"tysiąc",1).encode("utf-8")
|
||||
return cosslownie(no, units, plec=gender).replace("jeden tysiąc", "tysiąc",1).encode("utf-8")
|
||||
|
||||
# This one tiny simply removes diactrics (lower case only). This function
|
||||
# must be defined even if your language doesn't use diactrics (like English),
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import urllib
|
||||
import debug
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
from . import debug
|
||||
import json
|
||||
import os
|
||||
import BeautifulSoup
|
||||
|
@ -32,21 +32,21 @@ def safe_name(s):
|
|||
I've no idea if such situation appears in czech, but... just in case..."""
|
||||
|
||||
if str(s.__class__)=="<type 'str'>":
|
||||
s=unicode(s, 'utf-8')
|
||||
return s.replace(u'á','a_').replace(u'é','e_').\
|
||||
replace(u'ě','e!').replace(u'í','i_').replace(u'ó','o_').\
|
||||
replace(u'ú','o!').replace(u'ů','u_').replace(u'ý','y_').\
|
||||
replace(u'ď','d_').replace(u'ť','t_').replace(u'ň','n_').\
|
||||
replace(u'ř','r_').replace(u'š','s_').replace(u'č','c_').\
|
||||
replace(u'ž','z_').replace(u'Á','a_').replace(u'É','e_').\
|
||||
replace(u'Ě','e!').replace(u'Í','i_').replace(u'Ó','o_').\
|
||||
replace(u'Ú','o!').replace(u'Ů','u_').replace(u'Ý','y_').\
|
||||
replace(u'Ď','d_').replace(u'Ť','t_').replace(u'Ň','n_').\
|
||||
replace(u'Ř','r_').replace(u'Š','s_').replace(u'Č','c_').\
|
||||
replace(u'Ž','z_').lower().replace(' ','_').replace(u'–','_')
|
||||
s=str(s, 'utf-8')
|
||||
return s.replace('á','a_').replace('é','e_').\
|
||||
replace('ě','e!').replace('í','i_').replace('ó','o_').\
|
||||
replace('ú','o!').replace('ů','u_').replace('ý','y_').\
|
||||
replace('ď','d_').replace('ť','t_').replace('ň','n_').\
|
||||
replace('ř','r_').replace('š','s_').replace('č','c_').\
|
||||
replace('ž','z_').replace('Á','a_').replace('É','e_').\
|
||||
replace('Ě','e!').replace('Í','i_').replace('Ó','o_').\
|
||||
replace('Ú','o!').replace('Ů','u_').replace('Ý','y_').\
|
||||
replace('Ď','d_').replace('Ť','t_').replace('Ň','n_').\
|
||||
replace('Ř','r_').replace('Š','s_').replace('Č','c_').\
|
||||
replace('Ž','z_').lower().replace(' ','_').replace('–','_')
|
||||
|
||||
def downloadFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
def my_import(name):
|
||||
|
@ -63,20 +63,20 @@ def getData(l):
|
|||
regions = get_config_regions()
|
||||
|
||||
if not os.path.exists('povodi_cz.json'):
|
||||
regions = generate_json(regions=regions.keys(), dont_save=False)
|
||||
regions = generate_json(regions=list(regions.keys()), dont_save=False)
|
||||
else:
|
||||
regions = json.loads(unicode(open('povodi_cz.json','r').read(),'utf-8'))
|
||||
regions = json.loads(str(open('povodi_cz.json','r').read(),'utf-8'))
|
||||
|
||||
awarenesses = {}
|
||||
|
||||
for region in regions.keys():
|
||||
for region in list(regions.keys()):
|
||||
for river in regions[region]:
|
||||
for station in regions[region][river].keys():
|
||||
for station in list(regions[region][river].keys()):
|
||||
station_name, level = regions[region][river][station]
|
||||
if [region,station] in config.stations and level>0:
|
||||
if not awarenesses.has_key(str(level)):
|
||||
if str(level) not in awarenesses:
|
||||
awarenesses[str(level)]={}
|
||||
if not awarenesses[str(level)].has_key(safe_name(river)):
|
||||
if safe_name(river) not in awarenesses[str(level)]:
|
||||
awarenesses[str(level)][safe_name(river)]=[]
|
||||
awarenesses[str(level)][safe_name(river)].\
|
||||
append(safe_name(regions[region][river][station][0]))
|
||||
|
@ -102,7 +102,7 @@ def getData(l):
|
|||
return data
|
||||
|
||||
def show_help():
|
||||
print u"""
|
||||
print("""
|
||||
Uruchamiając ten skrypt z linii komend możesz wygenerować w łatwy sposób
|
||||
fragment słownika sr0wx dla rzek i wodowskazów wskazanych w pliku config.py
|
||||
|
||||
|
@ -114,7 +114,7 @@ a następnie
|
|||
|
||||
python google_tts_downloader.py povodi_cz_dict.py
|
||||
|
||||
aby dociągnąć niezbędne pliki."""
|
||||
aby dociągnąć niezbędne pliki.""")
|
||||
|
||||
def get_region(region):
|
||||
"""Returns dictionary with all rivers and stations with flood awareness
|
||||
|
@ -141,7 +141,7 @@ def get_region(region):
|
|||
#try:
|
||||
if 1==1:
|
||||
for station in html.findAll('div'):
|
||||
if station.has_key('id') and 'text' in station['id']:
|
||||
if 'id' in station and 'text' in station['id']:
|
||||
r1, r2 = station.findAll('table')
|
||||
stid= station['id'][4:] # station id
|
||||
river=str(r1.findAll('tr')[0].findAll('td')[0].\
|
||||
|
@ -177,7 +177,7 @@ def get_region(region):
|
|||
|
||||
#print '|'.join( (region,_map, str(stid),river, station, level) )
|
||||
|
||||
if not rv.has_key(river):
|
||||
if river not in rv:
|
||||
rv[river]={}
|
||||
rv[river][stid]=[station, level]
|
||||
# debug trick: WE are steering water levels
|
||||
|
@ -228,15 +228,15 @@ def generate_json(regions=None, dont_save=False):
|
|||
def generate_config():
|
||||
regions=generate_json(dont_save=True)
|
||||
|
||||
print u'povodi_cz.stations = ['
|
||||
print('povodi_cz.stations = [')
|
||||
|
||||
for region in sorted(regions.keys()):
|
||||
for river in sorted(regions[region].keys()):
|
||||
for station in sorted(regions[region][river].keys()):
|
||||
print u" ['%s','%s'],\t# %s, station %s"%\
|
||||
(region,station,unicode(river,'utf-8'),\
|
||||
unicode(regions[region][river][station][0],'utf-8'),)
|
||||
print u']'
|
||||
print(" ['%s','%s'],\t# %s, station %s"%\
|
||||
(region,station,str(river,'utf-8'),\
|
||||
str(regions[region][river][station][0],'utf-8'),))
|
||||
print(']')
|
||||
|
||||
def get_config_regions():
|
||||
regions = {}
|
||||
|
@ -250,7 +250,7 @@ def generate_dictionary():
|
|||
regions = get_config_regions()
|
||||
|
||||
phrases = []
|
||||
for region in regions.keys():
|
||||
for region in list(regions.keys()):
|
||||
region_data = get_region(region)
|
||||
for river in sorted(region_data.keys()):
|
||||
for station in sorted(region_data[river].keys()):
|
||||
|
@ -260,7 +260,7 @@ def generate_dictionary():
|
|||
if river not in phrases:
|
||||
phrases.append(river)
|
||||
|
||||
print u"""#!/usr/bin/python
|
||||
print("""#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Caution! I am not responsible for using these samples. Use at your own risk
|
||||
|
@ -276,19 +276,19 @@ END_MARKER = '@'
|
|||
CUT_START = 0.9
|
||||
CUT_END=0.7
|
||||
|
||||
download_list = [ """
|
||||
download_list = [ """)
|
||||
|
||||
for phrase in phrases:
|
||||
print u" [\"%s\", \"%s\"], # %s"%\
|
||||
(unicode(phrase,'utf-8'), safe_name(phrase),\
|
||||
unicode(phrase,'utf-8'))
|
||||
print(" [\"%s\", \"%s\"], # %s"%\
|
||||
(str(phrase,'utf-8'), safe_name(phrase),\
|
||||
str(phrase,'utf-8')))
|
||||
|
||||
print u']'
|
||||
print(']')
|
||||
|
||||
if __name__ == '__main__':
|
||||
class DummyDebug:
|
||||
def log(self,module,message,buglevel=None):
|
||||
print message
|
||||
print(message)
|
||||
|
||||
debug = DummyDebug()
|
||||
import sys
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#
|
||||
|
||||
import re
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
from config import prospect_mp as config
|
||||
import datetime
|
||||
import debug
|
||||
from . import debug
|
||||
import json
|
||||
import os
|
||||
lang=None
|
||||
|
@ -32,17 +32,17 @@ def bezpiecznaNazwa(s):
|
|||
rzeka Ślęza jak i Ślęża oznaczany jest każdy niełaciński
|
||||
znak"""
|
||||
if str(s.__class__)=="<type 'str'>":
|
||||
s=unicode(s, 'utf-8')
|
||||
return s.lower().replace(u'ą',u'a_').replace(u'ć',u'c_').\
|
||||
replace(u'ę',u'e_').replace(u'ł',u'l_').\
|
||||
replace(u'ń',u'n_').replace(u'ó',u'o_').\
|
||||
replace(u'ś',u's_').replace(u'ź',u'x_').\
|
||||
replace(u'ż',u'z_').replace(u' ',u'_').\
|
||||
replace(u'-',u'_').replace(u'(',u'').\
|
||||
replace(u')',u'')
|
||||
s=str(s, 'utf-8')
|
||||
return s.lower().replace('ą','a_').replace('ć','c_').\
|
||||
replace('ę','e_').replace('ł','l_').\
|
||||
replace('ń','n_').replace('ó','o_').\
|
||||
replace('ś','s_').replace('ź','x_').\
|
||||
replace('ż','z_').replace(' ','_').\
|
||||
replace('-','_').replace('(','').\
|
||||
replace(')','')
|
||||
|
||||
def downloadFile(url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
return webFile.read()
|
||||
|
||||
def my_import(name):
|
||||
|
@ -73,11 +73,11 @@ def pobierzOstrzezenia(domena,stacja):
|
|||
elif wynik[0][1] in ('ostrzegawczy','alarmowy'):
|
||||
return wynik[0][1]
|
||||
else:
|
||||
debug.log('PROSPECT-MP', u'Regex nie zwrócił oczekiwanych danych',\
|
||||
debug.log('PROSPECT-MP', 'Regex nie zwrócił oczekiwanych danych',\
|
||||
buglevel=5)
|
||||
return None
|
||||
except:
|
||||
debug.log('PROSPECT-MP', u'Regex nie zwrócił oczekiwanych danych',\
|
||||
debug.log('PROSPECT-MP', 'Regex nie zwrócił oczekiwanych danych',\
|
||||
buglevel=5)
|
||||
pass
|
||||
return None
|
||||
|
@ -90,7 +90,7 @@ def getData(l):
|
|||
if not os.path.exists('prospect_mp.json'):
|
||||
stany = generuj_json(nie_zapisuj=True)
|
||||
else:
|
||||
stany = json.loads(unicode(open('prospect_mp.json','r').read(),'utf-8'))
|
||||
stany = json.loads(str(open('prospect_mp.json','r').read(),'utf-8'))
|
||||
|
||||
if stany['ostrzegawczy']!={} or stany['alarmowy']!={}:
|
||||
data['data'] += 'lokalny_komunikat_hydrologiczny '
|
||||
|
@ -117,7 +117,7 @@ def getData(l):
|
|||
return data
|
||||
|
||||
def show_help():
|
||||
print u"""
|
||||
print("""
|
||||
Uruchamiając ten skrypt z linii komend możesz wygenerować w łatwy sposób
|
||||
fragment słownika sr0wx dla rzek i wodowskazów wskazanych w pliku config.py
|
||||
|
||||
|
@ -129,13 +129,13 @@ a następnie
|
|||
|
||||
python google_tts_downloader.py prospect_mp_dict.py
|
||||
|
||||
aby dociągnąć niezbędne pliki."""
|
||||
aby dociągnąć niezbędne pliki.""")
|
||||
|
||||
def generuj_slownik():
|
||||
# generowanie listy słów słownika; ostatnie słowo (rozielone spacją)
|
||||
# jest nazwą pliku docelowego
|
||||
|
||||
print """#!/usr/bin/python
|
||||
print("""#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Caution! I am not responsible for using these samples. Use at your own risk
|
||||
|
@ -151,7 +151,7 @@ END_MARKER = ' k'
|
|||
CUT_START = 0.9
|
||||
CUT_END=0.7
|
||||
|
||||
download_list = [ """
|
||||
download_list = [ """)
|
||||
|
||||
frazy = []
|
||||
for wpis in config.wodowskazy:
|
||||
|
@ -159,14 +159,14 @@ download_list = [ """
|
|||
frazy.append(wpis[2])
|
||||
|
||||
for fraza in set(frazy):
|
||||
print "\t['ę. %s', '%s'],"%(fraza, str(bezpiecznaNazwa(fraza)),)
|
||||
print("\t['ę. %s', '%s'],"%(fraza, str(bezpiecznaNazwa(fraza)),))
|
||||
|
||||
|
||||
print """['lokalny komunikat hydrologiczny]',
|
||||
print("""['lokalny komunikat hydrologiczny]',
|
||||
['przekroczenia stanów ostrzegawczych'],
|
||||
['przekroczenia stanów alarmowych'], ['rzeka'], ['wodowskaz'],
|
||||
['err wu de prospekt','rwd_prospect']
|
||||
]"""
|
||||
]""")
|
||||
|
||||
|
||||
def generuj_json(nie_zapisuj=False):
|
||||
|
@ -191,13 +191,13 @@ def generuj_json(nie_zapisuj=False):
|
|||
# Koniec chłytu
|
||||
|
||||
if stan in ('ostrzegawczy','alarmowy'):
|
||||
if not stany[stan].has_key(rzeka):
|
||||
if rzeka not in stany[stan]:
|
||||
stany[stan][rzeka]=[]
|
||||
stany[stan][rzeka].append(wodowskaz)
|
||||
except:
|
||||
raise
|
||||
debug.log('PROSPECT-MP', u'Pobieranie danych zakończyło się '+\
|
||||
u'błędem', buglevel=5)
|
||||
debug.log('PROSPECT-MP', 'Pobieranie danych zakończyło się '+\
|
||||
'błędem', buglevel=5)
|
||||
pass
|
||||
|
||||
if nie_zapisuj==False:
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import datetime
|
||||
from config import radAtHome as config
|
||||
import datetime
|
||||
import csv
|
||||
import debug
|
||||
from . import debug
|
||||
import sqlite3
|
||||
|
||||
lang=None
|
||||
|
|
|
@ -79,7 +79,7 @@ def add_sms_to_db(sender, message, date_rcvd):
|
|||
message = message.split('.',1)[1]
|
||||
|
||||
c = conn.cursor()
|
||||
print (sender,message,date_rcvd,valid_until[1],)
|
||||
print((sender,message,date_rcvd,valid_until[1],))
|
||||
c.execute("""insert into sms_rcvd(sender,message,date_rcvd,valid_until)
|
||||
values(?,?,?,?);""",(sender,message,date_rcvd,valid_until[1],))
|
||||
conn.commit()
|
||||
|
@ -119,7 +119,7 @@ def get_last_authorized_message():
|
|||
order by date_rcvd desc;""")
|
||||
|
||||
for sms in c.fetchall():
|
||||
if sms[1] in config.authorized_senders.keys():
|
||||
if sms[1] in list(config.authorized_senders.keys()):
|
||||
callsign = lang.readCallsign(\
|
||||
config.authorized_senders[sms[1]])
|
||||
return {'id':sms[0], 'callsign':callsign, 'message':sms[2]}
|
||||
|
|
|
@ -83,4 +83,4 @@ def getData(l):
|
|||
return data
|
||||
|
||||
if __name__ == '__main__':
|
||||
print getData('pl')["data"]
|
||||
print(getData('pl')["data"])
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import debug
|
||||
import urllib2
|
||||
from . import debug
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import json
|
||||
import datetime
|
||||
import pytz
|
||||
|
@ -54,7 +54,7 @@ def getData(l):
|
|||
params = {'LAT':str(config.latitude), 'LON':str(config.longitude),\
|
||||
'API_KEY':config.api_key}
|
||||
|
||||
weather= json.loads(urllib2.urlopen(REQ_URL.format(**params)).read())
|
||||
weather= json.loads(urllib.request.urlopen(REQ_URL.format(**params)).read())
|
||||
|
||||
# `w`, `f0` and `f1` are parts of big weather dictionary; we have to unpack it for further
|
||||
# formatting.
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
fake_gettext = lambda(s): s
|
||||
fake_gettext = lambda s: s
|
||||
_ = fake_gettext
|
||||
|
||||
from config import wview as config
|
||||
|
||||
# For debugging purposes:
|
||||
|
||||
import debug
|
||||
from . import debug
|
||||
import sqlite3
|
||||
|
||||
lang = None
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
fake_gettext = lambda(s): s
|
||||
fake_gettext = lambda s: s
|
||||
_ = fake_gettext
|
||||
|
||||
from config import y_weather as config
|
||||
|
||||
# For debugging purposes:
|
||||
|
||||
import debug
|
||||
import urllib2
|
||||
from . import debug
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
|
||||
lang = None
|
||||
|
||||
|
@ -38,7 +38,7 @@ def my_import(name):
|
|||
# Taken from http://developer.yahoo.com/python/python-xml.html (SLIGHTLY modified)
|
||||
# simple and elegant, but I HATE XML!
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
from xml.dom import minidom
|
||||
|
||||
import datetime
|
||||
|
@ -53,7 +53,7 @@ def weather_for_zip(zip_code):
|
|||
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'
|
||||
|
||||
url = WEATHER_URL % zip_code
|
||||
dom = minidom.parse(urllib.urlopen(url))
|
||||
dom = minidom.parse(urllib.request.urlopen(url))
|
||||
forecasts = []
|
||||
for node in dom.getElementsByTagNameNS(WEATHER_NS, 'forecast'):
|
||||
forecasts.append({
|
||||
|
|
16
lib/taf.py
16
lib/taf.py
|
@ -16,7 +16,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
import re, urllib
|
||||
import re, urllib.request, urllib.parse, urllib.error
|
||||
|
||||
|
||||
def between(a,b,c):
|
||||
|
@ -280,14 +280,14 @@ class taf:
|
|||
result = []
|
||||
for el in x:
|
||||
#if isinstance(el, (list, tuple)):
|
||||
if hasattr(el, "__iter__") and not isinstance(el, basestring):
|
||||
if hasattr(el, "__iter__") and not isinstance(el, str):
|
||||
result.extend(self.flatten(el))
|
||||
else:
|
||||
result.append(el)
|
||||
return result
|
||||
|
||||
def getFile(self, url):
|
||||
webFile = urllib.urlopen(url)
|
||||
webFile = urllib.request.urlopen(url)
|
||||
contents = webFile.read()
|
||||
webFile.close()
|
||||
return contents
|
||||
|
@ -382,7 +382,7 @@ class taf:
|
|||
int(wind[wind.index('V')-1]),
|
||||
int(wind[wind.index('V')+1]) ]
|
||||
else:
|
||||
if direction<>[] and direction[0]<>"VRB":
|
||||
if direction!=[] and direction[0]!="VRB":
|
||||
return ([int(direction[0])] or [None])
|
||||
else:
|
||||
return ["VRB"]
|
||||
|
@ -406,7 +406,7 @@ class taf:
|
|||
|
||||
|
||||
def getTemperature(self):
|
||||
print "---> lib/taf.py: temperature not supported", self.weather["temp"]
|
||||
print("---> lib/taf.py: temperature not supported", self.weather["temp"])
|
||||
return None
|
||||
|
||||
def getSkyConditions(self):
|
||||
|
@ -421,7 +421,7 @@ class taf:
|
|||
return None
|
||||
|
||||
def getPressure(self):
|
||||
print "---> lib/taf.py: pressure not supported", self.weather["press"]
|
||||
print("---> lib/taf.py: pressure not supported", self.weather["press"])
|
||||
return None
|
||||
|
||||
def getWeather(self):
|
||||
|
@ -433,12 +433,12 @@ class taf:
|
|||
|
||||
for w in self.weather["weather"].strip().split():
|
||||
wx = ["", "", ""]
|
||||
for k in self._WeatherConditions.keys():
|
||||
for k in list(self._WeatherConditions.keys()):
|
||||
if k in w:
|
||||
for elem in self._WeatherConditions[k]:
|
||||
if elem in w:
|
||||
if self._WeatherConditions[k][elem] == "%":
|
||||
print " ".join( ("---> lib/taf.py: couldn't interpret",elem,"in",self.weather["weather"].strip().split()) )
|
||||
print(" ".join( ("---> lib/taf.py: couldn't interpret",elem,"in",self.weather["weather"].strip().split()) ))
|
||||
else:
|
||||
if self._WeatherConditions[k][elem][1]!="":
|
||||
wx = self._WeatherConditions[k][elem]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import json as JSON
|
||||
|
@ -86,12 +86,12 @@ class OpenWeatherSq9atk(SR0WXModule):
|
|||
|
||||
def downloadFile(self, url):
|
||||
try:
|
||||
webFile = urllib2.urlopen(url, None, 30)
|
||||
webFile = urllib.request.urlopen(url, None, 30)
|
||||
return webFile.read()
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
return ""
|
||||
|
||||
def getHour(self):
|
||||
|
|
|
@ -38,7 +38,7 @@ with open(pyliczba_init, 'w') as f:
|
|||
|
||||
# It works!
|
||||
|
||||
import pyliczba
|
||||
from . import pyliczba
|
||||
|
||||
def rmv_pl_chars(string):
|
||||
return ''.join([i if ord(i) < 128 else '_' for i in string]).lower()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import unittest
|
||||
from six import u
|
||||
from kwotaslownie import kwotaslownie
|
||||
from .kwotaslownie import kwotaslownie
|
||||
|
||||
|
||||
class TestKwotaSlownie(unittest.TestCase):
|
||||
|
@ -21,7 +21,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
8.00: u("osiem złotych 0/100"),
|
||||
9.00: u("dziewięć złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in jednosci_bez_groszy.items():
|
||||
for kwota, spodziewana in list(jednosci_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_nastki_bez_groszy(self):
|
||||
|
@ -38,7 +38,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
18.00: u("osiemnaście złotych 0/100"),
|
||||
19.00: u("dziewiętnaście złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in nastki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(nastki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_dziesiatki_bez_groszy(self):
|
||||
|
@ -53,7 +53,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
80.00: u("osiemdziesiąt złotych 0/100"),
|
||||
90.00: u("dziewięćdziesiąt złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in dziesiatki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(dziesiatki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_setki_bez_groszy(self):
|
||||
|
@ -69,7 +69,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
800.00: u("osiemset złotych 0/100"),
|
||||
900.00: u("dziewięćset złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in setki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(setki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_tysiace_bez_groszy(self):
|
||||
|
@ -89,7 +89,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
100000.00: u("sto tysięcy złotych 0/100"),
|
||||
300000.00: u("trzysta tysięcy złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in tysiace_bez_groszy.items():
|
||||
for kwota, spodziewana in list(tysiace_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_miliony_bez_groszy(self):
|
||||
|
@ -102,7 +102,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
30000000.00: u("trzydzieści milionów złotych 0/100"),
|
||||
100000000.00: u("sto milionów złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in miliony_bez_groszy.items():
|
||||
for kwota, spodziewana in list(miliony_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_jeden_na_koncu_bez_groszy(self):
|
||||
|
@ -119,7 +119,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14001.00: u("czternaście tysięcy jeden złotych 0/100"),
|
||||
1000001.00: u("jeden milion jeden złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in jeden_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(jeden_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_trzy_na_koncu_bez_groszy(self):
|
||||
|
@ -136,7 +136,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14003.00: u("czternaście tysięcy trzy złote 0/100"),
|
||||
1000003.00: u("jeden milion trzy złote 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in trzy_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(trzy_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_siedem_na_koncu_bez_groszy(self):
|
||||
|
@ -153,7 +153,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14007.00: u("czternaście tysięcy siedem złotych 0/100"),
|
||||
1000007.00: u("jeden milion siedem złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in siedem_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(siedem_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_czternascie_na_koncu_bez_groszy(self):
|
||||
|
@ -168,7 +168,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14014.00: u("czternaście tysięcy czternaście złotych 0/100"),
|
||||
1000014.00: u("jeden milion czternaście złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in czternascie_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(czternascie_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_liczba_groszy_bez_odmiany(self):
|
||||
|
@ -181,7 +181,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
0.25: u("zero złotych 25/100"),
|
||||
0.48: u("zero złotych 48/100"),
|
||||
}
|
||||
for kwota, spodziewana in liczba_groszy_bez_odmiany.items():
|
||||
for kwota, spodziewana in list(liczba_groszy_bez_odmiany.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_z_groszami(self):
|
||||
|
@ -222,7 +222,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
2.90: u("dwa złote dziewięćdziesiąt groszy"),
|
||||
}
|
||||
|
||||
for kwota, spodziewana in z_groszami.items():
|
||||
for kwota, spodziewana in list(z_groszami.items()):
|
||||
self.assertEqual(kwotaslownie(kwota, fmt=1), spodziewana)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -38,7 +38,7 @@ with open(pyliczba_init, 'w') as f:
|
|||
|
||||
# It works!
|
||||
|
||||
import pyliczba
|
||||
from . import pyliczba
|
||||
|
||||
def rmv_pl_chars(string):
|
||||
return ''.join([i if ord(i) < 128 else '_' for i in string]).lower()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import unittest
|
||||
from six import u
|
||||
from kwotaslownie import kwotaslownie
|
||||
from .kwotaslownie import kwotaslownie
|
||||
|
||||
|
||||
class TestKwotaSlownie(unittest.TestCase):
|
||||
|
@ -21,7 +21,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
8.00: u("osiem złotych 0/100"),
|
||||
9.00: u("dziewięć złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in jednosci_bez_groszy.items():
|
||||
for kwota, spodziewana in list(jednosci_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_nastki_bez_groszy(self):
|
||||
|
@ -38,7 +38,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
18.00: u("osiemnaście złotych 0/100"),
|
||||
19.00: u("dziewiętnaście złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in nastki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(nastki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_dziesiatki_bez_groszy(self):
|
||||
|
@ -53,7 +53,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
80.00: u("osiemdziesiąt złotych 0/100"),
|
||||
90.00: u("dziewięćdziesiąt złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in dziesiatki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(dziesiatki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_setki_bez_groszy(self):
|
||||
|
@ -69,7 +69,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
800.00: u("osiemset złotych 0/100"),
|
||||
900.00: u("dziewięćset złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in setki_bez_groszy.items():
|
||||
for kwota, spodziewana in list(setki_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_tysiace_bez_groszy(self):
|
||||
|
@ -89,7 +89,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
100000.00: u("sto tysięcy złotych 0/100"),
|
||||
300000.00: u("trzysta tysięcy złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in tysiace_bez_groszy.items():
|
||||
for kwota, spodziewana in list(tysiace_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_miliony_bez_groszy(self):
|
||||
|
@ -102,7 +102,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
30000000.00: u("trzydzieści milionów złotych 0/100"),
|
||||
100000000.00: u("sto milionów złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in miliony_bez_groszy.items():
|
||||
for kwota, spodziewana in list(miliony_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_jeden_na_koncu_bez_groszy(self):
|
||||
|
@ -119,7 +119,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14001.00: u("czternaście tysięcy jeden złotych 0/100"),
|
||||
1000001.00: u("jeden milion jeden złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in jeden_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(jeden_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_trzy_na_koncu_bez_groszy(self):
|
||||
|
@ -136,7 +136,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14003.00: u("czternaście tysięcy trzy złote 0/100"),
|
||||
1000003.00: u("jeden milion trzy złote 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in trzy_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(trzy_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_siedem_na_koncu_bez_groszy(self):
|
||||
|
@ -153,7 +153,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14007.00: u("czternaście tysięcy siedem złotych 0/100"),
|
||||
1000007.00: u("jeden milion siedem złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in siedem_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(siedem_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_czternascie_na_koncu_bez_groszy(self):
|
||||
|
@ -168,7 +168,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
14014.00: u("czternaście tysięcy czternaście złotych 0/100"),
|
||||
1000014.00: u("jeden milion czternaście złotych 0/100"),
|
||||
}
|
||||
for kwota, spodziewana in czternascie_na_koncu_bez_groszy.items():
|
||||
for kwota, spodziewana in list(czternascie_na_koncu_bez_groszy.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_liczba_groszy_bez_odmiany(self):
|
||||
|
@ -181,7 +181,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
0.25: u("zero złotych 25/100"),
|
||||
0.48: u("zero złotych 48/100"),
|
||||
}
|
||||
for kwota, spodziewana in liczba_groszy_bez_odmiany.items():
|
||||
for kwota, spodziewana in list(liczba_groszy_bez_odmiany.items()):
|
||||
self.assertEqual(kwotaslownie(kwota), spodziewana)
|
||||
|
||||
def test_z_groszami(self):
|
||||
|
@ -222,7 +222,7 @@ class TestKwotaSlownie(unittest.TestCase):
|
|||
2.90: u("dwa złote dziewięćdziesiąt groszy"),
|
||||
}
|
||||
|
||||
for kwota, spodziewana in z_groszami.items():
|
||||
for kwota, spodziewana in list(z_groszami.items()):
|
||||
self.assertEqual(kwotaslownie(kwota, fmt=1), spodziewana)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import logging
|
||||
import socket
|
||||
|
||||
|
@ -40,13 +40,13 @@ class PropagationSq9atk(SR0WXModule):
|
|||
def downloadImage(self, url):
|
||||
try:
|
||||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
webFile = urllib.URLopener()
|
||||
webFile = urllib.request.URLopener()
|
||||
webFile.retrieve(url, "propagacja.png")
|
||||
return Image.open("propagacja.png",'r')
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
except:
|
||||
print "Data download error!"
|
||||
print("Data download error!")
|
||||
return
|
||||
|
||||
def collectBandConditionsFromImage(self, image, dayTime):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python -tt
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
import re
|
||||
import logging
|
||||
import pytz
|
||||
|
@ -22,12 +22,12 @@ class RadioactiveSq9atk(SR0WXModule):
|
|||
def downloadFile(self, url):
|
||||
try:
|
||||
self.__logger.info("::: Odpytuję adres: " + url)
|
||||
webFile = urllib2.urlopen(url, None, 30)
|
||||
webFile = urllib.request.urlopen(url, None, 30)
|
||||
return webFile.read()
|
||||
except urllib2.URLError, e:
|
||||
print e
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
except socket.timeout:
|
||||
print "Timed out!"
|
||||
print("Timed out!")
|
||||
return ""
|
||||
|
||||
def isSensorMatchedById(self, sensorId, string):
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
certifi
|
||||
chardet
|
||||
idna
|
||||
numpy
|
||||
Pillow
|
||||
pygame
|
||||
pyserial
|
||||
pytz
|
||||
requests
|
||||
six
|
||||
urllib3
|
24
sr0wx.py
24
sr0wx.py
|
@ -77,7 +77,7 @@ import pygame
|
|||
import sys
|
||||
import logging, logging.handlers
|
||||
import numpy
|
||||
import urllib2
|
||||
import urllib.request, urllib.error, urllib.parse
|
||||
|
||||
# ``os``, ``sys`` and ``time`` doesn't need further explanation, these are
|
||||
# syandard Python packages.
|
||||
|
@ -162,8 +162,8 @@ else:
|
|||
modules = config.modules
|
||||
|
||||
try:
|
||||
dane = urllib2.urlopen('http://google.pl', None, 30);
|
||||
except urllib2.URLError, e:
|
||||
dane = urllib.request.urlopen('http://google.pl', None, 30);
|
||||
except urllib.error.URLError as e:
|
||||
modules = []
|
||||
message += " ".join(config.data_sources_error_msg)
|
||||
logger.info(COLOR_FAIL + "Brak połączenia z internetem" + COLOR_ENDC + "\n")
|
||||
|
@ -256,15 +256,15 @@ if config.serial_port is not None:
|
|||
|
||||
import serial
|
||||
try:
|
||||
ser = serial.Serial(config.serial_port, config.serial_baud_rate)
|
||||
if config.serial_signal == 'DTR':
|
||||
logger.info(COLOR_OKGREEN + "DTR/PTT set to ON\n" + COLOR_ENDC)
|
||||
ser.setDTR(1)
|
||||
ser.setRTS(0)
|
||||
else:
|
||||
logger.info(COLOR_OKGREEN + "RTS/PTT set to ON\n" + COLOR_ENDC)
|
||||
ser.setDTR(0)
|
||||
ser.setRTS(1)
|
||||
ser = serial.Serial(config.serial_port, config.serial_baud_rate)
|
||||
if config.serial_signal == 'DTR':
|
||||
logger.info(COLOR_OKGREEN + "DTR/PTT set to ON\n" + COLOR_ENDC)
|
||||
ser.dtr = True
|
||||
ser.rts = False
|
||||
else:
|
||||
logger.info(COLOR_OKGREEN + "RTS/PTT set to ON\n" + COLOR_ENDC)
|
||||
ser.dtr = False
|
||||
ser.rts = True
|
||||
except:
|
||||
log = COLOR_FAIL + "Failed to open serial port %s@%i\n" + COLOR_ENDC
|
||||
logger.error(log, config.serial_port, config.serial_baud_rate)
|
||||
|
|
|
@ -41,7 +41,7 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
return None
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print("HTML download error: %s" % e)
|
||||
print(("HTML download error: %s" % e))
|
||||
return None
|
||||
|
||||
def findMapUrlInHtml(self, html, target_id):
|
||||
|
@ -64,7 +64,7 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
except requests.exceptions.Timeout:
|
||||
print("Przekroczono czas oczekiwania")
|
||||
except Exception as e:
|
||||
print("Błąd pobierania mapy: %s" % e)
|
||||
print(("Błąd pobierania mapy: %s" % e))
|
||||
return
|
||||
|
||||
|
||||
|
@ -77,7 +77,7 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
mapCropped.save(fileName)
|
||||
|
||||
except Exception as e:
|
||||
print("Błąd odczytu pliku z mapą: %s" % e)
|
||||
print(("Błąd odczytu pliku z mapą: %s" % e))
|
||||
return mapCropped
|
||||
|
||||
def lonLatToMapXY(self, lon, lat, imgWidth, imgHeight):
|
||||
|
@ -136,11 +136,11 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
frequency_dict[value] = 1
|
||||
|
||||
percentage_frequencies = {}
|
||||
for key, value in frequency_dict.items():
|
||||
for key, value in list(frequency_dict.items()):
|
||||
percentage = (value / float(total_elements)) * 100
|
||||
percentage_frequencies[key] = percentage
|
||||
|
||||
return sorted(percentage_frequencies.items(), key=lambda item: item[1], reverse=True)
|
||||
return sorted(list(percentage_frequencies.items()), key=lambda item: item[1], reverse=True)
|
||||
|
||||
def getColorPunctation(self, colorHex):
|
||||
colors = {
|
||||
|
@ -160,7 +160,7 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
}
|
||||
|
||||
result = False
|
||||
for color, value in colors.iteritems():
|
||||
for color, value in colors.items():
|
||||
if color == colorHex:
|
||||
result = value
|
||||
return result
|
||||
|
@ -207,7 +207,7 @@ class VhfTropoSq9atk(SR0WXModule):
|
|||
|
||||
def getTopDirectionsValues(self, input_table):
|
||||
filtered_rows = []
|
||||
for key, value in input_table.iteritems():
|
||||
for key, value in input_table.items():
|
||||
filtered_rows.append((key, value))
|
||||
|
||||
filtered_rows.sort(key=lambda x: x[1], reverse=True)
|
||||
|
|
Ładowanie…
Reference in New Issue