mirror of https://github.com/ARMmbed/mbed-os.git
arm_pack_manager - Add --and, --or, --intersection, and --union options
These change the behavior of the search terms.pull/2975/head
parent
817ac6631d
commit
a9c52e27eb
|
@ -27,6 +27,10 @@ def subcommand(name, *args, **kwargs):
|
||||||
subparser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="Verbose diagnostic output")
|
subparser.add_argument("-v", "--verbose", action="store_true", dest="verbose", help="Verbose diagnostic output")
|
||||||
subparser.add_argument("-vv", "--very_verbose", action="store_true", dest="very_verbose", help="Very verbose diagnostic output")
|
subparser.add_argument("-vv", "--very_verbose", action="store_true", dest="very_verbose", help="Very verbose diagnostic output")
|
||||||
subparser.add_argument("--no-timeouts", action="store_true", help="Remove all timeouts and try to download unconditionally")
|
subparser.add_argument("--no-timeouts", action="store_true", help="Remove all timeouts and try to download unconditionally")
|
||||||
|
subparser.add_argument("--and", action=s"store_true", dest="intersection" help="combine search terms as if with an and")
|
||||||
|
subparser.add_argument("--or", action=s"store_false", dest="intersection" help="combine search terms as if with an or")
|
||||||
|
subparser.add_argument("--union", action=s"store_false", dest="intersection" help="combine search terms as if with a set union")
|
||||||
|
subparser.add_argument("--intersection", action=s"store_true", dest="intersection" help="combine search terms as if with a set intersection")
|
||||||
|
|
||||||
def thunk(parsed_args):
|
def thunk(parsed_args):
|
||||||
cache = Cache(not parsed_args.verbose, parsed_args.no_timeouts)
|
cache = Cache(not parsed_args.verbose, parsed_args.no_timeouts)
|
||||||
|
@ -82,7 +86,7 @@ def fuzzy_find(matches, urls) :
|
||||||
dict(name=["-b","--batch"], action="store_true",
|
dict(name=["-b","--batch"], action="store_true",
|
||||||
help="don't ask for user input and assume download all"),
|
help="don't ask for user input and assume download all"),
|
||||||
help="Cache a group of PACK or PDSC files")
|
help="Cache a group of PACK or PDSC files")
|
||||||
def command_cache (cache, matches, everything=False, descriptors=False, batch=False, verbose= False) :
|
def command_cache (cache, matches, everything=False, descriptors=False, batch=False, verbose= False, intersection=True) :
|
||||||
if everything :
|
if everything :
|
||||||
cache.cache_everything()
|
cache.cache_everything()
|
||||||
return True
|
return True
|
||||||
|
@ -93,7 +97,10 @@ def command_cache (cache, matches, everything=False, descriptors=False, batch=Fa
|
||||||
print("No action specified nothing to do")
|
print("No action specified nothing to do")
|
||||||
else :
|
else :
|
||||||
urls = cache.get_urls()
|
urls = cache.get_urls()
|
||||||
choices = fuzzy_find(matches, map(basename, urls))
|
if intersection :
|
||||||
|
choices = fuzzy_find(matches, map(basename, urls))
|
||||||
|
else :
|
||||||
|
choices = sum([fuzzy_find([m], map(basename, urls) for m in matches)])
|
||||||
if not batch and len(choices) > 1 :
|
if not batch and len(choices) > 1 :
|
||||||
choices = user_selection("Please select a file to cache", choices)
|
choices = user_selection("Please select a file to cache", choices)
|
||||||
to_download = []
|
to_download = []
|
||||||
|
@ -110,12 +117,15 @@ def command_cache (cache, matches, everything=False, descriptors=False, batch=Fa
|
||||||
dict(name=['-l',"--long"], action="store_true",
|
dict(name=['-l',"--long"], action="store_true",
|
||||||
help="print out part details with part"),
|
help="print out part details with part"),
|
||||||
help="Find a Part and it's description within the cache")
|
help="Find a Part and it's description within the cache")
|
||||||
def command_find_part (cache, matches, long=False) :
|
def command_find_part (cache, matches, long=False, intersection=True) :
|
||||||
if long :
|
if long :
|
||||||
import pprint
|
import pprint
|
||||||
pp = pprint.PrettyPrinter()
|
pp = pprint.PrettyPrinter()
|
||||||
parts = cache.index
|
parts = cache.index
|
||||||
choices = fuzzy_find(matches, parts.keys())
|
if intersection :
|
||||||
|
choices = fuzzy_find(matches, map(basename, index.keys()))
|
||||||
|
else :
|
||||||
|
choices = sum([fuzzy_find([m], map(basename, index.keys()) for m in matches)])
|
||||||
for part in choices :
|
for part in choices :
|
||||||
print part
|
print part
|
||||||
if long :
|
if long :
|
||||||
|
@ -126,10 +136,14 @@ def command_find_part (cache, matches, long=False) :
|
||||||
dict(name='parts', nargs='+', help='parts to dump'),
|
dict(name='parts', nargs='+', help='parts to dump'),
|
||||||
help='Create a directory with an index.json describing the part and all of their associated flashing algorithms.'
|
help='Create a directory with an index.json describing the part and all of their associated flashing algorithms.'
|
||||||
)
|
)
|
||||||
def command_dump_parts (cache, out, parts) :
|
def command_dump_parts (cache, out, parts, intersection=True) :
|
||||||
index = {}
|
index = {}
|
||||||
for part in parts :
|
if intersection :
|
||||||
index.update(dict(cache.find_device(part)))
|
for part in fuzzy_find(matches, map(basename, urls)):
|
||||||
|
index.update(cache.index[part])
|
||||||
|
else :
|
||||||
|
for part in parts :
|
||||||
|
index.update(dict(cache.find_device(part)))
|
||||||
for n, p in index.iteritems() :
|
for n, p in index.iteritems() :
|
||||||
try :
|
try :
|
||||||
if not exists(join(out, dirname(p['algorithm']['file']))) :
|
if not exists(join(out, dirname(p['algorithm']['file']))) :
|
||||||
|
@ -147,7 +161,10 @@ def command_dump_parts (cache, out, parts) :
|
||||||
help='Cache PACK files associated with the parts matching the provided words')
|
help='Cache PACK files associated with the parts matching the provided words')
|
||||||
def command_cache_part (cache, matches) :
|
def command_cache_part (cache, matches) :
|
||||||
index = cache.index
|
index = cache.index
|
||||||
choices = fuzzy_find(matches, index.keys())
|
if intersection :
|
||||||
|
choices = fuzzy_find(matches, map(basename, index.keys()))
|
||||||
|
else :
|
||||||
|
choices = sum([fuzzy_find([m], map(basename, index.keys()) for m in matches)])
|
||||||
urls = [index[c]['file'] for c in choices]
|
urls = [index[c]['file'] for c in choices]
|
||||||
cache.cache_pack_list(urls)
|
cache.cache_pack_list(urls)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue