<commit_before>import json
from BeautifulSoup import BeautifulSoup
import requests
import sys
import re
try:
  import websocket
except:
  "Websockets not available. Please don't use initSocket()"

class SEChatBrowser:
  def __init__(self):
    self.session = requests.Session()
    self.rooms={}
    self.sockets={}
    self.chatfkey = ""
    self.chatroot = "http://chat.stackexchange.com"

  def loginSEOpenID(self, user, password):
    self.userlogin=user
    self.userpass=password
    fkey = self.getSoup("https://openid.stackexchange.com/account/login") \
             .find('input', {"name": "fkey"})['value']
    logindata = {"email": user,
                 "password": password,
                 "fkey": fkey}
    return self.session.post("https://openid.stackexchange.com/account/login/submit",
                             data=logindata,
                             allow_redirects=True)

  def loginSECOM(self):
    fkey = self.getSoup("http://stackexchange.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    return self.session.post("http://stackexchange.com/users/authenticate",
                             data=data,
                             allow_redirects=True)
  def loginMSE(self):
    fkey = self.getSoup("http://meta.stackexchange.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    self.session.post("http://meta.stackexchange.com/users/authenticate",
                      data=data,
                      allow_redirects=True)
    self.chatroot = "http://chat.meta.stackexchange.com"
    self.updateFkey()
  def loginSO(self):
    fkey = self.getSoup("http://stackoverflow.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    self.session.post("http://stackoverflow.com/users/authenticate",
                      data=data,
                      allow_redirects=True)
    self.chatroot = "http://chat.stackoverflow.com"
    self.updateFkey()

  def loginSO(self):
    fkey = self.getSoup("http://meta.stackexchange.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    self.session.post("http://meta.stackexchange.com/users/authenticate",
                      data=data,
                      allow_redirects=True)
    self.chatroot = "http://chat.meta.stackexchange.com"
    self.updateFkey()
  def loginChatSE(self):
    chatlogin = self.getSoup("http://stackexchange.com/users/chat-login")
    authToken = chatlogin.find('input', {"name": "authToken"})['value']
    nonce = chatlogin.find('input', {"name": "nonce"})['value']
    data = {"authToken": authToken, "nonce": nonce}
    referer_header = {"Referer": "http://stackexchange.com/users/chat-login"}
    rdata = self.session.post("http://chat.stackexchange.com/login/global-fallback",
                              data=data,
                              allow_redirects=True,
                              headers=referer_header).content
    fkey = BeautifulSoup(rdata).find('input', {"name": "fkey"})['value']
    self.chatfkey = fkey
    self.chatroot = "http://chat.stackexchange.com"
    return rdata

  def updateFkey(self):
    try:
      fkey = self.getSoup(self.getURL("chats/join/favorite")) \
               .find('input', {"name": "fkey"})['value']
      if fkey is not None and fkey != "":
        self.chatfkey = fkey
        return True
    except Exception as e:
        print "Error updating fkey:", e
    return False<commit_msg>Unborkify chat.SO, and remove that mSE thing<commit_after>import json
from BeautifulSoup import BeautifulSoup
import requests
import sys
import re
try:
  import websocket
except:
  "Websockets not available. Please don't use initSocket()"

class SEChatBrowser:
  def __init__(self):
    self.session = requests.Session()
    self.rooms={}
    self.sockets={}
    self.chatfkey = ""
    self.chatroot = "http://chat.stackexchange.com"

  def loginSEOpenID(self, user, password):
    self.userlogin=user
    self.userpass=password
    fkey = self.getSoup("https://openid.stackexchange.com/account/login") \
             .find('input', {"name": "fkey"})['value']
    logindata = {"email": user,
                 "password": password,
                 "fkey": fkey}
    return self.session.post("https://openid.stackexchange.com/account/login/submit",
                             data=logindata,
                             allow_redirects=True)

  def loginSECOM(self):
    fkey = self.getSoup("http://stackexchange.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    return self.session.post("http://stackexchange.com/users/authenticate",
                             data=data,
                             allow_redirects=True)
  def loginMSE(self):
    fkey = self.getSoup("http://meta.stackexchange.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    self.session.post("http://meta.stackexchange.com/users/authenticate",
                      data=data,
                      allow_redirects=True)
    self.chatroot = "http://chat.meta.stackexchange.com"
    self.updateFkey()
  def loginSO(self):
    fkey = self.getSoup("http://stackoverflow.com/users/login?returnurl = %2f") \
             .find('input', {"name": "fkey"})['value']
    data = {"fkey": fkey,
            "oauth_version": "",
            "oauth_server": "",
            "openid_identifier": "https://openid.stackexchange.com/"}
    self.session.post("http://stackoverflow.com/users/authenticate",
                      data=data,
                      allow_redirects=True)
    self.chatroot = "http://chat.stackoverflow.com"
    self.updateFkey()
  def loginChatSE(self):
    chatlogin = self.getSoup("http://stackexchange.com/users/chat-login")
    authToken = chatlogin.find('input', {"name": "authToken"})['value']
    nonce = chatlogin.find('input', {"name": "nonce"})['value']
    data = {"authToken": authToken, "nonce": nonce}
    referer_header = {"Referer": "http://stackexchange.com/users/chat-login"}
    rdata = self.session.post("http://chat.stackexchange.com/login/global-fallback",
                              data=data,
                              allow_redirects=True,
                              headers=referer_header).content
    fkey = BeautifulSoup(rdata).find('input', {"name": "fkey"})['value']
    self.chatfkey = fkey
    self.chatroot = "http://chat.stackexchange.com"
    return rdata

  def updateFkey(self):
    try:
      fkey = self.getSoup(self.getURL("chats/join/favorite")) \
               .find('input', {"name": "fkey"})['value']
      if fkey is not None and fkey != "":
        self.chatfkey = fkey
        return True
    except Exception as e:
        print "Error updating fkey:", e
    return False
{'fraction_non_alphanumeric': 0.1569005397070162, 'fraction_numerical': 0.0008995116936520175, 'mean_word_length': 2.3475268817204302, 'pattern_counts': {'":': 59, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7343085', 'n_tokens_mistral': 2493, 'n_tokens_neox': 2451, 'n_words': 390}