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

Replace directory with destination, allow specifying filename (#92) #234

Closed
wants to merge 7 commits into from
Closed

Conversation

ujjwalwahi
Copy link
Contributor

@whimboo
Replaced directory(-d, --directory) with destination(-d, --dest), now user can specify filename of the download content. Also updated test cases to test added functionality. This will fix issue #92.

@whimboo whimboo assigned whimboo and ujjwalwahi and unassigned whimboo Jan 19, 2015
directory_part = self.destination

# if file name is present in destination
if(self.target == self.destination):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please remove the brackets. Those are not necessary here.

@whimboo
Copy link
Contributor

whimboo commented Jan 19, 2015

Good start @ujjwalwahi! The changes in the base code looks fine and need some smaller updates. For the tests a bit more work will still be necessary. Therefore please see my inline comments. If you have questions don't hesitate to ask me here or on IRC. Thanks!

@whimboo
Copy link
Contributor

whimboo commented Jan 23, 2015

Hi @ujjwalwahi. I hope all is fine for you? I would like to know if you can find the time to address my review comments. Or if you have remaining questions. Thanks

@ujjwalwahi
Copy link
Contributor Author

Hi @whimboo . I am working on this, little busy with my exams. I updated scrapper.py as per reviews, no issue there. Working with tests. Will deliver it soon.

@whimboo
Copy link
Contributor

whimboo commented Jan 26, 2015

Good to hear that! But given that you are in exams please concentrate on those for now. This PR can wait.

@ujjwalwahi
Copy link
Contributor Author

@whimboo
Made changes according to review

# Don't re-download the file
if os.path.isfile(os.path.abspath(self.target)):
self.logger.info("File has already been downloaded: %s" %
(self.target))
return

directory = os.path.dirname(self.target)
if directory and not os.path.isdir(directory):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always have a valid directory here. It should never be None. So you can get rid of the first check.

version=None,
log_level='ERROR')
expected_target = os.path.join(self.temp_dir, filename)
self.assertEqual(scraper.target, expected_target)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to define expected_target first. Just put it directly inside the call to assertEqual.

@ujjwalwahi
Copy link
Contributor Author

@whimboo
Worked on reviews.

log_level='ERROR')
self.assertEqual(scraper.target, destination)

# destination directory does not exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like to see the case when a filename has been specified and the folder does not exist yet. Maybe even multiple levels deep, so we can ensure that we correctly create a folder tree.

@whimboo
Copy link
Contributor

whimboo commented Mar 3, 2015

Except the one missing test this PR looks great! I also tested it and weren't able to find a problem. @davehunt would you mind to have a look at, so we can make sure this change satisfies your needs?

@ujjwalwahi
Copy link
Contributor Author

@whimboo
Added the required test section

@whimboo
Copy link
Contributor

whimboo commented Mar 3, 2015

This looks great now! Thanks for your tireless work @ujjwalwahi! Given that Travis is also happy this time let me get it merged in a bit.

@whimboo
Copy link
Contributor

whimboo commented Mar 3, 2015

When squashing the branch I got some rebase problems, so I had to fix those before pushing out. Finally the PR got merged as 942d972.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants