jenkins-bot has submitted this change and it was merged. Change subject: [FEAT] upload: Scan directory non-recursively ......................................................................
[FEAT] upload: Scan directory non-recursively Adds an `-recursive` option to scan a directory recursively (the current default state) and otherwise it just scans the files in a directory. Change-Id: I5127196ac2554cebd56286bb18b182b4999625b6 --- M scripts/upload.py 1 file changed, 8 insertions(+), 0 deletions(-) Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified diff --git a/scripts/upload.py b/scripts/upload.py index 29eaf4a..fbf4c10 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -27,6 +27,8 @@ is defined for all. It will also require a valid file name and description. It'll only overwrite files if -ignorewarn includes the 'exists' warning. + -recursive When the filename is a directory it also uploads the files from + the subdirectories. It is possible to combine -abortonwarn and -ignorewarn so that if the specific warning is given it won't apply the general one but more specific one. So if it @@ -513,6 +515,7 @@ chunk_size = 0 chunk_size_regex = r'^-chunked(?::(\d+(?:\.\d+)?)[ \t]*(k|ki|m|mi)?b?)?$' chunk_size_regex = re.compile(chunk_size_regex, re.I) + recursive = False # process all global bot args # returns a list of non-global args, i.e. args for upload.py @@ -522,6 +525,8 @@ keepFilename = True always = True verifyDescription = False + elif arg == '-recursive': + recursive = True elif arg.startswith('-keep'): keepFilename = True elif arg.startswith('-filename:'): @@ -598,6 +603,9 @@ if os.path.isdir(url): file_list = [] for directory_info in os.walk(url): + if not recursive: + # Do not visit any subdirectories + directory_info[1][:] = [] for dir_file in directory_info[2]: file_list.append(os.path.join(directory_info[0], dir_file)) url = file_list -- To view, visit https://gerrit.wikimedia.org/r/235248 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5127196ac2554cebd56286bb18b182b4999625b6 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits