[issue12806] argparse: Hybrid help text formatter
David Steele added the comment: For those looking for a solution now, see https://pypi.org/project/argparse-formatter/ -- ___ Python tracker <https://bugs.python.org/issue12806> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12806] argparse: Hybrid help text formatter
David Steele added the comment: I've submitted FlexiHelpFormatter as PR22129. This adds the FlexiHelpFormatter class to argparse. It supports wrapping text, while preserving paragraphs. Bullet lists are supported. There are a number of differences, relative to the latest patch in the issue report: - single line feeds in a paragraph are allowed - the code is refactored to avoid duplication - test failure fixes (mostly whitespace) - Tests and documentation are included. >>> parser = argparse.ArgumentParser( ... prog='PROG', ... formatter_class=argparse.FlexiHelpFormatter, ... description=""" ... The FlexiHelpFormatter will wrap text within paragraphs ... when required to in order to make the text fit. ... ... Paragraphs are preserved. ... ... It also supports bulleted lists in a number of formats: ... * stars ... 1. numbers ... - ... and so on ... """) >>> parser.add_argument( ... "argument", ... help=""" ... Argument help text also supports flexible formatting, ... with word wrap: ... * See? ... """) >>> parser.print_help() usage: PROG [-h] option The FlexiHelpFormatter will wrap text within paragraphs when required to in order to make the text fit. Paragraphs are preserved. It also supports bulleted lists in a number of formats: * stars 1. numbers - ... and so on positional arguments: argumentArgument help text also supports flexible formatting, with word wrap: * See? optional arguments: -h, --help show this help message and exit -- ___ Python tracker <https://bugs.python.org/issue12806> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12806] argparse: Hybrid help text formatter
Change by David Steele : -- keywords: +patch pull_requests: +21210 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22129 ___ Python tracker <https://bugs.python.org/issue12806> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12806] argparse: Hybrid help text formatter
David Steele added the comment: I came across this thread after making a simple argparse formatter for preserving paragraphs. The submissions here look better than that effort. Here is a quick, hacky look at the patches from one perspective. I wanted to prefer ParagraphFormatterML, but didn't like that it doesn't appear to wrap bullet lines, and it wrapped help and epilogs to different lengths. For all options I found an initial textwrap.dedent() was needed to get the results I expected. When I did the dedent with ParagraphFormatter*, a subsequent textwrap.indent(" ") hack was needed to restore spaces at the wrap point. FlexiFormatter was incomplete - epilogs weren't affected. Ultimately, I settled on reworking FlexiFormatter. My version has the following changes: - Refactor the formatting code out a la ParagraphFormatter, and add to _fill_text() as well, so formatting is available for both epilogs and option help - Add a leading textwrap.dedent(), to get it to feel more like HelpFormatter. Note - The result requires line feed escapes within paragraphs. - I'm not using the "indent" argument for _fill_text(), with no apparent consequences. - Automated tests show that FlexiFormatter adds a space to each blank line. I decided that was not a problem Code is at: https://github.com/davesteele/argparse_formatter https://pypi.org/project/argparse-formatter/ Regarding licensing, my contributions (and presumably the others') is addressed by the CLA. I'd very much like to see something from this thread merged. This looks to me to be good enough. Any objections to a pull request? -- nosy: +daves ___ Python tracker <https://bugs.python.org/issue12806> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser default browser detection and/or public API for _trylist.
David Steele added the comment: Jaysinh, Thanks for the feedback. I'm adding the documentation now. As I noted in github, I'm not sure what the preferred exception handling would be for xdg-settings. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24241> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser default browser detection and/or public API for _trylist.
Changes by David Steele <dste...@gmail.com>: -- pull_requests: +123 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24241> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser default browser detection and/or public API for _trylist.
David Steele added the comment: See https://github.com/python/cpython/pull/85 -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24241> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser default browser detection and/or public API for _trylist.
David Steele added the comment: Patch attached, to sort the desktop default browser to the top of _tryorder. -- keywords: +patch Added file: http://bugs.python.org/file39940/preferredbrowser.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24241 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser (very often) doesn't support the 'new' parameter
New submission from David Steele: When calling webbrowser.open*(), the module goes through a list of installed browsers, and uses the first one that succeeds, to process the request. The first 'browsers' in the 'X' list are 'xdg-open' and others of that ilk. The problem is that they only have one 'open' behavior - the 'new' parameter is ignored ('same window', 'new window', 'new tab'). I can get the fully supported default browser in GNOME with e.g. def browser(): app = Gio.app_info_get_default_for_type('x-scheme-handler/https', True) bpath = app.get_filename() for candidate in webbrowser._tryorder: if candidate in bpath: return webbrowser.get(using=candidate) return webbrowser.get() ... but this code accesses a private list. The problems are: 1) webbrowser does not determine and return the current default browser. 2) There is no public interface for determining the current/installed browser type list. The problem can be mitigated by resolving (1) and/or (2). Also, the browser type list in the documentation is missing many entries. Checked on 2.7 and 3.4. I believe this is valid across all supported versions. -- messages: 243590 nosy: daves priority: normal severity: normal status: open title: webbrowser (very often) doesn't support the 'new' parameter type: behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24241 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24241] webbrowser default browser detection and/or public API for _trylist.
David Steele added the comment: On Tue, May 19, 2015 at 10:19 AM, R. David Murray rep...@bugs.python.org wrote: ... Would you like to propose a patch? My preferred solution would be a bit intrusive - check for and use xdg-settings or gi.repository.Gio to identify the default browser, and match the result against the type list. I'm not sure that would get approval, nor am I sure of the best standard-library-compliant way to go about it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24241 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com