Create file (controller/model/library)
191547
function createFile($name, $type = 'controller')
    {
        $name = $type == 'html'?strtolower($name):$name;
        $path = _APP.ucfirst($type).'/';
        $ext = $type == 'html'?'.html':'.php';

        if(file_exists($path.$name.$ext))
            return "\n\n  WARNNING: this file already exists!\n  ".$path.$name.$ext."\n\n";

        if(!$this->checkAndOrCreateDir(dirname($path.$name.$ext),true))
            return "\n\n  WARNNING: access denied in directory '".dirname($path.$name.$ext)."'\n\n";

        //get template
        $file = file_get_contents($this->cliPath.'templates/'.$type.'.tpl');

        //replace %namespace% and %name%
        $file = str_replace('%name%', ucfirst(basename($name)), $file);
        $namespace = ucfirst($type).'\\';
        foreach(explode('/', dirname($name)) as $namespc){
            if($namespc == '.') break;
            $namespace .= ucfirst($namespc).'\\';
        }
        $file = str_replace('%namespace%', trim($namespace, '\\'), $file);

        //saving the file
        $ok = file_put_contents($path.$name.$ext, $file);

        if($ok) return "\n\n  Arquivo '".$path.$name.$ext."' criado com sucesso!\n\n";
        else return "\n\n  Não foi possível criar '".$path.$name."'!\n\n";
    }
771205
def create_or_open(file_name, initial_template_file_name, args):
    
    file = None
    if not os.path.isfile(
        os.path.join(
            args['django_application_folder'],
            file_name
        )
    ):
        # If file_name does not exists, create
        file = codecs.open(
            os.path.join(
                args['django_application_folder'],
                file_name
            ),
            'w+',
            encoding='UTF-8'
        )
        print("Creating {}".format(file_name))
        if initial_template_file_name:
            render_template_with_args_in_file(file, initial_template_file_name, **{})
    else:
        # If file exists, just load the file
        file = codecs.open(
            os.path.join(
                args['django_application_folder'],
                file_name
            ),
            'a+',
            encoding='UTF-8'
        )

    return file
940948
public function generate()
  {
    $this->printMessage('');

    $this->printMessage(
      'Creating Collection config'
    );

    Files::saveCollectionConfig((new ConfigGenerator($this->config))->create());

    $this->printMessage(
      'Creating Models, Controllers, Requests, Responses, and Exceptions'
    );

    /**
     * @var string $name
     * @var Config $entity
     */
    foreach ($this->config->versions as $version => $api)
    {
      $requests = [];
      $this->printMessage($version . '...');
      foreach ($api as $entityName => $entity)
      {
        $entity = $this->vaidateEntityConfig($entityName, $entity);

        Files::initializeFolders($version, $entityName);

        if (isset($entity->model))
        {
          $columns = $entity->model->columns;

          // Models
          Files::saveModel(
            new ModelGenerator($version, $entityName, $columns)
          );

          // Requests
          foreach ($entity->requests as $requestMethod => $actions)
          {
            foreach ($actions as $actionName => $action)
            {
              if (empty($action))
              {
                continue;
              }

              $requests[] = Files::saveRequest(
                new RequestGenerator(
                  $version,
                  $entityName,
                  $entity->model,
                  $requestMethod,
                  $actionName,
                  $action
                )
              );
            }
          }

          // Responses
          Files::saveResponse(
            new ResponseGenerator($version, $entityName, $columns)
          );
        }

        // Exceptions
        $exceptions = $this->getExceptionsFromEntityConfig($entity);
        foreach ($exceptions as $exception)
        {
          Files::saveException(
            new ExceptionGenerator($version, $entityName, $exception)
          );
        }

        // Controllers
        Files::saveController(
          new ControllerGenerator($version, $entityName, $entity)
        );
      }

      Files::saveSDK(
        new SDKGenerator($version, $this->config->name, $requests)
      );
    }

    $this->printMessage("All done, Remember to add the files to VCS!");
  }
