<commit_before>import os
import sys
import urllib2
import xbmc
import xbmcgui
import xbmcplugin
import socket
from pulsar.config import PULSARD_HOST
from pulsar.addon import ADDON, ADDON_ID
from pulsar.platform import PLATFORM
try:
    import simplejson as json
except ImportError:
    import json


HANDLE = int(sys.argv[1])


class closing(object):
    def __init__(self, thing):
        self.thing = thing
    def __enter__(self):
        return self.thing
    def __exit__(self, *exc_info):
        self.thing.close()


class NoRedirectHandler(urllib2.HTTPRedirectHandler):
    def http_error_302(self, req, fp, code, msg, headers):
        import urllib
        infourl = urllib.addinfourl(fp, headers, headers["Location"])
        infourl.status = code
        infourl.code = code
        return infourl
    http_error_300 = http_error_302
    http_error_301 = http_error_302
    http_error_303 = http_error_302
    http_error_307 = http_error_302


def _json(url):
    with closing(urllib2.urlopen(url)) as response:
        if response.code >= 300 and response.code <= 307:
            item = xbmcgui.ListItem(path=response.geturl(), thumbnailImage=xbmc.getInfoLabel("ListItem.Art(thumb)"))
            xbmcplugin.setResolvedUrl(HANDLE, True, item)
            return
        payload = response.read()
        if payload:
            return json.loads(payload)


def run(url_suffix=""):
    if ("%(os)s_%(arch)s" % PLATFORM) not in [
        "windows_x86",
        "darwin_x64",
        "linux_x86", "linux_x64", "linux_arm",
    ]:
        from pulsar.util import notify
        notify("Pulsar is compatible only with Windows, Linux and OS X")
        return
    if not os.path.exists(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), ".firstrun")):
        from pulsar.util import notify
        notify("You must restart XBMC before using Pulsar")
        return
    if PLATFORM["os"] not in ["windows", "linux", "darwin"]:
        from pulsar.util import notify
        notify("Pulsar is compatible only with Windows, Linux and OS X")
        return

    socket.setdefaulttimeout(300)
    urllib2.install_opener(urllib2.build_opener(NoRedirectHandler()))

    url = sys.argv[0].replace("plugin://%s" % ADDON_ID, PULSARD_HOST + url_suffix) + sys.argv[2]
    xbmc.log(url)
    data = _json(url)
    if not data:
        return<commit_msg>Remove OS checks in navigation<commit_after>import os
import sys
import urllib2
import xbmc
import xbmcgui
import xbmcplugin
import socket
from pulsar.config import PULSARD_HOST
from pulsar.addon import ADDON, ADDON_ID
from pulsar.platform import PLATFORM
try:
    import simplejson as json
except ImportError:
    import json


HANDLE = int(sys.argv[1])


class closing(object):
    def __init__(self, thing):
        self.thing = thing
    def __enter__(self):
        return self.thing
    def __exit__(self, *exc_info):
        self.thing.close()


class NoRedirectHandler(urllib2.HTTPRedirectHandler):
    def http_error_302(self, req, fp, code, msg, headers):
        import urllib
        infourl = urllib.addinfourl(fp, headers, headers["Location"])
        infourl.status = code
        infourl.code = code
        return infourl
    http_error_300 = http_error_302
    http_error_301 = http_error_302
    http_error_303 = http_error_302
    http_error_307 = http_error_302


def _json(url):
    with closing(urllib2.urlopen(url)) as response:
        if response.code >= 300 and response.code <= 307:
            item = xbmcgui.ListItem(path=response.geturl(), thumbnailImage=xbmc.getInfoLabel("ListItem.Art(thumb)"))
            xbmcplugin.setResolvedUrl(HANDLE, True, item)
            return
        payload = response.read()
        if payload:
            return json.loads(payload)


def run(url_suffix=""):
    if not os.path.exists(os.path.join(xbmc.translatePath(ADDON.getAddonInfo("path")), ".firstrun")):
        from pulsar.util import notify
        notify("You must restart XBMC before using Pulsar")
        return

    socket.setdefaulttimeout(300)
    urllib2.install_opener(urllib2.build_opener(NoRedirectHandler()))

    url = sys.argv[0].replace("plugin://%s" % ADDON_ID, PULSARD_HOST + url_suffix) + sys.argv[2]
    xbmc.log(url)
    data = _json(url)
    if not data:
        return
{'fraction_non_alphanumeric': 0.09925093632958802, 'fraction_numerical': 0.02247191011235955, 'mean_word_length': 3.1205400192864032, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '2225468', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1383, 'n_words': 330}