Unverified Commit c81a3886 authored by Moisés López - https://www.vauxoo.com/'s avatar Moisés López - https://www.vauxoo.com/ 🖥
Browse files

[REF] reqgen: Search requirements files based on parameter

In order to be able to looking for requirements-test.txt where it is needed
parent 7183165a
Pipeline #181468 passed with stage
in 42 seconds
......@@ -105,8 +105,9 @@ def merge_requirements(merge_to, merge_from, exclude_libs=False):
return res
def generate_merged_file(dest_file, path, recursive=False, exclude=False):
file_list = search_reqs_files(path, recursive)
def generate_merged_file(dest_file, path, recursive=False, exclude=False,
requirements_name='requirements.txt'):
file_list = search_reqs_files(path, recursive, requirements_name)
for files in file_list:
save_requirements(files, dest_file, exclude)
......@@ -136,7 +137,7 @@ def save_requirements(requirementstxt, filename, exclude_path=False):
req_file.write(req.line + '\n')
def search_reqs_files(folder_name, recursive=False):
def search_reqs_files(folder_name, recursive=False, requirements_name='requirements.txt'):
"""
Searchs for all requirements.txt file recursively in the given path
:param folder_name: the folder where you want to search
......@@ -144,7 +145,7 @@ def search_reqs_files(folder_name, recursive=False):
"""
res = list()
for base, directories, files in os.walk(folder_name):
for file_name in fnmatch.filter(files, 'requirements.txt'):
for file_name in fnmatch.filter(files, requirements_name):
res.append(os.path.join(base, file_name))
if not recursive:
# Clean the directories so the walk doesn't go any further
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment