10
10
Created on Mon Aug 13 11:40:01 2012
11
11
"""
12
12
13
- import os .path as osp
13
+ # import os.path as osp
14
14
from pathlib import Path
15
15
import os
16
16
import sys
69
69
# Local imports
70
70
from winpython import __version__ , __project_url__
71
71
from winpython import wppm , associate , utils
72
- from winpython .py3compat import getcwd , to_text_string
72
+ # from winpython.py3compat import getcwd, to_text_string
73
73
74
74
75
75
COLUMNS = ACTION , CHECK , NAME , VERSION , DESCRIPTION = list (
@@ -249,7 +249,8 @@ def add_packages(self, fnames):
249
249
notcompatible = []
250
250
dist = self .distribution
251
251
for fname in fnames :
252
- bname = osp .basename (fname )
252
+ # bname = osp.basename(fname)
253
+ bname = Path (fname ).name
253
254
try :
254
255
package = wppm .Package (fname )
255
256
if package .is_compatible_with (dist ):
@@ -355,7 +356,7 @@ def dropEvent(self, event):
355
356
fnames = [
356
357
path
357
358
for path in mimedata2url (source )
358
- if osp .isfile (path )
359
+ if Path ( path ). is_file () # if osp.isfile(path)
359
360
]
360
361
self .add_packages (fnames )
361
362
event .acceptProposedAction ()
@@ -405,9 +406,11 @@ def setup_widget(self):
405
406
406
407
def select_directory (self ):
407
408
"""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()
411
414
while True :
412
415
directory = getexistingdirectory (
413
416
self , self .TITLE , basedir
@@ -423,7 +426,9 @@ def select_directory(self):
423
426
)
424
427
basedir = directory
425
428
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 ))
427
432
self .set_distribution (directory )
428
433
# PyQt4 old SIGNAL: self.emit(SIGNAL('selected_distribution(QString)'), directory)
429
434
self .selected_distribution .emit (directory )
@@ -667,7 +672,8 @@ def setup_window(self):
667
672
),
668
673
)
669
674
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 ()
671
677
)
672
678
add_actions (
673
679
option_menu ,
@@ -822,7 +828,8 @@ def distribution_changed(self, path):
822
828
"""Distribution path has just changed"""
823
829
for package in self .table .model .packages :
824
830
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 ))
826
833
self .table .refresh_distribution (dist )
827
834
self .untable .refresh_distribution (dist )
828
835
self .distribution = dist
@@ -843,7 +850,8 @@ def add_packages(self):
843
850
filters = '*.exe *.zip *.tar.gz *.whl' ,
844
851
)
845
852
if fnames :
846
- self .basedir = osp .dirname (fnames [0 ])
853
+ # self.basedir = osp.dirname(fnames[0])
854
+ self .basedir = str (Path (fnames [0 ]).parent )
847
855
self .table .add_packages (fnames )
848
856
849
857
def get_packages_to_be_installed (self ):
@@ -911,7 +919,7 @@ def process_packages(self, action):
911
919
table .remove_package (package )
912
920
error = thread .error
913
921
except Exception as error :
914
- error = to_text_string (error )
922
+ error = str ( error ) # to_text_string(error)
915
923
if error is not None :
916
924
pstr = (
917
925
package .name + ' ' + package .version
0 commit comments