diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2015-07-22 15:36:23 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2015-07-22 15:36:23 -0500 |
commit | 49ab865657f03795139e95490b1978fcceca2f41 (patch) | |
tree | c41beeca523fca354a586ad63c283a9c2133b709 /src/lib/Bcfg2/Client/Tools/POSIX/File.py | |
parent | c7e67299381df961ff8274e9b53827c2bddbb47b (diff) | |
parent | b54c32c861b517b889b1cd6c0bbe082b8d93e5d2 (diff) | |
download | bcfg2-49ab865657f03795139e95490b1978fcceca2f41.tar.gz bcfg2-49ab865657f03795139e95490b1978fcceca2f41.tar.bz2 bcfg2-49ab865657f03795139e95490b1978fcceca2f41.zip |
Merge branch 'merge-files-ignore-binary' of https://github.com/AlexanderS/bcfg2
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools/POSIX/File.py')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/POSIX/File.py | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/File.py b/src/lib/Bcfg2/Client/Tools/POSIX/File.py index fc445e07c..1f1772d46 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIX/File.py +++ b/src/lib/Bcfg2/Client/Tools/POSIX/File.py @@ -8,6 +8,7 @@ import tempfile import Bcfg2.Options from Bcfg2.Client.Tools.POSIX.base import POSIXTool from Bcfg2.Compat import unicode, b64encode, b64decode # pylint: disable=W0622 +import Bcfg2.Utils class POSIXFile(POSIXTool): @@ -17,21 +18,6 @@ class POSIXFile(POSIXTool): def fully_specified(self, entry): return entry.text is not None or entry.get('empty', 'false') == 'true' - def _is_string(self, strng, encoding): - """ Returns true if the string contains no ASCII control - characters and can be decoded from the specified encoding. """ - for char in strng: - if ord(char) < 9 or ord(char) > 13 and ord(char) < 32: - return False - if not hasattr(strng, "decode"): - # py3k - return True - try: - strng.decode(encoding) - return True - except: # pylint: disable=W0702 - return False - def _get_data(self, entry): """ Get a tuple of (<file data>, <is binary>) for the given entry """ is_binary = entry.get('encoding', 'ascii') == 'base64' @@ -181,8 +167,8 @@ class POSIXFile(POSIXTool): (entry.get("name"), sys.exc_info()[1])) return False if not is_binary: - is_binary |= not self._is_string(content, - Bcfg2.Options.setup.encoding) + is_binary |= not Bcfg2.Utils.is_string( + content, Bcfg2.Options.setup.encoding) if is_binary: # don't compute diffs if the file is binary prompt.append('Binary file, no printable diff') |