Merge ~cjwatson/launchpad:py3-true-division into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: f32dbb8ec9e88bffbd39234dd83773051c2d76cf
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-true-division
Merge into: launchpad:master
Diff against target: 135 lines (+23/-10)
5 files modified
lib/lp/app/browser/stringformatter.py (+3/-1)
lib/lp/app/browser/tales.py (+6/-4)
lib/lp/code/model/sourcepackagerecipe.py (+3/-1)
lib/lp/code/tests/helpers.py (+7/-2)
lib/lp/registry/browser/distribution.py (+4/-2)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396326@code.launchpad.net

Commit message

Handle / being true division in Python 3

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/app/browser/stringformatter.py b/lib/lp/app/browser/stringformatter.py
index f66bb43..c791cf7 100644
--- a/lib/lp/app/browser/stringformatter.py
+++ b/lib/lp/app/browser/stringformatter.py
@@ -3,6 +3,8 @@
33
4"""TALES formatter for strings."""4"""TALES formatter for strings."""
55
6from __future__ import division
7
6__metaclass__ = type8__metaclass__ = type
7__all__ = [9__all__ = [
8 'add_word_breaks',10 'add_word_breaks',
@@ -921,7 +923,7 @@ class FormattersAPI:
921 def ellipsize(self, maxlength):923 def ellipsize(self, maxlength):
922 """Use like tal:content="context/foo/fmt:ellipsize/60"."""924 """Use like tal:content="context/foo/fmt:ellipsize/60"."""
923 if len(self._stringtoformat) > maxlength:925 if len(self._stringtoformat) > maxlength:
924 length = (maxlength - 3) / 2926 length = (maxlength - 3) // 2
925 return (927 return (
926 self._stringtoformat[:maxlength - length - 3] + '...' +928 self._stringtoformat[:maxlength - length - 3] + '...' +
927 self._stringtoformat[-length:])929 self._stringtoformat[-length:])
diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
index 268b5bd..115bc0f 100644
--- a/lib/lp/app/browser/tales.py
+++ b/lib/lp/app/browser/tales.py
@@ -3,6 +3,8 @@
33
4"""Implementation of the lp: htmlform: fmt: namespaces in TALES."""4"""Implementation of the lp: htmlform: fmt: namespaces in TALES."""
55
6from __future__ import division
7
6__metaclass__ = type8__metaclass__ = type
79
8from bisect import bisect10from bisect import bisect
@@ -2277,8 +2279,8 @@ class DateTimeFormatterAPI:
2277 future = delta < timedelta(0, 0, 0)2279 future = delta < timedelta(0, 0, 0)
2278 delta = abs(delta)2280 delta = abs(delta)
2279 days = delta.days2281 days = delta.days
2280 hours = delta.seconds / 36002282 hours = delta.seconds // 3600
2281 minutes = (delta.seconds - (3600 * hours)) / 602283 minutes = (delta.seconds - (3600 * hours)) // 60
2282 seconds = delta.seconds % 602284 seconds = delta.seconds % 60
2283 result = ''2285 result = ''
2284 if future:2286 if future:
@@ -2341,7 +2343,7 @@ class DateTimeFormatterAPI:
2341 number = delta.days2343 number = delta.days
2342 unit = 'day'2344 unit = 'day'
2343 else:2345 else:
2344 number = delta.seconds / 602346 number = delta.seconds // 60
2345 if number == 0:2347 if number == 0:
2346 return 'less than a minute'2348 return 'less than a minute'
2347 unit = 'minute'2349 unit = 'minute'
@@ -2483,7 +2485,7 @@ class DurationFormatterAPI:
2483 hours, remaining_seconds = divmod(seconds, 3600)2485 hours, remaining_seconds = divmod(seconds, 3600)
2484 ten_minute_chunks = round_half_up(remaining_seconds / 600.0)2486 ten_minute_chunks = round_half_up(remaining_seconds / 600.0)
2485 minutes = ten_minute_chunks * 102487 minutes = ten_minute_chunks * 10
2486 hours += (minutes / 60)2488 hours += (minutes // 60)
2487 minutes %= 602489 minutes %= 60
2488 if hours < 10:2490 if hours < 10:
2489 if minutes:2491 if minutes:
diff --git a/lib/lp/code/model/sourcepackagerecipe.py b/lib/lp/code/model/sourcepackagerecipe.py
index 10ee27e..9eba658 100644
--- a/lib/lp/code/model/sourcepackagerecipe.py
+++ b/lib/lp/code/model/sourcepackagerecipe.py
@@ -3,6 +3,8 @@
33
4"""Implementation of the `SourcePackageRecipe` content type."""4"""Implementation of the `SourcePackageRecipe` content type."""
55
6from __future__ import division
7
6__metaclass__ = type8__metaclass__ = type
7__all__ = [9__all__ = [
8 'SourcePackageRecipe',10 'SourcePackageRecipe',
@@ -406,4 +408,4 @@ class SourcePackageRecipe(Storm):
406 if len(durations) == 0:408 if len(durations) == 0:
407 return None409 return None
408 durations.sort(reverse=True)410 durations.sort(reverse=True)
409 return durations[len(durations) / 2]411 return durations[len(durations) // 2]
diff --git a/lib/lp/code/tests/helpers.py b/lib/lp/code/tests/helpers.py
index fae251a..c9d980c 100644
--- a/lib/lp/code/tests/helpers.py
+++ b/lib/lp/code/tests/helpers.py
@@ -3,7 +3,12 @@
33
4"""Helper functions for code testing live here."""4"""Helper functions for code testing live here."""
55
6from __future__ import absolute_import, print_function, unicode_literals6from __future__ import (
7 absolute_import,
8 division,
9 print_function,
10 unicode_literals,
11 )
712
8__metaclass__ = type13__metaclass__ = type
9__all__ = [14__all__ = [
@@ -212,7 +217,7 @@ def make_project_cloud_data(factory, details):
212 project = factory.makeProduct(name=project_name)217 project = factory.makeProduct(name=project_name)
213 start_date = last_commit - delta * (num_commits - 1)218 start_date = last_commit - delta * (num_commits - 1)
214 gen = time_counter(start_date, delta)219 gen = time_counter(start_date, delta)
215 commits_each = num_commits / num_authors220 commits_each = num_commits // num_authors
216 for committer in range(num_authors - 1):221 for committer in range(num_authors - 1):
217 make_project_branch_with_revisions(222 make_project_branch_with_revisions(
218 factory, gen, project, commits_each)223 factory, gen, project, commits_each)
diff --git a/lib/lp/registry/browser/distribution.py b/lib/lp/registry/browser/distribution.py
index c499689..f638654 100644
--- a/lib/lp/registry/browser/distribution.py
+++ b/lib/lp/registry/browser/distribution.py
@@ -3,6 +3,8 @@
33
4"""Browser views for distributions."""4"""Browser views for distributions."""
55
6from __future__ import division
7
6__metaclass__ = type8__metaclass__ = type
79
8__all__ = [10__all__ = [
@@ -1258,9 +1260,9 @@ class DistributionMirrorsView(LaunchpadView):
1258 if throughput < 1000:1260 if throughput < 1000:
1259 return str(throughput) + ' Kbps'1261 return str(throughput) + ' Kbps'
1260 elif throughput < 1000000:1262 elif throughput < 1000000:
1261 return str(throughput / 1000) + ' Mbps'1263 return str(throughput // 1000) + ' Mbps'
1262 else:1264 else:
1263 return str(throughput / 1000000) + ' Gbps'1265 return str(throughput // 1000000) + ' Gbps'
12641266
1265 @cachedproperty1267 @cachedproperty
1266 def total_throughput(self):1268 def total_throughput(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: