Skip to content

Commit

Permalink
Import existing obsolete path and not_active_path files to modern con…
Browse files Browse the repository at this point in the history
…figuration and remove the files.

Revert this commit for a future release.
  • Loading branch information
mrclary committed Jul 29, 2022
1 parent ef685b8 commit 0ebf27d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ def signal_handler(signum, frame=None):
# Handle Spyder path
self.old_path = OrderedDict()
self._path_manager = None
self.load_python_path() # TODO: Remove on later release

# New API
self._APPLICATION_TOOLBARS = OrderedDict()
Expand Down Expand Up @@ -1646,6 +1647,38 @@ def open_external_file(self, fname):
)

# ---- Path Manager
def load_python_path(self):
"""
Load paths stored in Spyder configuration folder, add them to the
modern configuration, and remove the obsolete files.
TODO: Remove on later release
"""
SPYDER_PATH = get_conf_path('path')
SPYDER_NOT_ACTIVE_PATH = get_conf_path('not_active_path')

path_dict = OrderedDict()
if osp.isfile(SPYDER_PATH):
with open(SPYDER_PATH, 'r', encoding='utf-8') as f:
paths = f.read().splitlines()
for path in paths:
if osp.isdir(path):
path_dict[path] = True
os.remove(SPYDER_PATH) # No longer use file
logger.info(f"Removed obsolete '{SPYDER_PATH}'")

if osp.isfile(SPYDER_NOT_ACTIVE_PATH):
with open(SPYDER_NOT_ACTIVE_PATH, 'r', encoding='utf-8') as f:
paths = f.read().splitlines()
for path in paths:
if osp.isdir(path):
path_dict[path] = False
os.remove(SPYDER_NOT_ACTIVE_PATH) # No longer use file
logger.info(f"Removed obsolete '{SPYDER_NOT_ACTIVE_PATH}'")

if path_dict:
self.update_python_path(path_dict)

def get_spyder_pythonpath(self):
"""
Return Spyder PYTHONPATH, including project paths, as ordered
Expand Down

0 comments on commit 0ebf27d

Please sign in to comment.