summaryrefslogtreecommitdiff
path: root/venv/Lib/site-packages/isort/utils.py
diff options
context:
space:
mode:
authorSann Yay Aye2020-01-30 12:57:51 +0530
committerSann Yay Aye2020-01-30 12:57:51 +0530
commit190966e010e321e4df56d40104ec80467a870e53 (patch)
treef97ac913ec59a975ad64d5a3cd61e11923d98a69 /venv/Lib/site-packages/isort/utils.py
parent7ecaa6f103b2755dc3bb3fae10a0d7ab28162596 (diff)
downloadChemical-Simulator-GUI-190966e010e321e4df56d40104ec80467a870e53.tar.gz
Chemical-Simulator-GUI-190966e010e321e4df56d40104ec80467a870e53.tar.bz2
Chemical-Simulator-GUI-190966e010e321e4df56d40104ec80467a870e53.zip
undo&redo_implementation
Diffstat (limited to 'venv/Lib/site-packages/isort/utils.py')
-rw-r--r--venv/Lib/site-packages/isort/utils.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/venv/Lib/site-packages/isort/utils.py b/venv/Lib/site-packages/isort/utils.py
new file mode 100644
index 0000000..ce4e588
--- /dev/null
+++ b/venv/Lib/site-packages/isort/utils.py
@@ -0,0 +1,53 @@
+import os
+import sys
+from contextlib import contextmanager
+
+
+def exists_case_sensitive(path):
+ """
+ Returns if the given path exists and also matches the case on Windows.
+
+ When finding files that can be imported, it is important for the cases to match because while
+ file os.path.exists("module.py") and os.path.exists("MODULE.py") both return True on Windows, Python
+ can only import using the case of the real file.
+ """
+ result = os.path.exists(path)
+ if (sys.platform.startswith('win') or sys.platform == 'darwin') and result:
+ directory, basename = os.path.split(path)
+ result = basename in os.listdir(directory)
+ return result
+
+
+@contextmanager
+def chdir(path):
+ """Context manager for changing dir and restoring previous workdir after exit.
+ """
+ curdir = os.getcwd()
+ os.chdir(path)
+ try:
+ yield
+ finally:
+ os.chdir(curdir)
+
+
+def union(a, b):
+ """ Return a list of items that are in `a` or `b`
+ """
+ u = []
+ for item in a:
+ if item not in u:
+ u.append(item)
+ for item in b:
+ if item not in u:
+ u.append(item)
+ return u
+
+
+def difference(a, b):
+ """ Return a list of items from `a` that are not in `b`.
+ """
+ d = []
+ for item in a:
+ if item not in b:
+ d.append(item)
+ return d