663495
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aControllers = array_filter(
                array_map(function ($sController) {
                    return implode('/', array_map('ucfirst', explode('/', ucfirst(trim($sController)))));
                }, explode(',', $aFields['CONTROLLER_NAME']))
            );
            $aMethods     = array_filter(
                array_map(function ($sMethod) {
                    return lcfirst(trim($sMethod));
                }, explode(',', $aFields['METHODS']))
            );

            sort($aControllers);

            foreach ($aControllers as $sController) {

                $aControllerBits = explode('/', $sController);
                $aControllerBits = array_map('ucfirst', $aControllerBits);

                if (count($aControllerBits) > 2) {
                    throw new ConsoleException('Controllers cannot be deeper than one directory');
                }

                $aFields['MODULE_NAME']     = getFromArray(0, $aControllerBits);
                $aFields['CONTROLLER_NAME'] = getFromArray(1, $aControllerBits, $aFields['MODULE_NAME']);
                $this->oOutput->write('Creating controller <comment>' . $sController . '</comment>... ');


                if (count($aControllerBits) == 2) {
                    //  A path has been specified, splice in the correct folder structure
                    $aLastControllerBits = array_splice($aControllerBits, -1, 1);
                    $aControllerBits     = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aLastControllerBits)
                    );
                } else {
                    //  The controller should be in a folder called itself
                    $aControllerBits = array_merge(
                        array_map('lcfirst', $aControllerBits),
                        ['controllers'],
                        array_map('ucfirst', $aControllerBits)
                    );
                }

                $aViewBits = $aControllerBits;
                array_splice($aViewBits, -2, 1, ['views']);

                $sControllerPath     = self::CONTROLLER_PATH . implode('/', array_slice($aControllerBits, 0, -1)) . '/';
                $sViewPath           = self::CONTROLLER_PATH . implode('/', array_slice($aViewBits, 0, -1)) . '/';
                $sControllerFilename = end($aControllerBits) . '.php';
                $sClassName          = ucfirst(underscoreToCamelcase(end($aControllerBits)));

                $aFields['CONTROLLER_PATH']     = $sControllerPath;
                $aFields['CONTROLLER_FILENAME'] = $sControllerFilename;
                $aFields['CONTROLLER_CLASS']    = $sClassName;
                $aFields['VIEW_PATH']           = $sViewPath;

                //  Check if the controller already exists
                if (file_exists($sControllerPath . $sControllerFilename)) {
                    throw new ConsoleException(
                        'Controller "' . $sController . '" already exists at "' . $sControllerPath . $sControllerFilename . '"'
                    );
                }

                //  Generate methods
                if ($aFields['MODULE_NAME'] === $aFields['CONTROLLER_NAME']) {
                    $sViewPathPrefix = '';
                    $sViewPrefix     = lcfirst($aFields['CONTROLLER_NAME']) . '/';
                } else {
                    $sViewPathPrefix = $aFields['CONTROLLER_NAME'] . '/';
                    $sViewPrefix     = lcfirst($aFields['MODULE_NAME']) . '/' . $aFields['CONTROLLER_NAME'] . '/';
                }

                $aMethodStrings = [];
                $aViews         = [];
                reset($aMethods);
                foreach ($aMethods as $sMethod) {

                    $aViews[]         = $sViewPathPrefix . $sMethod;
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = $this->getResource(
                        'template/controller_method.php',
                        [
                            'METHOD_NAME' => $sMethod,
                            'METHOD_VIEW' => $sViewPrefix . $sMethod,
                        ]
                    );
                    $aMethodStrings[] = '';
                    $aMethodStrings[] = '// --------------------------------------------------------------------------';
                }

                //  Remove the first item (blank string) and the last two (separators)
                $aMethodStrings = array_slice($aMethodStrings, 1, -2);

                //  Add leading tabs
                array_walk(
                    $aMethodStrings,
                    function (&$sLine) {
                        $sLine = trim($sLine);
                        if (!empty($sLine)) {
                            $aLines = explode("\n", $sLine);
                            foreach ($aLines as &$sSingleLine) {
                                $sSingleLine = $this->tabs(1) . $sSingleLine;
                            }
                            $sLine = implode("\n", $aLines);
                        }
                    }
                );

                $aFields['METHODS'] = implode("\n", $aMethodStrings);

                //  Ensure the path exists
                $this->createPath($aFields['CONTROLLER_PATH']);

                //  Create the controller and write to it
                $this->createFile(
                    $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'],
                    $this->getResource('template/controller.php', $aFields)
                );
                $aCreated[] = $aFields['CONTROLLER_PATH'] . $aFields['CONTROLLER_FILENAME'];
                $this->oOutput->writeln('<info>done!</info>');

                //  Create the views
                $this->oOutput->write('Creating views for controller <comment>' . $sController . '</comment>... ');
                $this->createPath($aFields['VIEW_PATH']);

                foreach ($aViews as $sView) {
                    $sViewPath    = $aFields['VIEW_PATH'] . $sView . '.php';
                    $sViewSubPath = dirname($sView);
                    if ($sViewSubPath !== '.') {
                        $this->createPath($aFields['VIEW_PATH'] . $sViewSubPath);
                    }
                    $this->createFile(
                        $sViewPath,
                        $this->getResource(
                            'template/view.php',
                            [
                                'VIEW' => preg_replace('#^' . NAILS_APP_PATH . '#', '', $sViewPath),
                            ]
                        )
                    );
                    $aCreated[] = $sView;

                }
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (ConsoleException $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created files</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw new ConsoleException($e->getMessage());
        }
    }
