From a4705afa1951b3e86630f5849e459751b6d78be7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 24 Jan 2013 17:18:58 -0500 Subject: [PATCH] mutt_ldap.py: Rename sys to _sys on import Keeping the namespace clean when __name__ == '__main__' is not really important, but this way all the imports are consistently renamed. This future-proofs the code in case those modules ever need to get shifted to module-wide imports. --- mutt_ldap.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mutt_ldap.py b/mutt_ldap.py index 21a1174..dab031c 100755 --- a/mutt_ldap.py +++ b/mutt_ldap.py @@ -268,7 +268,7 @@ def format_entry(entry): if __name__ == '__main__': import codecs as _codecs import locale as _locale - import sys + import sys as _sys default_encoding = _locale.getpreferredencoding(do_setlocale=True) for key in ['output-encoding', 'argv-encoding']: @@ -278,17 +278,18 @@ if __name__ == '__main__': # HACK: convert sys.stdout to Unicode (not needed in Python 3) output_encoding = CONFIG.get('system', 'output-encoding') - sys.stdout = _codecs.getwriter(output_encoding)(sys.stdout) + _sys.stdout = _codecs.getwriter(output_encoding)(_sys.stdout) # HACK: convert sys.argv to Unicode (not needed in Python 3) argv_encoding = CONFIG.get('system', 'argv-encoding') - sys.argv = [unicode(arg, argv_encoding) for arg in sys.argv] + _sys.argv = [unicode(arg, argv_encoding) for arg in _sys.argv] - if len(sys.argv) < 2: - sys.stderr.write(u'{0}: no search string given\n'.format(sys.argv[0])) - sys.exit(1) + if len(_sys.argv) < 2: + _sys.stderr.write( + u'{0}: no search string given\n'.format(_sys.argv[0])) + _sys.exit(1) - query = u' '.join(sys.argv[1:]) + query = u' '.join(_sys.argv[1:]) if CONFIG.getboolean('cache', 'enable'): connection_class = CachedLDAPConnection -- 2.26.2