@ -104,7 +104,7 @@ EXAMPLES = """
import os
import os
import tempfile
import tempfile
from distutils . version import Strict Version
from distutils . version import Loose Version
try :
try :
from passlib . apache import HtpasswdFile , htpasswd_context
from passlib . apache import HtpasswdFile , htpasswd_context
@ -138,7 +138,7 @@ def present(dest, username, password, crypt_scheme, create, check_mode):
if check_mode :
if check_mode :
return ( " Create %s " % dest , True )
return ( " Create %s " % dest , True )
create_missing_directories ( dest )
create_missing_directories ( dest )
if StrictVersion( passlib . __version__ ) > = Strict Version( ' 1.6 ' ) :
if LooseVersion( passlib . __version__ ) > = Loose Version( ' 1.6 ' ) :
ht = HtpasswdFile ( dest , new = True , default_scheme = crypt_scheme , context = context )
ht = HtpasswdFile ( dest , new = True , default_scheme = crypt_scheme , context = context )
else :
else :
ht = HtpasswdFile ( dest , autoload = False , default = crypt_scheme , context = context )
ht = HtpasswdFile ( dest , autoload = False , default = crypt_scheme , context = context )
@ -149,7 +149,7 @@ def present(dest, username, password, crypt_scheme, create, check_mode):
ht . save ( )
ht . save ( )
return ( " Created %s and added %s " % ( dest , username ) , True )
return ( " Created %s and added %s " % ( dest , username ) , True )
else :
else :
if StrictVersion( passlib . __version__ ) > = Strict Version( ' 1.6 ' ) :
if LooseVersion( passlib . __version__ ) > = Loose Version( ' 1.6 ' ) :
ht = HtpasswdFile ( dest , new = False , default_scheme = crypt_scheme , context = context )
ht = HtpasswdFile ( dest , new = False , default_scheme = crypt_scheme , context = context )
else :
else :
ht = HtpasswdFile ( dest , default = crypt_scheme , context = context )
ht = HtpasswdFile ( dest , default = crypt_scheme , context = context )
@ -176,7 +176,7 @@ def absent(dest, username, check_mode):
""" Ensures user is absent
""" Ensures user is absent
Returns ( msg , changed ) """
Returns ( msg , changed ) """
if StrictVersion( passlib . __version__ ) > = Strict Version( ' 1.6 ' ) :
if LooseVersion( passlib . __version__ ) > = Loose Version( ' 1.6 ' ) :
ht = HtpasswdFile ( dest , new = False )
ht = HtpasswdFile ( dest , new = False )
else :
else :
ht = HtpasswdFile ( dest )
ht = HtpasswdFile ( dest )