{"action":"created","comment":{"url":"https://api.github.com/repos/biolab/orange3-text/pulls/comments/65092755","id":65092755,"diff_hunk":"@@ -0,0 +1,275 @@\n+import functools\n+\n+from PyQt4 import QtGui, QtCore\n+from PyQt4.QtGui import QComboBox, QDialog\n+\n+from Orange.widgets import gui\n+from Orange.widgets.settings import Setting\n+from Orange.widgets.widget import OWWidget\n+\n+from orangecontrib.text import twitter\n+from orangecontrib.text.corpus import Corpus\n+from orangecontrib.text.widgets.ownyt import _i\n+from orangecontrib.text.languge_codes import lang2code\n+\n+\n+class APICredentialsDialog(QDialog):\n+    size_hint = (470, 100)\n+    widgets_min_width = 380\n+\n+    def __init__(self, parent, windowTitle=\"Twitter API credentials\"):\n+        super().__init__(parent, windowTitle=windowTitle)\n+\n+        self.parent = parent\n+\n+        self.setLayout(QtGui.QVBoxLayout())\n+        self.layout().setMargin(10)\n+        self.mainArea = gui.widgetBox(self)\n+\n+        self.layout().addLayout(self.setup_main_layout())\n+\n+        # Buttons\n+        self.button_box = gui.widgetBox(self, orientation=QtCore.Qt.Horizontal)\n+        gui.button(self.button_box, self, \"Check\", self.check_api_key)\n+        gui.button(self.button_box, self, \"Cancel\", self.reject)\n+        gui.button(self.button_box, self, \"OK\", self.accept)\n+\n+        # Label\n+        # self.label_box = gui.widgetBox(self, orientation=QtCore.Qt.Horizontal)\n+        self.api_key_check_label = QtGui.QLabel(text='')\n+        self.api_key_check_label.setAlignment(QtCore.Qt.AlignCenter)\n+        self.layout().addWidget(self.api_key_check_label)\n+\n+        self.check_api_key()\n+\n+    def setup_main_layout(self):\n+        layout = QtGui.QFormLayout()\n+\n+        # Key combo box.\n+        self.key_combo = QComboBox(self)\n+        self.key_combo.setEditable(True)\n+        self.key_combo.activated[int].connect(self.key_selected)\n+        self.key_combo.setMinimumWidth(self.widgets_min_width)\n+        layout.addRow('Key', self.key_combo)\n+\n+        self.secret_line_edit = QtGui.QLineEdit(self)\n+        self.secret_line_edit.editingFinished.connect(self.secret_changed)\n+        self.secret_line_edit.setMinimumWidth(self.widgets_min_width)\n+        layout.addRow('Secret', self.secret_line_edit)\n+        self.set_key_list()\n+        return layout\n+\n+    def sizeHint(self):\n+        return QtCore.QSize(*self.size_hint)\n+\n+    @property\n+    def key(self):\n+        return self.recent_keys[0] if self.recent_keys else None\n+\n+    @property\n+    def recent_keys(self):\n+        return self.parent.recent_api_keys\n+\n+    def set_key_list(self):\n+        self.key_combo.clear()\n+        if self.recent_keys:\n+            for key in self.recent_keys:\n+                self.key_combo.addItem(key.consumer_key)\n+            self.secret_line_edit.setText(self.recent_keys[0].consumer_secret)\n+\n+    def check_api_key(self):\n+        key = twitter.Credentials(self.key_combo.currentText(),\n+                                  self.secret_line_edit.text())\n+        valid = key.check_credentials()\n+        if valid:\n+            self.api_key_check_label.setText(\"API key is valid.\")\n+            self.save_key(key)\n+        else:\n+            self.api_key_check_label.setText(\"API key not validated!\")\n+\n+    def save_key(self, key):\n+        if key in self.recent_keys:\n+            self.key_selected(self.recent_keys.index(key))\n+        else:\n+            self.recent_keys.insert(0, key)\n+            self.set_key_list()\n+\n+    def accept(self):\n+        if self.key not in self.recent_keys:\n+            self.check_api_key()\n+        self.parent.update_api(self.key)\n+        super().accept()\n+\n+    def key_selected(self, n):\n+        key = self.recent_keys[n]\n+        self.recent_keys.pop(n)\n+        self.recent_keys.insert(0, key)\n+        self.set_key_list()\n+\n+    def secret_changed(self):\n+        pass\n+\n+\n+class Output:\n+    CORPUS = \"Corpus\"\n+\n+\n+def api_required(func):\n+    @functools.wraps(func)\n+    def wrapper(self, *args, **kwargs):\n+        if not self.api:\n+            self.open_set_api_key_dialog_button.setFocus()\n+            tip = 'Please provide a valid API key in order to get the data.'\n+            QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip)\n+        else:\n+            return func(self, *args, **kwargs)\n+    return wrapper\n+\n+\n+def word_list_required(func):\n+    @functools.wraps(func)\n+    def wrapper(self, *args, **kwargs):\n+        if not self.query_words:\n+            self.query_words_text_edit.setFocus()\n+            tip = 'Please input query words.'\n+            QtGui.QToolTip.showText(QtGui.QCursor.pos(), tip)\n+        else:\n+            return func(self, *args, **kwargs)\n+    return wrapper\n+\n+\n+class OWTwitter(OWWidget):\n+    \"\"\"\n+    Attributes:\n+        key (twitter.Credentials): Twitter API key/secret holder\n+        api (twitter.TwitterAPI): Twitter API obj\n+    \"\"\"\n+    name = \"Twitter\"\n+    description = \"Loads tweets from the Twitter API.\"\n+    icon = \"icons/Twitter.svg\"","path":"orangecontrib/text/widgets/owtwitter.py","position":149,"original_position":149,"commit_id":"15ee4b629f0db7cbf2cf4c1cc668706898ccff30","original_commit_id":"15ee4b629f0db7cbf2cf4c1cc668706898ccff30","user":{"login":"nikicc","id":713026,"avatar_url":"https://avatars.githubusercontent.com/u/713026?v=3","gravatar_id":"","url":"https://api.github.com/users/nikicc","html_url":"https://github.com/nikicc","followers_url":"https://api.github.com/users/nikicc/followers","following_url":"https://api.github.com/users/nikicc/following{/other_user}","gists_url":"https://api.github.com/users/nikicc/gists{/gist_id}","starred_url":"https://api.github.com/users/nikicc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikicc/subscriptions","organizations_url":"https://api.github.com/users/nikicc/orgs","repos_url":"https://api.github.com/users/nikicc/repos","events_url":"https://api.github.com/users/nikicc/events{/privacy}","received_events_url":"https://api.github.com/users/nikicc/received_events","type":"User","site_admin":false},"body":"Please set the priority here so that this widget will be higher in the Text Mining section (currently it is the last one). It should be among Corpus and NY Times since they all conceptually do the same thing.","created_at":"2016-05-30T16:56:44Z","updated_at":"2016-05-30T16:56:44Z","html_url":"https://github.com/biolab/orange3-text/pull/55#discussion_r65092755","pull_request_url":"https://api.github.com/repos/biolab/orange3-text/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/comments/65092755"},"html":{"href":"https://github.com/biolab/orange3-text/pull/55#discussion_r65092755"},"pull_request":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/biolab/orange3-text/pulls/55","id":71795369,"html_url":"https://github.com/biolab/orange3-text/pull/55","diff_url":"https://github.com/biolab/orange3-text/pull/55.diff","patch_url":"https://github.com/biolab/orange3-text/pull/55.patch","issue_url":"https://api.github.com/repos/biolab/orange3-text/issues/55","number":55,"state":"open","locked":false,"title":"[WiP] Twitter API","user":{"login":"s-alexey","id":9372243,"avatar_url":"https://avatars.githubusercontent.com/u/9372243?v=3","gravatar_id":"","url":"https://api.github.com/users/s-alexey","html_url":"https://github.com/s-alexey","followers_url":"https://api.github.com/users/s-alexey/followers","following_url":"https://api.github.com/users/s-alexey/following{/other_user}","gists_url":"https://api.github.com/users/s-alexey/gists{/gist_id}","starred_url":"https://api.github.com/users/s-alexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-alexey/subscriptions","organizations_url":"https://api.github.com/users/s-alexey/orgs","repos_url":"https://api.github.com/users/s-alexey/repos","events_url":"https://api.github.com/users/s-alexey/events{/privacy}","received_events_url":"https://api.github.com/users/s-alexey/received_events","type":"User","site_admin":false},"body":"OWTwitter widget and twitter module.","created_at":"2016-05-28T07:21:15Z","updated_at":"2016-05-30T16:56:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fec06e19a63cf414e02db217bf1e4acebc3a474f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/biolab/orange3-text/pulls/55/commits","review_comments_url":"https://api.github.com/repos/biolab/orange3-text/pulls/55/comments","review_comment_url":"https://api.github.com/repos/biolab/orange3-text/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biolab/orange3-text/issues/55/comments","statuses_url":"https://api.github.com/repos/biolab/orange3-text/statuses/15ee4b629f0db7cbf2cf4c1cc668706898ccff30","head":{"label":"s-alexey:twitter","ref":"twitter","sha":"15ee4b629f0db7cbf2cf4c1cc668706898ccff30","user":{"login":"s-alexey","id":9372243,"avatar_url":"https://avatars.githubusercontent.com/u/9372243?v=3","gravatar_id":"","url":"https://api.github.com/users/s-alexey","html_url":"https://github.com/s-alexey","followers_url":"https://api.github.com/users/s-alexey/followers","following_url":"https://api.github.com/users/s-alexey/following{/other_user}","gists_url":"https://api.github.com/users/s-alexey/gists{/gist_id}","starred_url":"https://api.github.com/users/s-alexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-alexey/subscriptions","organizations_url":"https://api.github.com/users/s-alexey/orgs","repos_url":"https://api.github.com/users/s-alexey/repos","events_url":"https://api.github.com/users/s-alexey/events{/privacy}","received_events_url":"https://api.github.com/users/s-alexey/received_events","type":"User","site_admin":false},"repo":{"id":53016749,"name":"orange3-text","full_name":"s-alexey/orange3-text","owner":{"login":"s-alexey","id":9372243,"avatar_url":"https://avatars.githubusercontent.com/u/9372243?v=3","gravatar_id":"","url":"https://api.github.com/users/s-alexey","html_url":"https://github.com/s-alexey","followers_url":"https://api.github.com/users/s-alexey/followers","following_url":"https://api.github.com/users/s-alexey/following{/other_user}","gists_url":"https://api.github.com/users/s-alexey/gists{/gist_id}","starred_url":"https://api.github.com/users/s-alexey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s-alexey/subscriptions","organizations_url":"https://api.github.com/users/s-alexey/orgs","repos_url":"https://api.github.com/users/s-alexey/repos","events_url":"https://api.github.com/users/s-alexey/events{/privacy}","received_events_url":"https://api.github.com/users/s-alexey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/s-alexey/orange3-text","description":"Text Mining add-on for Orange3","fork":true,"url":"https://api.github.com/repos/s-alexey/orange3-text","forks_url":"https://api.github.com/repos/s-alexey/orange3-text/forks","keys_url":"https://api.github.com/repos/s-alexey/orange3-text/keys{/key_id}","collaborators_url":"https://api.github.com/repos/s-alexey/orange3-text/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/s-alexey/orange3-text/teams","hooks_url":"https://api.github.com/repos/s-alexey/orange3-text/hooks","issue_events_url":"https://api.github.com/repos/s-alexey/orange3-text/issues/events{/number}","events_url":"https://api.github.com/repos/s-alexey/orange3-text/events","assignees_url":"https://api.github.com/repos/s-alexey/orange3-text/assignees{/user}","branches_url":"https://api.github.com/repos/s-alexey/orange3-text/branches{/branch}","tags_url":"https://api.github.com/repos/s-alexey/orange3-text/tags","blobs_url":"https://api.github.com/repos/s-alexey/orange3-text/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/s-alexey/orange3-text/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/s-alexey/orange3-text/git/refs{/sha}","trees_url":"https://api.github.com/repos/s-alexey/orange3-text/git/trees{/sha}","statuses_url":"https://api.github.com/repos/s-alexey/orange3-text/statuses/{sha}","languages_url":"https://api.github.com/repos/s-alexey/orange3-text/languages","stargazers_url":"https://api.github.com/repos/s-alexey/orange3-text/stargazers","contributors_url":"https://api.github.com/repos/s-alexey/orange3-text/contributors","subscribers_url":"https://api.github.com/repos/s-alexey/orange3-text/subscribers","subscription_url":"https://api.github.com/repos/s-alexey/orange3-text/subscription","commits_url":"https://api.github.com/repos/s-alexey/orange3-text/commits{/sha}","git_commits_url":"https://api.github.com/repos/s-alexey/orange3-text/git/commits{/sha}","comments_url":"https://api.github.com/repos/s-alexey/orange3-text/comments{/number}","issue_comment_url":"https://api.github.com/repos/s-alexey/orange3-text/issues/comments{/number}","contents_url":"https://api.github.com/repos/s-alexey/orange3-text/contents/{+path}","compare_url":"https://api.github.com/repos/s-alexey/orange3-text/compare/{base}...{head}","merges_url":"https://api.github.com/repos/s-alexey/orange3-text/merges","archive_url":"https://api.github.com/repos/s-alexey/orange3-text/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/s-alexey/orange3-text/downloads","issues_url":"https://api.github.com/repos/s-alexey/orange3-text/issues{/number}","pulls_url":"https://api.github.com/repos/s-alexey/orange3-text/pulls{/number}","milestones_url":"https://api.github.com/repos/s-alexey/orange3-text/milestones{/number}","notifications_url":"https://api.github.com/repos/s-alexey/orange3-text/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/s-alexey/orange3-text/labels{/name}","releases_url":"https://api.github.com/repos/s-alexey/orange3-text/releases{/id}","deployments_url":"https://api.github.com/repos/s-alexey/orange3-text/deployments","created_at":"2016-03-03T03:15:47Z","updated_at":"2016-03-03T03:15:48Z","pushed_at":"2016-05-30T10:33:54Z","git_url":"git://github.com/s-alexey/orange3-text.git","ssh_url":"git@github.com:s-alexey/orange3-text.git","clone_url":"https://github.com/s-alexey/orange3-text.git","svn_url":"https://github.com/s-alexey/orange3-text","homepage":"","size":24360,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"biolab:master","ref":"master","sha":"f6d765dbe166d01a59dcf160d7c45a0b74a2a627","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":38108816,"name":"orange3-text","full_name":"biolab/orange3-text","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-text","description":"Text Mining add-on for Orange3","fork":false,"url":"https://api.github.com/repos/biolab/orange3-text","forks_url":"https://api.github.com/repos/biolab/orange3-text/forks","keys_url":"https://api.github.com/repos/biolab/orange3-text/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biolab/orange3-text/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biolab/orange3-text/teams","hooks_url":"https://api.github.com/repos/biolab/orange3-text/hooks","issue_events_url":"https://api.github.com/repos/biolab/orange3-text/issues/events{/number}","events_url":"https://api.github.com/repos/biolab/orange3-text/events","assignees_url":"https://api.github.com/repos/biolab/orange3-text/assignees{/user}","branches_url":"https://api.github.com/repos/biolab/orange3-text/branches{/branch}","tags_url":"https://api.github.com/repos/biolab/orange3-text/tags","blobs_url":"https://api.github.com/repos/biolab/orange3-text/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biolab/orange3-text/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biolab/orange3-text/git/refs{/sha}","trees_url":"https://api.github.com/repos/biolab/orange3-text/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biolab/orange3-text/statuses/{sha}","languages_url":"https://api.github.com/repos/biolab/orange3-text/languages","stargazers_url":"https://api.github.com/repos/biolab/orange3-text/stargazers","contributors_url":"https://api.github.com/repos/biolab/orange3-text/contributors","subscribers_url":"https://api.github.com/repos/biolab/orange3-text/subscribers","subscription_url":"https://api.github.com/repos/biolab/orange3-text/subscription","commits_url":"https://api.github.com/repos/biolab/orange3-text/commits{/sha}","git_commits_url":"https://api.github.com/repos/biolab/orange3-text/git/commits{/sha}","comments_url":"https://api.github.com/repos/biolab/orange3-text/comments{/number}","issue_comment_url":"https://api.github.com/repos/biolab/orange3-text/issues/comments{/number}","contents_url":"https://api.github.com/repos/biolab/orange3-text/contents/{+path}","compare_url":"https://api.github.com/repos/biolab/orange3-text/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biolab/orange3-text/merges","archive_url":"https://api.github.com/repos/biolab/orange3-text/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biolab/orange3-text/downloads","issues_url":"https://api.github.com/repos/biolab/orange3-text/issues{/number}","pulls_url":"https://api.github.com/repos/biolab/orange3-text/pulls{/number}","milestones_url":"https://api.github.com/repos/biolab/orange3-text/milestones{/number}","notifications_url":"https://api.github.com/repos/biolab/orange3-text/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biolab/orange3-text/labels{/name}","releases_url":"https://api.github.com/repos/biolab/orange3-text/releases{/id}","deployments_url":"https://api.github.com/repos/biolab/orange3-text/deployments","created_at":"2015-06-26T12:02:06Z","updated_at":"2016-05-16T17:55:44Z","pushed_at":"2016-05-30T11:11:17Z","git_url":"git://github.com/biolab/orange3-text.git","ssh_url":"git@github.com:biolab/orange3-text.git","clone_url":"https://github.com/biolab/orange3-text.git","svn_url":"https://github.com/biolab/orange3-text","homepage":"","size":24447,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":7,"forks":13,"open_issues":7,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/55"},"html":{"href":"https://github.com/biolab/orange3-text/pull/55"},"issue":{"href":"https://api.github.com/repos/biolab/orange3-text/issues/55"},"comments":{"href":"https://api.github.com/repos/biolab/orange3-text/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biolab/orange3-text/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/biolab/orange3-text/statuses/15ee4b629f0db7cbf2cf4c1cc668706898ccff30"}}}}
{"actor":{"display_login":"nikicc"}}