Skip to content

Commit 2f0a591

Browse files
rpocaseAdam Stephens
authored and
Adam Stephens
committed
Addressing stankevich/puppet-python issue voxpupuli#258.
Updating grep regex to use package name with underscores replaced with hyphens.
1 parent e7389f6 commit 2f0a591

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

manifests/pip.pp

+12-8
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@
3535
# Boolean. If true the package is installed as an editable resource.
3636
#
3737
# [*environment*]
38-
# Additional environment variables required to install the packages. Default: none
38+
# Additional environment variables required to install the packages.
39+
# Default: none
3940
#
4041
# [*timeout*]
41-
# The maximum time in seconds the "pip install" command should take. Default: 1800
42+
# The maximum time in seconds the "pip install" command should take.
43+
# Default: 1800
4244
#
4345
# [*install_args*]
4446
# String. Any additional installation arguments that will be supplied
4547
# when running pip install.
4648
#
47-
# [*uninstall_args*]
49+
# [*uninstall args*]
4850
# String. Any additional arguments that will be supplied when running
4951
# pip uninstall.
5052
#
@@ -82,6 +84,8 @@
8284
$log_dir = '/tmp',
8385
) {
8486

87+
$pip_freeze_pkgname = regsubst($pkgname, '_', '-', 'G')
88+
notice("Pip freeze pkgname: ${pip_freeze_pkgname}")
8589
# Parameter validation
8690
if ! $virtualenv {
8791
fail('python::pip: virtualenv parameter must not be empty')
@@ -135,12 +139,12 @@
135139
}
136140

137141
# Check if searching by explicit version.
138-
if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ {
139-
$grep_regex = "^${pkgname}==${ensure}\$"
142+
if $ensure =~ /^((19|20)[0-9][0-9]-(0[1-9]|1[1-2])-([0-2][1-9]|3[0-1])|[0-9]+\.[0-9]+(\.[0-9]+)?)$/ { #lint:ignore:80chars
143+
$grep_regex = "^${pip_freeze_pkgname}==${ensure}\$"
140144
} else {
141-
$grep_regex = $pkgname ? {
142-
/==/ => "^${pkgname}\$",
143-
default => "^${pkgname}==",
145+
$grep_regex = $pip_freeze_pkgname ? {
146+
/==/ => "^${pip_freeze_pkgname}\$",
147+
default => "^${pip_freeze_pkgname}==",
144148
}
145149
}
146150

0 commit comments

Comments
 (0)