<commit_before>"""
fs.httpfs
=========


"""

from fs.base import FS
from fs.path import normpath
from fs.errors import ResourceNotFoundError
from urlparse import urlparse
from urllib2 import urlopen, URLError

class HTTPFS(FS):
    
    """Can barely be called a filesystem, but this enables the opener system
    to open http files"""
    
    def __init__(self, url):        
        self.root_url = url
        
    def _make_url(self, path):
        path = normpath(path)
        url = '%s/%s' % (self.root_url.rstrip('/'), path.lstrip('/'))
        return url

    def open(self, path, mode="r"):
        
        if '+' in mode or 'w' in mode or 'a' in mode:
            raise UnsuportedError('write access')
        
        url = self._make_url(path)
        try:
            f = urlopen(url)
        except URLError, e:
            raise ResourceNotFoundError(path)
        except OSError, e:
            raise ResourceNotFoundError(path)
        
        return f
    
    def exists(self, path):
        return self.isfile(path)
    
    def isdir(self, path):
        return False
    
    def isfile(self, path):
        url = self._make_url(path)
        f = None
        try:
            try:
                f = urlopen(url)
            except (URLError, OSError):
                return False
        finally:
            if f is not None:
                f.close()
            
        return True
    
    def listdir(self, path="./",
                      wildcard=None,
                      full=False,
                      absolute=False,
                      dirs_only=False,
                      files_only=False):
        return []<commit_msg>Fixed wrong exception in httpfs<commit_after>"""
fs.httpfs
=========


"""

from fs.base import FS
from fs.path import normpath
from fs.errors import ResourceNotFoundError, UnsupportedError
from urlparse import urlparse
from urllib2 import urlopen, URLError

class HTTPFS(FS):
    
    """Can barely be called a filesystem, but this enables the opener system
    to open http files"""
    
    def __init__(self, url):        
        self.root_url = url
        
    def _make_url(self, path):
        path = normpath(path)
        url = '%s/%s' % (self.root_url.rstrip('/'), path.lstrip('/'))
        return url

    def open(self, path, mode="r"):
        
        if '+' in mode or 'w' in mode or 'a' in mode:
            raise UnsupportedError('write')
        
        url = self._make_url(path)
        try:
            f = urlopen(url)
        except URLError, e:
            raise ResourceNotFoundError(path)
        except OSError, e:
            raise ResourceNotFoundError(path)
        
        return f
    
    def exists(self, path):
        return self.isfile(path)
    
    def isdir(self, path):
        return False
    
    def isfile(self, path):
        url = self._make_url(path)
        f = None
        try:
            try:
                f = urlopen(url)
            except (URLError, OSError):
                return False
        finally:
            if f is not None:
                f.close()
            
        return True
    
    def listdir(self, path="./",
                      wildcard=None,
                      full=False,
                      absolute=False,
                      dirs_only=False,
                      files_only=False):
        return []
{'fraction_non_alphanumeric': 0.0950829383886256, 'fraction_numerical': 0.0005924170616113745, 'mean_word_length': 1.4776228906823183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3975598', 'n_tokens_mistral': 981, 'n_tokens_neox': 941, 'n_words': 276}