Esempio n. 1
0
def sorted_diff_list(difflist):
    keys = difflist.keys()
    keys.sort(
        (lambda a, b: cmp(difflist[a], difflist[b]) or util.difficulty_sort(
            a, b)))
    return keys
Esempio n. 2
0
    def _create_folders(self):
        mixes = {}
        artists = {}
        titles = {}
        bpms = {}
        difficulties = {}
        ratings = {}

        for s in self._all_songs:
            if s.info["mix"] not in mixes: mixes[s.info["mix"]] = []
            mixes[s.info["mix"]].append(s)
            s.folder["mix"] = s.info["mix"]

            label = s.info["title"][0].capitalize()
            if label not in titles: titles[label] = []
            titles[label].append(s)
            s.folder["title"] = label

            label = s.info["artist"][0].capitalize()
            if label not in artists: artists[label] = []
            artists[label].append(s)
            s.folder["artist"] = label

            for rng in ((0, 50), (50, 100), (100, 121), (110, 120), (120, 130),
                        (130, 140), (140, 150), (150, 160), (160, 170),
                        (170, 180), (180, 190), (190, 200), (200, 225),
                        (225, 250), (250, 275), (275, 299.99999999)):
                if rng[0] < s.info["bpm"] <= rng[1]:
                    label = "%3d - %3d" % rng
                    if not label in bpms: bpms[label] = []
                    bpms[label].append(s)
                    s.folder["bpm"] = label
            if s.info["bpm"] >= 300:
                if "300+" not in bpms: bpms["300+"] = []
                bpms["300+"].append(s)
                s.folder["bpm"] = "300+"
        for s in self._all_dances:
            difficulty = self._unify_difficulties(s.diff_list[0])
            label = difficulty
            if not label in difficulties: difficulties[label] = []
            difficulties[label].append(s)
            # s.folder["difficulty"] is only initialised here.
            if "difficulty" in s.folder.keys():
                # min() can't handle arbitrary comparators, so:
                if util.difficulty_sort(s.folder["difficulty"], label) <= 0:
                    s.folder["difficulty"] = s.folder["difficulty"]
                else:
                    s.folder["difficulty"] = label
            else:
                s.folder["difficulty"] = label

            rating = s.difficulty.values()[0]
            label = "%2d" % rating
            if not label in ratings: ratings[label] = []
            ratings[label].append(s)
            # s.folder["rating"] is only initialised here.
            if "rating" in s.folder.keys():
                s.folder["rating"] = min(s.folder["rating"], label)
            else:
                s.folder["rating"] = label

        self._folders = {
            "mix": mixes,
            "title": titles,
            "artist": artists,
            "bpm": bpms,
            "rating": ratings,
            "difficulty": difficulties
        }
Esempio n. 3
0
  def _create_folders(self):
    mixes = {}
    artists = {}
    titles = {}
    bpms = {}
    difficulties = {}
    ratings = {}

    for s in self._all_songs:
      if s.info["mix"] not in mixes: mixes[s.info["mix"]] = []
      mixes[s.info["mix"]].append(s)
      s.folder["mix"] = s.info["mix"]

      label = s.info["title"][0].capitalize()
      if label not in titles: titles[label] = []
      titles[label].append(s)
      s.folder["title"] = label

      label = s.info["artist"][0].capitalize()
      if label not in artists: artists[label] = []
      artists[label].append(s)
      s.folder["artist"] = label

      for rng in ((0, 50), (50, 100), (100, 121), (110, 120), (120, 130),
                  (130, 140), (140, 150), (150, 160), (160, 170), (170, 180),
                  (180, 190), (190, 200), (200, 225), (225, 250), (250, 275),
                  (275, 299.99999999)):
        if rng[0] < s.info["bpm"] <= rng[1]:
          label = "%3d - %3d" % rng
          if not label in bpms: bpms[label] = []
          bpms[label].append(s)
          s.folder["bpm"] = label
      if s.info["bpm"] >= 300:
        if "300+" not in bpms: bpms["300+"] = []
        bpms["300+"].append(s)
        s.folder["bpm"] = "300+"
    for s in self._all_dances:
      difficulty = self._unify_difficulties(s.diff_list[0])
      label = difficulty
      if not label in difficulties: difficulties[label]=[]
      difficulties[label].append(s)
      # s.folder["difficulty"] is only initialised here.
      if "difficulty" in s.folder.keys():
        # min() can't handle arbitrary comparators, so:
        if util.difficulty_sort(s.folder["difficulty"], label)<=0 :
          s.folder["difficulty"] = s.folder["difficulty"]
        else: s.folder["difficulty"] = label
      else:
        s.folder["difficulty"] = label

      rating = s.difficulty.values()[0]
      label = "%2d" % rating
      if not label in ratings: ratings[label]=[]
      ratings[label].append(s)
      # s.folder["rating"] is only initialised here.
      if "rating" in s.folder.keys():
        s.folder["rating"] = min(s.folder["rating"], label) 
      else:
        s.folder["rating"] = label
        
    self._folders = { "mix": mixes, "title": titles, "artist": artists,
                      "bpm": bpms, "rating": ratings, "difficulty": difficulties }
Esempio n. 4
0
def sorted_diff_list(difflist):
  keys = difflist.keys()
  keys.sort((lambda a, b: cmp(difflist[a], difflist[b]) or
             util.difficulty_sort(a, b)))
  return keys