Changeset 174:e1594aa49677
- Timestamp:
- 11/26/08 02:15:03 (3 years ago)
- Author:
- cfreeze@…
- Branch:
- CAP_1.1
- Message:
-
more cleanup with the output
- Location:
- StormSiren
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r173
|
r174
|
|
| 49 | 49 | from XmlFetcher import XmlFetcher |
| 50 | 50 | |
| 51 | | class CapAlert: |
| | 51 | class CapAlert(object): |
| 52 | 52 | def __init__(self,url,simfetch,proxy): |
| 53 | 53 | self.__url = url |
-
|
r172
|
r174
|
|
| 51 | 51 | from CapAlert import CapAlert |
| 52 | 52 | |
| 53 | | class CapAtom: |
| | 53 | class CapAtom(object): |
| 54 | 54 | def __init__(self,xml,state): |
| 55 | 55 | self.log = logging.getLogger("CapAtom") |
| … |
… |
|
| 241 | 241 | str = "\tId: " + self.id + "\n" + \ |
| 242 | 242 | "\tState: " + self.state + "\n" |
| 243 | | str += "\tArea: %s\n" % self.__areas |
| | 243 | str += "\tAreas: %s\n" % self.getAreas() |
| 244 | 244 | if(self.type != None): |
| 245 | 245 | str += "\tType: " + WeatherTypes.toString(self.__type) + "\n" |
-
|
r172
|
r174
|
|
| 88 | 88 | cap_atom.expand(self.simfetch,self.proxy) |
| 89 | 89 | self.logAtom(cap_atom) |
| 90 | | dev.send(WeatherAlert(cap_atom)) |
| | 90 | dev.send(cap_atom) |
| 91 | 91 | self.__history.add(cap_atom.id) |
| 92 | 92 | else: |
-
|
r172
|
r174
|
|
| 44 | 44 | import textwrap |
| 45 | 45 | import sys |
| | 46 | import string |
| 46 | 47 | import re |
| 47 | 48 | |
| 48 | 49 | from WeatherTypes import WeatherTypes |
| | 50 | from CapAtom import CapAtom |
| 49 | 51 | |
| 50 | | class WeatherAlert(object): |
| 51 | | def __init__(self,cap_item): |
| 52 | | self.cap_item = cap_item |
| 53 | | self.__terse = cap_item.headline + "\n" + \ |
| 54 | | "Expires: " + cap_item.expires + "\n" |
| 55 | | self.__text = cap_item.headline + "\n\n" + \ |
| 56 | | " Issued: " + cap_item.issued + "\n" + \ |
| 57 | | "Expires: " + cap_item.expires + "\n" |
| 58 | | self.__detailed = self.text + "\n\n" + cap_item.description + "\n" |
| 59 | | |
| 60 | | def __str__(self): |
| 61 | | return self.detailed |
| | 52 | class WeatherAlert(CapAtom): |
| | 53 | def __init__(self,xml,state): |
| | 54 | super(WeatherAlert,self).__init__(xml,state) |
| 62 | 55 | |
| 63 | 56 | def display(self): |
| … |
… |
|
| 65 | 58 | |
| 66 | 59 | def getTerse(self): |
| 67 | | return self.__terse |
| | 60 | str = self.headline + "\n" |
| | 61 | str += "Expires: " + self.expires + "\n" |
| | 62 | return str |
| 68 | 63 | |
| 69 | 64 | def getText(self): |
| 70 | | return self.__text |
| | 65 | str = self.headline + "\n\n" |
| | 66 | str += " Issued: " + self.issued + "\n" |
| | 67 | str += "Expires: " + self.expires + "\n" |
| | 68 | return str |
| 71 | 69 | |
| 72 | 70 | def getDetailedWithFormat(self, desc_width): |
| 73 | | return self.text + "\n\n" + textwrap.fill(self.cap_item.description.replace("\n",' '),desc_width) + "\n" |
| | 71 | return self.text + "\n\n" + textwrap.fill(self.description.replace("\n",' '),desc_width) + "\n" |
| 74 | 72 | |
| 75 | 73 | def getDetailed(self): |
| 76 | | return self.text + "\n\n" + self.cap_item.description + "\n" |
| | 74 | return self.text + "\n\n" + self.description + "\n" |
| 77 | 75 | |
| 78 | | def getEvent(self): |
| 79 | | return self.cap_item.matter |
| | 76 | def getAreas(self): |
| | 77 | str = "(" |
| | 78 | str += string.join(self.areas,',') |
| | 79 | str += ")" |
| | 80 | return str |
| 80 | 81 | |
| 81 | | def getId(self): |
| 82 | | return self.cap_item.id |
| 83 | | |
| 84 | | def getType(self): |
| 85 | | return self.cap_item.type |
| 86 | | |
| 87 | | def getState(self): |
| 88 | | return self.cap_item.state |
| 89 | | |
| 90 | | id = property(getId,None,None) |
| 91 | | event = property(getEvent,None,None) |
| 92 | | type = property(getType,None,None) |
| 93 | | state = property(getState,None,None) |
| 94 | 82 | text = property(getText,None,None) |
| 95 | 83 | terse = property(getTerse,None,None) |
-
|
r169
|
r174
|
|
| 46 | 46 | from WeatherTypes import * |
| 47 | 47 | from XmlFetcher import * |
| 48 | | from CapAtom import CapAtom |
| | 48 | from WeatherAlert import WeatherAlert |
| 49 | 49 | |
| 50 | 50 | class XmlWeather(object): |
| … |
… |
|
| 85 | 85 | def __parse(self): |
| 86 | 86 | for capXmlText in self.__dom.getElementsByTagName(self.__tag_item): |
| 87 | | self.handleAtom(CapAtom(capXmlText, self.__state)) |
| | 87 | self.handleAtom(WeatherAlert(capXmlText, self.__state)) |
| 88 | 88 | |
| 89 | 89 | def getSimFetch(self): |