Method to get the file writer required for the .story files

@param scenarioName
@param aux_package_path
@param dest_dir
@return The file writer that generates the .story files for each test
@throws BeastException
499053
protected static FileWriter createFileWriter(String scenarioName,
            String aux_package_path, String dest_dir) throws BeastException {
        try {
            return new FileWriter(new File(createFolder(aux_package_path,
                    dest_dir), scenarioName + ".story"));
        } catch (IOException e) {
            String message = "ERROR writing the " + scenarioName
                    + ".story file: " + e.toString();
            logger.severe(message);
            throw new BeastException(message, e);
        }
    }
548905
function write(destPath, options) {
  var debug = require('../debug').spawn('write');

  debug(function() { return 'destPath'; });
  debug(function() { return destPath; });

  debug(function() { return 'original options';});
  debug(function() { return options; });

  if (options === undefined && typeof destPath !== 'string') {
    options = destPath;
    destPath = undefined;
  }
  options = options || {};

  // set defaults for options if unset
  if (options.includeContent === undefined) {
    options.includeContent = true;
  }
  if (options.addComment === undefined) {
    options.addComment = true;
  }
  if (options.charset === undefined) {
    options.charset = 'utf8';
  }

  debug(function() { return 'derrived options'; });
  debug(function() { return options; });

  var internals = internalsInit(destPath, options);

  function sourceMapWrite(file, encoding, callback) {
    if (file.isNull() || !file.sourceMap) {
      this.push(file);
      return callback();
    }

    if (file.isStream()) {
      return callback(new Error(utils.PLUGIN_NAME + '-write: Streaming not supported'));
    }

    // fix paths if Windows style paths
    file.sourceMap.file = unixStylePath(file.relative);

    internals.setSourceRoot(file);
    internals.loadContent(file);
    internals.mapSources(file);
    internals.mapDestPath(file, this);

    this.push(file);
    callback();
  }

  return through.obj(sourceMapWrite);
}
870825
public AbstractBuilder getPackageSummaryBuilder(PackageElement pkg, PackageElement prevPkg,
            PackageElement nextPkg) {
        return PackageSummaryBuilder.getInstance(context, pkg,
            writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
    }
455073
protected void writePackageFiles(QualifiedName name, String lineSeparator,
			IExtraLanguageGeneratorContext context) {
		final IFileSystemAccess2 fsa = context.getFileSystemAccess();
		final String outputConfiguration = getOutputConfigurationName();
		QualifiedName libraryName = null;
		for (final String segment : name.skipLast(1).getSegments()) {
			if (libraryName == null) {
				libraryName = QualifiedName.create(segment, LIBRARY_FILENAME);
			} else {
				libraryName = libraryName.append(segment).append(LIBRARY_FILENAME);
			}
			final String fileName = toFilename(libraryName);
			if (!fsa.isFile(fileName)) {
				final String content = PYTHON_FILE_HEADER + lineSeparator
						+ getGenerationComment(context) + lineSeparator
						+ LIBRARY_CONTENT;
				if (Strings.isEmpty(outputConfiguration)) {
					fsa.generateFile(fileName, content);
				} else {
					fsa.generateFile(fileName, outputConfiguration, content);
				}
			}
			libraryName = libraryName.skipLast(1);
		}
	}
749749
def write(dest)
      path = destination(dest)
      FileUtils.mkdir_p(File.dirname(path))
      File.write(path, output, :mode => "wb")
      Bunto::Hooks.trigger hook_owner, :post_write, self
    end
708247
def fromXml(cls, xdata, filepath=''):
        
        module = None
        pkg_data = xdata.find('package')
        if pkg_data is not None:
            path = pkg_data.find('path').text
            name = pkg_data.find('name').text

            if filepath:
                path = os.path.join(filepath, path)

            path = os.path.abspath(path)
            sys.path.insert(0, path)
            sys.modules.pop(name, None)

            try:
                __import__(name)
                module = sys.modules[name]
            except (ImportError, KeyError):
                return None
        else:
            return None

        # generate the builder
        builder = cls(module)
        builder.loadXml(xdata, filepath=filepath)
        return builder
444453
protected String compile(JoinableResourceBundle bundle, String content, String path, GeneratorContext context) {

		try {
			JawrScssResolver scssResolver = new JawrScssResolver(bundle, rsHandler);
			JawrScssStylesheet sheet = new JawrScssStylesheet(bundle, content, path, scssResolver,
					context.getCharset());
			sheet.compile(urlMode);
			String parsedScss = sheet.printState();
			addLinkedResources(path, context, scssResolver.getLinkedResources());

			return parsedScss;
		} catch (Exception e) {
			throw new BundlingProcessException("Unable to generate content for resource path : '" + path + "'", e);
		}
	}
563543
def create_modules_toc_file(master_package, modules, opts, name='modules'):
    
    text = format_heading(1, '%s Modules' % opts.header)
    text += '.. toctree::\n'
    text += '   :maxdepth: %s\n\n' % opts.maxdepth

    modules.sort()
    prev_module = ''
    for module in modules:
        # look if the module is a subpackage and, if yes, ignore it
        if module.startswith(prev_module + '.'):
            continue
        prev_module = module
        text += '   %s\n' % module

    write_file(name, text, opts)
1292765
def workbench_scenarios(cls):
        
        module = cls.__module__
        module = module.split('.')[0]
        directory = pkg_resources.resource_filename(module, 'scenarios')
        files = _find_files(directory)
        scenarios = _read_files(files)
        return scenarios
295373
private static FileWriter createPackageFile(String name, String packageName, String directory, String outDir)
         throws IOException
   {
      if (packageName != null && !packageName.trim().equals(""))
      {
         directory = directory + File.separatorChar +
               packageName.replace('.', File.separatorChar);
      }

      File path = new File(outDir, directory);
      if (!path.exists())
      {
         if (!path.mkdirs())
            throw new IOException("outdir can't be created");
      }

      File file = new File(path.getAbsolutePath() + File.separatorChar + name);

      if (file.exists())
      {
         if (!file.delete())
            throw new IOException("there is exist file, please check");
      }

      return new FileWriter(file);
   }
1373137
@Override
    protected List<ScenarioSpec> getChildren() {
        TestPackageRoot rootPackageAnnotation = testClass.getAnnotation(TestPackageRoot.class);
        JsonTestCases jsonTestCasesAnnotation = testClass.getAnnotation(JsonTestCases.class);
        validateSuiteAnnotationPresent(rootPackageAnnotation, jsonTestCasesAnnotation);

        if (rootPackageAnnotation != null) {
            /*
             * Different scenarios with same name -or- Same scenarios with same name more than once is prevented
             */
            smartUtils.checkDuplicateScenarios(rootPackageAnnotation.value());

            return smartUtils.getScenarioSpecListByPackage(rootPackageAnnotation.value());

        } else {
            List<JsonTestCase> jsonTestCases = Arrays.asList(testClass.getAnnotationsByType(JsonTestCase.class));
            List<String> allEndPointFiles = jsonTestCases.stream()
                    .map(thisTestCase -> thisTestCase.value())
                    .collect(Collectors.toList());

            return allEndPointFiles.stream()
                    .map(testResource -> {
                        try {
                            return smartUtils.jsonFileToJava(testResource, ScenarioSpec.class);
                        } catch (IOException e) {
                            throw new RuntimeException("Exception while deserializing to Spec. Details: " + e);
                        }
                    })
                    .collect(Collectors.toList());
        }
    }
1154913
def create_module_page(mod, dest_path, force=False):
    ""
    nb = get_empty_notebook()
    mod_name = mod.__name__
    strip_name = strip_fastai(mod_name)
    init_cell = [get_md_cell(f'## Title for {strip_name} (use plain english, not module name!)'), get_md_cell('Type an introduction of the package here.')]
    cells = [get_code_cell(f'from fastai.gen_doc.nbdoc import *\nfrom {mod_name} import * ', True)]

    gvar_map = get_global_vars(mod)
    if gvar_map: cells.append(get_md_cell('### Global Variable Definitions:'))
    for name in get_exports(mod):
        if name in gvar_map: cells.append(get_md_cell(gvar_map[name]))

    for ft_name in get_ft_names(mod, include_inner=True):
        if not hasattr(mod, ft_name):
            warnings.warn(f"Module {strip_name} doesn't have a function named {ft_name}.")
            continue
        cells += _symbol_skeleton(ft_name)
        elt = getattr(mod, ft_name)
    nb['cells'] = init_cell + cells + [get_md_cell(UNDOC_HEADER)]

    doc_path = get_doc_path(mod, dest_path)
    write_nb(nb, doc_path, 'w' if force else 'x')
    execute_nb(doc_path)
    return doc_path
1152732
@Override
  public URI uploadPackage() throws UploaderException {
    // first, check if the topology package exists
    boolean fileExists = new File(topologyPackageLocation).isFile();
    if (!fileExists) {
      throw new UploaderException(
          String.format("Topology package does not exist at '%s'", topologyPackageLocation));
    }

    // get the directory containing the file
    Path filePath = Paths.get(destTopologyFile);
    File parentDirectory = filePath.getParent().toFile();
    assert parentDirectory != null;

    // if the dest directory does not exist, create it.
    if (!parentDirectory.exists()) {
      LOG.fine(String.format(
          "Working directory does not exist. Creating it now at %s", parentDirectory.getPath()));
      if (!parentDirectory.mkdirs()) {
        throw new UploaderException(
            String.format("Failed to create directory for topology package at %s",
                parentDirectory.getPath()));
      }
    }

    // if the dest file exists, write a log message
    fileExists = new File(filePath.toString()).isFile();
    if (fileExists) {
      LOG.fine(String.format("Target topology package already exists at '%s'. Overwriting it now",
          filePath.toString()));
    }

    // copy the topology package to target working directory
    LOG.fine(String.format("Copying topology package at '%s' to target working directory '%s'",
        topologyPackageLocation, filePath.toString()));

    Path source = Paths.get(topologyPackageLocation);
    try {
      CopyOption[] options = new CopyOption[]{StandardCopyOption.REPLACE_EXISTING};
      Files.copy(source, filePath, options);
    } catch (IOException e) {
      throw new UploaderException(
            String.format("Unable to copy topology file from '%s' to '%s'",
                source, filePath), e);
    }

    return getUri(destTopologyFile);
  }
749452
public Writer getFileObjectWriterInClassOutput(String pkg, String name) throws IOException {
		FileObject resource = filer.createResource(StandardLocation.CLASS_OUTPUT, pkg, name);
		return resource.openWriter();
	}
1110812
def write(dest)
      path = destination(dest)
      FileUtils.mkdir_p(File.dirname(path))
      Jekyll.logger.debug "Writing:", path
      File.write(path, output, :mode => "wb")

      trigger_hooks(:post_write)
    end
56214
private static void generateContextDiagrams(RootDoc root, Options opt, String outputFolder)
	    throws IOException {
        Set<ClassDoc> classDocs = new TreeSet<ClassDoc>(new Comparator<ClassDoc>() {
            public int compare(ClassDoc cd1, ClassDoc cd2) {
                return cd1.name().compareTo(cd2.name());
            }
        });
        for (ClassDoc classDoc : root.classes())
            classDocs.add(classDoc);

	ContextView view = null;
	for (ClassDoc classDoc : classDocs) {
	    try {
		if(view == null)
		    view = new ContextView(outputFolder, classDoc, root, opt);
		else
		    view.setContextCenter(classDoc);
		UmlGraph.buildGraph(root, view, classDoc);
		runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root);
		alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(),
			classDoc.name() + ".html", Pattern.compile(".*(Class|Interface|Enum) " + classDoc.name() + ".*") , root);
	    } catch (Exception e) {
		throw new RuntimeException("Error generating " + classDoc.name(), e);
	    }
	}
    }
203791
public static void toFile(String templateFileName, VelocityContext context, String destPath) {
		assertInit();

		toFile(Velocity.getTemplate(templateFileName), context, destPath);
	}