예제 #1
0
 def get_changes(self):
     package = self.info.get_package()
     changes = change.ChangeSet('Generate Package <%s>' % self.name)
     new_resource = self.project.get_folder('%s/%s' % (package.path, self.name))
     if new_resource.exists():
         raise exceptions.RefactoringError(
             'Package <%s> already exists' % new_resource.path)
     changes.add_change(change.CreateResource(new_resource))
     changes.add_change(_add_import_to_module(
                        self.project.pycore, self.resource, new_resource))
     child = self.project.get_folder(package.path + '/' + self.name)
     changes.add_change(change.CreateFile(child, '__init__.py'))
     return changes
예제 #2
0
 def create_file(self, file_name):
     self._perform_change(
         change.CreateFile(self, file_name),
         'Creating file <%s>' % self._get_child_path(file_name))
     return self.get_child(file_name)