find.py 953 B

1234567891011121314151617181920212223242526272829
  1. import os
  2. base_dirs = [
  3. os.path.expanduser('~/.conda'),
  4. os.path.expanduser('~/.condarc'),
  5. os.path.expanduser('~/.continuum'),
  6. os.environ.get('CONDA_PREFIX', ''),
  7. os.path.join(os.environ.get('USERPROFILE', ''), '.conda'),
  8. os.path.join(os.environ.get('USERPROFILE', ''), 'AppData', 'Local', 'conda')
  9. ]
  10. def search_tilde_in_files(base_dir):
  11. for root, _, files in os.walk(base_dir):
  12. for file in files:
  13. try:
  14. filepath = os.path.join(root, file)
  15. with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
  16. content = f.read()
  17. if '~' in content:
  18. print(f"[!] Found '~' in: {filepath}")
  19. except Exception as e:
  20. pass
  21. print("Searching for '~' in Conda-related files...\n")
  22. for d in base_dirs:
  23. if d and os.path.exists(d):
  24. search_tilde_in_files(d)
  25. print("\nSearch complete.")