APIMethod: write

Parameters:
context - {Object} An object representing the map context.
options - {Object} Optional object.

Returns:
{String} An OWS Context document string.
779154
function(context, options) {
        var name = "OWSContext";
        this.nestingLayerLookup = {}; //start with empty lookup
        options = options || {};
        OpenLayers.Util.applyDefaults(options, context);
        var root = this.writeNode(name, options);
        this.nestingLayerLookup = null; //clear lookup
        this.setAttributeNS(
            root, this.namespaces["xsi"],
            "xsi:schemaLocation", this.schemaLocation
        );
        return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
    }
133380
function(context) {
        var node = this.createElementDefaultNS(
            "Layer", null, {
                queryable: context.queryable ? "1" : "0",
                hidden: context.visibility ? "0" : "1"
            }
        );
        
        // required Server element
        node.appendChild(this.write_wmc_Server(context));

        // required Name element
        node.appendChild(this.createElementDefaultNS(
            "Name", context.name
        ));
        
        // required Title element
        node.appendChild(this.createElementDefaultNS(
            "Title", context.title
        ));

         // optional Abstract element
         if (context["abstract"]) {
             node.appendChild(this.createElementDefaultNS(
                 "Abstract", context["abstract"]
             ));
         }

         // optional DataURL element
         if (context.dataURL) {
             node.appendChild(this.write_wmc_URLType("DataURL", context.dataURL));
         }

        // optional MetadataURL element
        if (context.metadataURL) {
             node.appendChild(this.write_wmc_URLType("MetadataURL", context.metadataURL));
        }
        
        return node;
    }
1216516
async function getContext(target, contextOptions) {
	if (isURL(target)) {
		const cdef = await got(target)
			.then(response => {
				const contentType = response.headers["content-type"]
				switch (contentType) {
					case 'application/x-yaml':
					case 'application/x-yml':
						return yaml.load(response.body)
					case 'application/json':
					case 'application/ld+json':
						return JSON.parse(response.body)
					default:
						throw new Error(`context type not recognized ${contentType}`)
				}
			})
		return new Context(cdef, contextOptions)
	} else {
		return loadContext(target, contextOptions)
	}
}
707380
function interpolate(template, context, options) {

  template = template || ''
  options = options || {}
  context = context || {}

  var json = options.json
    , patterns = options.patterns || ['[%]']
    , raw_patterns = options.raw_patterns || ['{{%}}']

  function replace(pattern, key, json) {
    var val = context[key]
      , re = makePattern(pattern, key)

    template = template.replace(re, function() {
      return json ? JSON.stringify(val) : val
    })
  }

  // escape special regex characters and insert key name
  function makePattern(pattern, key) {
    return new RegExp(regexSafe(pattern).replace('%', key), 'g')
  }

  for (var key in context) {
    if (!context.hasOwnProperty(key)) continue

    _.each(patterns, function(pattern) {
      replace(pattern, key, json)
    })

    _.each(raw_patterns, function(pattern) {
      replace(pattern, key)
    })
  }

  return template
}
653774
def generate_context(force_overwrite=False, drop_secret_key=False):
    

    print('... generating context')
    context_fp = '%s/context.json' % os.environ['PRODUCT_DIR']
    context = {}

    if os.path.isfile(context_fp):
        print('... augment existing context.json')

        with open(context_fp, 'r') as context_f:
            content = context_f.read().strip() or '{}'
            try:
                context = json.loads(content)
            except ValueError:
                print('ERROR: not valid json in your existing context.json!!!')
                return

        if force_overwrite:
            print('... overwriting existing context.json')
            if drop_secret_key:
                print('... generating new SECRET_KEY')
                context = {}
            else:
                print('... using existing SECRET_KEY from existing context.json')
                context = {'SECRET_KEY': context['SECRET_KEY']}

    with open(context_fp, 'w') as context_f:
        new_context = tasks.get_context_template()

        new_context.update(context)
        context_f.write(json.dumps(new_context, indent=4, sort_keys=True))
    print()
    print('*** Successfully generated context.json')
407341
def options(self, context, module_options):
        '''
        
        '''

        self.cleanup = False

        if 'CLEANUP' in module_options:
            self.cleanup = bool(module_options['CLEANUP'])

        if 'NAME' not in module_options:
            context.log.error('NAME option is required!')
            exit(1)

        if not self.cleanup and 'SERVER' not in module_options:
            context.log.error('SERVER option is required!')
            exit(1)

        self.lnk_name   = module_options['NAME']
        self.lnk_path  = '/tmp/{}.lnk'.format(self.lnk_name)
        self.file_path = ntpath.join('\\', '{}.lnk'.format(self.lnk_name))

        if not self.cleanup:
            self.server = module_options['SERVER']
            link = pylnk.create(self.lnk_path)
            link.icon = '\\\\{}\\icons\\icon.ico'.format(self.server)
            link.save()
