[issue46317] Pathlib.rename isn't robust
Change by Oz Tiram : -- keywords: +patch pull_requests: +28851 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30650 ___ Python tracker <https://bugs.python.org/issue46317> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46317] Pathlib.rename isn't robust
Oz Tiram added the comment: Thanks for the answer, it makes sense now. Yes, I would adopt this. Allowing users to use `copy2` (or any other functio ...) using a keyword. -- ___ Python tracker <https://bugs.python.org/issue46317> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46317] Pathlib.rename isn't robust
Oz Tiram added the comment: @barney, I am not sure that I understand your question. I think adding another method `Pathlib.Path` and `Pathlib._Accessor` is my preferred way. The would be something like: class _NormalAccessor(_Accessor): ... self.move = shutil.move class Path: def move(self, src, dest): self._accessor.move(self, target) return self.__class__(target) Now, this is hardly a patch. I need to submit a PR with proper docs, tests and NEWS entry... I will be glad to work on it. However, I guess I need someone to "sponsor" it and merge it. -- ___ Python tracker <https://bugs.python.org/issue46317> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46317] Pathlib.rename isn't robust
New submission from Oz Tiram : Pathlib.rename will fail across file system with: OSError: [Errno 18] Invalid cross-device link e.g: -> path_dict["current_path"].rename(path_dict["destination"]) (Pdb) n OSError: [Errno 18] Invalid cross-device link: '/tmp/pipenv-k1m0oynt-yaml/PyYAML-6.0/lib/yaml' -> '/home/oz123/Software/pipenv/pipenv/patched/yaml3' This is because it uses os.rename under the hood: https://github.com/python/cpython/blob/3.10/Lib/pathlib.py#L306 One can either replace it with `shutil.move` which works, or one could add another method to Pathlib.move(...) with similar signature and return value, which calls `shutil.move` under the hood. Before submitting a patch for that, I would like to get feedback for that. -- components: Library (Lib) messages: 410155 nosy: Oz.Tiram priority: normal severity: normal status: open title: Pathlib.rename isn't robust versions: Python 3.10, Python 3.11, Python 3.9 ___ Python tracker <https://bugs.python.org/issue46317> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39348] wrong rst syntax in socket.rst
Change by Oz Tiram : -- keywords: +patch pull_requests: +17413 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18018 ___ Python tracker <https://bugs.python.org/issue39348> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39348] wrong rst syntax in socket.rst
New submission from Oz Tiram : The code block for the isn't hightlighted: Changed in version 3.7: When SOCK_NONBLOCK or SOCK_CLOEXEC bit flags are applied to type they are cleared, and socket.type will not reflect them. They are still passed to the underlying system socket() call. Therefore:: sock = socket.socket( ... This is because the double colon is directly after the word Therefore. This fix is very simple: :attr:`socket.type` will not reflect them. They are still passed - to the underlying system `socket()` call. Therefore:: + to the underlying system `socket()` call. Therefore, + + :: sock = socket.socket( socket.AF_INET, ... I have prepared a PR for this. -- assignee: docs@python components: Documentation messages: 360086 nosy: Oz.Tiram, docs@python priority: normal severity: normal status: open title: wrong rst syntax in socket.rst versions: Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue39348> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14102] argparse: add ability to create a man page
Oz Tiram added the comment: As already pointed out, it can get the parser somehow, you don't need an explicit extra option --man. That's the approach suggesed in: man-argparse and build_manpage.py attached here You can use it a make file like this: install: ./setup.py build_manpage ./setup.py install install -D -m 644 foo.1 ${DESTDIR}/usr/share/man/man1 -- ___ Python tracker <https://bugs.python.org/issue14102> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33227] Cmd do_something only accepts one argument
Oz Tiram added the comment: I am disappointed you want to deprecate CMD. I knew about cmd2 and some other alternatives, but I think their execive use of decorators isn't so comfortable. That is why I wrote my own module. I'm also willing to adopt the module and add even more features. -- status: pending -> open ___ Python tracker <https://bugs.python.org/issue33227> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33227] Cmd do_something only accepts one argument
Change by Oz Tiram : -- components: +Library (Lib) type: -> enhancement ___ Python tracker <https://bugs.python.org/issue33227> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33227] Cmd do_something only accepts one argument
New submission from Oz Tiram : Considering that I want to build an CLI interactive program using cmd.Cmd, which has multiple functions that accept two or more arguments, I always have to do parsing of arg inside my do_methods for example: class Calc(cmd.Cmd): do_add(self, arg): a, b = parse_ints(arg) return a+b do_mult(self, arg): a, b = parse_ints(arg) return a*b This is easy enough for a simple calculator. But for more logic I need to create more parse_type and explicitly call them at the top of each do_stuff. Considering this I have created a patch for Cmd.cmd, that keeps the old functionality, but adds the ability to pass multiple arguments without having to parse them every time. The functionality is as follows: class MyProg(cmd.Cmd): do_simple(self, arg): print(arg) do_greet(self, name="World") print("Hello %s" %s) do_add(self, a, b): print(a+b) Now in the cmd prompt: (Cmd) simple foo foo (Cmd) # keeps the old functionallity (Cmd) add 2 3 5 # add two properly add the values (Cmd) add 2 # expects two arguments, so it will print the help for add (Cmd) greet Hello World # does not complain because it has a default value (Cmd) greet Guido Hello Guido (Cmd) greet name=Raymond Hello Raymond # works too None of these example guess the type. It is simply handles as a string. but I am playing around with automatically detecting types of variables using function annotations in python 3.5 and later. Also, although, not demonstrated here, one can also define: def do_some_method_with_kwargs(self, arg1, arg2, **kwargs): ... do fancy stuff ... (Cmd) some_method_with_kwargs foo bar kwargs='{"name": "John", "age"=35}' kwargs is parsed to a dict (using json.loads) when escaped properly. This is a bit esoteric, hence not shown here (but the patch patch includes it). I was wondering if this kind of enhancement would be considered for this module? I will happily create a PR with tests and documentation explaining this enhanced functionality. -- files: cmd.patch keywords: patch messages: 314968 nosy: Oz.Tiram priority: normal severity: normal status: open title: Cmd do_something only accepts one argument Added file: https://bugs.python.org/file47520/cmd.patch ___ Python tracker <https://bugs.python.org/issue33227> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: @Walter, I fixed the issues your raised, and also solved the merge conflict in What's New. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: @Walter, I implemented your suggestions plus the obvious tasks of adding tests and documentation. Would be happy to hear your feedback. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Changes by Oz Tiram : -- pull_requests: +1537 ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: Apparently, I forgot to push the second branch. It is now pushed. I renamed the class attribute names on the v1 branch. I still need to do the following: - Add docs - Fix existing tests and add new tests demonstrating the usage of the new attributes. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: @Walter, I agree with you about consistent naming. Personally, I would prefer to name all the variables "styles". But I preferred not to break past compatibility too. So I guess we are stuck for a while with "classes". I will rename the variables. As for documenting that, I would also do that. Thanks for the feedback. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: @Walter, I implemented two possible solutions. Chronologically speaking V2 was implemented before V1, but it's a bit über-smart and might surprise it's users requiring the class attributes to be some kind of iterable. The first version is my current preferred solution. I intentionally didn't create a PR for that yet. These are the branches: https://github.com/oz123/cpython/tree/issue30095-v1 https://github.com/oz123/cpython/tree/issue30095-v2 -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: ... Using class attributes would nice, also considering that the days CSS classes are defined as class attributes. I meant to write : Using class attributes would be nicer, also considering that the days CSS classes are defined as class attributes. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: @doerwalter, exactly. I found myself overwriting the relevant methods too many times. I usually did something like this: class WorkCalendar(HTMLCalendar): def formatmonthname(self, theyear, themonth, withyear=True, style=r'class="month-head"'): """ Return a month name as a table row. """ monthname = super().formatmonthname(theyear, themonth, withyear) regex = r'class\="month"' return re.sub(regex, style, monthname, 1) Using class attributes would nice, also considering that the days CSS classes are defined as class attributes. My intention was a few more class attributes (for the month header, and month) and also change the existing code such that each day can have multiple CSS classes and not just one. I am willing to work on a PR for that if that sounds good and there is someone who would be willing to merge it. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
Oz Tiram added the comment: Of course I can, but I can't add multiple css classes, and I forced to have the same class for both the title of the month and the body of the month. -- ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30095] HTMLCalendar allow custom classes
New submission from Oz Tiram: At the moment methods like HTMLCalendar.formatmonthname and HTMLCalendar.formatmonth have hard coded name 'month'. This class is pretty helpful as a good start, but if you want to customize the styles it's not helpful. I think it would be helpful for others too, if this would have be customize able. Would you accept a PR for such thing? -- components: Library (Lib) messages: 291841 nosy: Oz.Tiram priority: normal severity: normal status: open title: HTMLCalendar allow custom classes type: enhancement versions: Python 3.6 ___ Python tracker <http://bugs.python.org/issue30095> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14102] argparse: add ability to create a man page
Oz Tiram added the comment: @Raymond Hettinger, You don't have to wait anymore. I would be happy if you review the patch, and share your opinion. I might have posted my patch too early. I am still doing changes on the upstream, in my github posted earlier.So, please test the one upstream. -- ___ Python tracker <http://bugs.python.org/issue14102> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14102] argparse: add ability to create a man page
Oz Tiram added the comment: Hi, I have been wanting this feature for quite a long time. IMHO, binaries and scripts should always include a man page. The Debian developers require that. However, man pages have a 'bizarre' format. Long talk, short time. I did implement something. I tested it on Python 2.7 since my project currently only supports Python 2.7. I think it should not be complicated to port to Python 3.X. I doubt if the correct place for formatting a man page should be in argparse.py itself. My solution is an extension of Andial's brecht solution that uses ofcourse argparse. You can see it in action in https://github.com/pwman3/pwman3 I am also attaching the code here. I hope you will find this file useful. I would appreciate your comments too. Regards, Oz -- nosy: +Oz.Tiram versions: +Python 2.7 -Python 3.3 Added file: http://bugs.python.org/file35576/build_manpage.py ___ Python tracker <http://bugs.python.org/issue14102> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com