<commit_before>#!/usr/bin/python

import requests
import re
import datetime
import subprocess
import json
from argparse import ArgumentParser
from auto_nag.bugzilla.utils import (get_config_path, get_project_root_path,
                                     createQueriesList, cleanUp)
from urllib2 import urlopen


def getTemplateValue(url):
    version_regex = re.compile(".*<p>(.*)</p>.*")
    template_page = str(requests.get(url).text.encode('utf-8')).replace('\n', '')
    parsed_template = version_regex.match(template_page)
    return parsed_template.groups()[0]


def loadJSON(url):
    jsonurl = urlopen(url)
    return json.loads(jsonurl.read())


def getVersion(jsonVersion, key):
    # In X.Y, we just need X
    version = jsonVersion[key].split(".")
    return version[0]


def getReportURL(approval_flag, span):
    a = requests.get("https://bugzilla.mozilla.org/page.cgi?id=release_tracking_report.html&q=" + approval_flag + "%3A%2B%3A" + span + "%3A0%3Aand%3A")
    return a.url


no_nag = ";field3-1-0=status_whiteboard;type3-1-0=notsubstring;value3-1-0=[no-nag]"
jsonContent = loadJSON("https://product-details.mozilla.org/1.0/firefox_versions.json")
beta_version = getVersion(jsonContent, "LATEST_FIREFOX_DEVEL_VERSION")
aurora_version = getVersion(jsonContent, "FIREFOX_AURORA")
central_version = getVersion(jsonContent, "FIREFOX_NIGHTLY")
esr_next_version = getVersion(jsonContent, "FIREFOX_ESR_NEXT")
if not len(esr_next_version):
    # We are in a cycle where we don't have esr_next
    # For example, with 52.6, esr_next doesn't exist
    # But it will exist, once 60 is released
    # esr_next will be 60
    esr_version = getVersion(jsonContent, "FIREFOX_ESR")

# TODO: We should have this in p-d at some point.
cycle_span = getTemplateValue("https://wiki.mozilla.org/Template:CURRENT_CYCLE")<commit_msg>Two changes requested by Julien<commit_after>#!/usr/bin/python

import requests
import re
import datetime
import subprocess
import json
from argparse import ArgumentParser
from auto_nag.bugzilla.utils import (get_config_path, get_project_root_path,
                                     createQueriesList, cleanUp)
from urllib2 import urlopen


def getTemplateValue(url):
    version_regex = re.compile(".*<p>(.*)</p>.*")
    template_page = str(requests.get(url).text.encode('utf-8')).replace('\n', '')
    parsed_template = version_regex.match(template_page)
    return parsed_template.groups()[0]


def loadJSON(url):
    return json.load(urlopen(url))


def getVersion(jsonVersion, key):
    # In X.Y, we just need X
    version = jsonVersion[key].split(".")
    return version[0]


def getReportURL(approval_flag, span):
    a = requests.get("https://bugzilla.mozilla.org/page.cgi?id=release_tracking_report.html&q=" + approval_flag + "%3A%2B%3A" + span + "%3A0%3Aand%3A")
    return a.url


no_nag = ";field3-1-0=status_whiteboard;type3-1-0=notsubstring;value3-1-0=[no-nag]"
jsonContent = loadJSON("https://product-details.mozilla.org/1.0/firefox_versions.json")
beta_version = getVersion(jsonContent, "LATEST_FIREFOX_DEVEL_VERSION")
aurora_version = getVersion(jsonContent, "FIREFOX_AURORA")
central_version = getVersion(jsonContent, "FIREFOX_NIGHTLY")
esr_next_version = getVersion(jsonContent, "FIREFOX_ESR_NEXT")
if not esr_next_version:
    # We are in a cycle where we don't have esr_next
    # For example, with 52.6, esr_next doesn't exist
    # But it will exist, once 60 is released
    # esr_next will be 60
    esr_version = getVersion(jsonContent, "FIREFOX_ESR")

# TODO: We should have this in p-d at some point.
cycle_span = getTemplateValue("https://wiki.mozilla.org/Template:CURRENT_CYCLE")
{'fraction_non_alphanumeric': 0.12304312002197199, 'fraction_numerical': 0.015929689645701732, 'mean_word_length': 4.681747269890796, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2342651', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1244, 'n_words': 259}