<commit_before>var XML = require('pixl-xml');
var request = require('request');

module.exports = {getWeatherData, getWeatherDataByCoords};

function getWeatherData(callback) {
  var url = 'http://www.yr.no/stad/Noreg/Sør-Trøndelag/Trondheim/Trondheim/varsel.xml';
  request(url, function(error, response, body) {
    if (error) {
      callback(error);
    } else if (response.statusCode != 200) {
      callback(new Error(response.statusCode));
    } else {
      var xmlDoc = XML.parse(body);
      var currentTimePeriod = xmlDoc.forecast.tabular.time[0];

      var temperature = currentTimePeriod.temperature.value;
      var windSpeed = currentTimePeriod.windSpeed.mps;
      var effectiveTemperature = getEffectiveTemperature(temperature, windSpeed);

      var weatherData = {
        temperature: Math.round(temperature),
        effectiveTemperature: Math.round(effectiveTemperature),
        windSpeed: windSpeed,
        windDirection: currentTimePeriod.windDirection.code,
        symbol: currentTimePeriod.symbol.number,
      };

      isItShortsWeather(weatherData, callback);
    }
  });
}

function getWeatherDataByCoords(lat, long, callback) {
  var url = 'http://api.met.no/weatherapi/locationforecast/1.9/?lat=' + lat + ';lon=' + long;
  request(url, function(error, response, body) {
    if (error) {
      callback(error);
    } else if (response.statusCode != 200) {
      callback(new Error(response.statusCode));
    } else {
      var xmlDoc = XML.parse(body);
      var currentTimePeriod = xmlDoc.product.time[0].location;

      var temperature = currentTimePeriod.temperature.value;
      var windSpeed = currentTimePeriod.windSpeed.mps;
      var effectiveTemperature = getEffectiveTemperature(temperature, windSpeed);

      // Symbols are weird in the met.no API
      // The first time data-point doesn't seem to have symbol data,
      // but the next one usually does.
      var symbol = xmlDoc.product.time.filter(function(timePeriod) {
        return timePeriod.location.hasOwnProperty('symbol');
      })[0].location.symbol.number;

      var weatherData = {
        temperature: Math.round(temperature),
        effectiveTemperature: Math.round(effectiveTemperature),<commit_msg>Allow all 2xx status codes<commit_after>var XML = require('pixl-xml');
var request = require('request');

module.exports = {getWeatherData, getWeatherDataByCoords};

function getWeatherData(callback) {
  var url = 'http://www.yr.no/stad/Noreg/Sør-Trøndelag/Trondheim/Trondheim/varsel.xml';
  request(url, function(error, response, body) {
    if (error) {
      callback(error);
    } else if (response.statusCode != 200) {
      callback(new Error(response.statusCode));
    } else {
      var xmlDoc = XML.parse(body);
      var currentTimePeriod = xmlDoc.forecast.tabular.time[0];

      var temperature = currentTimePeriod.temperature.value;
      var windSpeed = currentTimePeriod.windSpeed.mps;
      var effectiveTemperature = getEffectiveTemperature(temperature, windSpeed);

      var weatherData = {
        temperature: Math.round(temperature),
        effectiveTemperature: Math.round(effectiveTemperature),
        windSpeed: windSpeed,
        windDirection: currentTimePeriod.windDirection.code,
        symbol: currentTimePeriod.symbol.number,
      };

      isItShortsWeather(weatherData, callback);
    }
  });
}

function getWeatherDataByCoords(lat, long, callback) {
  var url = 'http://api.met.no/weatherapi/locationforecast/1.9/?lat=' + lat + ';lon=' + long;
  request(url, function(error, response, body) {
    if (error) {
      callback(error);
    } else if (response.statusCode < 200 || response.statusCode >= 300) {
      callback(new Error(response.statusCode));
    } else {
      var xmlDoc = XML.parse(body);
      var currentTimePeriod = xmlDoc.product.time[0].location;

      var temperature = currentTimePeriod.temperature.value;
      var windSpeed = currentTimePeriod.windSpeed.mps;
      var effectiveTemperature = getEffectiveTemperature(temperature, windSpeed);

      // Symbols are weird in the met.no API
      // The first time data-point doesn't seem to have symbol data,
      // but the next one usually does.
      var symbol = xmlDoc.product.time.filter(function(timePeriod) {
        return timePeriod.location.hasOwnProperty('symbol');
      })[0].location.symbol.number;

      var weatherData = {
        temperature: Math.round(temperature),
        effectiveTemperature: Math.round(effectiveTemperature),
{'fraction_non_alphanumeric': 0.11473214285714285, 'fraction_numerical': 0.005803571428571429, 'mean_word_length': 3.472055888223553, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7443675', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1286, 'n_words': 271}