Extract headers from options object
484127
function extractHeaders(options) {
    let headers = {};
    if (options && options.headers) {
        headers = options.headers;
        delete options.headers;
    }
    return headers;
}
1313267
function normalizeOptions(options) {
  options = options ? options : {}
  if (!options.headers) {
    options.headers = {}
  }
  if (!options.query) {
    options.query = {}
  }
  if (!options.hasOwnProperty('auth')) {
    options.auth = true
  }
  return options
}
431041
def parse_options(cls, options):
        
        d = {}
        for filename_check, dictionary in cls.filename_checks.items():
            # retrieve the marks from the passed options
            filename_data = getattr(options, filename_check)
            if len(filename_data) != 0:
                parsed_params = {}
                for single_line in filename_data:
                    a = [s.strip() for s in single_line.split('=')]
                    # whitelist the acceptable params
                    if a[0] in ['filter_regex', 'filename_regex']:
                        parsed_params[a[0]] = a[1]
                d[filename_check] = parsed_params
        cls.filename_checks.update(d)
        # delete any empty rules
        cls.filename_checks = {x: y for x, y in cls.filename_checks.items() if len(y) > 0}
237944
function fromQueryStringWithOptions(obj, opts) {
  var str = String(obj || '').replace(/^.*?\?/, ''), result = {}, auto;
  opts = opts || {};
  if (str) {
    forEach(str.split('&'), function(p) {
      var split = p.split('=');
      var key = decodeURIComponent(split[0]);
      var val = split.length === 2 ? decodeURIComponent(split[1]) : '';
      auto = opts.auto !== false;
      parseQueryComponent(result, key, val, opts.deep, auto, opts.separator, opts.transform);
    });
  }
  return result;
}
389523
function setHeaders (options) {
  if (!options.headers) {
    options.headers = {};
  }

  if (options.bugReport) {
    options.headers[ 'Report-Msgid-Bugs-To' ] = options.bugReport;
  }

  if (options.lastTranslator) {
    options.headers[ 'Last-Translator' ] = options.lastTranslator;
  }

  if (options.team) {
    options.headers[ 'Language-Team' ] = options.team;
  }

  if (options.defaultHeaders && !options.headers.hasOwnProperty('X-Poedit-KeywordsList')) {
    options.headers[ 'X-Poedit-KeywordsList' ] = keywordsListStrings(options.gettextFunctions).join(';');
  }

  return options;
}
349055
function parseOptions(req, options) {
  if (options.query) {
    req.qs = options.query
  }
  if (options.body) {
    req.json = options.body
  }
  if (options.hasOwnProperty('encoding')) {
    req.encoding = options.encoding
  }
  if (options.headers) {
    for (let key in options.headers) {
      req.headers[key] = options.headers[key]
    }
  }
  return req
}
485719
def extract_download_options(options)
        url = options.fetch('url')

        # This avoids the potential for a KeyError
        headers = options.fetch('headers', {}) || {}

        file_size_value = options.fetch('file_size', 0)
        file_size = file_size_value.to_i

        output = {
          url: ::Addressable::URI.parse(url),
          headers: headers,
          file_size: file_size
        }

        output[:file_size] = get_file_size(output) if output[:file_size] < 1
        output
      end
43556
def get_headers(hide_env=True):
    """"""

    headers = dict(request.headers.items())

    if hide_env and ('show_env' not in request.args):
        for key in ENV_HEADERS:
            try:
                del headers[key]
            except KeyError:
                pass

    return CaseInsensitiveDict(headers.items())
978930
function parseHeaders(headers) {
  var parsed = createMap(), i;

  function fillInParsed(key, val) {
    if (key) {
      parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
    }
  }

  if (isString(headers)) {
    forEach(headers.split('\n'), function(line) {
      i = line.indexOf(':');
      fillInParsed(lowercase(trim(line.substr(0, i))), trim(line.substr(i + 1)));
    });
  } else if (isObject(headers)) {
    forEach(headers, function(headerVal, headerKey) {
      fillInParsed(lowercase(headerKey), trim(headerVal));
    });
  }

  return parsed;
}
875582
def define_options(self, names, parser_options=None):
        """"""
        def copy_option(options, name):
            return {k: v for k, v in options[name].items()}
        if parser_options is None:
            parser_options = {}
        options = {}
        for name in names:
            try:
                option = copy_option(parser_options, name)
            except KeyError:
                option = copy_option(shared_options, name)
            try:
                options.update({option['clarg']: option})
            except TypeError:
                options.update({option['clarg'][0]: option})
        return options
