summaryrefslogtreecommitdiff
path: root/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py
diff options
context:
space:
mode:
authorShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
committerShubham Saini <shubham6405@gmail.com>2019-08-05 08:32:33 +0000
commit227b2d30a8675b44918f9d9ca89b24144a938215 (patch)
tree9f8e6a28724514b6fdf463a9ab2067a7ef309b72 /venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py
parent842a8cfbbbdb1f92889d892e4859dbd5d40c5be8 (diff)
removing venv files
Diffstat (limited to 'venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py')
-rw-r--r--venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py82
1 files changed, 0 insertions, 82 deletions
diff --git a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py b/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py
deleted file mode 100644
index 25bc0d9..0000000
--- a/venv/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip/_internal/utils/temp_dir.py
+++ /dev/null
@@ -1,82 +0,0 @@
1from __future__ import absolute_import
2
3import logging
4import os.path
5import tempfile
6
7from pip._internal.utils.misc import rmtree
8
9logger = logging.getLogger(__name__)
10
11
12class TempDirectory(object):
13 """Helper class that owns and cleans up a temporary directory.
14
15 This class can be used as a context manager or as an OO representation of a
16 temporary directory.
17
18 Attributes:
19 path
20 Location to the created temporary directory or None
21 delete
22 Whether the directory should be deleted when exiting
23 (when used as a contextmanager)
24
25 Methods:
26 create()
27 Creates a temporary directory and stores its path in the path
28 attribute.
29 cleanup()
30 Deletes the temporary directory and sets path attribute to None
31
32 When used as a context manager, a temporary directory is created on
33 entering the context and, if the delete attribute is True, on exiting the
34 context the created directory is deleted.
35 """
36
37 def __init__(self, path=None, delete=None, kind="temp"):
38 super(TempDirectory, self).__init__()
39
40 if path is None and delete is None:
41 # If we were not given an explicit directory, and we were not given
42 # an explicit delete option, then we'll default to deleting.
43 delete = True
44
45 self.path = path
46 self.delete = delete
47 self.kind = kind
48
49 def __repr__(self):
50 return "<{} {!r}>".format(self.__class__.__name__, self.path)
51
52 def __enter__(self):
53 self.create()
54 return self
55
56 def __exit__(self, exc, value, tb):
57 if self.delete:
58 self.cleanup()
59
60 def create(self):
61 """Create a temporary directory and store it's path in self.path
62 """
63 if self.path is not None:
64 logger.debug(
65 "Skipped creation of temporary directory: {}".format(self.path)
66 )
67 return
68 # We realpath here because some systems have their default tmpdir
69 # symlinked to another directory. This tends to confuse build
70 # scripts, so we canonicalize the path by traversing potential
71 # symlinks here.
72 self.path = os.path.realpath(
73 tempfile.mkdtemp(prefix="pip-{}-".format(self.kind))
74 )
75 logger.debug("Created temporary directory: {}".format(self.path))
76
77 def cleanup(self):
78 """Remove the temporary directory created and reset state
79 """
80 if self.path is not None and os.path.exists(self.path):
81 rmtree(self.path)
82 self.path = None