Skip to main content
Fixed grammar.
Source Link
user650881
  • 484
  • 2
  • 5
  • all next and previous track computations will overflow. Computation should be modulus number of tracks

      song_index = (self.ui.current_song_number() + 1) % self.ui.song_count()
    
  • track label formation catches exceptions but (a) uses a bare except, (b) largely repeats the try block in the exception handler, (c) inserts the malformed label and (d) includes a dangling variable name. Perhaps something like this:

      try:
          id3 = ID3(file_name)
          data = id3['TPE1'].text[0] + " - " + id3["TIT2"].text[0]
          self.filenames_by_track_label[data] = file_name
          self.ui.listWidget.addItem(data)
      except (IOError, LookupError):
          self.ui.show_error("El archivo que ha elegido no funciona. Seleccione otro archivo por favor.")
    
  • all next and previous track computations will overflow. Computation should be modulus number of tracks

      song_index = (self.ui.current_song_number() + 1) % self.ui.song_count()
    
  • track label formation catches exceptions but (a) uses a bare except, (b) largely repeats the try block in the exception handler, (c) inserts the malformed label and (d) includes a dangling variable name

      try:
          id3 = ID3(file_name)
          data = id3['TPE1'].text[0] + " - " + id3["TIT2"].text[0]
          self.filenames_by_track_label[data] = file_name
          self.ui.listWidget.addItem(data)
      except (IOError, LookupError):
          self.ui.show_error("El archivo que ha elegido no funciona. Seleccione otro archivo por favor.")
    
  • all next and previous track computations will overflow. Computation should be modulus number of tracks

      song_index = (self.ui.current_song_number() + 1) % self.ui.song_count()
    
  • track label formation catches exceptions but (a) uses a bare except, (b) largely repeats the try block in the exception handler, (c) inserts the malformed label and (d) includes a dangling variable name. Perhaps something like this:

      try:
          id3 = ID3(file_name)
          data = id3['TPE1'].text[0] + " - " + id3["TIT2"].text[0]
          self.filenames_by_track_label[data] = file_name
          self.ui.listWidget.addItem(data)
      except (IOError, LookupError):
          self.ui.show_error("El archivo que ha elegido no funciona. Seleccione otro archivo por favor.")
    
Fixed grammar.
Source Link
user650881
  • 484
  • 2
  • 5

You could further remove code duplication by in the UI construction by use of a helper, for example

You might consider separating the UI from the controller to provide some structure. I have shown some elements inof that byin my examples with self.ui

You could further remove code duplication by in UI construction by use of a helper for example

You might consider separating the UI from the controller to provide some structure. I have shown some elements in that by my examples with self.ui

You could further remove code duplication in the UI construction by use of a helper, for example

You might consider separating the UI from the controller to provide some structure. I have shown some elements of that in my examples with self.ui

Remove extraneous comment
Source Link
user650881
  • 484
  • 2
  • 5

It can be a pleasure to whip something up in an hour on the plane. This may be an example of the 80-20 rule. This code could be improved by looking at theusing pylint.

It can be a pleasure to whip something up in an hour on the plane. This may be an example of the 80-20 rule. This code could be improved by looking at the pylint.

It can be a pleasure to whip something up in an hour on the plane. This code could be improved by using pylint.

Source Link
user650881
  • 484
  • 2
  • 5
Loading