549928
public function createHomeController()
    {
        $homeController = $this->directory.'/Controllers/HomeController.php';
        $contents = $this->getStub('HomeController');

        $this->laravel['files']->put(
            $homeController,
            str_replace('DummyNamespace', config('lia.route.namespace'), $contents)
        );
        $this->line('<info>HomeController file was created:</info> '.str_replace(base_path(), '', $homeController));
    }
419122
def create_dump():
    
    dump = upkey("dump").setResultsName("action")
    return (
        dump
        + upkey("schema")
        + Optional(Group(delimitedList(table)).setResultsName("tables"))
    )
496452
protected function createRoutesFile()
    {
        $file = $this->directory.'/routes.php';

        $contents = $this->getStub('routes');
        $this->laravel['files']->put($file, str_replace('DummyNamespace', config('admin.route.namespace'), $contents));
        $this->line('<info>Routes file was created:</info> '.str_replace(base_path(), '', $file));
    }
156098
protected function writeModels()
    {
        $files = $this->modeler->create($this->options);

        foreach ($files as $file) {
            $path = pathinfo($file, PATHINFO_FILENAME);
            $this->line("      <fg=green;options=bold>create</fg=green;options=bold>  $path");
        }
    }
842143
def save_model(model, filename):
    
    with open(filename, 'w') as f:
        f.write(serialize_model(model))
