Export the specified context to a file
@param c
@param file
@throws ConfigurationException
548970
public void exportContext (Context c, File file) throws ConfigurationException {
		ZapXmlConfiguration config = new ZapXmlConfiguration();

		config.setProperty(Context.CONTEXT_CONFIG_NAME, c.getName());
		config.setProperty(Context.CONTEXT_CONFIG_DESC, c.getDescription());
		config.setProperty(Context.CONTEXT_CONFIG_INSCOPE, c.isInScope());
		config.setProperty(Context.CONTEXT_CONFIG_INC_REGEXES, c.getIncludeInContextRegexs());
		config.setProperty(Context.CONTEXT_CONFIG_EXC_REGEXES, c.getExcludeFromContextRegexs());
		config.setProperty(Context.CONTEXT_CONFIG_TECH_INCLUDE, techListToStringList(c.getTechSet().getIncludeTech()));
		config.setProperty(Context.CONTEXT_CONFIG_TECH_EXCLUDE, techListToStringList(c.getTechSet().getExcludeTech()));
		config.setProperty(Context.CONTEXT_CONFIG_URLPARSER_CLASS, c.getUrlParamParser().getClass().getCanonicalName());
		config.setProperty(Context.CONTEXT_CONFIG_URLPARSER_CONFIG, c.getUrlParamParser().getConfig());
		config.setProperty(Context.CONTEXT_CONFIG_POSTPARSER_CLASS, c.getPostParamParser().getClass().getCanonicalName());
		config.setProperty(Context.CONTEXT_CONFIG_POSTPARSER_CONFIG, c.getPostParamParser().getConfig());
		for (StructuralNodeModifier snm : c.getDataDrivenNodes()) {
			config.addProperty(Context.CONTEXT_CONFIG_DATA_DRIVEN_NODES, snm.getConfig());
		}
		
		model.exportContext(c, config);
		config.save(file);
	}
1070424
def save_context(context):
    """"""
    file_path = _get_context_filepath()
    content = format_to_http_prompt(context, excluded_options=EXCLUDED_OPTIONS)
    with io.open(file_path, 'w', encoding='utf-8') as f:
        f.write(content)
887910
public final void append( StringBuilder buffer, Map<String, String> configuration, Tree<Appender> context )
    {
        // Create context if needed
        Tree<Appender> currentContext = context == null ? new Tree<Appender>( this ) : context.addLeaf( this );

        // Check recursion
        if ( currentContext.inAncestors( this ) )
        {
            // For the moment just log a warning, and stop the resolving by appending original chunk
            buffer.append( chunk );

            logger.warning( format( "Recursion detected within variable resolving:%n%s", currentContext.getRoot() ) );
        }
        // Process real appending
        else
        {
            doAppend( buffer, configuration, currentContext );
            // Dump some info on resolution if this is a root appender
            if ( currentContext.isRoot() && logger.isLoggable( FINEST ) )
            {
                logger.finest( format( "Resolving variables:%n%s", currentContext ) );
            }
        }
    }
254307
def context_export(zap_helper, name, file_path):
    """"""
    with zap_error_handler():
        result = zap_helper.zap.context.export_context(name, file_path)

        if result != 'OK':
            raise ZAPError('Exporting context to file failed: {}'.format(result))

    console.info('Exported context {0} to {1}'.format(name, file_path))
662922
public static void configure(final File file, final String defaultIdent) {
    final Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);

    // Setup context
    final LoggerContext context = rootLogger.getLoggerContext();
    context.reset();

    // Log uncaught exceptions
    UncaughtExceptionLogger.setDefaultUncaughtExceptionHandler();

    // Load logging configuration from file
    try {
      final JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(context);
      configurator.doConfigure(file);
    } catch (JoranException je) {
      // StatusPrinter will handle this
    }

    context.putProperty("pid", getMyPid());
    final String hostname = getSpotifyHostname();
    if (hostname != null) {
      context.putProperty("hostname", hostname);
    }

    final String ident = context.getProperty("ident");
    if (ident == null) {
      context.putProperty("ident", defaultIdent);
    }

    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
  }
