def _create_resource(self, file_name, kind='file'): resource_path = self.project._get_resource_path(file_name) if os.path.exists(resource_path): raise exceptions.RopeError('Resource <%s> already exists' % resource_path) resource = self.project.get_file(file_name) if not resource.parent.exists(): raise exceptions.ResourceNotFoundError( 'Parent folder of <%s> does not exist' % resource.path) fscommands = self._get_fscommands(resource) try: if kind == 'file': fscommands.create_file(resource_path) else: fscommands.create_folder(resource_path) except IOError as e: raise exceptions.RopeError(e)
def _create_resource(self, file_name, kind='file'): resource_path = self.project._get_resource_path(file_name) if os.path.exists(resource_path): raise exceptions.RopeError('Resource <%s> already exists' % resource_path) resource = self.project.get_file(file_name) if not resource.parent.exists(): raise exceptions.ResourceNotFoundError( 'Parent folder of <%s> does not exist' % resource.path) fscommands = self._get_fscommands(resource) try: if kind == 'file': fscommands.create_file(resource_path) else: fscommands.create_folder(resource_path) except IOError, e: raise exceptions.RopeError(e)