Example #1
0
    def test_download_file(self):
        url = "http://ndbserver.rutgers.edu/files/ftp/NDB/coordinates/na-chiral-correct/pdb5dg7.ent.gz"
        file = DownloadHelper.download_file(url)
        self.assertIsNotNone(file)

        with self.assertRaises(FileNotFoundError):
            url = "http://ndbserver.rutgers.edu/files/ftp/NDB/coordinates/na-chiral-correct/NotExistingOne.ent.gz"
            DownloadHelper.download_file(url)
Example #2
0
    def test_download_file(self):
        url = "http://ndbserver.rutgers.edu/files/ftp/NDB/coordinates/na-chiral-correct/pdb5dg7.ent.gz"
        file = DownloadHelper.download_file(url)
        self.assertIsNotNone(file)

        with self.assertRaises(FileNotFoundError):
            url = "http://ndbserver.rutgers.edu/files/ftp/NDB/coordinates/na-chiral-correct/NotExistingOne.ent.gz"
            DownloadHelper.download_file(url)
Example #3
0
def parse_search_report(html: str) -> SimpleResult:
    """To parse simple search report from html to SimpleResult

    :param html: html string to parse
    :type html: str
    :return: simple search result
    :rtype: SimpleResult
    """
    result = SearchResult()
    parser = NDBHtmlParser()

    parser.analyze(html)
    count_tag = parser.find_one('span', params={'id': 'numRec'})

    file_tag = parser.find_one('a', after=count_tag, params={'id': 'fileGal'})
    url = file_tag.attrs.get('href', '') if file_tag else ''

    from ndb_adapter.ndb_download import DownloadHelper
    file = DownloadHelper.download_file(NDBBase.siteUrl + url)
    report = parse_xls(file)

    try:
        result.count = int(count_tag.data)
    except (TypeError, ValueError, OverflowError, AttributeError):
        pass

    result.report = report

    return result
Example #4
0
def parse_search_report(html: str) -> SimpleResult:
    """To parse simple search report from html to SimpleResult

    :param html: html string to parse
    :type html: str
    :return: simple search result
    :rtype: SimpleResult
    """
    result = SearchResult()
    parser = NDBHtmlParser()

    parser.analyze(html)
    count_tag = parser.find_one('span', params={'id': 'numRec'})

    file_tag = parser.find_one('a', after=count_tag, params={'id': 'fileGal'})
    url = file_tag.attrs.get('href', '') if file_tag else ''

    from ndb_adapter.ndb_download import DownloadHelper
    file = DownloadHelper.download_file(NDBBase.siteUrl + url)
    report = parse_xls(file)

    try:
        result.count = int(count_tag.data)
    except (TypeError, ValueError, OverflowError, AttributeError):
        pass

    result.report = report

    return result