327192
public final void setContext(Kind c) {
        //NOTE:  Put context specific link code here.
        switch (c) {
            case ALL_CLASSES_FRAME:
            case PACKAGE_FRAME:
            case IMPLEMENTED_CLASSES:
            case SUBCLASSES:
            case METHOD_DOC_COPY:
            case FIELD_DOC_COPY:
            case PROPERTY_DOC_COPY:
            case CLASS_USE_HEADER:
                includeTypeInClassLinkLabel = false;
                break;

            case ANNOTATION:
                excludeTypeParameterLinks = true;
                excludeTypeBounds = true;
                break;

            case IMPLEMENTED_INTERFACES:
            case SUPER_INTERFACES:
            case SUBINTERFACES:
            case CLASS_TREE_PARENT:
            case TREE:
            case CLASS_SIGNATURE_PARENT_NAME:
                excludeTypeParameterLinks = true;
                excludeTypeBounds = true;
                includeTypeInClassLinkLabel = false;
                includeTypeAsSepLink = true;
                break;

            case PACKAGE:
            case CLASS_USE:
            case CLASS_HEADER:
            case CLASS_SIGNATURE:
                excludeTypeParameterLinks = true;
                includeTypeAsSepLink = true;
                includeTypeInClassLinkLabel = false;
                break;

            case MEMBER_TYPE_PARAMS:
                includeTypeAsSepLink = true;
                includeTypeInClassLinkLabel = false;
                break;

            case RETURN_TYPE:
            case SUMMARY_RETURN_TYPE:
                excludeTypeBounds = true;
                break;
            case EXECUTABLE_MEMBER_PARAM:
                excludeTypeBounds = true;
                break;
        }
        context = c;
        if (type != null &&
            type.asTypeVariable()!= null &&
            type.asTypeVariable().owner() instanceof ExecutableMemberDoc) {
            excludeTypeParameterLinks = true;
        }
    }
1235704
@Benchmark
	@BenchmarkMode(Mode.AverageTime)
	public void byteBufferFileOutputStream(final Configuration configuration) throws IOException {
		ByteBuffer buffer = ByteBuffer.allocate(BUFFER_CAPACITY);

		try (OutputStream stream = new FileOutputStream(configuration.file)) {
			for (long i = 0; i < LINES; ++i) {
				if (buffer.remaining() < DATA.length) {
					stream.write(buffer.array(), 0, buffer.position());
					buffer.rewind();
				}

				if (buffer.remaining() < DATA.length) {
					stream.write(DATA);
				} else {
					buffer.put(DATA);
				}
			}

			if (buffer.position() > 0) {
				stream.write(buffer.array(), 0, buffer.position());
			}
		}
	}
24179
@Override
    public void setFile(File file) {
        configFile = file;
        if (tc.isDebugEnabled())
            Tr.debug(tc, "Jaspi configuration of persistent providers will be stored in file: " + file);
    }
737964
public void storeSettingsToFile(File file) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    this.conf.writeXml(fos);
    fos.close();
  }
1189230
protected boolean writeFile(QualifiedName name, ExtraLanguageAppendable appendable, IExtraLanguageGeneratorContext context) {
		final ExtraLanguageAppendable fileAppendable = createAppendable(null, context);
		generateFileHeader(name, fileAppendable, context);

		final ImportManager importManager = appendable.getImportManager();
		if (importManager != null && !importManager.getImports().isEmpty()) {
			for (final String imported : importManager.getImports()) {
				final QualifiedName qn = getQualifiedNameConverter().toQualifiedName(imported);
				generateImportStatement(qn, fileAppendable, context);
			}
			fileAppendable.newLine();
		}

		fileAppendable.append(appendable.getContent());
		final String content = fileAppendable.getContent();

		if (!Strings.isEmpty(content)) {
			final String fileName = toFilename(name, FILENAME_SEPARATOR);
			final String outputConfiguration = getOutputConfigurationName();
			if (Strings.isEmpty(outputConfiguration)) {
				context.getFileSystemAccess().generateFile(fileName, content);
			} else {
				context.getFileSystemAccess().generateFile(fileName, outputConfiguration, content);
			}
			return true;
		}
		return false;
	}
