1
1
#!/usr/bin/env python
2
- # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-lines, line-too-long
2
+ # pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-lines, line-too-long, too-many-nested-blocks
3
3
# pylint: disable=invalid-name, missing-docstring
4
4
5
5
import argparse
@@ -142,7 +142,7 @@ def popen(command, stdin=None, **kwargs):
142
142
"Please verify that it's installed and accessible from your current path by executing \" %s\" .\n " % (command [0 ], command [0 ]), e [0 ])
143
143
else :
144
144
raise
145
-
145
+
146
146
if proc .wait () != 0 :
147
147
raise ProcessException (proc .returncode )
148
148
@@ -202,9 +202,7 @@ def scm(cls):
202
202
return cls
203
203
return scm
204
204
205
- # pylint: disable=no-self-argument
206
- # pylint: disable=no-method-argument
207
- # pylint: disable=no-member
205
+ # pylint: disable=no-self-argument, no-method-argument, no-member, no-self-use
208
206
@scm ('hg' )
209
207
@staticclass
210
208
class Hg (object ):
@@ -386,9 +384,7 @@ def unignore(repo, file):
386
384
except IOError :
387
385
error ("Unable to write ignore file in \" %s\" " % exclude , 1 )
388
386
389
- # pylint: disable=no-self-argument
390
- # pylint: disable=no-method-argument
391
- # pylint: disable=no-member
387
+ # pylint: disable=no-self-argument, no-method-argument, no-member, no-self-use
392
388
@scm ('git' )
393
389
@staticclass
394
390
class Git (object ):
@@ -528,6 +524,12 @@ def unignore(repo, file):
528
524
# Repository object
529
525
class Repo (object ):
530
526
is_local = False
527
+ name = None
528
+ path = None
529
+ url = None
530
+ hash = None
531
+ scm = None
532
+ libs = []
531
533
532
534
@classmethod
533
535
def fromurl (cls , url , path = None ):
@@ -583,11 +585,9 @@ def fromrepo(cls, path=None):
583
585
584
586
@classmethod
585
587
def isrepo (cls , path = None ):
586
- for name , scm in scms .items ():
588
+ for name , _ in scms .items ():
587
589
if os .path .isdir (os .path .join (path , '.' + name )):
588
590
return True
589
- else :
590
- return False
591
591
592
592
return False
593
593
@@ -764,34 +764,31 @@ def check_repo(self, show_warning=None):
764
764
# Program object, used to indicate the root of the code base
765
765
class Program (object ):
766
766
config_file = ".mbed"
767
+ path = None
768
+ name = None
769
+ is_cwd = False
770
+ is_repo = False
767
771
768
772
@classmethod
769
773
def get_program (cls , path = None , warnings = False ):
770
774
path = os .path .abspath (path or os .getcwd ())
771
- rpath = None
772
775
773
776
program = cls ()
774
777
program .path = os .getcwd ()
775
778
program .is_cwd = True
776
779
777
780
while cd (path ):
778
781
tpath = path
779
- if os . path . isfile ( os . path . join ( path , program . config_file ) ):
782
+ if Repo . isrepo ( path ):
780
783
program .path = path
781
784
program .is_cwd = False
782
- program .is_repo = Repo .isrepo (program .path )
785
+ program .is_repo = True
786
+ path = os .path .split (path )[0 ]
787
+ if tpath == path : # Reached root.
783
788
break
784
- else :
785
- if Repo .isrepo (path ):
786
- program .path = path
787
- program .is_cwd = False
788
- program .is_repo = True
789
- path = os .path .split (path )[0 ]
790
- if tpath == path : # Reached root.
791
- break
792
789
793
790
program .name = os .path .basename (program .path )
794
-
791
+
795
792
if warnings :
796
793
if program .is_cwd :
797
794
warning (
@@ -1024,7 +1021,6 @@ def import_(url, path=None, depth=None, protocol=None, top=True):
1024
1021
except ProcessException :
1025
1022
if os .path .isdir (repo .path ):
1026
1023
rmtree_readonly (repo .path )
1027
- pass
1028
1024
else :
1029
1025
error ("Unable to clone repository (%s)" % url , 1 )
1030
1026
@@ -1047,7 +1043,6 @@ def import_(url, path=None, depth=None, protocol=None, top=True):
1047
1043
dict (name = '--protocol' , nargs = '?' , help = 'Transport protocol for the source control management. Supported: https, http, ssh, git. Default: inferred from URL.' ),
1048
1044
help = "Import missing dependencies in the current program or library." )
1049
1045
def deploy (depth = None , protocol = None ):
1050
- sys .exit (1 )
1051
1046
repo = Repo .fromrepo ()
1052
1047
repo .scm .ignores (repo )
1053
1048
@@ -1262,7 +1257,7 @@ def sync(recursive=True, keep_refs=False, top=True):
1262
1257
sync (keep_refs = keep_refs , top = False )
1263
1258
1264
1259
1265
- # List command
1260
+ # List command
1266
1261
@subcommand ('ls' ,
1267
1262
dict (name = ['-a' , '--all' ], action = 'store_true' , help = "List repository URL and hash pairs" ),
1268
1263
dict (name = ['-I' , '--ignore' ], action = "store_true" , help = "Ignore errors regarding missing libraries." ),
@@ -1346,7 +1341,6 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
1346
1341
1347
1342
if not source or len (source ) == 0 :
1348
1343
source = [os .path .relpath (root_path , orig_path )]
1349
-
1350
1344
if compile_tests :
1351
1345
# Compile tests
1352
1346
if not build :
@@ -1410,7 +1404,7 @@ def test(list=False):
1410
1404
# List all available tests (by default in a human-readable format)
1411
1405
try :
1412
1406
popen (['python' , 'mbed-os/tools/test.py' , '-l' ] + args , env = env )
1413
- except ProcessException as e :
1407
+ except ProcessException :
1414
1408
error ('Failed to run test script' )
1415
1409
1416
1410
0 commit comments