diff --git a/openstack_requirements/cmds/build_lower_constraints.py b/openstack_requirements/cmds/build_lower_constraints.py index 438270f5d7..324660404a 100644 --- a/openstack_requirements/cmds/build_lower_constraints.py +++ b/openstack_requirements/cmds/build_lower_constraints.py @@ -18,18 +18,13 @@ import argparse import collections -from openstack_requirements import requirement +from openstack_requirements.utils import read_requirements_file + import packaging.specifiers import packaging.version -def read_requirements_file(filename): - with open(filename, 'rt') as f: - body = f.read() - return requirement.parse(body) - - def get_requirements_version(req): """Find the version for a requirement. diff --git a/openstack_requirements/cmds/check_conflicts.py b/openstack_requirements/cmds/check_conflicts.py index 11c7be4cf8..d7e861f0bf 100644 --- a/openstack_requirements/cmds/check_conflicts.py +++ b/openstack_requirements/cmds/check_conflicts.py @@ -20,13 +20,7 @@ import traceback import pkg_resources -from openstack_requirements import requirement - - -def read_requirements_file(filename): - with open(filename, 'rt') as f: - body = f.read() - return requirement.parse(body) +from openstack_requirements.utils import read_requirements_file def main(): diff --git a/openstack_requirements/cmds/check_exists.py b/openstack_requirements/cmds/check_exists.py index 5c958af57c..a5c2e11863 100644 --- a/openstack_requirements/cmds/check_exists.py +++ b/openstack_requirements/cmds/check_exists.py @@ -22,12 +22,7 @@ from packaging.version import Version from openstack_requirements import project from openstack_requirements import requirement - - -def read_requirements_file(filename): - with open(filename, 'rt') as f: - body = f.read() - return requirement.parse(body) +from openstack_requirements.utils import read_requirements_file def main(args=None): diff --git a/openstack_requirements/cmds/validate.py b/openstack_requirements/cmds/validate.py index 845ecd6660..41f352526b 100644 --- a/openstack_requirements/cmds/validate.py +++ b/openstack_requirements/cmds/validate.py @@ -19,12 +19,7 @@ import os from openstack_requirements import constraints from openstack_requirements import requirement - - -def read_requirements_file(filename): - with open(filename, 'rt') as f: - body = f.read() - return requirement.parse(body) +from openstack_requirements.utils import read_requirements_file def main(): diff --git a/openstack_requirements/utils.py b/openstack_requirements/utils.py new file mode 100644 index 0000000000..58b13d0175 --- /dev/null +++ b/openstack_requirements/utils.py @@ -0,0 +1,7 @@ +from openstack_requirements import requirement + + +def read_requirements_file(filename): + with open(filename, 'rt') as f: + body = f.read() + return requirement.parse(body)