[MRG+1] Included new optional parameter in startproject command line #2005
Conversation
Hello, @feliperuhland. I like the feature idea, it will be nice to be able to do The build is failing for Python 3, can you have a look? |
Thanks, @eliasdorneles . I am working on it. |
The template should also be updated to print a message with the correct project dir. I just tried it with:
And it printed:
It should point me to |
@eliasdorneles you're right. |
Looks great, thanks @feliperuhland ! |
|
||
if len(args) == 2: | ||
project_dir = args[1] | ||
if exists(join(project_dir, 'scrapy.cfg')): |
eliasdorneles
Jul 11, 2016
Member
hey @feliperuhland, I'm looking at this again, and I'm thinking this check if scrapy.cfg
exists is needed in both cases (args == 1
or args == 2
), right?
looks like it should be outside of this if
.
hey @feliperuhland, I'm looking at this again, and I'm thinking this check if scrapy.cfg
exists is needed in both cases (args == 1
or args == 2
), right?
looks like it should be outside of this if
.
feliperuhland
Jul 13, 2016
Author
Contributor
Not really, because in the case of len(args) == 1
the directory will be created and can't have the scrapy.cfg
. But I can't see any problem in this change. What do you think? Thanks.
Not really, because in the case of len(args) == 1
the directory will be created and can't have the scrapy.cfg
. But I can't see any problem in this change. What do you think? Thanks.
eliasdorneles
Jul 13, 2016
Member
Since we're using a custom copytree that now works in existing directories, I think we shouldn't assume the directory will be created.
Users can now do mkdir myproj; scrapy startproject myproj
and scrapy will work without complaining, therefore the extra check is a good idea.
In fact, I just tried running scrapy startproject myproj
twice and it breaks the second time.
Since we're using a custom copytree that now works in existing directories, I think we shouldn't assume the directory will be created.
Users can now do mkdir myproj; scrapy startproject myproj
and scrapy will work without complaining, therefore the extra check is a good idea.
In fact, I just tried running scrapy startproject myproj
twice and it breaks the second time.
elif _module_exists(project_name): | ||
print('Error: Module %r already exists' % project_name) | ||
else: | ||
return True | ||
return False | ||
|
||
def _copytree(self, src, dst): |
eliasdorneles
Jul 11, 2016
Member
Also, do you think we could get rid of this function, if we use the ignore
callable argument for shutil.copytree
?
Also, do you think we could get rid of this function, if we use the ignore
callable argument for shutil.copytree
?
feliperuhland
Jul 13, 2016
Author
Contributor
Hi, @eliasdorneles. I would like to remove that function, but the original implementation always creates the destination directory and that is not useful to us. I'm not happy of rewrite some internal library behavior. Do you have any other ideias? Thanks again.
Hi, @eliasdorneles. I would like to remove that function, but the original implementation always creates the destination directory and that is not useful to us. I'm not happy of rewrite some internal library behavior. Do you have any other ideias? Thanks again.
eliasdorneles
Jul 13, 2016
Member
Ah yeah, you're right.
The problem is that os.makedirs
call that is always called and requires the directory not to exist.
Can you perhaps add a docstring explaining this, then?
Ah yeah, you're right.
The problem is that os.makedirs
call that is always called and requires the directory not to exist.
Can you perhaps add a docstring explaining this, then?
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
@eliasdorneles I done what you suggested and I think it's good. Can you read the docstring to see if it's good enough? Thanks again! |
Yup, looks great now. Thank you, @feliperuhland ! @redapple this looks ready. How do you feel about merging it for 1.2? |
Thanks @feliperuhland ! |
I don't know if anyone creates project like me.
I have a habit to create git repository and then I create scrapy project.
You can see something similar at django startproject command.
Unfortunately, I had to rewrite
copytree
function, to make sure that thestartproject
won't fail if itproject_dir
already exists.I am available to any feedback,
Thanks.