def download_schema(uri, path, comment=None):
<EOL>if requests is None:<EOL><INDENT>sys.stderr.write(req_requests_msg)<EOL>return<EOL><DEDENT>schema = os.path.basename(uri)<EOL>try:<EOL><INDENT>req = requests.get(uri, stream=True)<EOL>req.raise_for_status()<EOL>with open(path, '<STR_LIT:wb>') as schema_download:<EOL><INDENT>for chunk in req.iter_content(chunk_size=<NUM_LIT>):<EOL><INDENT>if chunk: <EOL><INDENT>schema_download.write(chunk)<EOL><DEDENT><DEDENT><DEDENT>if comment is not None:<EOL><INDENT>tree = etree.parse(path)<EOL>tree.getroot().append(etree.Comment(comment))<EOL>with open(path, '<STR_LIT:wb>') as xml_catalog:<EOL><INDENT>xml_catalog.write(etree.tostring(tree, pretty_print=True,<EOL>xml_declaration=True, encoding="<STR_LIT>"))<EOL><DEDENT>logger.debug('<STR_LIT>', schema)<EOL><DEDENT>return True<EOL><DEDENT>except requests.exceptions.HTTPError as err:<EOL><INDENT>msg = '<STR_LIT>' % schema<EOL>msg += '<STR_LIT>' % err.response.status_code<EOL>logger.warn(msg)<EOL>return False<EOL><DEDENT>
Download a schema from a specified URI and save it locally.

    :param uri: url where the schema should be downloaded
    :param path: local file path where the schema should be saved
    :param comment: optional comment; if specified, will be added to
        the downloaded schema
    :returns: true on success, false if there was an error and the
        schema failed to download