# Path: fladgejt/helpers.py
# def decode_key(string):
#     '''Decode the output of :func:`encode_key` back into a tuple of strings.
# 
#     See :func:`keyed_namedtuple` for the rationale.
# 
#     Args:
#         string: A string created with :func:`encode_key`.
#     Returns:
#         The tuple of strings that was originally given to :func:`encode_key`.
#     '''
#     result = []
#     for part in string.split('.'):
#         part = part.encode('ascii')
#         part += b'=' * (-len(part) % 4)
#         part = urlsafe_b64decode(part)
#         part = part.decode('utf8')
#         result.append(part)
#     return tuple(result)
# 
# Path: fladgejt/structures.py



from fladgejt.helpers import decode_key
from fladgejt.structures import Predmet, Termin



class RestTerminyMixin:
    def get_predmety(self, zapisny_list_key):
        studium_key, akademicky_rok = decode_key(zapisny_list_key)
        sp_skratka, zaciatok = decode_key(studium_key)

        predmety = self.context.request_json(
            "zapisnyList/predmety",
            skratkaStudijnehoProgramu=sp_skratka,
            zaciatokStudia=zaciatok,
            akademickyRok=akademicky_rok)

        result = [Predmet(skratka=row['skratka'],
                          nazov=row['nazov'],
                          typ_vyucby=row['kodTypVyucby'],
                          semester=row['semester'],
                          kredit=row['kredit'])
                  for row in predmety]
        return result

    def get_prihlasene_terminy(self, zapisny_list_key):

# Path: fladgejt/helpers.py
# def decode_key(string):
#     '''Decode the output of :func:`encode_key` back into a tuple of strings.
# 
#     See :func:`keyed_namedtuple` for the rationale.
# 
#     Args:
#         string: A string created with :func:`encode_key`.
#     Returns:
#         The tuple of strings that was originally given to :func:`encode_key`.
#     '''
#     result = []
#     for part in string.split('.'):
#         part = part.encode('ascii')
#         part += b'=' * (-len(part) % 4)
#         part = urlsafe_b64decode(part)
#         part = part.decode('utf8')
#         result.append(part)
#     return tuple(result)
# 
# Path: fladgejt/structures.py



# Path: fladgejt/rest/terminy.py
from fladgejt.helpers import decode_key
from fladgejt.structures import Predmet, Termin




class RestTerminyMixin:
    def get_predmety(self, zapisny_list_key):
        studium_key, akademicky_rok = decode_key(zapisny_list_key)
        sp_skratka, zaciatok = decode_key(studium_key)

        predmety = self.context.request_json(
            "zapisnyList/predmety",
            skratkaStudijnehoProgramu=sp_skratka,
            zaciatokStudia=zaciatok,
            akademickyRok=akademicky_rok)

        result = [Predmet(skratka=row['skratka'],
                          nazov=row['nazov'],
                          typ_vyucby=row['kodTypVyucby'],
                          semester=row['semester'],
                          kredit=row['kredit'])
                  for row in predmety]
        return result

    def get_prihlasene_terminy(self, zapisny_list_key):

        studium_key, akademicky_rok = decode_key(zapisny_list_key)