Преглед изворни кода

IS1146 [filebrowser] Fixed XxdTest:test_compare_to_xxd failed (#1146)

- xxd_test.py : In this case, chr(not unichr) is enough for python2 and python3
- xxd.py: hex.ljust expect the first argument as integer not float

Co-authored-by: Romain Rigaux <romain.rigaux@gmail.com>
Sungpeo Kook пре 5 година
родитељ
комит
5dcaeeafdb

+ 1 - 1
apps/filebrowser/src/filebrowser/lib/xxd.py

@@ -94,7 +94,7 @@ def main(input, output):
         return "%02x" % ord
         return "%02x" % ord
       hex = " ".join([ "".join(map(ashex, sentence)) for sentence in ordinals])
       hex = " ".join([ "".join(map(ashex, sentence)) for sentence in ordinals])
       # 2 characters per byte, 1 extra for spacing, and 1 extra at the end.
       # 2 characters per byte, 1 extra for spacing, and 1 extra at the end.
-      hex = hex.ljust(bytes_per_line*2 + (math.floor(bytes_per_line / bytes_per_sentence)) - 1)
+      hex = hex.ljust(bytes_per_line*2 + int(math.floor(bytes_per_line / bytes_per_sentence)) - 1)
       output.write("%07x: %s  %s\n" % (off, hex, printable))
       output.write("%07x: %s  %s\n" % (off, hex, printable))
 
 
     offset += len(data)
     offset += len(data)

+ 0 - 1
apps/filebrowser/src/filebrowser/lib/xxd_test.py

@@ -18,7 +18,6 @@
 from __future__ import absolute_import
 from __future__ import absolute_import
 from future import standard_library
 from future import standard_library
 standard_library.install_aliases()
 standard_library.install_aliases()
-from builtins import chr
 from builtins import range
 from builtins import range
 import unittest
 import unittest
 import logging
 import logging