Clean up code
This commit is contained in:
parent
73fda1111c
commit
b2e20763d9
|
@ -1,4 +1,5 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.swp
|
*.swp
|
||||||
|
*.tmp
|
||||||
chutney.cfg
|
chutney.cfg
|
||||||
weather.txt
|
weather.txt
|
||||||
|
|
|
@ -7,21 +7,21 @@ class WeatherDisplay:
|
||||||
self.topRow = topRow
|
self.topRow = topRow
|
||||||
self.twoDigitStartColumn = 9
|
self.twoDigitStartColumn = 9
|
||||||
self.oneDigitStartColumn = 13
|
self.oneDigitStartColumn = 13
|
||||||
|
self.digitWidth = 4
|
||||||
self.currentTemperature = ''
|
self.currentTemperature = ''
|
||||||
self.color = colors.GREEN
|
self.color = colors.BLUE
|
||||||
self.weatherFile = 'weather.txt'
|
self.weatherFile = 'weather.txt'
|
||||||
|
|
||||||
def showWeather(self):
|
def showWeather(self):
|
||||||
temperature = self.getTemperature()
|
temperature = self.getTemperature()
|
||||||
|
|
||||||
if temperature != self.currentTemperature:
|
if temperature != self.currentTemperature:
|
||||||
|
self.currentTemperature = temperature
|
||||||
self.characterDisplay.clearRow(self.topRow)
|
self.characterDisplay.clearRow(self.topRow)
|
||||||
|
|
||||||
if self.isTemperatureValid(temperature):
|
if self.isTemperatureValid(temperature):
|
||||||
self.showTemperature(list(temperature))
|
self.showTemperature(list(temperature))
|
||||||
|
|
||||||
self.currentTemperature = temperature
|
|
||||||
|
|
||||||
def getTemperature(self):
|
def getTemperature(self):
|
||||||
try:
|
try:
|
||||||
with open(self.weatherFile) as file:
|
with open(self.weatherFile) as file:
|
||||||
|
@ -50,7 +50,7 @@ class WeatherDisplay:
|
||||||
digit=c,
|
digit=c,
|
||||||
color=self.color
|
color=self.color
|
||||||
)
|
)
|
||||||
start = start + 4
|
start = start + self.digitWidth
|
||||||
|
|
||||||
def getStartColumn(self, temperature):
|
def getStartColumn(self, temperature):
|
||||||
return self.oneDigitStartColumn if (self.isOneDigit(temperature)) else self.twoDigitStartColumn
|
return self.oneDigitStartColumn if (self.isOneDigit(temperature)) else self.twoDigitStartColumn
|
||||||
|
|
Loading…
Reference in New Issue