Exemplo n.º 1
0
    def __init__(self, text, tp):
        """ Constructor """
        self.unixtext = text
        self.tp = tp  # Reference to parent
        self.ugcs, self.ugcexpire = ugc.parse(text, tp.valid,
                                              ugc_provider=tp.ugc_provider)
        self.vtec = vtec.parse(text)
        self.headlines = self.parse_headlines()
        self.hvtec = hvtec.parse(text, nwsli_provider=tp.nwsli_provider)

        # TIME...MOT...LOC Stuff!
        self.tml_giswkt = None
        self.tml_valid = None
        self.tml_sknt = None
        self.tml_dir = None
        self.process_time_mot_loc()

        #
        self.giswkt = None
        self.sbw = self.process_latlon()

        # tags
        self.windtag = None
        self.windtagunits = None
        self.hailtag = None
        self.haildirtag = None
        self.winddirtag = None
        self.tornadotag = None
        self.waterspouttag = None
        self.tornadodamagetag = None
        self.is_emergency = False
        self.process_tags()

        self.bullets = self.process_bullets()
Exemplo n.º 2
0
    def __init__(self, text, tp):
        """ Constructor """
        self.unixtext = text
        self.tp = tp  # Reference to parent
        self.ugcs, self.ugcexpire = ugc.parse(text, tp.valid,
                                              ugc_provider=tp.ugc_provider)
        self.vtec = vtec.parse(text)
        self.headlines = self.parse_headlines()
        self.hvtec = hvtec.parse(text, nwsli_provider=tp.nwsli_provider)

        # TIME...MOT...LOC Stuff!
        self.tml_giswkt = None
        self.tml_valid = None
        self.tml_sknt = None
        self.tml_dir = None
        self.process_time_mot_loc()

        #
        self.giswkt = None
        self.sbw = self.process_latlon()

        # tags
        self.windtag = None
        self.windtagunits = None
        self.hailtag = None
        self.haildirtag = None
        self.winddirtag = None
        self.tornadotag = None
        self.tornadodamagetag = None
        self.process_tags()

        self.bullets = self.process_bullets()
Exemplo n.º 3
0
def test_missed_ugc():
    """Invalid encoded county string, check that NMC006 was not included"""
    text = ("NMC001-005>007-011-019-027-028-031-033-039-041-043-045-"
            "047-049-053-055-057-061-040300-")
    valid = utc(2018, 6, 4, 3, 0)
    (ugcs, expire) = ugc.parse(text, valid)
    assert expire == valid
    assert ugcs[3] != ugc.UGC("NM", "C", "006")
Exemplo n.º 4
0
def test_str1():
    """ check ugc.parse of STR1 parsing """
    valid = utc(2008, 12, 17, 3, 0)
    (ugcs, expire) = ugc.parse(STR1, valid)

    expire_answer = valid.replace(hour=2)
    ugcs_answer = [ugc.UGC("DC", "Z", "001")]

    assert ugcs == ugcs_answer
    assert expire == expire_answer
Exemplo n.º 5
0
def test_str1():
    """ check ugc.parse of STR1 parsing """
    valid = utc(2008, 12, 17, 3, 0)
    (ugcs, expire) = ugc.parse(STR1, valid)

    expire_answer = valid.replace(hour=2)
    ugcs_answer = [ugc.UGC("DC", "Z", "001"), ]

    assert ugcs == ugcs_answer
    assert expire == expire_answer
Exemplo n.º 6
0
    def test_str1(self):
        """ check ugc.parse of STR1 parsing """
        valid = datetime.datetime(2008, 12, 17, 3, 0)
        valid = valid.replace(tzinfo=pytz.timezone('UTC'))
        (ugcs, expire) = ugc.parse(STR1, valid)

        expire_answer = valid.replace(hour=2)
        ugcs_answer = [ugc.UGC("DC", "Z", "001"), ]

        self.assertEqual(ugcs, ugcs_answer)
        self.assertEqual(expire, expire_answer)
Exemplo n.º 7
0
def test_str2():
    """ check ugc.parse of STR2 parsing """
    valid = utc(2008, 12, 17, 3, 0)
    (ugcs, expire) = ugc.parse(STR2, valid)

    expire_answer = valid.replace(hour=2)
    ugcs_answer = [
        ugc.UGC("DC", "Z", "001"),
        ugc.UGC("MD", "Z", "004"),
        ugc.UGC("MD", "Z", "005"),
        ugc.UGC("MD", "Z", "006"),
        ugc.UGC("MD", "Z", "007"),
        ugc.UGC("MD", "Z", "009"),
        ugc.UGC("MD", "Z", "010"),
        ugc.UGC("MD", "Z", "011"),
        ugc.UGC("MD", "Z", "013"),
        ugc.UGC("MD", "Z", "014"),
        ugc.UGC("MD", "Z", "016"),
        ugc.UGC("MD", "Z", "017"),
        ugc.UGC("MD", "Z", "018"),
        ugc.UGC("VA", "Z", "036"),
        ugc.UGC("VA", "Z", "037"),
        ugc.UGC("VA", "Z", "038"),
        ugc.UGC("VA", "Z", "039"),
        ugc.UGC("VA", "Z", "040"),
        ugc.UGC("VA", "Z", "041"),
        ugc.UGC("VA", "Z", "042"),
        ugc.UGC("VA", "Z", "050"),
        ugc.UGC("VA", "Z", "051"),
        ugc.UGC("VA", "Z", "052"),
        ugc.UGC("VA", "Z", "053"),
        ugc.UGC("VA", "Z", "054"),
        ugc.UGC("VA", "Z", "055"),
        ugc.UGC("VA", "Z", "056"),
        ugc.UGC("VA", "Z", "057"),
    ]

    assert ugcs == ugcs_answer
    assert expire == expire_answer
