<commit_before>from piston.utils import rc


class OcgException(Exception):
    pass


class DatasetExists(OcgException):
    
    def __init__(self,uri):
        self.uri = uri
        
    def __str__(self):
        msg = 'Dataset with URI={0} already exists.'.format(self.uri)
        return(msg)
    
    
class OcgUrlError(OcgException):
    _rc = None
    _msg = None
    
    def __init__(self,msg=None):
        assert(self._rc is not None)
        
        self.msg = msg or self._msg
        
    def __str__(self):
        return(self.msg)
        
    def response(self):
        if self.msg is not None:
            self._rc.write('\n\n'+self.msg)
        return(self._rc)
    
    
class SlugError(OcgUrlError):
    _rc = rc.BAD_REQUEST
    _msg = 'Cannot parse URL argument "{0}" following slug "{1}".'
    
    def __init__(self,slug):
        self.slug = slug
        self.msg = self.format_msg()
        super(SlugError,self).__init__(msg=self.msg)
        
    def format_msg(self):
        return(self._msg.format(self.slug.url_arg,self.slug.code))
        
        
class NoRecordsFound(SlugError):
    _msg = 'No records found for URL argument "{0}" following slug "{1}".'


class MultipleRecordsFound(SlugError):
    _msg = ('Multiple records found for URL argument {0} following slug "{1}".'
           ' Only one record should be returned by this argument.')
    
    
class UserGeometryNotFound(SlugError):
    _msg = ('The requested user geometry "{0}" could not be found.')
    
    def format_msg(self):
        return(self._msg.format(self.slug.url_arg))
    
    
class MalformedSimulationOutputSelection(OcgUrlError):
    _rc = rc.BAD_REQUEST
    _msg = ("This URL does not return a valid simulation output. Ensure the"
            " combination of archive, climate model, scenario, run, and variable"
            " return a valid simulation output.")<commit_msg>updated error message for malformed query urls<commit_after>from piston.utils import rc


class OcgException(Exception):
    pass


class DatasetExists(OcgException):
    
    def __init__(self,uri):
        self.uri = uri
        
    def __str__(self):
        msg = 'Dataset with URI={0} already exists.'.format(self.uri)
        return(msg)
    
    
class OcgUrlError(OcgException):
    _rc = None
    _msg = None
    
    def __init__(self,msg=None):
        assert(self._rc is not None)
        
        self.msg = msg or self._msg
        
    def __str__(self):
        return(self.msg)
        
    def response(self):
        if self.msg is not None:
            self._rc.write('\n\n'+self.msg)
        return(self._rc)
    
    
class SlugError(OcgUrlError):
    _rc = rc.BAD_REQUEST
    _msg = 'Cannot parse URL argument "{0}" following slug "{1}".'
    
    def __init__(self,slug):
        self.slug = slug
        self.msg = self.format_msg()
        super(SlugError,self).__init__(msg=self.msg)
        
    def format_msg(self):
        return(self._msg.format(self.slug.url_arg,self.slug.code))
        
        
class NoRecordsFound(SlugError):
    _msg = 'No records found for URL argument "{0}" following slug "{1}".'


class MultipleRecordsFound(SlugError):
    _msg = ('Multiple records found for URL argument {0} following slug "{1}".'
           ' Only one record should be returned by this argument.')
    
    
class UserGeometryNotFound(SlugError):
    _msg = ('The requested user geometry "{0}" could not be found.')
    
    def format_msg(self):
        return(self._msg.format(self.slug.url_arg))
    
    
class MalformedSimulationOutputSelection(OcgUrlError):
    _rc = rc.BAD_REQUEST
    _msg = ("Simulation data matching parameters in the URL were not found. "
            "Ensure the combination of "
            "archive, climate model, emissions scenario, run, and variable "
            "specified in the URL match a record in the simulation output table.")
{'fraction_non_alphanumeric': 0.10274852298998202, 'fraction_numerical': 0.004109940919599281, 'mean_word_length': 2.3831450912250216, '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': '2941907', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1167, 'n_words': 322}