-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Create shortcuts to files which dont exist #10
Comments
If |
Question @kiwi0fuit? Should a shortcut to a directory be created if it does not exist? If so, the target would be considered a directory if the |
Do we really need it for files except entry points? If not then will we have separate function that creates dir shortcuts |
The needed and convenient part of creating shortcuts for files that do not exist is creating shortcuts to entry points and creating shortcuts to folders and creating that folders at the same time. I cannot imagine why we need it except that. |
Oh, I see now that you do not plan separate method for dirs. In this case I only need kwarg like |
I suggest closing this and not implementing this. Instead using Python 3.4+ and writing
|
Or even better: add new |
I'm quite satisfied with the latest idea: looks consistent, concise and convenient. |
class ShortCutter:
...
def makedirs(*args):
"""
Recursively creates dirs if they don't exist.
Utilizes self.raise_errors and self.error_log
:param str *args:
Multiple paths for folders to create.
Returns True on success False of failure
"""
ret = True
for path in args:
if not os.path.isdir(path):
if self.raise_errors:
os.makedirs(path)
else:
try:
os.makedirs(path)
except OSError:
if self.error_log is not None:
self.error_log.write(''.join(traceback.format_exc()))
ret = False
return ret |
I am not convinced shortcut should be creating directories, the API is for creating shortcuts and it makes significant assumptions about how users want directories to be created.
I will look at the implementation, if its possible to create a shortcut without creating the directory it links too I will otherwise I will create the directory and then the shortcut. re |
@martinohanlon My latest suggestion is to drop non-existing dirs and files support and add:
So we do not need to figure out if it's a dir or file - simply check the existing object. |
I understand the requirement for a |
@martinohanlon See this comment to see how it's different from It's convenient to use because it utilizes |
@martinohanlon |
@martinohanlon this all comes from using PS All my additions come from using shortcut in setup.py actually :) |
@martinohanlon and it's better not to fail the module installation completely if shortcuts creation fails for some reason. |
There are use cases (particularly when creating python packages) where it is required to create shortcuts to files which dont exist [yet].
The full path would have to be defined and a parameter passed which would determine that the shortcut should be created even if the target didnt exist.
Based on requests in #7 from @kiwi0fruit
The text was updated successfully, but these errors were encountered: