# -*- coding: utf-8 -*-

import os
from contextlib import contextmanager


def constant(f):
    def fset(self, value):
        raise TypeError

    def fget(self):
        return f()
    return property(fget, fset)


@contextmanager
def cd(new_dir):
    prev_dir = os.getcwd()
    try:
        os.chdir(os.path.expanduser(new_dir))
        yield
    finally:
        os.chdir(prev_dir)


class FramePopulator(object):
    def __init__(self, frame):
        self.lists = {}
        self.frame = frame
        self.variables = ['commit_id', 'commit_message', 'commit_author']
        for variable in self.variables:
            self.lists[variable] = []

    def create_lists(self, commit):
        for variable in self.variables:
            key = self.extract_key(variable)
            value = getattr(commit, key)
            if key == 'author':
                value = value.name
            self.lists[variable].append(value)

    def to_frame(self):
        for variable in self.variables:
            self.frame.add_column(variable, self.lists[variable])

    def extract_key(self, index):
        return index.split('_', maxsplit=1)[1]

@@ -66,16 +66,56 @@
 manager%0A
+from abc import ABCMeta, abstractmethod%0A
 %0A%0Adef co
@@ -421,16 +421,489 @@
 _dir)%0A%0A%0A
+class final(type):%0A    def __init__(cls, name, bases, namespace):%0A        super(final, cls).__init__(name, bases, namespace)%0A        for klass in bases:%0A            if isinstance(klass, final):%0A                raise TypeError(str(klass.__name__) + %22 is final%22)%0A%0A%0Aclass Singleton(type):%0A    instance = None%0A%0A    def __call__(cls, *args, **kw):%0A        if not cls.instance:%0A            cls.instance = super(Singleton, cls).__call__(*args, **kw)%0A        return cls.instance%0A%0A%0A
 class Fr
@@ -1601,16 +1601,16 @@
 index):%0A
-
         
@@ -1648,8 +1648,139 @@
 t=1)%5B1%5D%0A
+%0A%0Aclass TransformInterface(object, metaclass=ABCMeta):%0A%0A    @abstractmethod%0A    def convert(self, value: str) -%3E str:%0A        pass%0A

add meta programming helpers