provide acces to opts during parsing. process data return by XML2JSON
321625
function(err, result) {
        var data=[];
    
        // default route name if not present in XML
        var now=new Date();
        data.name= 'ParseGPX' + now.toISOString(); 
    
        // search for gpx tag
        if (result['gpx'] === undefined) {
            console.log ("Fatal: Not a GPX route/track file [no <gpx></gpx> tag]");
            return (-1);
        }
        // search for track tag
        if (result['gpx']["trk"] !== undefined) {
            // console.log ("track=%s", JSON.stringify(result['gpx']["trk"]));
            data = {
                mode    : 'track',
                name    : result['gpx']["trk"][0].name,
                segment : result['gpx']["trk"][0]["trkseg"][0]['trkpt']
            };
        }
        // search for route tag
        if (result['gpx']["rte"] !== undefined) {
            //console.log ("route=%s", JSON.stringify(result['gpx']["rte"]));
            data = {
                mode    :'route',
                name    :result['gpx']["rte"][0].name,
                segment :result['gpx']["rte"][0]["rtept"]
            };
        }
        if (data.mode === undefined) {
           console.log ("Fatal Not a valid GPX route/track file <trk>|<rte> tag");
           return (-1);
        }
    
        // provide a default name if nothing found in gpxfile
        if (data.name === undefined) {
            now= new Date();
            route.name = 'GGsimulator://' + opts.gpxfile + "/" + now.toISOString();
        } else {
            route.name = 'GGsimulator://' + data.name;
        }
    
        switch (data.mode) {
            case "track":
            var spd, crs, alt,dat;
            for (var trackpts in data.segment)  {
                // console.log ("trackpts[%s]=%s", trackpts, JSON.stringify(data.segment[trackpts]));
                if (data.segment[trackpts]['name'] === undefined) nam= 'TrackPts-' + trackpts; 
                    else nam=data.segment[trackpts]['name'];
                
                lat=parseFloat (data.segment[trackpts]["$"].lat);
                lon=parseFloat (data.segment[trackpts]["$"].lon);
                spd=data.segment[trackpts]['sog'];
                crs=data.segment[trackpts]['course'];
                alt=data.segment[trackpts]['ele'];
                dat=data.segment[trackpts]['time'];
                //console.log ("name=%s  lat=%s lon=%s sog=%s course=%s alt=%s", nam, lat, lon, spd, crs, alt);
                route.waypts.push ({name: nam, lat: lat, lon: lon, date: dat});
                route.count++;
            }
            break;
        case 'route':
            var nam, lat, lon;
            for (var routepts in data.segment)  {
                // console.log ("routepts[%s]=%s", routepts, JSON.stringify(data.segment[routepts]));
                if (data.segment[routepts]['name'] === undefined)
                    nam= 'TrackPts-' + routepts;
                else
                    nam=data.segment[routepts]['name'];

                lat=parseFloat (data.segment[routepts]["$"].lat);
                lon=parseFloat (data.segment[routepts]["$"].lon);
                // console.log ("name=%s  lat=%s lon=%s", nam, lat, lon);
                route.waypts.push ({name: nam, lat: lat, lon: lon});
                route.count++;
            }
            break;
        }
    }
