# Path: nudge/utils.py
# class Dict(dict):
#     def __getattr__(self, attr):
#         return self.get(attr, None)
#     __setattr__= dict.__setitem__
#     __delattr__= dict.__delitem__


import os
from nudge.utils import Dict
from jinja2 import Environment, FileSystemLoader
    extension = 'txt'
    template = get_template('default.txt')

    def __init__(self, dir='/tmp', filename='autogenerated_output'):
        self.dir = dir
        if not os.path.exists(dir):
            os.makedirs(dir)
        self.filename = filename
        self.output_file = self._filepath(self.filename)
        self.ensure_output_file()

    def _filepath(self, filename, subdir=None, extension=None):
        dir = self.dir 
        if subdir:
            dir += '/' + subdir
        if not os.path.exists(dir):
            os.makedirs(dir)
        extension = extension or self.extension
        full_path = os.path.join(dir,'%s.%s' % (filename, extension))
        return full_path

    def ensure_output_file(self, overwrite=False):
        if not os.path.exists(self.output_file):
            return True
        if overwrite:
            os.remove(self.output_file)
            return True
        raise Exception("This filename already exists.  Please remove it.")

    def generate(self, project):

# Path: nudge/utils.py
# class Dict(dict):
#     def __getattr__(self, attr):
#         return self.get(attr, None)
#     __setattr__= dict.__setitem__
#     __delattr__= dict.__delitem__


# Path: nudge/automagic/scribes/default.py
import os
from nudge.utils import Dict
from jinja2 import Environment, FileSystemLoader

    extension = 'txt'
    template = get_template('default.txt')

    def __init__(self, dir='/tmp', filename='autogenerated_output'):
        self.dir = dir
        if not os.path.exists(dir):
            os.makedirs(dir)
        self.filename = filename
        self.output_file = self._filepath(self.filename)
        self.ensure_output_file()

    def _filepath(self, filename, subdir=None, extension=None):
        dir = self.dir 
        if subdir:
            dir += '/' + subdir
        if not os.path.exists(dir):
            os.makedirs(dir)
        extension = extension or self.extension
        full_path = os.path.join(dir,'%s.%s' % (filename, extension))
        return full_path

    def ensure_output_file(self, overwrite=False):
        if not os.path.exists(self.output_file):
            return True
        if overwrite:
            os.remove(self.output_file)
            return True
        raise Exception("This filename already exists.  Please remove it.")

    def generate(self, project):

        data = self._prepare_data(Dict(project))