Exemplo n.º 8
0
def test_str2():
    """ check ugc.parse of STR2 parsing """
    valid = utc(2008, 12, 17, 3, 0)
    (ugcs, expire) = ugc.parse(STR2, valid)

    expire_answer = valid.replace(hour=2)
    ugcs_answer = [ugc.UGC("DC", "Z", "001"), ugc.UGC("MD", "Z", "004"),
                   ugc.UGC("MD", "Z", "005"), ugc.UGC("MD", "Z", "006"),
                   ugc.UGC("MD", "Z", "007"), ugc.UGC("MD", "Z", "009"),
                   ugc.UGC("MD", "Z", "010"), ugc.UGC("MD", "Z", "011"),
                   ugc.UGC("MD", "Z", "013"), ugc.UGC("MD", "Z", "014"),
                   ugc.UGC("MD", "Z", "016"), ugc.UGC("MD", "Z", "017"),
                   ugc.UGC("MD", "Z", "018"), ugc.UGC("VA", "Z", "036"),
                   ugc.UGC("VA", "Z", "037"), ugc.UGC("VA", "Z", "038"),
                   ugc.UGC("VA", "Z", "039"), ugc.UGC("VA", "Z", "040"),
                   ugc.UGC("VA", "Z", "041"), ugc.UGC("VA", "Z", "042"),
                   ugc.UGC("VA", "Z", "050"), ugc.UGC("VA", "Z", "051"),
                   ugc.UGC("VA", "Z", "052"), ugc.UGC("VA", "Z", "053"),
                   ugc.UGC("VA", "Z", "054"), ugc.UGC("VA", "Z", "055"),
                   ugc.UGC("VA", "Z", "056"), ugc.UGC("VA", "Z", "057")]

    assert ugcs == ugcs_answer
    assert expire == expire_answer
Exemplo n.º 9
0
    def test_str2(self):
        """ check ugc.parse of STR2 parsing """
        valid = datetime.datetime(2008, 12, 17, 3, 0)
        valid = valid.replace(tzinfo=pytz.timezone('UTC'))
        (ugcs, expire) = ugc.parse(STR2, valid)

        expire_answer = valid.replace(hour=2)
        ugcs_answer = [ugc.UGC("DC", "Z", "001"), ugc.UGC("MD", "Z", "004"),
                       ugc.UGC("MD", "Z", "005"), ugc.UGC("MD", "Z", "006"),
                       ugc.UGC("MD", "Z", "007"), ugc.UGC("MD", "Z", "009"),
                       ugc.UGC("MD", "Z", "010"), ugc.UGC("MD", "Z", "011"),
                       ugc.UGC("MD", "Z", "013"), ugc.UGC("MD", "Z", "014"),
                       ugc.UGC("MD", "Z", "016"), ugc.UGC("MD", "Z", "017"),
                       ugc.UGC("MD", "Z", "018"), ugc.UGC("VA", "Z", "036"),
                       ugc.UGC("VA", "Z", "037"), ugc.UGC("VA", "Z", "038"),
                       ugc.UGC("VA", "Z", "039"), ugc.UGC("VA", "Z", "040"),
                       ugc.UGC("VA", "Z", "041"), ugc.UGC("VA", "Z", "042"),
                       ugc.UGC("VA", "Z", "050"), ugc.UGC("VA", "Z", "051"),
                       ugc.UGC("VA", "Z", "052"), ugc.UGC("VA", "Z", "053"),
                       ugc.UGC("VA", "Z", "054"), ugc.UGC("VA", "Z", "055"),
                       ugc.UGC("VA", "Z", "056"), ugc.UGC("VA", "Z", "057")]

        self.assertEqual(ugcs, ugcs_answer)
        self.assertEqual(expire, expire_answer)
Exemplo n.º 10
0
def test_parse_exception():
    """Test that we raise a proper exception when given bad data."""
    valid = utc(2008, 12, 17, 3, 0)
    text = "IA078-170300-"
    with pytest.raises(UGCParseException):
        ugc.parse(text, valid)