コード例 #1
0
    def test_pattern(self):
        infoq_client = client.InfoQ(cache_enabled=True)
        summary = next(scrap.get_summaries(infoq_client))

        # Nowadays, the /presentations page contains more than 10 entries
        output = self.run_cmd(self.default_cmd + ["-p", summary['title']])
        self.assertEqual(output.count("Id: "), 1)
コード例 #2
0
 def test_summaries_max_pages(self):
     # Check that only one page is fetched
     count = 0
     for summary in scrap.get_summaries(self.iq, filter=scrap.MaxPagesFilter(1)):
         self.assert_valid_summary(summary)
         # The number of presentation per page to be updated from time to time
         # We expect that the number of presentation will never be greater than
         # this magic number
         self.assertLessEqual(count, 20)
         count += 1
コード例 #3
0
ファイル: main.py プロジェクト: LispyAriaro/infoqscraper
        def main(self, infoq_client, args):
            parser = argparse.ArgumentParser(prog="%s %s %s" % (app_name, PresentationModule.name, PresentationModule.PresentationList.name))
            parser.add_argument('-m', '--max-pages', type=int, default=10,   help='maximum number of pages to fetch (~10 presentations per page)')
            parser.add_argument('-n', '--max-hits',  type=int, default=10,   help='maximum number of hits')
            parser.add_argument('-p', '--pattern',   type=str, default=None, help='filter hits according to this pattern')
            parser.add_argument('-s', '--short',     action="store_true",    help='short output, only ids are displayed')
            args = parser.parse_args(args=args)

            filter = PresentationModule.PresentationList._Filter(pattern=args.pattern, max_hits=args.max_hits, max_pages=args.max_pages)
            summaries = scrap.get_summaries(infoq_client, filter=filter)
            if args.short:
                self.__short_output(summaries)
            else:
                self.__standard_output(summaries)

            return 0
コード例 #4
0
ファイル: main.py プロジェクト: zerkms/infoqscraper
        def main(self, infoq_client, args):
            parser = argparse.ArgumentParser(
                prog="%s %s %s" % (app_name, PresentationModule.name,
                                   PresentationModule.PresentationList.name))
            parser.add_argument(
                '-m',
                '--max-pages',
                type=int,
                default=10,
                help=
                'maximum number of pages to fetch (~10 presentations per page)'
            )
            parser.add_argument('-n',
                                '--max-hits',
                                type=int,
                                default=10,
                                help='maximum number of hits')
            parser.add_argument('-p',
                                '--pattern',
                                type=str,
                                default=None,
                                help='filter hits according to this pattern')
            parser.add_argument('-s',
                                '--short',
                                action="store_true",
                                help='short output, only ids are displayed')
            args = parser.parse_args(args=args)

            filter = PresentationModule.PresentationList._Filter(
                pattern=args.pattern,
                max_hits=args.max_hits,
                max_pages=args.max_pages)
            summaries = scrap.get_summaries(infoq_client, filter=filter)
            if args.short:
                self.__short_output(summaries)
            else:
                self.__standard_output(summaries)

            return 0
コード例 #5
0
ファイル: __init__.py プロジェクト: LispyAriaro/infoqscraper
def get_latest_presentation(client):
    summary = next(scrap.get_summaries(client))
    return scrap.Presentation(client, summary['id'])
コード例 #6
0
ファイル: test_scrap.py プロジェクト: naxhh/infoqscraper
 def test_summaries(self):
     summaries = scrap.get_summaries(self.iq)
     for i in range(12):
         summary = next(summaries)
         self.assert_valid_summary(summary)
コード例 #7
0
 def test_summaries(self):
     summaries = scrap.get_summaries(self.iq)
     for i in range(12):
         summary = next(summaries)
         self.assert_valid_summary(summary)
コード例 #8
0
ファイル: __init__.py プロジェクト: zerkms/infoqscraper
def get_latest_presentation(client):
    summary = next(scrap.get_summaries(client))
    return scrap.Presentation(client, summary['id'])