@@ -54,44 +54,6 @@ def __init__(self, fs: FileSystem, project_root: str,
5454 file_contents = self .fs .open (file_path )
5555 cache_file_path .write_text (file_contents )
5656
57- @property
58- @lru_cache ()
59- def VENV_PATH (self ):
60- self .ensure_venv_created ()
61- venv_path = self .run_command ("pipenv --venv" ).out .rstrip ()
62- return Path (venv_path )
63-
64- def cleanup (self ):
65- log .info ("Removing project's virtual environment %s" , self .VENV_PATH )
66- self .remove_venv ()
67-
68- log .info ("Removing cloned project cache %s" , self .CLONED_PROJECT_PATH )
69- rmtree (self .CLONED_PROJECT_PATH , ignore_errors = True )
70-
71- def project_to_cache_path (self , project_path ):
72- """
73- Translates a path from the root of the project to the equivalent path in
74- the local cache.
75-
76- e.x.: '/a/b.py' -> 'python-cloned-projects-cache/project_name/a/b.py'
77- """
78- # strip the leading '/' so that we can join it properly
79- file_path = project_path
80- if file_path .startswith ("/" ):
81- file_path = file_path [1 :]
82-
83- return os .path .join (self .CLONED_PROJECT_PATH , file_path )
84-
85- def ensure_venv_created (self ):
86- '''
87- This runs a noop pipenv command, which will
88- create the venv if it doesn't exist as a side effect.
89- '''
90- self .run_command ("true" )
91-
92- def remove_venv (self ):
93- self .run_command ("pipenv --rm" , no_prefix = True )
94-
9557 def get_module_info (self , raw_jedi_module_path ):
9658 """
9759 Given an absolute module path provided from jedi,
@@ -183,6 +145,44 @@ def external_dependencies(self):
183145
184146 return out
185147
148+ def project_to_cache_path (self , project_path ):
149+ """
150+ Translates a path from the root of the project to the equivalent path in
151+ the local cache.
152+
153+ e.x.: '/a/b.py' -> 'python-cloned-projects-cache/project_name/a/b.py'
154+ """
155+ # strip the leading '/' so that we can join it properly
156+ file_path = project_path
157+ if file_path .startswith ("/" ):
158+ file_path = file_path [1 :]
159+
160+ return os .path .join (self .CLONED_PROJECT_PATH , file_path )
161+
162+ @property
163+ @lru_cache ()
164+ def VENV_PATH (self ):
165+ self .ensure_venv_created ()
166+ venv_path = self .run_command ("pipenv --venv" ).out .rstrip ()
167+ return Path (venv_path )
168+
169+ def cleanup (self ):
170+ log .info ("Removing project's virtual environment %s" , self .VENV_PATH )
171+ self .remove_venv ()
172+
173+ log .info ("Removing cloned project cache %s" , self .CLONED_PROJECT_PATH )
174+ rmtree (self .CLONED_PROJECT_PATH , ignore_errors = True )
175+
176+ def ensure_venv_created (self ):
177+ '''
178+ This runs a noop pipenv command, which will
179+ create the venv if it doesn't exist as a side effect.
180+ '''
181+ self .run_command ("true" )
182+
183+ def remove_venv (self ):
184+ self .run_command ("pipenv --rm" , no_prefix = True )
185+
186186 def run_command (self , command , no_prefix = False , ** kwargs ):
187187 '''
188188 Runs the given command inside the context
0 commit comments