{"action":"created","issue":{"url":"https://api.github.com/repos/erikrose/blessings/issues/73","labels_url":"https://api.github.com/repos/erikrose/blessings/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/erikrose/blessings/issues/73/comments","events_url":"https://api.github.com/repos/erikrose/blessings/issues/73/events","html_url":"https://github.com/erikrose/blessings/pull/73","id":54651042,"number":73,"title":"Redesign the input API a bit","user":{"login":"erikrose","id":295816,"avatar_url":"https://avatars.githubusercontent.com/u/295816?v=3","gravatar_id":"","url":"https://api.github.com/users/erikrose","html_url":"https://github.com/erikrose","followers_url":"https://api.github.com/users/erikrose/followers","following_url":"https://api.github.com/users/erikrose/following{/other_user}","gists_url":"https://api.github.com/users/erikrose/gists{/gist_id}","starred_url":"https://api.github.com/users/erikrose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikrose/subscriptions","organizations_url":"https://api.github.com/users/erikrose/orgs","repos_url":"https://api.github.com/users/erikrose/repos","events_url":"https://api.github.com/users/erikrose/events{/privacy}","received_events_url":"https://api.github.com/users/erikrose/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-17T05:07:21Z","updated_at":"2015-01-18T19:59:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/erikrose/blessings/pulls/73","html_url":"https://github.com/erikrose/blessings/pull/73","diff_url":"https://github.com/erikrose/blessings/pull/73.diff","patch_url":"https://github.com/erikrose/blessings/pull/73.patch"},"body":"Redesign the input API a bit to guide the caller toward proper use and to divide state. (See commit message.)\r\n\r\ntest_inkey_0s_raw_ctrl_c fails but only when running `py.test blessed/tests/test_keyboard.py --tb=short`, not when running the whole suite:\r\n\r\n    _________________________________________ test_inkey_0s_raw_ctrl_c __________________________________________\r\n    blessed/tests/test_keyboard.py:424: in test_inkey_0s_raw_ctrl_c\r\n        os.write(master_fd, u'\\x03'.encode('latin1'))\r\n    E   OSError: [Errno 5] Input/output error\r\n\r\n\r\nI'm not sure offhand why. Any ideas?\r\n \r\nAnd then test_key_mode_no_kb's raises() appears to not work when running the whole suite. When running just test_keyboard, it's fine.\r\n\r\n    ____________________________________________ test_key_mode_no_kb ____________________________________________\r\n    blessed/tests/test_keyboard.py:229: in test_key_mode_no_kb\r\n        child()\r\n    blessed/tests/accessories.py:122: in __call__\r\n        assert exc_output == '', exc_output_msg\r\n    E   AssertionError: Output in child process:\r\n    E   ========================================\r\n    E     File \"/Users/grinch/Checkouts/blessings/blessed/tests/accessories.py\", line 76, in __call__\r\n    E       self.func(*args, **kwargs)\r\n    E     File \"/Users/grinch/Checkouts/blessings/blessed/tests/test_keyboard.py\", line 227, in child\r\n    E       with term.key_mode():\r\n    E     File \"/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py\", line 17, in __enter__\r\n    E       return self.gen.next()\r\n    E     File \"/Users/grinch/Checkouts/blessings/blessed/terminal.py\", line 577, in key_mode\r\n    E       raise NoKeyboard\r\n    E   -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n    E   NoKeyboard\r\n    E   ========================================\r\n\r\nBut that aside, this is ready for feedback.\r\n\r\nWhat do you think? I'm particularly interested in your opinion on key_mode() raising an immediate NoKeyboard exception if there's no keyboard or tty attached. I don't see much call for setting cbreak or raw mode unless you can also take input (in which case we'd defer the error until key() was called), but you may know something I don't."},"comment":{"url":"https://api.github.com/repos/erikrose/blessings/issues/comments/70423064","html_url":"https://github.com/erikrose/blessings/pull/73#issuecomment-70423064","issue_url":"https://api.github.com/repos/erikrose/blessings/issues/73","id":70423064,"user":{"login":"jquast","id":972584,"avatar_url":"https://avatars.githubusercontent.com/u/972584?v=3","gravatar_id":"","url":"https://api.github.com/users/jquast","html_url":"https://github.com/jquast","followers_url":"https://api.github.com/users/jquast/followers","following_url":"https://api.github.com/users/jquast/following{/other_user}","gists_url":"https://api.github.com/users/jquast/gists{/gist_id}","starred_url":"https://api.github.com/users/jquast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jquast/subscriptions","organizations_url":"https://api.github.com/users/jquast/orgs","repos_url":"https://api.github.com/users/jquast/repos","events_url":"https://api.github.com/users/jquast/events{/privacy}","received_events_url":"https://api.github.com/users/jquast/received_events","type":"User","site_admin":false},"created_at":"2015-01-18T19:59:57Z","updated_at":"2015-01-18T19:59:57Z","body":"I implemented the ability to do timed polling w/o keyboard to continue the blessed philosophy of \"everything is safe for piping\".  I could provide examples, but they're trivial. It's your call, I made great effort in trying to remain compatible with blessings API, you're certainly free to change your mind about any such things. If you haven't seen pull #74, it fixes the ./bin programs so that you may try/test keyboard input, as well as the test cases.\r\n\r\n------\r\n\r\nLooks like you changed your mind about Key, then? Everybody, and I mean everybody, uses \"key\" to refer to dictionary values (or a dictionary key, or the first item of a 2-tuple in series, or something to do with using zip or iterators) I just picked out a ~8,000 LOC project laying here, it has 220 uses of the phrase \"key\" and they all have this meaning.\r\n\r\nThis would be like naming a class Value() for something that provides \"business value\", or a function named 'object' that, when called with an argument, returns \"An objective opinion\". It is hard to document, read, and write without triggering unrelated portions of the brain that cause cross-talk and delay comprehension. But the worst offense of all is search/grep-ability.\r\n\r\n------\r\n\r\n(As for my bbs, the Terminal is always in character-at-a-time mode and uses the ``inkey()`` method, so the context manager ``with key_mode()`` would be an unnerving complication and introduce over-indentation. blessed will have to remain at least here as well as all other projects already using blessed that would require porting.)"}}