Skip to content

Commit

Permalink
utils: delay chardet import until it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
radhermit committed Aug 23, 2019
1 parent 061d819 commit 484ce00
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pkgcheck/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import chardet


# based on https://github.com/audreyr/binaryornot
#
# Copyright (c) 2013, Audrey Roy
Expand Down Expand Up @@ -86,6 +83,10 @@ def is_binary(path, blocksize=1024):
byte_str.decode()
decodable = True
except UnicodeDecodeError:
# Delay import to hide during wheel/sdist builds that iterate over and
# import most modules to generate check/keyword/reporter lists.
import chardet

# guess character encoding using chardet
detected_encoding = chardet.detect(byte_str)
if detected_encoding['confidence'] > 0.8:
Expand Down

0 comments on commit 484ce00

Please sign in to comment.