937693
function addAuthContext(namespace) {
  if (!namespace) {
    throw new Error('No context namespace specified!');
  }

  return function addAuthContextMiddleWare(req, res, next) {
    contextService.setContext(namespace, req.userInfo);
    next();
  };
}
287612
function html(options) {
  return Object.assign(function (context) {
    var defaultOpts = {
      filename: 'index.html',
      template: 'templates/index.html',
      showErrors: false
    };

    // Merge the provided html config into the context
    var html = context.html || defaultOpts;

    /* Warning: Thar be mutation ahead! */
    /* eslint-disable fp/no-mutation */
    context.html = (0, _deepmerge2.default)(html, options, { clone: true });
    /* eslint-enable fp/no-mutation */

    // Return empty config snippet (configuration will be created by the post hook)
    return {};
  }, { post: postConfig });
}
1087190
function newContext(context, params) {
  if (!params) {
    return context;
  }

  return assign({}, context, {
    data: params.data ? arrayPush(params.data, context.data) : context.data,
    parent: params.newParent ? context : context.parent,
    index: 'index' in params ? params.index : context.index,
    item: 'item' in params ? params.item : context.item
  });
}
208536
function getContext(i) {
  if (context) {
    return context
  } else {
    const path = getCallsite(i || 2).getFileName()
    const file = files[path]
    if (file) return file.group
    throw Error(`Test module was not loaded properly: "${path}"`)
  }
}
290497
function(context, options) {
        options = OpenLayers.Util.applyDefaults({
            maxExtent:  context.maxExtent,
            projection: context.projection,
            units:      context.units
        }, options);

        if (options.maxExtent) {
            options.maxResolution = 
                options.maxExtent.getWidth() / OpenLayers.Map.TILE_WIDTH;
        }

        var metadata = {
            contactInformation: context.contactInformation,
            "abstract":         context["abstract"],
            keywords:           context.keywords,
            logo:               context.logo,
            descriptionURL:     context.descriptionURL
        };

        options.metadata = metadata;

        var map = new OpenLayers.Map(options);
        map.addLayers(this.getLayersFromContext(context.layersContext));
        map.setCenter(
            context.bounds.getCenterLonLat(),
            map.getZoomForExtent(context.bounds, true)
        );
        return map;
    }
866729
function requestToContext(req) {
  const queryMap = req.method === 'POST' ? req.body : _url2.default.parse(req.url, true).query;
  const context = {};

  if (queryMap) {
    Object.keys(queryMap).forEach(key => {
      let arg = queryMap[key];

      if (parseArgs[key] && arg) {
        context[key] = JSON.parse(arg);
      } else {
        context[key] = arg;
      }
    });
  }
  return Object.freeze(context);
}
1310655
def options(self, context, module_options):
        '''
        
        '''
        self.domains = None
        if module_options and 'DOMAIN' in module_options:
            self.domains = module_options['DOMAIN']
337224
def get_context(self, publish=False):
        
        context = self.project.DEFAULT_CONTEXT
        try:
            file = self.project.CONTEXT_SOURCE_FILE
            # CSV
            if re.search(r'(csv|CSV)$', file):
                context.update(self.get_context_from_csv())
            # Excel
            if re.search(r'(xlsx|XLSX|xls|XLS)$', file):
                context.update(self.get_context_from_xlsx())
        except AttributeError:
            context.update(self.get_context_from_gdoc())

        return context
666053
def get(self, sid):
        
        return DocumentContext(self._version, service_sid=self._solution['service_sid'], sid=sid, )
78080
func Context(ctx context.Context) Option {
	return func(o *Options) {
		o.Context = ctx
	}
}
93829
def options(self, context, module_options):
        '''
            
        '''

        if not 'PATH' in module_options:
            context.log.error('PATH option is required!')
            exit(1)

        self.payload_path = os.path.expanduser(module_options['PATH'])
        if not os.path.exists(self.payload_path):
            context.log.error('Invalid path to EXE/DLL!')
            exit(1)

        self.procid  = None
        self.exeargs = None

        if 'PROCID' in module_options:
            self.procid = module_options['PROCID']

        if 'EXEARGS' in module_options:
            self.exeargs = module_options['EXEARGS']

        self.ps_script = obfs_ps_script('powersploit/CodeExecution/Invoke-ReflectivePEInjection.ps1')