{"action":"created","comment":{"url":"https://api.github.com/repos/biolab/orange3/pulls/comments/42287237","id":42287237,"diff_hunk":"@@ -0,0 +1,641 @@\n+import itertools\n+import time\n+from collections import OrderedDict\n+from itertools import chain\n+from PyQt4.QtCore import Qt, QAbstractItemModel, QByteArray, QBuffer, QIODevice\n+from PyQt4.QtGui import QGraphicsScene, QStandardItemModel, QColor\n+from Orange.widgets.io import PngFormat\n+\n+\n+class Report:\n+    \"\"\"\n+    A class that adds report-related methods to the widget.\n+    \"\"\"\n+    report_html = \"\"\n+    name = \"\"\n+\n+    def show_report(self):\n+        \"\"\"\n+        Raise the report window.\n+        \"\"\"\n+        from Orange.canvas.report.owreport import OWReport\n+\n+        report = OWReport.get_instance()\n+        self.create_report_html()\n+        report.make_report(self)\n+        report.show()\n+        report.raise_()\n+\n+    def get_widget_name_extension(self):\n+        \"\"\"\n+        Return the text that is added to the section name in the report.\n+\n+        For instance, the Distribution widget adds the name of the attribute\n+        whose distribution is shown.\n+\n+        :return: str or None\n+        \"\"\"\n+        return None\n+\n+    def create_report_html(self):\n+        \"\"\" Start a new section in report and call :obj:`send_report` method\n+        to add content.\"\"\"\n+        self.report_html = get_html_section(self.name)\n+        self.report_html += '<div class=\"content\">\\n'\n+        self.send_report()\n+        self.report_html += '</div>\\n\\n'\n+\n+    @staticmethod\n+    def _fix_args(name, items):\n+        if items is None:\n+            return \"\", name\n+        else:\n+            return name, items\n+\n+    def report_items(self, name, items=None):\n+        \"\"\"\n+        Add a sequence of pairs or an `OrderedDict` as a HTML list to report.\n+\n+        The first argument, `name` can be omitted.\n+\n+        :param name: report section name (can be omitted)\n+        :param name: str or tuple or OrderedDict\n+        :param items: a sequence of items\n+        :type items: list or tuple or OrderedDict\n+        \"\"\"\n+        name, items = self._fix_args(name, items)\n+        self.report_name(name)\n+        self.report_html += render_items(items)\n+\n+    def report_name(self, name):\n+        \"\"\" Add a section name to the report\"\"\"\n+        if name != \"\":\n+            self.report_html += get_html_subsection(name)\n+\n+    def report_data(self, name, data=None):\n+        \"\"\"\n+        Add description of data table to the report.\n+\n+        See :obj:`describe_data` for details.\n+\n+        The first argument, `name` can be omitted.\n+\n+        :param name: report section name (can be omitted)\n+        :param name: str or tuple or OrderedDict\n+        :param data: data whose description is added to the report\n+        :type data: Orange.data.Table\n+        \"\"\"\n+\n+        name, data = self._fix_args(name, data)\n+        self.report_items(name, describe_data(data))\n+\n+    def report_domain(self, name, domain=None):\n+        \"\"\"\n+        Add description of domain to the report.\n+\n+        See :obj:`describe_domain` for details.\n+\n+        The first argument, `name` can be omitted.\n+\n+        :param name: report section name (can be omitted)\n+        :param name: str or tuple or OrderedDict\n+        :param domain: domain whose description is added to the report\n+        :type domain: Orange.data.Domain\n+        \"\"\"\n+        name, domain = self._fix_args(name, domain)\n+        self.report_items(name, describe_domain(domain))\n+\n+    def report_data_brief(self, name, data=None):\n+        \"\"\"\n+        Add description of data table to the report.\n+\n+        See :obj:`describe_data_brief` for details.\n+\n+        The first argument, `name` can be omitted.\n+\n+        :param name: report section name (can be omitted)\n+        :param name: str or tuple or OrderedDict\n+        :param data: data whose description is added to the report\n+        :type data: Orange.data.Table\n+        \"\"\"\n+        name, data = self._fix_args(name, data)\n+        self.report_items(name, describe_data_brief(data))\n+\n+    def report_plot(self, name, plot=None):\n+        \"\"\"\n+        Add a plot to the report.\n+\n+        The first argument, `name` can be omitted.\n+\n+        :param name: report section name (can be omitted)\n+        :param name: str or tuple or OrderedDict\n+        :param plot: plot widget\n+        :type plot:\n+            QGraphicsScene or pyqtgraph.PlotItem or pyqtgraph.PlotWidget\n+            or pyqtgraph.GraphicsWidget\n+        \"\"\"\n+        name, plot = self._fix_args(name, plot)\n+        from pyqtgraph import PlotWidget, PlotItem, GraphicsWidget\n+        self.report_name(name)\n+        if isinstance(plot, QGraphicsScene):\n+            self.report_html += get_html_img(plot)\n+        elif isinstance(plot, PlotItem):\n+            self.report_html += get_html_img(plot)\n+        elif isinstance(plot, PlotWidget):\n+            self.report_html += get_html_img(plot.plotItem)\n+        elif isinstance(plot, GraphicsWidget):\n+            self.report_html += get_html_img(plot.scene())\n+\n+    # noinspection PyBroadException\n+    def report_table(self, name, table=None, header_rows=0, header_columns=0,\n+                     num_format=None):\n+        \"\"\"\n+        Add content of a table to the report.\n+\n+        The method accepts different kinds of two-dimensional data, including\n+        Qt's views and models.\n+\n+        The first argument, `name` can be omitted if other arguments (except\n+        `table`) are passed as keyword arguments.\n+\n+        :param name: name of the section\n+        :type name: str\n+        :param table: table to be reported\n+        :type table:\n+            QAbstractItemModel or QStandardItemModel or two-dimensional list or\n+            any object with method `model()` that returns one of the above\n+        :param header_rows: the number of rows that are marked as header rows\n+        :type header_rows: int\n+        :param header_columns:\n+            the number of columns that are marked as header columns\n+        :type header_columns: int\n+        :param num_format: numeric format, e.g. `{:.3}`","path":"Orange/canvas/report/report.py","position":172,"original_position":172,"commit_id":"fc1b5fa94bcdf9ea527a2e2216323fce654d96d9","original_commit_id":"fc1b5fa94bcdf9ea527a2e2216323fce654d96d9","user":{"login":"kernc","id":684364,"avatar_url":"https://avatars.githubusercontent.com/u/684364?v=3","gravatar_id":"","url":"https://api.github.com/users/kernc","html_url":"https://github.com/kernc","followers_url":"https://api.github.com/users/kernc/followers","following_url":"https://api.github.com/users/kernc/following{/other_user}","gists_url":"https://api.github.com/users/kernc/gists{/gist_id}","starred_url":"https://api.github.com/users/kernc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kernc/subscriptions","organizations_url":"https://api.github.com/users/kernc/orgs","repos_url":"https://api.github.com/users/kernc/repos","events_url":"https://api.github.com/users/kernc/events{/privacy}","received_events_url":"https://api.github.com/users/kernc/received_events","type":"User","site_admin":false},"body":":+1: for Napoleon here as well.","created_at":"2015-10-16T20:36:06Z","updated_at":"2015-10-16T20:36:06Z","html_url":"https://github.com/biolab/orange3/pull/739#discussion_r42287237","pull_request_url":"https://api.github.com/repos/biolab/orange3/pulls/739","_links":{"self":{"href":"https://api.github.com/repos/biolab/orange3/pulls/comments/42287237"},"html":{"href":"https://github.com/biolab/orange3/pull/739#discussion_r42287237"},"pull_request":{"href":"https://api.github.com/repos/biolab/orange3/pulls/739"}}},"pull_request":{"url":"https://api.github.com/repos/biolab/orange3/pulls/739","id":46887771,"html_url":"https://github.com/biolab/orange3/pull/739","diff_url":"https://github.com/biolab/orange3/pull/739.diff","patch_url":"https://github.com/biolab/orange3/pull/739.patch","issue_url":"https://api.github.com/repos/biolab/orange3/issues/739","number":739,"state":"open","locked":false,"title":"Reporting","user":{"login":"VesnaT","id":11465003,"avatar_url":"https://avatars.githubusercontent.com/u/11465003?v=3","gravatar_id":"","url":"https://api.github.com/users/VesnaT","html_url":"https://github.com/VesnaT","followers_url":"https://api.github.com/users/VesnaT/followers","following_url":"https://api.github.com/users/VesnaT/following{/other_user}","gists_url":"https://api.github.com/users/VesnaT/gists{/gist_id}","starred_url":"https://api.github.com/users/VesnaT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VesnaT/subscriptions","organizations_url":"https://api.github.com/users/VesnaT/orgs","repos_url":"https://api.github.com/users/VesnaT/repos","events_url":"https://api.github.com/users/VesnaT/events{/privacy}","received_events_url":"https://api.github.com/users/VesnaT/received_events","type":"User","site_admin":false},"body":"OWReport: New report widget.\r\nAdd report to most widgets.","created_at":"2015-10-06T10:52:52Z","updated_at":"2015-10-16T20:36:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a18da4bea97f73b4e83d6bdb2204814ec79935be","assignee":{"login":"astaric","id":588601,"avatar_url":"https://avatars.githubusercontent.com/u/588601?v=3","gravatar_id":"","url":"https://api.github.com/users/astaric","html_url":"https://github.com/astaric","followers_url":"https://api.github.com/users/astaric/followers","following_url":"https://api.github.com/users/astaric/following{/other_user}","gists_url":"https://api.github.com/users/astaric/gists{/gist_id}","starred_url":"https://api.github.com/users/astaric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astaric/subscriptions","organizations_url":"https://api.github.com/users/astaric/orgs","repos_url":"https://api.github.com/users/astaric/repos","events_url":"https://api.github.com/users/astaric/events{/privacy}","received_events_url":"https://api.github.com/users/astaric/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/biolab/orange3/pulls/739/commits","review_comments_url":"https://api.github.com/repos/biolab/orange3/pulls/739/comments","review_comment_url":"https://api.github.com/repos/biolab/orange3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biolab/orange3/issues/739/comments","statuses_url":"https://api.github.com/repos/biolab/orange3/statuses/fc1b5fa94bcdf9ea527a2e2216323fce654d96d9","head":{"label":"VesnaT:report1","ref":"report1","sha":"fc1b5fa94bcdf9ea527a2e2216323fce654d96d9","user":{"login":"VesnaT","id":11465003,"avatar_url":"https://avatars.githubusercontent.com/u/11465003?v=3","gravatar_id":"","url":"https://api.github.com/users/VesnaT","html_url":"https://github.com/VesnaT","followers_url":"https://api.github.com/users/VesnaT/followers","following_url":"https://api.github.com/users/VesnaT/following{/other_user}","gists_url":"https://api.github.com/users/VesnaT/gists{/gist_id}","starred_url":"https://api.github.com/users/VesnaT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VesnaT/subscriptions","organizations_url":"https://api.github.com/users/VesnaT/orgs","repos_url":"https://api.github.com/users/VesnaT/repos","events_url":"https://api.github.com/users/VesnaT/events{/privacy}","received_events_url":"https://api.github.com/users/VesnaT/received_events","type":"User","site_admin":false},"repo":{"id":35279595,"name":"orange3","full_name":"VesnaT/orange3","owner":{"login":"VesnaT","id":11465003,"avatar_url":"https://avatars.githubusercontent.com/u/11465003?v=3","gravatar_id":"","url":"https://api.github.com/users/VesnaT","html_url":"https://github.com/VesnaT","followers_url":"https://api.github.com/users/VesnaT/followers","following_url":"https://api.github.com/users/VesnaT/following{/other_user}","gists_url":"https://api.github.com/users/VesnaT/gists{/gist_id}","starred_url":"https://api.github.com/users/VesnaT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VesnaT/subscriptions","organizations_url":"https://api.github.com/users/VesnaT/orgs","repos_url":"https://api.github.com/users/VesnaT/repos","events_url":"https://api.github.com/users/VesnaT/events{/privacy}","received_events_url":"https://api.github.com/users/VesnaT/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VesnaT/orange3","description":"","fork":true,"url":"https://api.github.com/repos/VesnaT/orange3","forks_url":"https://api.github.com/repos/VesnaT/orange3/forks","keys_url":"https://api.github.com/repos/VesnaT/orange3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VesnaT/orange3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VesnaT/orange3/teams","hooks_url":"https://api.github.com/repos/VesnaT/orange3/hooks","issue_events_url":"https://api.github.com/repos/VesnaT/orange3/issues/events{/number}","events_url":"https://api.github.com/repos/VesnaT/orange3/events","assignees_url":"https://api.github.com/repos/VesnaT/orange3/assignees{/user}","branches_url":"https://api.github.com/repos/VesnaT/orange3/branches{/branch}","tags_url":"https://api.github.com/repos/VesnaT/orange3/tags","blobs_url":"https://api.github.com/repos/VesnaT/orange3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VesnaT/orange3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VesnaT/orange3/git/refs{/sha}","trees_url":"https://api.github.com/repos/VesnaT/orange3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VesnaT/orange3/statuses/{sha}","languages_url":"https://api.github.com/repos/VesnaT/orange3/languages","stargazers_url":"https://api.github.com/repos/VesnaT/orange3/stargazers","contributors_url":"https://api.github.com/repos/VesnaT/orange3/contributors","subscribers_url":"https://api.github.com/repos/VesnaT/orange3/subscribers","subscription_url":"https://api.github.com/repos/VesnaT/orange3/subscription","commits_url":"https://api.github.com/repos/VesnaT/orange3/commits{/sha}","git_commits_url":"https://api.github.com/repos/VesnaT/orange3/git/commits{/sha}","comments_url":"https://api.github.com/repos/VesnaT/orange3/comments{/number}","issue_comment_url":"https://api.github.com/repos/VesnaT/orange3/issues/comments{/number}","contents_url":"https://api.github.com/repos/VesnaT/orange3/contents/{+path}","compare_url":"https://api.github.com/repos/VesnaT/orange3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VesnaT/orange3/merges","archive_url":"https://api.github.com/repos/VesnaT/orange3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VesnaT/orange3/downloads","issues_url":"https://api.github.com/repos/VesnaT/orange3/issues{/number}","pulls_url":"https://api.github.com/repos/VesnaT/orange3/pulls{/number}","milestones_url":"https://api.github.com/repos/VesnaT/orange3/milestones{/number}","notifications_url":"https://api.github.com/repos/VesnaT/orange3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VesnaT/orange3/labels{/name}","releases_url":"https://api.github.com/repos/VesnaT/orange3/releases{/id}","created_at":"2015-05-08T13:04:38Z","updated_at":"2015-05-08T13:04:41Z","pushed_at":"2015-10-16T14:56:58Z","git_url":"git://github.com/VesnaT/orange3.git","ssh_url":"git@github.com:VesnaT/orange3.git","clone_url":"https://github.com/VesnaT/orange3.git","svn_url":"https://github.com/VesnaT/orange3","homepage":null,"size":31009,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"biolab:master","ref":"master","sha":"37b37d6bb8fc6ae273516cf370236ca009b97672","user":{"login":"biolab","id":555189,"avatar_url":"https://avatars.githubusercontent.com/u/555189?v=3","gravatar_id":"","url":"https://api.github.com/users/biolab","html_url":"https://github.com/biolab","followers_url":"https://api.github.com/users/biolab/followers","following_url":"https://api.github.com/users/biolab/following{/other_user}","gists_url":"https://api.github.com/users/biolab/gists{/gist_id}","starred_url":"https://api.github.com/users/biolab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biolab/subscriptions","organizations_url":"https://api.github.com/users/biolab/orgs","repos_url":"https://api.github.com/users/biolab/repos","events_url":"https://api.github.com/users/biolab/events{/privacy}","received_events_url":"https://api.github.com/users/biolab/received_events","type":"Organization","site_admin":false},"repo":{"id":8357227,"name":"orange3","full_name":"biolab/orange3","owner":{"login":"biolab","id":555189,"avatar_url":"https://avatars.githubusercontent.com/u/555189?v=3","gravatar_id":"","url":"https://api.github.com/users/biolab","html_url":"https://github.com/biolab","followers_url":"https://api.github.com/users/biolab/followers","following_url":"https://api.github.com/users/biolab/following{/other_user}","gists_url":"https://api.github.com/users/biolab/gists{/gist_id}","starred_url":"https://api.github.com/users/biolab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biolab/subscriptions","organizations_url":"https://api.github.com/users/biolab/orgs","repos_url":"https://api.github.com/users/biolab/repos","events_url":"https://api.github.com/users/biolab/events{/privacy}","received_events_url":"https://api.github.com/users/biolab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biolab/orange3","description":"","fork":false,"url":"https://api.github.com/repos/biolab/orange3","forks_url":"https://api.github.com/repos/biolab/orange3/forks","keys_url":"https://api.github.com/repos/biolab/orange3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biolab/orange3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biolab/orange3/teams","hooks_url":"https://api.github.com/repos/biolab/orange3/hooks","issue_events_url":"https://api.github.com/repos/biolab/orange3/issues/events{/number}","events_url":"https://api.github.com/repos/biolab/orange3/events","assignees_url":"https://api.github.com/repos/biolab/orange3/assignees{/user}","branches_url":"https://api.github.com/repos/biolab/orange3/branches{/branch}","tags_url":"https://api.github.com/repos/biolab/orange3/tags","blobs_url":"https://api.github.com/repos/biolab/orange3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biolab/orange3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biolab/orange3/git/refs{/sha}","trees_url":"https://api.github.com/repos/biolab/orange3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biolab/orange3/statuses/{sha}","languages_url":"https://api.github.com/repos/biolab/orange3/languages","stargazers_url":"https://api.github.com/repos/biolab/orange3/stargazers","contributors_url":"https://api.github.com/repos/biolab/orange3/contributors","subscribers_url":"https://api.github.com/repos/biolab/orange3/subscribers","subscription_url":"https://api.github.com/repos/biolab/orange3/subscription","commits_url":"https://api.github.com/repos/biolab/orange3/commits{/sha}","git_commits_url":"https://api.github.com/repos/biolab/orange3/git/commits{/sha}","comments_url":"https://api.github.com/repos/biolab/orange3/comments{/number}","issue_comment_url":"https://api.github.com/repos/biolab/orange3/issues/comments{/number}","contents_url":"https://api.github.com/repos/biolab/orange3/contents/{+path}","compare_url":"https://api.github.com/repos/biolab/orange3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biolab/orange3/merges","archive_url":"https://api.github.com/repos/biolab/orange3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biolab/orange3/downloads","issues_url":"https://api.github.com/repos/biolab/orange3/issues{/number}","pulls_url":"https://api.github.com/repos/biolab/orange3/pulls{/number}","milestones_url":"https://api.github.com/repos/biolab/orange3/milestones{/number}","notifications_url":"https://api.github.com/repos/biolab/orange3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biolab/orange3/labels{/name}","releases_url":"https://api.github.com/repos/biolab/orange3/releases{/id}","created_at":"2013-02-22T12:52:56Z","updated_at":"2015-10-16T06:07:30Z","pushed_at":"2015-10-16T20:24:38Z","git_url":"git://github.com/biolab/orange3.git","ssh_url":"git@github.com:biolab/orange3.git","clone_url":"https://github.com/biolab/orange3.git","svn_url":"https://github.com/biolab/orange3","homepage":"","size":76812,"stargazers_count":145,"watchers_count":145,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":34,"forks":62,"open_issues":34,"watchers":145,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biolab/orange3/pulls/739"},"html":{"href":"https://github.com/biolab/orange3/pull/739"},"issue":{"href":"https://api.github.com/repos/biolab/orange3/issues/739"},"comments":{"href":"https://api.github.com/repos/biolab/orange3/issues/739/comments"},"review_comments":{"href":"https://api.github.com/repos/biolab/orange3/pulls/739/comments"},"review_comment":{"href":"https://api.github.com/repos/biolab/orange3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biolab/orange3/pulls/739/commits"},"statuses":{"href":"https://api.github.com/repos/biolab/orange3/statuses/fc1b5fa94bcdf9ea527a2e2216323fce654d96d9"}}}}