summaryrefslogtreecommitdiff
path: root/isort/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'isort/utils.py')
-rw-r--r--isort/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/isort/utils.py b/isort/utils.py
index 1f1b5143..0f6f57bf 100644
--- a/isort/utils.py
+++ b/isort/utils.py
@@ -52,3 +52,12 @@ def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
if item not in b:
d.append(item)
return d
+
+
+def infer_line_separator(file_contents: str) -> str:
+ if '\r\n' in file_contents:
+ return '\r\n'
+ elif '\r' in file_contents:
+ return '\r'
+ else:
+ return '\n'