Skip to content

Commit

Permalink
Add a few extra .format() method call fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tuffy committed Nov 18, 2015
1 parent 9e09945 commit c6aff0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -7511,7 +7511,8 @@
** TODO Convert old string formatting to new .format()-based formatting
That is, instead of using: "foo %s bar" % (argument)
it's better to use "foo {} bar".format(argument)
since the old string formatting is deprecated and not as powerful.
since the new format method is recommended for new code
and the old one is somewhat clunky and not as powerful.

Since the old format sync is baked into some areas of the code
(like the --format utility flags) it'll take longer to remove
Expand Down
2 changes: 1 addition & 1 deletion audiotools/freedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __repr__(self):
for attr in ["offsets",
"total_length",
"track_count",
"playable_length"]])
"playable_length"]]))

if sys.version_info[0] >= 3:
def __str__(self):
Expand Down
14 changes: 7 additions & 7 deletions audiotools/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def __unicode__(self):
from hashlib import sha1
from base64 import b64encode

raw_id = (u"{:02X}{:02X}{}".format(
(self.first_track_number,
self.last_track_number,
u"".join([u"{:08X}".format(offset) for offset in
[self.lead_out_offset] +
self.offsets +
[0] * (99 - len(self.offsets))])))
raw_id = u"{:02X}{:02X}{}".format(
self.first_track_number,
self.last_track_number,
u"".join([u"{:08X}".format(offset) for offset in
[self.lead_out_offset] +
self.offsets +
[0] * (99 - len(self.offsets))]))

return b64encode(sha1(raw_id.encode("ascii")).digest(),
b"._").replace(b"=", b"-").decode('ascii')
Expand Down

0 comments on commit c6aff0f

Please sign in to comment.