Removed Python < 2.7 support from formatting.py

Patch by Bernardo Botella Corbi, reviewed by Brad Schoening, ycai and
brandonwilliams for CASSANDRA-17694
This commit is contained in:
Bernardo Botella Corbi 2022-08-01 10:57:04 -07:00 committed by Brandon Williams
parent afa7dfb5a4
commit 9a4a677823
2 changed files with 4 additions and 13 deletions

View File

@ -1,4 +1,5 @@
4.2
* Removed Python < 2.7 support from formatting.py (CASSANDRA-17694)
* Cleanup pylint issues with pylexotron.py (CASSANDRA-17779)
* NPE bug in streaming checking if SSTable is being repaired (CASSANDRA-17801)
* Users of NativeLibrary should handle lack of JNA appropriately when running in client mode (CASSANDRA-17794)

View File

@ -326,19 +326,9 @@ def format_integer_type(val, colormap, thousands_sep=None, **_):
return colorme(bval, colormap, 'int')
# We can get rid of this in cassandra-2.2
if sys.version_info >= (2, 7):
def format_integer_with_thousands_sep(val, thousands_sep=','):
return "{:,.0f}".format(val).replace(',', thousands_sep)
else:
def format_integer_with_thousands_sep(val, thousands_sep=','):
if val < 0:
return '-' + format_integer_with_thousands_sep(-val, thousands_sep)
result = ''
while val >= 1000:
val, r = divmod(val, 1000)
result = "%s%03d%s" % (thousands_sep, r, result)
return "%d%s" % (val, result)
def format_integer_with_thousands_sep(val, thousands_sep=','):
return "{:,.0f}".format(val).replace(',', thousands_sep)
formatter_for('long')(format_integer_type)
formatter_for('int')(format_integer_type)