33# The MIT License (MIT)
44#
55# Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
6+ # 2018, 2019 Michael Schroeder
67#
78# Permission is hereby granted, free of charge, to any person obtaining a copy
89# of this software and associated documentation files (the "Software"), to deal
@@ -116,12 +117,16 @@ def library(library_path, output_directory, package_folder_prefix,
116117 glob_search .extend (list (lib_path .rglob (pattern )))
117118
118119 for file in glob_search :
119- #print(file_tree, ":", parent_idx)
120120 if file .parts [parent_idx ] == "examples" :
121121 example_files .append (file )
122122 else :
123123 if not example_bundle :
124- if file .parts [parent_idx ].startswith (package_folder_prefix ):
124+ is_package = False
125+ for prefix in package_folder_prefix :
126+ if file .parts [parent_idx ].startswith (prefix ):
127+ is_package = True
128+
129+ if is_package :
125130 package_files .append (file )
126131 else :
127132 if file .name in IGNORE_PY :
@@ -131,8 +136,8 @@ def library(library_path, output_directory, package_folder_prefix,
131136 py_files .append (file )
132137
133138 if len (py_files ) > 1 :
134- raise ValueError ("Multiple top level py files not allowed. Please put them in a package "
135- "or combine them into a single file." )
139+ raise ValueError ("Multiple top level py files not allowed. Please put "
140+ "them in a package or combine them into a single file." )
136141
137142 for fn in example_files :
138143 base_dir = os .path .join (output_directory .replace ("/lib" , "/" ),
@@ -142,7 +147,8 @@ def library(library_path, output_directory, package_folder_prefix,
142147 total_size += 512
143148
144149 for fn in package_files :
145- base_dir = os .path .join (output_directory , fn .relative_to (library_path ).parent )
150+ base_dir = os .path .join (output_directory ,
151+ fn .relative_to (library_path ).parent )
146152 if not os .path .isdir (base_dir ):
147153 os .makedirs (base_dir )
148154 total_size += 512
0 commit comments