Пример #1
0
    def __init__(self, uri):
        """Creates an object representing a jurisdiction, given
           a valid jurisdiction URI. For a complete list, see
           cc.license.jurisdictions.list_uris()"""
        self._default_language = None

        if uri == '': # handle default jurisdiction case
            self.code = ''
            self.id = ''
            self._titles = {'en':'Unported'} # FIXME
            self.local_url = ''
            self.launched = True
            return
        if not uri.startswith('http://creativecommons.org/international/') \
           or not uri.endswith('/'):
            raise InvalidURIError, "Invalid jurisdiction URI: <%s>" % uri
        self.code = cc.license.jurisdictions.uri2code(uri)
        self.id = uri
        self._titles = rdf_helper.get_titles(self.id, rdf_helper.JURI_MODEL)
        id_uri = RDF.Uri(self.id)
        try:
            self.local_url = rdf_helper.query_to_single_value(
                id_uri, RDF.Uri(rdf_helper.NS_CC + 'jurisdictionSite'), None)
        except NoValuesFoundError:
            self.local_url = None
        try:
            self.launched = rdf_helper.query_to_single_value(
                id_uri, RDF.Uri(rdf_helper.NS_CC + 'launched'), None)
        except NoValuesFoundError:
            self.launched = None
Пример #2
0
 def title(self, language='en'):
     if self._titles is None:
         self._titles = rdf_helper.get_titles(self.uri,
                                              rdf_helper.SEL_MODEL)
     return cc.license.util.locale_dict_fetch_with_fallbacks(
         self._titles, language)
Пример #3
0
 def title(self, language="en"):
     if self._titles is None:
         self._titles = rdf_helper.get_titles(self.uri, rdf_helper.SEL_MODEL)
     return cc.license.util.locale_dict_fetch_with_fallbacks(self._titles, language)