Ejemplo n.º 1
0
 def test_hours(self):
     self.assertEqual(search.formatSeconds(3600),
                      "1 hour 0 minutes 0 seconds")
     self.assertEqual(search.formatSeconds(3600 + 60),
                      "1 hour 1 minute 0 seconds")
     self.assertEqual(search.formatSeconds(3600 + 60 * 2),
                      "1 hour 2 minutes 0 seconds")
     self.assertEqual(search.formatSeconds(3600 * 2),
                      "2 hours 0 minutes 0 seconds")
Ejemplo n.º 2
0
 def test_minutes(self):
     self.assertEqual(search.formatSeconds(60), "1 minute 0 seconds")
     self.assertEqual(search.formatSeconds(60 + 1), "1 minute 1 second")
     self.assertEqual(search.formatSeconds(60 + 2), "1 minute 2 seconds")
Ejemplo n.º 3
0
 def test_seconds(self):
     self.assertEqual(search.formatSeconds(2), "2 seconds")
     self.assertEqual(search.formatSeconds(1), "1 second")
 def test_minutes(self) :
     self.assertEqual(search.formatSeconds(60), "1 minute 0 seconds")
     self.assertEqual(search.formatSeconds(60+1), "1 minute 1 second")
     self.assertEqual(search.formatSeconds(60+2), "1 minute 2 seconds")
 def test_seconds(self):
     self.assertEqual(search.formatSeconds(2), "2 seconds")
     self.assertEqual(search.formatSeconds(1), "1 second")
 def test_hours(self):
     self.assertEqual(search.formatSeconds(3600), "1 hour 0 minutes 0 seconds")
     self.assertEqual(search.formatSeconds(3600+60), "1 hour 1 minute 0 seconds")
     self.assertEqual(search.formatSeconds(3600+60*2), "1 hour 2 minutes 0 seconds")
     self.assertEqual(search.formatSeconds(3600*2), "2 hours 0 minutes 0 seconds")
        HTMLOfPages += html
    print("Finished downloading all pages. Searching for artists...")

    # There is an artist named "Erro" and he get's matched for every single
    # "error" in the site text. Since no artist has "error" in their name
    # we can safely get rid of "error" strings without messing up the results.
    pattern = re.compile("error", re.IGNORECASE)
    HTMLOfPages = pattern.sub("", HTMLOfPages.lower())

    ## For each artist, count the number of occurrences that artist has in the
    ## file and add it to an array (counter) with it's index corresponding to
    ## the index of that artist
    counter = []
    for index, artist in enumerate(artists, start=0):
        count = HTMLOfPages.count(artist.lower())
        counter.append(count)

    #search.printOccurrences(counter, artists)
    search.resultsToCsv(counter, artists, query, plant, results_file)

    # Figure out how long the program's been running and print it out
    plantFinishTime = time.time()
    plantElapsedTime = (plantFinishTime - plantStartTime)
    totalElapsedTime = (plantFinishTime - startTime)
    print("Successfully added " + plant + " to results file in " + search.formatSeconds(plantElapsedTime) + ".")
    print("Total elapsed time: " + search.formatSeconds(totalElapsedTime))
    
    print("Average time per plant: " + search.formatSeconds(totalElapsedTime/(timeIndex+1)))
    print("------------------------")
    print("")