1316190
public final void loadModel() {

		FileChooser fileChooser = new FileChooser();
		fileChooser.setTitle("Open configuration file");
		fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("daJLab json files", "*.json"));
		Preferences prefs = Preferences.userNodeForPackage(DajlabModel.class);
		String filePath = prefs.get(PREVIOUS_FILE_PATH, null);
		if (filePath != null) {
			fileChooser.setInitialDirectory(new File(filePath));
		}
		File file = fileChooser.showOpenDialog(getWindow());
		if (file != null) {

			DajlabModel model = ModelManager.loadModel(file);
			if (model != null) {

				// Here we have to find which controller matches with model.
				// So we look for the parameterized type M of the interface
				// DajlabControllerExtensionInterface<M>.
				// From this type, we can get the model which matches the
				// controller.
				for (DajlabControllerExtensionInterface<DajlabModelInterface> controller : controllers) {
					String typeNameController = null;
					Type[] types = controller.getClass().getGenericInterfaces();
					for (Type type : types) {
						if (type instanceof ParameterizedType && type.getTypeName()
								.contains(DajlabControllerExtensionInterface.class.getSimpleName())) {
							Type[] itypes = ((ParameterizedType) type).getActualTypeArguments();
							// Getting the type of the interface
							typeNameController = itypes[0].getTypeName();
							break;
						}
					}
					if (typeNameController != null) {
						Class<DajlabModelInterface> clazz = null;
						try {
							clazz = (Class<DajlabModelInterface>) Class.forName(typeNameController);
							controller.updateModel(model.get(clazz));
						} catch (ClassNotFoundException e) {
							// The loaded model already contains only existing
							// classes
						} catch (DaJLabRuntimeException e) {
							// Alert alert = new Alert(AlertType.WARNING);
							// alert.setContentText(MessagesUtil.getString(e.getMessage()));
							// alert.showAndWait();
						}
					}

				}
			}
		}
	}
579636
def create(self, filename, filedata):
        """"""
        attributes = {'filename': filename,
                      'source': filedata}
        return self.transport.POST(url='/file/v2/', body=attributes, type='multipart/form-data')
851057
protected function createResourceController()
    {
        Artisan::call('make:controller', [
            'name' => $controller = $this->controllerWithoutMethod($this->action()),
            '--resource' => true
        ]);
        $this->info('Resource Controller ' . $controller .' created.');
        $this->createView($this->argument('link'));
    }
1223703
public function createAction()
    {
        $console = $this->getServiceLocator()->get('console');

        if (!$console instanceof ConsoleAdapterInterface) {
            throw new \RuntimeException('Invalid controller invocation');
        }

        $io = new ConsoleIO($console);
        $skeleton = new ProjectSkeleton($io);
        $skeleton->addComponent(new DirectoryLayoutComponent())
            ->addComponent(new BootstrapGeneratorComponent());

        $console->writeLine('Application Skeleton Generator' . PHP_EOL, ColorInterface::LIGHT_CYAN);
        $console->writeLine('Creating application skeleton:' . PHP_EOL, ColorInterface::GREEN);

        $skeleton->create($this->params()->fromRoute());

        $console->writeLine(PHP_EOL . 'Done!' . PHP_EOL, ColorInterface::LIGHT_GREEN);
    }
851693
function createFile(file) {
    fs.ensureFileSync(file.name);
    fs.writeFileSync(file.name, file.source);
    return;
}
42725
protected function findFile(): void
    {
        $path = Application::getInstance()->getPath();
        $file = "$path/modules/{$this->module}/controllers/{$this->controller}.php";

        if (!file_exists($file)) {
            throw new ControllerException("Controller file not found '{$this->module}/{$this->controller}'", 404);
        }

        $this->file = $file;
    }
634108
def create(self, **kwargs):
        

        return super(PostController, self).create(**self._with_markdown(kwargs))
237230
private function makeResourceController()
    {
        $stubs = ['index', 'new', 'create', 'show', 'edit', 'update', 'delete'];
        $controllerClass = $this->applicationDir.DS.'Controllers'.DS.$this->controller.'Controller'.EXT;

        if (file_exists($controllerClass)) {
            throw new \Exception("$controllerClass already exists!!");
        }

        /*write operation ->*/
        $filePointer = fopen($controllerClass, 'w') or die('Unable to generate controller');
        $controllerContent = $this->getControllerTemplate();

        $resourceContent = '';
        foreach ($stubs as $key => $template) {
            $resourceContent .= file_get_contents($this->getControllerTemplatePath().$template.'.tpl.stub', true).PHP_EOL;
        }

        $content = $this->replaceTemplate('{%methods%}', $resourceContent, $controllerContent);

        return $this->writeContentToClass($filePointer, $content);
    }