aboutsummaryrefslogtreecommitdiffstats
path: root/jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-03-29 10:54:26 +0000
committerGerrit Code Review <gerrit@onap.org>2017-03-29 10:54:26 +0000
commit249698f5ece210994f8a3a7529653c67fc577ff4 (patch)
tree63052e82b5dc63e0a88988191ad7ecc9fbd79de2 /jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py
parentb4c0ae1af144b665c5cde3a3f44cee953e66683a (diff)
parente2cc2530fc6d54ebc975c01a4ff887ce12f0a736 (diff)
Merge "[SDC-6] sdc-distribution-client 1707 rebasing"
Diffstat (limited to 'jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py')
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py
new file mode 100644
index 0000000..ecd0163
--- /dev/null
+++ b/jython-tosca-parser/src/main/resources/Lib/site-packages/pip/_vendor/requests/packages/chardet/chardetect.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+"""
+Script which takes one or more file paths and reports on their detected
+encodings
+
+Example::
+
+ % chardetect somefile someotherfile
+ somefile: windows-1252 with confidence 0.5
+ someotherfile: ascii with confidence 1.0
+
+If no paths are provided, it takes its input from stdin.
+
+"""
+from io import open
+from sys import argv, stdin
+
+from chardet.universaldetector import UniversalDetector
+
+
+def description_of(file, name='stdin'):
+ """Return a string describing the probable encoding of a file."""
+ u = UniversalDetector()
+ for line in file:
+ u.feed(line)
+ u.close()
+ result = u.result
+ if result['encoding']:
+ return '%s: %s with confidence %s' % (name,
+ result['encoding'],
+ result['confidence'])
+ else:
+ return '%s: no result' % name
+
+
+def main():
+ if len(argv) <= 1:
+ print(description_of(stdin))
+ else:
+ for path in argv[1:]:
+ with open(path, 'rb') as f:
+ print(description_of(f, path))
+
+
+if __name__ == '__main__':
+ main()