Exemplo n.º 1
0
    def parse(cls, title, gfyear=None, **kwargs):
        root, period = tk.parse(title, _get_gfyear(gfyear))

        letter = '(?:[A-Z]|Æ|Ø|Å|AE|OE|AA)'
        title_patterns = [
            ('BEST', '^(?:CERM|FORM|INKA|KASS|NF|PR|SEKR|VC)$'),
            ('FU', '^FU%s%s$' % (letter, letter)),
            ('EFU', '^EFU%s%s$' % (letter, letter)),
        ]
        for kind, p in title_patterns:
            if re.match(p, root):
                return cls(period=period, root=root, kind=kind, **kwargs)
        raise ValueError(title)
Exemplo n.º 2
0
 def test_prefix_bestfuslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BBEST/FU'), ('BESTFU', 2011))
Exemplo n.º 3
0
 def test_postfix_bestfu(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BESTFU16'), ('BESTFU', 2016))
Exemplo n.º 4
0
 def test_postfix_leadingspace_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' FORM 1617'), ('FORM', 2016))
Exemplo n.º 5
0
 def test_context(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM'), ('FORM', 2013))
Exemplo n.º 6
0
 def test_FUAEU_absolute_later(self):
     with tk.set_gfyear(2023):
         self.assertEqual(tk.parse('FUAEU21'), ('FUÄU', 2021))
Exemplo n.º 7
0
 def test_AAE(self):
     with tk.set_gfyear(2013):
         with self.assertRaisesRegex(
                 ValueError, "FUAAE is an ambiguous alias. Cannot "
                 "normalize."):
             tk.parse('FUAAE11')
Exemplo n.º 8
0
 def test_OE_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUOEH11'), ('FUØH', 2011))
Exemplo n.º 9
0
 def test_postfix_long(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016'), ('FORM', 2016))
Exemplo n.º 10
0
 def test_postfix_double(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM1617'), ('FORM', 2016))
Exemplo n.º 11
0
 def test_prefix_unicode_combined_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OK³FORM'), ('FORM', 2011))
Exemplo n.º 12
0
 def test_prefix_unicode_plus_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('K³FORM'), ('FORM', 2016))
Exemplo n.º 13
0
 def test_prefix_plus_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('KFORM'), ('FORM', 2014))
Exemplo n.º 14
0
 def test_prefix_unicode_minus_35(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T³²OFORM'), ('FORM', 1978))
Exemplo n.º 15
0
 def test_prefix_minus_5(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OFORM'), ('FORM', 2008))
Exemplo n.º 16
0
 def test_AE_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAE11'), ('FUAE', 2011))
Exemplo n.º 17
0
 def test_OE_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUHOE11'), ('FUHØ', 2011))
Exemplo n.º 18
0
 def test_postfix_reallylongslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016/2017'), ('FORM', 2016))
Exemplo n.º 19
0
 def test_AAAA(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAAAA11'), ('FUÅÅ', 2011))
Exemplo n.º 20
0
 def test_postfix_2021_slash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM20/21'), ('FORM', 2020))
Exemplo n.º 21
0
 def test_FUAEU_relative_next_year(self):
     with tk.set_gfyear(2022):
         self.assertEqual(tk.parse('GFUAEU'), ('FUÄU', 2021))
Exemplo n.º 22
0
 def test_postfix_longslash_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM 2016/17'), ('FORM', 2016))
Exemplo n.º 23
0
 def test_prefix_leadingspace(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' T2OFORM'), ('FORM', 2008))
Exemplo n.º 24
0
 def test_arg(self):
     self.assertEqual(tk.parse('FORM', 2016), ('FORM', 2016))