659900
def _parse_api_options(self, options, query_string=False):
        
        api_options = self._select_options(options, self.API_OPTIONS)
        if query_string:
            # Prefix all options with "opt_"
            query_api_options = {}
            for key in api_options:
                # Transform list/tuples into comma separated list
                if isinstance(api_options[key], (list, tuple)):
                    query_api_options[
                        'opt_' + key] = ','.join(api_options[key])
                else:
                    query_api_options[
                        'opt_' + key] = api_options[key]
            return query_api_options
        else:
            return api_options
596183
function Options(opts) {

  //### Private properties

  var custfilt = [],
      varset   = {__FILE: '', $__FILE: '""'}

  //### Public Properties

  this.header1    = _defaults.header1
  this.headers    = _defaults.headers
  this.indent     = _defaults.indent
  this.eolType    = _defaults.eolType
  this.emptyLines = _defaults.emptyLines
  this.comments   = _defaults.comments
  this.filter     = _defaults.filter

  this.emitError  = procError     // error "handler"

  //### Public Methods

  this.invalid = function (msg, v) {
    this.emitError('Invalid ' + msg + ' ' + (v != null ? '"' + v + '"' : v))
  }

  this.getVars = function () {
    return varset
  }

  this.setFile = function (file) {
    varset.$__FILE = JSON.stringify(varset.__FILE = file)
  }

  this.def = function (s) {
    var m = s.match(RE_VARPAIR)

    if (m) {
      var k = m[1],
          v = m[2].trim()

      if (!RE_VARNAME.test(k))
        this.invalid('symbol name', k)
      else
        varset[k] = !v ? 1 :
          _fixValue(evalExpr(v, varset, this.emitError))
    }
    else
      this.invalid('symbol name or declaration', s) // only when starts with '='
  }

  this.undef = function (s) {
    var def = s.match(RE_VARNAME)

    if (def)
      delete varset[def[1]]
    else
      this.invalid('symbol name', s)
  }

  this.passFilter = function (str) {
    var i, f, filts

    for (i = 0; i < custfilt.length; ++i) {
      /* istanbul ignore else */
      if (custfilt[i].test(str)) return true
    }
    filts = this.filter
    if (filts === 'all')
      filts = Object.keys(_filters)
    for (i = 0; i < filts.length; ++i) {
      f = _filters[filts[i]]
      if (f.test(str)) return true
    }
    return false
  }

  this.merge = function (opt) {
    if (opt)
      merge.call(this, opt)
    return this
  }

  return this.merge(opts)

  //### Private methods

  // prepare a value for inclussion in the set of variables
  function _fixValue(v) {
    switch (typeof v) {
      case 'number':      // typeof NaN is 'number'
      case 'boolean':
      case 'undefined':
        break
      default:
        // date value returns 'new Date(NaN)' for null dates, ok
        v = v instanceof RegExp ? '' + v :
            v instanceof Date ? '(new Date(' + (+v) + '))' : // eslint-disable-line no-extra-parens
            v == null ? v : JSON.stringify(v)
        break
    }
    return v
  }

  // returns an array as-is or created from a delimited string
  function _split(v) {
    return Array.isArray(v) ? v : v.split(',')
  }

  // Enable filters for comments, 'all' enable all filters
  function _setFilter(filt) {
    filt = filt.trim()
    if (filt === 'all')
      this.filter = filt
    else if (filt in _filters) {
      if (this.filter !== 'all' && this.filter.indexOf(filt) < 0)
        this.filter.push(filt)
    }
    else this.invalid('filter', filt)
  }

  // Creates a custom filter
  function _createFilter(res) {
    for (var i = 0; i < res.length; ++i) {
      var f = res[i]

      if (f instanceof RegExp)
        custfilt.push(f)
      else {
        //console.log('--- creating regex with `' + str + '`')
        try {
          f = new RegExp(f)
          custfilt.push(f)
        }
        catch (e) {
          f = null
        }
        if (!f) this.invalid('custom filter', res[i])
      }
    }
  }

  function _formatHeader(str) {
    return !str ? '' :
      ('' + str)
      .replace(/\r\n?/g, '\n')
      .replace(/\^{1,2}/g, function (c) { return c[1] || '\n' })
  }

  function _setVars(set) {
    for (var k in set) {
      if (RE_VARNAME.test(k))
        varset[k] = _fixValue(set[k])
      else
        this.invalid('symbol name', k)
    }
  }

  /* eslint-disable guard-for-in, complexity */
  function merge(opt) {
    var k, v

    for (k in opt) {
      v = opt[k]

      switch (k) {
        case 'varset':
          _setVars.call(this, v)
          break
        case 'define':
        case 'set':
          _split(v).forEach(this.def, this)
          break
        case 'undef':
        case 'unset':
          _split(v).forEach(this.undef, this)
          break
        case 'filter':
          _split(v).forEach(_setFilter, this)
          break
        case 'customFilter':
          _createFilter(Array.isArray(v) ? v : [v])
          break
        case 'header1':
        case 'headers':
          this[k] = _formatHeader(v)
          break
        case 'emptyLines':
          this[k] = v | 0
          break
        case 'eolType':
          if (/^(?:win|mac|unix)$/.test(v))
            this[k] = v
          else
            this.invalid(k, v)
          break
        case 'comments':
          if (/^(?:all|none|filter)$/.test(v))
            this[k] = v
          else
            this.invalid(k + ' value', v)
          break
        case 'indent':
          if (/^\d+[ts]?/.test(v))
            this[k] = v
          else if (!v)
            this[k] = ''
          else
            this.invalid(k, v)
          break
        default:
          break
      }
      //else
      //  console.log('Ignoring option ' + k)
    }
  }
}
1145084
def read_header(headerlabels, options):
    

    # set input variables
    status_field = options.status_field

    # confirm that status_field exists
    status_field_matcher = re.compile(status_field)
    if not any(x for x in headerlabels if status_field_matcher.match(x)):
        print("\n The status_field column '{s}' doesn't exist\n".format(s=status_field))
        sys.exit(1)

    # initiate prop_column dictionary and csv column index
    prop_indices = {}
    index = 0

    for label in headerlabels:
        prop_indices[label] = index
        index += 1

    return prop_indices
