@@ -319,35 +319,34 @@ def argparse_none(description):
319
319
"--version" : "version" ,
320
320
}
321
321
322
- # Add "a0", "a1", ..., "u0", "u1", ..., "c0 ", "c1 ", ... as aliases
322
+ # Add "a0", "a1", ..., "u0", "u1", ..., "c1 ", "c2 ", ... as aliases
323
323
# for "connect /dev/ttyACMn" (and /dev/ttyUSBn, COMn) etc.
324
324
for port_num in range (4 ):
325
325
for prefix , port in [("a" , "/dev/ttyACM" ), ("u", "/dev/ttyUSB" ), ("c" , "COM" )]:
326
- _BUILTIN_COMMAND_EXPANSIONS ["{}{}" .format (prefix , port_num )] = {
327
- "command" : "connect {}{}" .format (port , port_num ),
328
- "help" : 'connect to serial port "{}{}"' .format (port , port_num ),
326
+ if port_num == 0 and port == "COM" :
327
+ continue # skip COM0 as it does not exist
328
+ _BUILTIN_COMMAND_EXPANSIONS [f"{ prefix } { port_num } " ] = {
329
+ "command" : f"connect { port } { port_num } " ,
330
+ "help" : f'connect to serial port "{ port } { port_num } "' ,
329
331
}
330
332
331
333
332
334
def load_user_config ():
333
335
# Create empty config object.
334
336
config = __build_class__ (lambda : None , "Config" )()
335
337
config .commands = {}
336
- # use $XDG_CONFIG_HOME, if on Windows use $APPDATA
338
+ # Get config file name.
337
339
if os .name != "nt" :
338
- # Get config file name.
339
- path = os .getenv ("XDG_CONFIG_HOME" )
340
+ path = os .getenv ("XDG_CONFIG_HOME" ) or os .getenv ("HOME" )
340
341
if path is None :
341
- path = os .getenv ("HOME" )
342
- if path is None :
343
- return config
344
- path = os .path .join (path , ".config" )
345
- path = os .path .join (path , _PROG )
342
+ return config
343
+ path = os .path .join (path , ".config" )
346
344
else :
347
- path = os .getenv ("APPDATA" )
345
+ # HOME might be used by MSYS2, but APPDATA is the standard on Windows.
346
+ path = os .getenv ("HOME" ) or os .getenv ("APPDATA" )
348
347
if path is None :
349
348
return config
350
- path = os .path .join (path , _PROG )
349
+ path = os .path .join (path , _PROG )
351
350
config_file = os .path .join (path , "config.py" )
352
351
# Check if config file exists.
353
352
if not os .path .exists (config_file ):
@@ -363,7 +362,6 @@ def load_user_config():
363
362
config .__dict__ ["__file__" ] = config_file
364
363
exec (config_data , config .__dict__ )
365
364
os .chdir (prev_cwd )
366
-
367
365
return config
368
366
369
367
0 commit comments