@@ -12,16 +12,13 @@ pub struct VenvInfo {
12
12
13
13
impl VenvInfo {
14
14
pub fn new ( path : PathBuf ) -> Option < Self > {
15
- // Check if this is really a virtualenv
16
15
let pyvenv_cfg = path. join ( "pyvenv.cfg" ) ;
17
16
if !pyvenv_cfg. exists ( ) {
18
17
return None ;
19
18
}
20
19
21
- // Calculate size
22
20
let size = get_dir_size ( & path) . unwrap_or ( 0 ) ;
23
21
24
- // Get last modified time
25
22
let metadata = fs:: metadata ( & path) . ok ( ) ?;
26
23
let modified = metadata. modified ( ) . ok ( )
27
24
. and_then ( |t| DateTime :: < Local > :: from ( t) . into ( ) ) ;
@@ -34,7 +31,6 @@ impl VenvInfo {
34
31
}
35
32
}
36
33
37
- /// Scan a directory recursively for potential Python virtualenv folders
38
34
pub fn scan_for_venvs ( root : & Path ) -> Vec < VenvInfo > {
39
35
let mut results = Vec :: new ( ) ;
40
36
@@ -44,7 +40,7 @@ pub fn scan_for_venvs(root: &Path) -> Vec<VenvInfo> {
44
40
}
45
41
46
42
let name = entry. file_name ( ) . to_string_lossy ( ) . to_lowercase ( ) ;
47
- if name == "venv" || name == ".venv" || name == "env" {
43
+ if name == "venv" || name == ".venv" || name == "env" || name == "virtualenv" || name == "pyenv" || name == ".env" {
48
44
if let Some ( venv) = VenvInfo :: new ( entry. path ( ) . to_path_buf ( ) ) {
49
45
results. push ( venv) ;
50
46
}
@@ -54,7 +50,6 @@ pub fn scan_for_venvs(root: &Path) -> Vec<VenvInfo> {
54
50
results
55
51
}
56
52
57
- /// Recursively calculate directory size in bytes
58
53
fn get_dir_size ( path : & Path ) -> Result < u64 , std:: io:: Error > {
59
54
let mut size = 0 ;
60
55
0 commit comments