3131else :
3232 import Tkinter as tk
3333
34+ import ipdb
35+
3436# The following is to capture a user tag automatically.
3537try :
3638 import pwd
@@ -75,14 +77,6 @@ def run_labeler(project_path, url, transfer_mode, user, export_labels,
7577 labeling windows
7678 """
7779
78- # To complete the migration to python 3, I should replace all "raw_input"
79- # by "input". Transitorily, to preserve compatibility with python 2, I
80- # simply rename inut to raw_input
81- if sys .version_info .major == 3 :
82- raw_input2 = input
83- else :
84- raw_input2 = raw_input
85-
8680 #######
8781 # Start
8882 #######
@@ -93,22 +87,17 @@ def run_labeler(project_path, url, transfer_mode, user, export_labels,
9387 tm_options ))
9488
9589 # # Check if project folder exists. Otherwise create a default one.
96- # if len(sys.argv) > 1:
97- # project_path = sys.argv[1]
98- # else:
99- # project_path = raw_input2("Select the (absolute or relative) path " +
100- # "to the labeling project folder: ")
10190 if project_path is None :
102- project_path = raw_input2 ("Select the (absolute or relative) path " +
103- "to the labeling project folder: " )
91+ project_path = input ("Select the (absolute or relative) path to " +
92+ " the labeling project folder: " )
10493
10594 if not project_path .endswith ('/' ):
10695 project_path = project_path + '/'
10796
10897 # Check if project folder exists. This is necessary to follow
10998 if not os .path .isdir (project_path ):
110- createfolder = raw_input2 ( "Folder " + project_path +
111- "does not exist. Create? (y/n)" )
99+ createfolder = input ( f "Folder { project_path } does not exist. " +
100+ " Create? (y/n)" )
112101
113102 if createfolder == "y" :
114103 os .makedirs (project_path ) # Create folder
@@ -154,8 +143,7 @@ def run_labeler(project_path, url, transfer_mode, user, export_labels,
154143 'DataPaths' , 'db_label_info_tablename' ),
155144 'history_tablename' : cf .get (
156145 'DataPaths' , 'db_history_tablename' ),
157- 'ref_name' : cf .get (
158- 'DataPaths' , 'db_ref_name' ),
146+ 'ref_name' : cf .get ('DataPaths' , 'db_ref_name' ),
159147 'mode' : cf .get ('DataPaths' , 'db_mode' )}
160148 elif source_type == 'mongodb' or dest_type == 'mongodb' :
161149 db_info = {'name' : cf .get ('DataPaths' , 'db_name' ),
@@ -287,14 +275,13 @@ def run_labeler(project_path, url, transfer_mode, user, export_labels,
287275 user0 = getpass .getuser () # For Windows
288276
289277 # Ask for a labeler name.
290- userId = raw_input2 (
291- "Please write you user name [{0}]: " .format (user0 ))
278+ userId = input (f"Please write you user name [{ user0 } ]: " )
292279 if userId == "" :
293280 userId = user0
294- print ("Your User Name is {0}" . format ( userId ) )
281+ print (f "Your User Name is { userId } " )
295282 else :
296283 userId = user
297- print ("Your User Name is {0}" . format ( userId ) )
284+ print (f "Your User Name is { userId } " )
298285 else :
299286 userId = None
300287 if user is not None :
@@ -309,7 +296,7 @@ def run_labeler(project_path, url, transfer_mode, user, export_labels,
309296 # Verify that parentclass names are in the category set
310297 for c in parentcat :
311298 if c not in categories :
312- log .error ("Unknown category {} " . format ( c ) + " in the parentcat " +
299+ log .error (f "Unknown category { c } in the parentcat " +
313300 "dictionary. Revise the configuration file" )
314301 sys .exit ()
315302 elif parentcat [c ] not in categories :
0 commit comments