From ca2517b151c6d0dfe8367a7233a0394e01fcae46 Mon Sep 17 00:00:00 2001 From: Tony DiCola Date: Fri, 26 Jun 2015 19:29:54 -0700 Subject: [PATCH] Add --new option to find_libraries.py to filter to 'new' libraries that don't have a library.properties file. --- find_libraries.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/find_libraries.py b/find_libraries.py index 83eaae5..8b8523b 100644 --- a/find_libraries.py +++ b/find_libraries.py @@ -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)