def write(self):
        self.generate()
        if os.path.exists(self.name):
            raise NameError, '%s project directory already exists' % self.name

        os.makedirs(self.name)
        with push_pop_dir(self.name):

            os.makedirs(self.libname)
            with open(os.path.join(self.libname, '__init__.py'), 'w') as fout:
                fout.write(self._init)
            with open(os.path.join(self.libname, 'meta.py'), 'w') as fout:
                fout.write(self._meta)
            with open('setup.py', 'w') as fout:
                fout.write(self._setup)
            with open('requirements.txt', 'w') as fout:
                fout.write(self._requirements)
            with open('Makefile', 'w') as fout:
                fout.write(MAKEFILE)

            for fname in ['README', 'LICENSE', 'INSTALL']:
                with open(fname, 'w') as fout:
                    fout.write('FILL IN')

            with open('MANIFEST.in', 'w') as fout:
                fout.write(MANIFEST)

            if self.scriptname:
                # Make a nice non .py script for end users.  It catches
                # exceptions and just prints out the error rather than a stack
                # trace, so as to not scare the end user.
                os.makedirs(self.bin_dir)
                with open(os.path.join(self.bin_dir, self.scriptname), 'w') as fout:
                    fout.write(self._script)

            os.makedirs(self.test_dir)
            with open(os.path.join(self.test_dir, 'test%s.py' % self.libname), 'w') as fout:
                fout.write(self._test)
dataset/ETHPy150Open mattharrison/poachplate/poachplatelib/package.py/Package.write/original