1010Created on Mon Aug 13 11:40:01 2012
1111"""
1212
13- import os .path as osp
13+ # import os.path as osp
1414from pathlib import Path
1515import os
1616import sys
6969# Local imports
7070from winpython import __version__ , __project_url__
7171from winpython import wppm , associate , utils
72- from winpython .py3compat import getcwd , to_text_string
72+ # from winpython.py3compat import getcwd, to_text_string
7373
7474
7575COLUMNS = ACTION , CHECK , NAME , VERSION , DESCRIPTION = list (
@@ -249,7 +249,8 @@ def add_packages(self, fnames):
249249 notcompatible = []
250250 dist = self .distribution
251251 for fname in fnames :
252- bname = osp .basename (fname )
252+ # bname = osp.basename(fname)
253+ bname = Path (fname ).name
253254 try :
254255 package = wppm .Package (fname )
255256 if package .is_compatible_with (dist ):
@@ -355,7 +356,7 @@ def dropEvent(self, event):
355356 fnames = [
356357 path
357358 for path in mimedata2url (source )
358- if osp .isfile (path )
359+ if Path ( path ). is_file () # if osp.isfile(path)
359360 ]
360361 self .add_packages (fnames )
361362 event .acceptProposedAction ()
@@ -405,9 +406,11 @@ def setup_widget(self):
405406
406407 def select_directory (self ):
407408 """Select directory"""
408- basedir = to_text_string (self .line_edit .text ())
409- if not osp .isdir (basedir ):
410- basedir = getcwd ()
409+ # basedir = to_text_string(self.line_edit.text())
410+ basedir = str (self .line_edit .text ())
411+ # if not osp.isdir(basedir):
412+ if not Path (basedir ).is_dir ():
413+ basedir = str (Path .cwd ()) # getcwd()
411414 while True :
412415 directory = getexistingdirectory (
413416 self , self .TITLE , basedir
@@ -423,7 +426,9 @@ def select_directory(self):
423426 )
424427 basedir = directory
425428 continue
426- directory = osp .abspath (osp .normpath (directory ))
429+ # directory = osp.abspath(osp.normpath(directory))
430+ # directory = str(Path(osp.normpath(directory)).resolve())
431+ directory = str (Path (directory ).resolve (strict = False ))
427432 self .set_distribution (directory )
428433 # PyQt4 old SIGNAL: self.emit(SIGNAL('selected_distribution(QString)'), directory)
429434 self .selected_distribution .emit (directory )
@@ -667,7 +672,8 @@ def setup_window(self):
667672 ),
668673 )
669674 open_console_action .setEnabled (
670- osp .exists (self .command_prompt_path )
675+ # osp.exists(self.command_prompt_path)
676+ Path (self .command_prompt_path ).exists ()
671677 )
672678 add_actions (
673679 option_menu ,
@@ -822,7 +828,8 @@ def distribution_changed(self, path):
822828 """Distribution path has just changed"""
823829 for package in self .table .model .packages :
824830 self .table .remove_package (package )
825- dist = wppm .Distribution (to_text_string (path ))
831+ # dist = wppm.Distribution(to_text_string(path))
832+ dist = wppm .Distribution (str (path ))
826833 self .table .refresh_distribution (dist )
827834 self .untable .refresh_distribution (dist )
828835 self .distribution = dist
@@ -843,7 +850,8 @@ def add_packages(self):
843850 filters = '*.exe *.zip *.tar.gz *.whl' ,
844851 )
845852 if fnames :
846- self .basedir = osp .dirname (fnames [0 ])
853+ # self.basedir = osp.dirname(fnames[0])
854+ self .basedir = str (Path (fnames [0 ]).parent )
847855 self .table .add_packages (fnames )
848856
849857 def get_packages_to_be_installed (self ):
@@ -911,7 +919,7 @@ def process_packages(self, action):
911919 table .remove_package (package )
912920 error = thread .error
913921 except Exception as error :
914- error = to_text_string (error )
922+ error = str ( error ) # to_text_string(error)
915923 if error is not None :
916924 pstr = (
917925 package .name + ' ' + package .version
0 commit comments