Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method PurePath.quote() that calls shlex.quote #73003

Closed
cool-RR mannequin opened this issue Nov 28, 2016 · 3 comments
Closed

Provide method PurePath.quote() that calls shlex.quote #73003

cool-RR mannequin opened this issue Nov 28, 2016 · 3 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@cool-RR
Copy link
Mannequin

cool-RR mannequin commented Nov 28, 2016

BPO 28817
Nosy @pitrou, @cool-RR, @zware, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-11-28.13:59:16.429>
created_at = <Date 2016-11-28.10:41:44.390>
labels = ['3.7', 'type-feature', 'library']
title = 'Provide method PurePath.quote() that calls shlex.quote'
updated_at = <Date 2016-11-28.13:59:16.426>
user = 'https://github.com/cool-RR'

bugs.python.org fields:

activity = <Date 2016-11-28.13:59:16.426>
actor = 'zach.ware'
assignee = 'none'
closed = True
closed_date = <Date 2016-11-28.13:59:16.429>
closer = 'zach.ware'
components = ['Library (Lib)']
creation = <Date 2016-11-28.10:41:44.390>
creator = 'cool-RR'
dependencies = []
files = []
hgrepos = []
issue_num = 28817
keywords = []
message_count = 3.0
messages = ['281858', '281859', '281876']
nosy_count = 4.0
nosy_names = ['pitrou', 'cool-RR', 'zach.ware', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue28817'
versions = ['Python 3.7']

@cool-RR
Copy link
Mannequin Author

cool-RR mannequin commented Nov 28, 2016

I have a a PurePath object like so:

    path = PurePath('/home/my awesome user/file.txt')

I'm SSHing into a server and I want to remove the file. So I have to do this:

ssh_client.run(f'/bin/rm {shlex.quote(str(path))}')

Which is really long and ugly.

I suggested in bpo-28623 that shlex.quote could just take a Path argument, and in bpo-28811 that __str__ would use shlex.quote, and it was rejected too.

My next suggestion: Implement PurePath.quote() method that calls shlex.quote() on the path. What do you think?

@cool-RR cool-RR mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement 3.7 (EOL) end of life labels Nov 28, 2016
@serhiy-storchaka
Copy link
Member

Please no. The interface of pathlib is already overburdened. We shouldn't add every function that is applicable to string paths as a Path method.

@zware
Copy link
Member

zware commented Nov 28, 2016

You already have a short, simple, one-line solution, and have had suggestions for shortening it yourself if you absolutely need to do so. If you can provide proof that this is an extremely common use case (and considering how short the solution already is, it would need to be completely ubiquitous), we might reconsider this, but in the absence of such proof these suggestions are trying to solve a problem that doesn't exist.

@zware zware closed this as completed Nov 28, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants