Esempio n. 1
0
 def print_results(self, items, requests, cb_name, opts):
     if not opts.noitems:
         print "# Scraped Items - callback: %s" % cb_name, "-"*60
         display.pprint([dict(x) for x in items], colorize=not opts.nocolour)
     if not opts.nolinks:
         print "# Requests - callback: %s" % cb_name, "-"*68
         display.pprint(requests, colorize=not opts.nocolour)
Esempio n. 2
0
    def print_items(self, lvl=None, colour=True):
        if lvl is None:
            items = [item for lst in self.items.values() for item in lst]
        else:
            items = self.items.get(lvl, [])

        print("# Scraped Items ", "-" * 60)
        display.pprint([dict(x) for x in items], colorize=colour)
Esempio n. 3
0
    def print_items(self, lvl=None, colour=True):
        if lvl is None:
            items = [item for lst in self.items.values() for item in lst]
        else:
            items = self.items.get(lvl, [])

        print("# Scraped Items ", "-"*60)
        display.pprint([dict(x) for x in items], colorize=colour)
Esempio n. 4
0
def print_items(lvl=None, colour=True):
    global items
    if lvl is None:
        items_out = [item for lst in items.values() for item in lst]
    else:
        items_out = items.get(lvl, [])

    print("# Scraped Items ", "-" * 60)
    display.pprint([dict(x) for x in items_out], colorize=colour)
Esempio n. 5
0
    def print_requests(self, lvl=None, colour=True):
        if lvl is None:
            if self.requests:
                requests = self.requests[max(self.requests)]
            else:
                requests = []
        else:
            requests = self.requests.get(lvl, [])

        print("# Requests ", "-" * 65)
        display.pprint(requests, colorize=colour)
Esempio n. 6
0
    def print_requests(self, lvl=None, colour=True):
        if lvl is None:
            levels = self.requests.keys()
            if levels:
                requests = self.requests[max(levels)]
            else:
                requests = []
        else:
            requests = self.requests.get(lvl, [])

        print "# Requests ", "-" * 65
        display.pprint(requests, colorize=colour)
Esempio n. 7
0
    def print_requests(self, lvl=None, colour=True):
        if lvl is None:
            levels = self.requests.keys()
            if levels:
                requests = self.requests[max(levels)]
            else:
                requests = []
        else:
            requests = self.requests.get(lvl, [])

        print("# Requests ", "-"*65)
        display.pprint(requests, colorize=colour)
Esempio n. 8
0
def print_requests(lvl=None, colour=True):
    global requests
    if lvl is None:
        if requests:
            requests_out = requests[max(requests)]
        else:
            requests_out = []
    else:
        requests_out = requests.get(lvl, [])

    print("# Requests ", "-" * 65)
    display.pprint(requests_out, colorize=colour)
Esempio n. 9
0
    def print_results(self, items, links, cb_name, opts):
        display.nocolour = opts.nocolour
        if not opts.noitems:
            for item in items:
                for key in item.__dict__.keys():
                    if key.startswith("_"):
                        item.__dict__.pop(key, None)
            print "# Scraped Items - callback: %s" % cb_name, "-" * 60
            display.pprint(list(items))

        if not opts.nolinks:
            print "# Links - callback: %s" % cb_name, "-" * 68
            display.pprint(list(links))
Esempio n. 10
0
    def print_items(self, lvl=None, colour=True):
        """
        print items by pprint
        :param lvl: level
        :param colour: color
        :return: None
        """
        if lvl is None:
            items = [item for lst in self.items.values() for item in lst]
        else:
            items = self.items.get(lvl, [])

        print("# Scraped Items ", "-" * 60)
        display.pprint([dict(x) for x in items], colorize=colour)
Esempio n. 11
0
    def print_requests(self, lvl=None, colour=True):
        """
        print requests by pprint
        :param lvl: level
        :param colour: color
        :return: None
        """
        if lvl is None:
            levels = list(self.requests.keys())
            if levels:
                requests = self.requests[max(levels)]
            else:
                requests = []
        else:
            requests = self.requests.get(lvl, [])

        print("# Requests ", "-" * 65)
        display.pprint(requests, colorize=colour)
 def test_pprint(self):
     with mock.patch('sys.stdout', new=StringIO()) as mock_out:
         pprint(self.object)
         self.assertEqual(mock_out.getvalue(), "{'a': 1}\n")