394150
function optionString(options) {
    return Object.keys(options).map(function (key) {
        var value = options[key];
        if (value === null) {
            return '-' + key;
        } else if (typeof value === 'number') {
            value += '';
        } else if (typeof value === 'string') {
            value = '"' + value.replace(/"/g, '\\"') + '"';
        }
        return '-' + key + '=' + value.replace(/`/g, '');
    }).join(' ');
}
179943
def showOptionalHeaderData(peInstance):
    
    
    print "[+] IMAGE_OPTIONAL_HEADER:\n"
    ohFields = peInstance.ntHeaders.optionalHeader.getFields()
    for field in ohFields:
        if not isinstance(ohFields[field],  datadirs.DataDirectory):
            print "--> %s = 0x%08x" % (field,  ohFields[field].value)
1131207
function getOptions(rules, opts) {
	var dir;
	var obj = {
		source: opts.source,
		transform: opts.transform || function (val) {
			return val;
		}
	};

	obj.path = opts.path || [];
	obj.path = Array.isArray(obj.path) ? obj.path : [obj.path];

	if (rules.length && rules[0].position && rules[0].position.source) {
		dir = path.dirname(rules[0].position.source);
	}

	if (dir && obj.path.indexOf(dir) === -1) {
		obj.path.unshift(dir);
	}

	if (!obj.path.length) {
		obj.path.push(process.cwd());
	}

	return obj;
}
907826
def extract_headers!(options = {})
      extract = {
        wrap_ttl: Vault::Client::WRAP_TTL_HEADER,
      }

      {}.tap do |h|
        extract.each do |k,v|
          if options[k]
            h[v] = options.delete(k)
          end
        end
      end
    end