628116
function parseString(xml, cb) {
    return fastxml2js.parseString(xml, function(err, data) {
        //So that it's asynchronous
        process.nextTick(function() {
            cb(err, data);
        });
    });
}
828724
function processUrl(result, decl, node, opts) {
    // ignore from the css file by `!`
    if (node.value.indexOf('!') === 0) {
        node.value = node.value.slice(1);
        return Promise.resolve();
    }

    if (
        node.value.indexOf('/') === 0 ||
        node.value.indexOf('data:') === 0 ||
        node.value.indexOf('#') === 0 ||
        /^[a-z]+:\/\//.test(node.value)
    ) {
        return Promise.resolve();
    }

    /**
     * dirname of the read file css
     * @type {String}
     */
    const dirname = path.dirname(decl.source.input.file);

    let fileMeta = getFileMeta(
        dirname,
        decl.source.input.file,
        node.value,
        opts
    );

    // ignore from the fileMeta config
    if (ignore(fileMeta, opts)) {
        return Promise.resolve();
    }

    return copy(
        fileMeta.absolutePath,
        () => fileMeta.resultAbsolutePath,
        (contents, isModified) => {
            fileMeta.contents = contents;

            return Promise.resolve(
                isModified ? opts.transform(fileMeta) : fileMeta
            )
                .then(fileMetaTransformed => {
                    fileMetaTransformed.hash = opts.hashFunction(
                        fileMetaTransformed.contents
                    );
                    let tpl = opts.template;
                    if (typeof tpl === 'function') {
                        tpl = tpl(fileMetaTransformed);
                    } else {
                        tags.forEach(tag => {
                            tpl = tpl.replace(
                                '[' + tag + ']',
                                fileMetaTransformed[tag] || opts[tag] || ''
                            );
                        });
                    }

                    const resultUrl = url.parse(tpl);
                    fileMetaTransformed.resultAbsolutePath = decodeURI(
                        path.resolve(
                            opts.dest,
                            resultUrl.pathname
                        )
                    );
                    fileMetaTransformed.extra = (resultUrl.search || '') +
                        (resultUrl.hash || '');

                    return fileMetaTransformed;
                })
                .then(fileMetaTransformed => fileMetaTransformed.contents);
        }
    ).then(() => {
        const destPath = defineCSSDestPath(
            dirname,
            fileMeta.basePath,
            result,
            opts
        );

        node.value = path
            .relative(destPath, fileMeta.resultAbsolutePath)
            .split('\\')
            .join('/') + fileMeta.extra;
    });
}
1247501
function processXML(name, uri, processor, resp, callback) {
  var parser = new xml2js.Parser();

  parser.parseString(resp, function (err, xml) {
    if (err) {
      GLOBAL.error(name, err);
      return;
    } else {
      processor.getAnnotations(name, uri, xml, function(err, annoRows) {
        callback(err, {name: name, uri: uri, annoRows: annoRows});
      });
    }
  });
}
694296
function processData(res, data, options) {
  const handlers = Object.assign({}, deserializers, options.deserializers);
  const contentType = res.headers['content-type'];
  const types = typeof contentType === 'string' ? contentType.split(';') : [];

  // if there are no content types, return the data unmodified
  if (!types.length) {
    return data;
  }

  return types.reduce((d, type) => {
    try {
      const t = type.toLocaleLowerCase().trim();
      const handler = handlers[t];

      if (d instanceof Error || typeof handler !== 'function') {
        return d;
      }
      return handler(d);
    } catch (error) {
      return error;
    }
  }, data);
}
319967
function toJson(xml) {
    var deferred = Q.defer();
    xml2js.parseString(xml, function(err, result) {
      if (err) {
        deferred.reject(new Error(err));
      } else {
        deferred.resolve(result);
      }
    });
    return deferred.promise;
  }
559215
def read_postmaster_opts(self):
        """"""
        result = {}
        try:
            with open(os.path.join(self._data_dir, 'postmaster.opts')) as f:
                data = f.read()
                for opt in data.split('" "'):
                    if '=' in opt and opt.startswith('--'):
                        name, val = opt.split('=', 1)
                        result[name.strip('-')] = val.rstrip('"\n')
        except IOError:
            logger.exception('Error when reading postmaster.opts')
        return result
958259
function parseOptions(opts) {
  opts = opts || {};
  var argv = [];
  var options = {};
  var process_argv = process.argv;
  for (var i = 2; i < process_argv.length; i++) {
    if (process_argv[i].indexOf('--') == 0) {
      var arg = process_argv[i];
      if (arg.indexOf("=") > 0) {
        var arg_kv = arg.split('=');
        arg = arg_kv[0];
        arg = arg.replace('--','');
        arg = replaceAll(arg, '-', '_');
        options[arg] = arg_kv[1];
        if (typeof opts[arg] == 'string') {
          if (opts[arg] == 'int' || opts[arg] == 'integer') {
            options[arg] = parseInt(options[arg]);
          } else if (opts[arg] == 'float') {
            options[arg] = parseFloat(options[arg]);
          }
        } else if (typeof opts[arg] == 'object') {
          if (opts[arg].type == 'array') {
            var sep = opts[arg].separator || opts[arg].sep || ',';
            options[arg] = options[arg].split(sep);
          }
        }
      } else {
        arg = arg.replace('--','');
        arg = replaceAll(arg, '-', '_');
        options[arg] = true;
      }
    } else {
      argv.push(process_argv[i]);
    }
  }
  options.argv = argv;
  return options;
}
1183833
def parse_opt(self):
        
        optparser = optparse.OptionParser()
        optparser.add_option('-c', '--config',
            action='store', dest='config', type='string', default='experiments.cfg', 
            help="your experiments config file")
        optparser.add_option('-n', '--numcores',
            action='store', dest='ncores', type='int', default=cpu_count(), 
            help="number of processes you want to use, default is %i"%cpu_count())  
        optparser.add_option('-d', '--del',
            action='store_true', dest='delete', default=False, 
            help="delete experiment folder if it exists")
        optparser.add_option('-e', '--experiment',
            action='append', dest='experiments', type='string',
            help="run only selected experiments, by default run all experiments in config file.")
        optparser.add_option('-b', '--browse',
            action='store_true', dest='browse', default=False, 
            help="browse existing experiments.")      
        optparser.add_option('-B', '--Browse',
            action='store_true', dest='browse_big', default=False, 
            help="browse existing experiments, more verbose than -b")      
        optparser.add_option('-p', '--progress',
            action='store_true', dest='progress', default=False, 
            help="like browse, but only shows name and progress bar")

        options, args = optparser.parse_args()
        self.options = options
        return options, args
