Add --new option to find_libraries.py to filter to 'new' libraries that don't have a library.properties file.

This commit is contained in:
Tony DiCola 2015-06-26 19:29:54 -07:00
parent 9a3445a85c
commit ca2517b151

View file

@ -1,6 +1,6 @@
"""
Scan a Github account for any Arduino libraries and print out a list of them.
The heuristic for identifying an Arduino library is to look for a Github
The heuristic for identifying an Arduino library is to look for a Github
repository that has an 'examples' folder in its root and subfolders beneath
it that contain either .ino or .pde files. Note that this is not a foolproof
heuristic and Processing libraries might be found too!
@ -37,6 +37,16 @@ def is_arduino_library(repository):
# Couldn't find any subdir with ino/pde files, must not be an Arduino library.
return False
def has_library_properties(repository):
"""Return True if the repository has a library.properties file."""
try:
lib = repository.get_contents('library.properties')
except UnknownObjectException:
# No library.properties file.
return False
# Found the file!
return True
if __name__ == '__main__':
# Build command line argument parser and parse arguments.
@ -57,6 +67,9 @@ if __name__ == '__main__':
choices=['all', 'owner', 'public', 'private', 'member'],
default='all',
help='scan for specific type of repositories. For example --type public will only scan public repositories. Default is all.')
parser.add_argument('-n', '--new',
action='store_true',
help='only list Arduino libraries which have no library.properties file (i.e. might be new)')
parser.add_argument('github_root',
action='store',
help='Github user/organization name to scan for Arduino libraries')
@ -69,4 +82,5 @@ if __name__ == '__main__':
# name of any that look like Arduino libraries.
for repo in gh.get_user(args.github_root).get_repos(type=args.type):
if is_arduino_library(repo):
print(repo.name)
if not args.new or (args.new and not has_library_properties(repo)):
print(repo.name)