예제 #1
0
파일: download.py 프로젝트: cessor/scrape
	def to(self, target_directory):
		filename = make_valid_filename(self.resource.name)
		filepath = os.path.join(target_directory, filename)

		if os.path.exists(filepath):
			self.skip(filepath)
			return
	
		self.load(filepath)
예제 #2
0
파일: scrape.py 프로젝트: cessor/scrape
def download(course):
	coursePath = os.path.join('courses', make_valid_filename(course.name))
	createCourseFolder(coursePath)

	page = moodle.material_page_for(course.id)
	for resource in page.resources():
	
		if was_already_downloaded(resource.url):
			continue
		
		remember(resource.url)
			
		print "\t" + resource.name
		if commandLine.do_not_download:
			continue
		Download(resource).to(coursePath)
예제 #3
0
	def test_should_replace_bad_characters(self):
		bad_filename = u"Einführung in die Pädagogische Psychologie - Bachelor WS11/12"
		good_filename = make_valid_filename(bad_filename)
		self.assertEqual(good_filename, u"Einführung in die Pädagogische Psychologie - Bachelor WS11-12")