182971
protected static Properties loadConfig(File file) {
    InputStream is = null;
    try {
      is = new FileInputStream(file);
      return loadConfig(file.getAbsolutePath(), is);     
    } catch (Exception ex) {
      throw new IllegalArgumentException("Failed to load configuration from [" + file.getAbsolutePath() + "]");
    }finally {
      if(is!=null) try { is.close(); } catch (Exception ex) { /* No Op */ }
    }
  }
1135253
public static void writeConfigFile(File configFile, Class<?>[] classes) throws SQLException, IOException {
		writeConfigFile(configFile, classes, false);
	}
307578
@Deprecated
    public static synchronized void initializeFromFile(final File file) {
        try {
            regionMetadata = loadMetadataFromFile(file);
        } catch (IOException exception) {
            throw new SdkClientException(
                    "Error parsing region metadata from " + file,
                    exception);
        }
    }
1134787
def export_c(self, target=C_TARGET, c_indent=C_INDENTATION, headerf=None):
        ''''''
        language = []
        indent = 0
        enums = set()
        for name in self._order:
            elem = getattr(self, name, None)
            if not isinstance(elem, Element):
                continue
            if not hasattr(elem, '_export_c'):
                continue
            language.append(
                '{indent}cleri_t * {name} = {value};'.format(
                    indent=c_indent,
                    name=name,
                    value=elem._export_c(c_indent, indent, enums)))

        for name, ref in self._refs.items():
            language.append(
                '{indent}cleri_ref_set({name}, {value});'
                .format(
                    indent=c_indent,
                    name=name,
                    value=ref._element._export_c(
                        c_indent,
                        indent,
                        enums,
                        ref)))

        pattern = self.RE_KEYWORDS.pattern.replace('\\', '\\\\')
        if not pattern.startswith('^'):
            pattern = '^' + pattern

        enums = ',\n'.join([
            '{}{}'.format(c_indent, gid)
            for gid in sorted(enums)]) + ','

        header_file = '"{}.h"'.format(target) if headerf is None else headerf

        fun = target.strip('/').replace('/', '_')

        return (self.__class__.C_TEMPLATE_C.format(
                    name=self.__class__.__name__,
                    target=target,
                    header_file=header_file,
                    fun=fun,
                    indent=c_indent,
                    datetime=time.strftime(
                        '%Y-%m-%d %H:%M:%S',
                        time.localtime()),
                    language='\n'.join(language),
                    re_keywords=pattern),
                self.__class__.C_TEMPLATE_H.format(
                    name=self.__class__.__name__,
                    target=target,
                    fun=fun,
                    guard=target.upper().replace('/', '_').replace('\\', '_'),
                    datetime=time.strftime(
                        '%Y-%m-%d %H:%M:%S',
                        time.localtime()),
                    language='\n'.join(language),
                    enums=enums))
213007
public static DocFile createFileForDirectory(Configuration configuration, String file) {
        return DocFileFactory.getFactory(configuration).createFileForDirectory(file);
    }