564309
function processBody(opts, body) {
  if (body === undefined) {
    return '';
  }
  const handlers = Object.assign({}, serializers, opts.serializers);
  const headers = typeof opts.headers === 'object' ? opts.headers : {};
  const contentType = Object.keys(headers).reduce((type, header) => {
    if (typeof type === 'string') {
      return type;
    }
    if (
      header.match(/^content-type$/i) &&
      typeof headers[header] === 'string'
    ) {
      return headers[header].toLowerCase();
    }
    return type;
  }, undefined);

  const handler = handlers[contentType];

  if (typeof handler === 'function') {
    return String(handler(body));
  }
  if (typeof body === 'object') {
    return JSON.stringify(body);
  }
  return String(body);
}
327830
def trips_process_xml():
    """"""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    xml_str = body.get('xml_str')
    tp = trips.process_xml(xml_str)
    return _stmts_from_proc(tp)
1003835
def prepare_and_invoke_api_call(path, options = {})
      api_call = prepare_api_call(path, options)
      data = invoke_api_call(api_call)

      parsed_data = case options[:format]
        when 'json' then JSON.parse(data)
        when 'xml' then REXML::Document.new(data)
        else JSON.parse(data) rescue REXML::Document.new(data) rescue data
      end
      RubyDesk.logger.info "Parsed data: #{parsed_data.inspect}"
      return parsed_data
    end
507711
function API(opts) {
  opts = opts || {};

  this.verbose = !!opts.verbose;
  this.request = opts.request || request;
  this.baseUrl = opts.baseUrl || BASE_URL;
  var parsedUrl = url.parse(this.baseUrl);
  this.basePath = parsedUrl.path;
  this.baseHost = parsedUrl.protocol + '//' + parsedUrl.host;
  this.timeout = opts.timeout || 50000;

  if (this.verbose) {
    log.setLevel('debug');
  } else {
    log.setLevel('info');
  }
}
301254
function Parser(html, opts) {
        // fake root node
        html = util.trim(html);
        this.originalHTML = html;    // only allow condition
                                     // 1. start with <!doctype
                                     // 2. start with <!html
                                     // 3. start with <!body
                                     // 4. not start with <head
                                     // 5. not start with <meta
        // only allow condition
        // 1. start with <!doctype
        // 2. start with <!html
        // 3. start with <!body
        // 4. not start with <head
        // 5. not start with <meta
        if (/^(<!doctype|<html|<body)/i.test(html)) {
            html = '<document>' + html + '</document>';
        } else {
            html = '<body>' + html + '</body>';
        }
        this.lexer = new Lexer(html);
        this.opts = opts || {};
    }
1009854
function parseObj(opts) {
    var obj = new Obj();

    Object.keys(opts).forEach(function (key) {
        obj[key] = opts[key];
    });

    return obj;
}
797725
function parse(str, options, callback) {
	if (typeof options === 'function') {
		callback = options
		options = {}
	}
	process.nextTick(() => {
		const output = parseSync(str, options)
		callback(output)
	})
}
848064
def optparse(*args)
      opts = OptionParser.new

      opts.banner = "usage: #{$0} [options]"

      opts.on('-H','--host HOST',"The host to run the server on","Default: #{@host}") do |host|
        @host = host
      end

      opts.on('-p','--port PORT',"The port to run the server on","Default: #{@port}") do |port|
        @port = port.to_i
      end

      opts.on('--s','--server NAME','Rack handler to run the server under') do |handler|
        @handler = handler
      end

      opts.on('-h','--help','Display the help output') do
        puts opts
        exit
      end

      begin
        opts.parse!(args)
      rescue OptionParser::InvalidOption => e
        STDERR.puts e.message
        STDERR.puts opts
        exit -1
      end
    end