{"action":"created","issue":{"url":"https://api.github.com/repos/tqdm/tqdm/issues/223","repository_url":"https://api.github.com/repos/tqdm/tqdm","labels_url":"https://api.github.com/repos/tqdm/tqdm/issues/223/labels{/name}","comments_url":"https://api.github.com/repos/tqdm/tqdm/issues/223/comments","events_url":"https://api.github.com/repos/tqdm/tqdm/issues/223/events","html_url":"https://github.com/tqdm/tqdm/pull/223","id":169483204,"number":223,"title":"Custom bar symbols formatting","user":{"login":"lrq3000","id":1118942,"avatar_url":"https://avatars.githubusercontent.com/u/1118942?v=3","gravatar_id":"","url":"https://api.github.com/users/lrq3000","html_url":"https://github.com/lrq3000","followers_url":"https://api.github.com/users/lrq3000/followers","following_url":"https://api.github.com/users/lrq3000/following{/other_user}","gists_url":"https://api.github.com/users/lrq3000/gists{/gist_id}","starred_url":"https://api.github.com/users/lrq3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrq3000/subscriptions","organizations_url":"https://api.github.com/users/lrq3000/orgs","repos_url":"https://api.github.com/users/lrq3000/repos","events_url":"https://api.github.com/users/lrq3000/events{/privacy}","received_events_url":"https://api.github.com/users/lrq3000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-08-04T21:58:21Z","updated_at":"2016-08-26T18:57:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tqdm/tqdm/pulls/223","html_url":"https://github.com/tqdm/tqdm/pull/223","diff_url":"https://github.com/tqdm/tqdm/pull/223.diff","patch_url":"https://github.com/tqdm/tqdm/pull/223.patch"},"body":"Not the most urgent PR, but we missed some more customization (pretty sure someone will ask someday!). So here it is: the ability to set custom bar symbols, just like our fellow [progressbar2](https://github.com/WoLpH/python-progressbar):\r\n\r\n```\r\nimport time\r\nfrom tqdm import tcrange\r\n\r\nfor i in tcrange(100, ascii=True, bar_format='{l_bar}{bar}{bar_symbols_ascii},A,B,C,D,E,O{/bar_symbols_ascii}{r_bar}'):\r\n    time.sleep(0.1)\r\n\r\nfor i in tcrange(100, ascii=True, bar_format='{l_bar}{bar}{bar_symbols_loop_ascii},/,-,\\,|{/bar_symbols_loop_ascii}{r_bar}'):\r\n    time.sleep(0.1)\r\n```\r\n\r\nRespective outputs:\r\n```\r\n  9%|OOOE                                      | 9/100 [00:00<00:09,  9.95it/s]\r\n\r\n 12%|/| 12/100 [00:01<00:08, 10.00it/s]\r\n```\r\n\r\nThere are four different new tags for `bar_format`:\r\n* `{bar_symbols}` and `{bar_symbols_ascii}` set custom progress bar symbols (unicode or ascii respectively)\r\n* `{bar_symbols_loop}` and `{bar_symbols_loop_ascii}` set animated looping symbols (unicode or ascii respectively)\r\n\r\nAs you can see, I added both unicode and ascii tags, so that the user can provide either one or both. If the user didn't provide custom symbols for the target environment (eg, user provided `{bar_symbols}` but the environment is ascii), then the bar will fallback to the default bar. Why? This is to ensure robustness, so the user has to explicitly provide both a unicode and an ascii bars to work in all envs.\r\n\r\nFormatting follow a rule similar to egrep: the first character is the separator, then the rest is compiled in a list of symbols. Eg:\r\n\r\n- `{bar_symbols}|1|2|3|#{/bar_symbols}` --> `|` is the separator\r\n- `{bar_symbols_loop},|,/,-,\\{/bar_symbols_loop}` --> `,` is the separator\r\n\r\nNote that symbols are not necessarily only one character long, they can be longer (can be interesting for animated loops). /EDIT: tested and it works.\r\n\r\nTODO:\r\n- [ ] Add indeterminate progress customization\r\n- [ ] Fix Flake8\r\n- [ ] Add unit tests\r\n- [ ] Update docstrings and readme\r\n\r\nFOR A FUTURE PR:\r\n- Multiline animated ascii-art bars like [nyanbar](https://github.com/apg/nyanbar) or [fish](https://github.com/lericson/fish)? Maybe we can get some inspiration from fish's docstring2line function? (we can memorize the number of lines we print and get back to original position, just like we currently do with automated nesting). Then we would have to figure out how to handle multiple progress bars spanning multiple lines... Probably as a separate submodule?"},"comment":{"url":"https://api.github.com/repos/tqdm/tqdm/issues/comments/242821836","html_url":"https://github.com/tqdm/tqdm/pull/223#issuecomment-242821836","issue_url":"https://api.github.com/repos/tqdm/tqdm/issues/223","id":242821836,"user":{"login":"coveralls","id":2354108,"avatar_url":"https://avatars.githubusercontent.com/u/2354108?v=3","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T18:57:05Z","updated_at":"2016-08-26T18:57:05Z","body":"\n[![Coverage Status](https://coveralls.io/builds/7629438/badge)](https://coveralls.io/builds/7629438)\n\nCoverage decreased (-14.2%) to 76.541% when pulling **a433ef4ddebc9ffaf3ef9f3d43ce0ef7b4d3a186 on custom_symbols** into **17bb11d60708722d7eed04abfd5d7b55b098fad1 on master**.\n"}}
{"actor":{"display_login":"coveralls"}}