@@ -769,34 +769,30 @@ class Program(object):
769
769
is_cwd = False
770
770
is_repo = False
771
771
772
- @classmethod
773
- def get_program (cls , path = None , warnings = False ):
772
+ def __init__ (self , path = None , warnings = False ):
774
773
path = os .path .abspath (path or os .getcwd ())
775
774
776
- program = cls ()
777
- program .path = os .getcwd ()
778
- program .is_cwd = True
775
+ self .path = os .getcwd ()
776
+ self .is_cwd = True
779
777
780
778
while cd (path ):
781
779
tpath = path
782
780
if Repo .isrepo (path ):
783
- program .path = path
784
- program .is_cwd = False
785
- program .is_repo = True
781
+ self .path = path
782
+ self .is_cwd = False
783
+ self .is_repo = True
786
784
path = os .path .split (path )[0 ]
787
785
if tpath == path : # Reached root.
788
786
break
789
787
790
- program .name = os .path .basename (program .path )
788
+ self .name = os .path .basename (self .path )
791
789
792
790
if warnings :
793
- if program .is_cwd :
791
+ if self .is_cwd :
794
792
warning (
795
793
"Could not mbed program in current path. Assuming current dir.\n "
796
794
"You can fix this by calling \" mbed new .\" in the root dir of your program" )
797
795
798
- return program
799
-
800
796
# Sets config value
801
797
def set_cfg (self , var , val ):
802
798
fl = os .path .join (self .path , self .config_file )
@@ -987,7 +983,7 @@ def new(name, tscm='git', depth=None, protocol=None):
987
983
if d_path :
988
984
os .chdir (d_path )
989
985
990
- program = Program . get_program (d_path )
986
+ program = Program (d_path )
991
987
program .post_clone ()
992
988
993
989
@@ -1034,7 +1030,7 @@ def import_(url, path=None, depth=None, protocol=None, top=True):
1034
1030
deploy (depth = depth , protocol = protocol )
1035
1031
1036
1032
if top :
1037
- program = Program . get_program (repo .path )
1033
+ program = Program (repo .path )
1038
1034
program .post_clone ()
1039
1035
1040
1036
@@ -1310,7 +1306,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
1310
1306
# Gather remaining arguments
1311
1307
args = remainder
1312
1308
# Find the root of the program
1313
- program = Program . get_program (os .getcwd (), True )
1309
+ program = Program (os .getcwd (), True )
1314
1310
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
1315
1311
orig_path = os .getcwd ()
1316
1312
@@ -1391,7 +1387,7 @@ def test(tlist=False):
1391
1387
# Gather remaining arguments
1392
1388
args = remainder
1393
1389
# Find the root of the program
1394
- program = Program . get_program (os .getcwd (), True )
1390
+ program = Program (os .getcwd (), True )
1395
1391
# Change directories to the program root to use mbed OS tools
1396
1392
with cd (program .path ):
1397
1393
# If "mbed-os" folder doesn't exist, error
@@ -1418,7 +1414,7 @@ def export(ide=None, mcu=None):
1418
1414
# Gather remaining arguments
1419
1415
args = remainder
1420
1416
# Find the root of the program
1421
- program = Program . get_program (os .getcwd (), True )
1417
+ program = Program (os .getcwd (), True )
1422
1418
# Change directories to the program root to use mbed OS tools
1423
1419
with cd (program .path ):
1424
1420
if not os .path .isdir ('mbed-os' ):
@@ -1448,7 +1444,7 @@ def export(ide=None, mcu=None):
1448
1444
help = 'Set default target for the current program.' )
1449
1445
def target_ (name = None ):
1450
1446
# Find the root of the program
1451
- program = Program . get_program (os .getcwd (), True )
1447
+ program = Program (os .getcwd (), True )
1452
1448
# Change directories to the program root to use mbed OS tools
1453
1449
with cd (program .path ):
1454
1450
if name is None :
@@ -1463,7 +1459,7 @@ def target_(name=None):
1463
1459
help = 'Sets default toolchain for the current program.' )
1464
1460
def toolchain_ (name = None ):
1465
1461
# Find the root of the program
1466
- program = Program . get_program (os .getcwd (), True )
1462
+ program = Program (os .getcwd (), True )
1467
1463
# Change directories to the program root to use mbed OS tools
1468
1464
with cd (program .path ):
1469
1465
if name is None :
0 commit comments