187373
String copyFile(
            final ExecutionContext executionContext,
            final File file,
            final InputStream input,
            final String content,
            final INodeEntry node,
            String destination
    ) throws FileCopierException
    {
        final String pluginname = getProvider().getName();
        final Map<String, Map<String, String>> localDataContext = createScriptDataContext(
            executionContext.getFramework(),
            executionContext.getFrameworkProject(),
            executionContext.getDataContext());
        //add node context data
        localDataContext.put("node", DataContextUtils.nodeData(node));

        Description pluginDesc = getDescription();
        //load config.* property values in from project or framework scope
        final Map<String, Map<String, String>> finalDataContext;
        try {
            finalDataContext = loadConfigData(executionContext, loadInstanceDataFromNodeAttributes(node, pluginDesc), localDataContext, pluginDesc,
                                              ServiceNameConstants.FileCopier
            );
        } catch (ConfigurationException e) {
            throw new FileCopierException("[" + pluginname + "]: "+e.getMessage(),
                    StepFailureReason.ConfigurationFailure, e);
        }

        final File srcFile =
                null != file ?
                        file :
                        BaseFileCopier.writeTempFile(executionContext, null, input, content);

        String destFilePath = destination;
        if (null == destFilePath) {

            String identity = null!=executionContext.getDataContext() && null!=executionContext.getDataContext().get("job")?
                              executionContext.getDataContext().get("job").get("execid"):null;
            destFilePath = BaseFileCopier.generateRemoteFilepathForNode(
                    node,
                    executionContext.getFramework().getFrameworkProjectMgr().getFrameworkProject(executionContext.getFrameworkProject()),
                    executionContext.getFramework(),
                    (null != file ? file.getName() : "dispatch-script"),
                    null,
                    identity
            );
        }
        //put file in a directory
        if (null != destFilePath && destFilePath.endsWith("/")) {
            destFilePath += srcFile.getName();
        }
        //add some more data context values to allow templatized script-copy attribute
        final HashMap<String, String> scptexec = new HashMap<>();
        //set up the data context to include the local temp file
        scptexec.put("file", srcFile.getAbsolutePath());
        scptexec.put("destination", null != destFilePath ? destFilePath : "");
        finalDataContext.put("file-copy", scptexec);
        Map<String, Map<String, String>> fileCopyContext =
                DataContextUtils.addContext(
                        "file-copy",
                        scptexec,
                        null
                );

        final ExecArgList execArgList = createScriptArgsList(fileCopyContext);
        final String localNodeOsFamily=getFramework().createFrameworkNode().getOsFamily();

        executionContext.getExecutionListener().log(3,
                                                    "[" +
                                                    getProvider().getName() +
                                                    "] executing: " +
                                                    execArgList.asFlatStringList()
        );

        final ByteArrayOutputStream captureSysOut = new ByteArrayOutputStream();
        try {
            final int result = getScriptExecHelper().runLocalCommand(
                    localNodeOsFamily,
                    execArgList,
                    finalDataContext,
                    null,
                    captureSysOut,
                    System.err
            );
            executionContext.getExecutionListener().log(3, "[" + pluginname + "]: result code: " + result);
            if(result!=0){
                throw new FileCopierException("[" + pluginname + "]: external script failed with exit code: " + result,
                                              NodeStepFailureReason.NonZeroResultCode);
            }
        } catch (IOException e) {
            throw new FileCopierException("[" + pluginname + "] " + e.getMessage(), StepFailureReason.IOFailure);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new FileCopierException("[" + pluginname + "] " + e.getMessage(), StepFailureReason.Interrupted);
        }finally {
            if(null == file) {
                if (!ScriptfileUtils.releaseTempFile(srcFile)) {
                    executionContext.getExecutionListener().log(
                            Constants.WARN_LEVEL,
                            "Unable to remove local temp file: " + srcFile.getAbsolutePath()
                    );
                }
            }
        }


        //load string of output from outputstream
        final String output = captureSysOut.toString();
        if (null == output || output.length() < 1) {
            if (null != destFilePath) {
                return destFilePath;
            }
            throw new FileCopierException("[" + pluginname + "]: No output from external script",
                                          ScriptPluginFailureReason.ScriptPluginFileCopierOutputMissing
            );
        }
        //TODO: require any specific format for the data?
        //look for first line of output
        final String[] split1 = output.split("(\\r?\\n)");
        if (split1.length < 1) {
            if (null != destFilePath) {
                return destFilePath;
            }
            throw new FileCopierException("[" + pluginname + "]: No output from external script",
                                          ScriptPluginFailureReason.ScriptPluginFileCopierOutputMissing);
        }
        final String remotefilepath = split1[0];

        executionContext.getExecutionListener().log(3, "[" + pluginname + "]: result filepath: " + remotefilepath);

        return remotefilepath;
    }
1331414
@Override
    public void setContext(Context context) {
        super.setContext(context);

        fsInfo = FSInfo.instance(context);

        symbolFileEnabled = !options.isSet("ignore.symbol.file");

        String sf = options.get("sortFiles");
        if (sf != null) {
            sortFiles = (sf.equals("reverse") ? SortFiles.REVERSE : SortFiles.FORWARD);
        }
    }