Example #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)
Example #2
0
 def test_prefix_bestfuslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BBEST/FU'), ('BESTFU', 2011))
Example #3
0
 def test_postfix_bestfu(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('BESTFU16'), ('BESTFU', 2016))
Example #4
0
 def test_postfix_leadingspace_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' FORM 1617'), ('FORM', 2016))
Example #5
0
 def test_context(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM'), ('FORM', 2013))
Example #6
0
 def test_FUAEU_absolute_later(self):
     with tk.set_gfyear(2023):
         self.assertEqual(tk.parse('FUAEU21'), ('FUÄU', 2021))
Example #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')
Example #8
0
 def test_OE_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUOEH11'), ('FUØH', 2011))
Example #9
0
 def test_postfix_long(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016'), ('FORM', 2016))
Example #10
0
 def test_postfix_double(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM1617'), ('FORM', 2016))
Example #11
0
 def test_prefix_unicode_combined_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OK³FORM'), ('FORM', 2011))
Example #12
0
 def test_prefix_unicode_plus_3(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('K³FORM'), ('FORM', 2016))
Example #13
0
 def test_prefix_plus_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('KFORM'), ('FORM', 2014))
Example #14
0
 def test_prefix_unicode_minus_35(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T³²OFORM'), ('FORM', 1978))
Example #15
0
 def test_prefix_minus_5(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('T2OFORM'), ('FORM', 2008))
Example #16
0
 def test_AE_1(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAE11'), ('FUAE', 2011))
Example #17
0
 def test_OE_2(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUHOE11'), ('FUHØ', 2011))
Example #18
0
 def test_postfix_reallylongslash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM2016/2017'), ('FORM', 2016))
Example #19
0
 def test_AAAA(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FUAAAA11'), ('FUÅÅ', 2011))
Example #20
0
 def test_postfix_2021_slash(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM20/21'), ('FORM', 2020))
Example #21
0
 def test_FUAEU_relative_next_year(self):
     with tk.set_gfyear(2022):
         self.assertEqual(tk.parse('GFUAEU'), ('FUÄU', 2021))
Example #22
0
 def test_postfix_longslash_space(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse('FORM 2016/17'), ('FORM', 2016))
Example #23
0
 def test_prefix_leadingspace(self):
     with tk.set_gfyear(2013):
         self.assertEqual(tk.parse(' T2OFORM'), ('FORM', 2008))
Example #24
0
 def test_arg(self):
     self.assertEqual(tk.parse('FORM', 2016), ('FORM', 2016))