Code Duplication    Length = 18-31 lines in 2 locations

pylast/__init__.py 2 locations

@@ 496-526 (lines=31) @@
493
494
        return _extract_top_artists(doc, self)
495
496
    def get_geo_top_tracks(
497
            self, country, location=None, limit=None, cacheable=True):
498
        """Get the most popular tracks on Last.fm last week by country.
499
        Parameters:
500
        country (Required) : A country name, as defined by the ISO 3166-1
501
            country names standard
502
        location (Optional) : A metro name, to fetch the charts for
503
            (must be within the country specified)
504
        limit (Optional) : The number of results to fetch per page.
505
            Defaults to 50.
506
        """
507
        params = {"country": country}
508
509
        if location:
510
            params["location"] = location
511
        if limit:
512
            params["limit"] = limit
513
514
        doc = _Request(self, "geo.getTopTracks", params).execute(cacheable)
515
516
        tracks = doc.getElementsByTagName("track")
517
        seq = []
518
519
        for track in tracks:
520
            title = _extract(track, "name")
521
            artist = _extract(track, "name", 1)
522
            listeners = _extract(track, "listeners")
523
524
            seq.append(TopItem(Track(artist, title, self), listeners))
525
526
        return seq
527
528
    def enable_proxy(self, host, port):
529
        """Enable a default web proxy"""
@@ 359-376 (lines=18) @@
356
357
        return _extract_top_artists(doc, self)
358
359
    def get_top_tracks(self, limit=None, cacheable=True):
360
        """Returns the most played tracks as a sequence of TopItem objects."""
361
362
        params = {}
363
        if limit:
364
            params["limit"] = limit
365
366
        doc = _Request(self, "chart.getTopTracks", params).execute(cacheable)
367
368
        seq = []
369
        for node in doc.getElementsByTagName("track"):
370
            title = _extract(node, "name")
371
            artist = _extract(node, "name", 1)
372
            track = Track(artist, title, self)
373
            weight = _number(_extract(node, "playcount"))
374
            seq.append(TopItem(track, weight))
375
376
        return seq
377
378
    def get_top_tags(self, limit=None, cacheable=True):
379
        """Returns the most used tags as a sequence of TopItem objects."""