Update smartwd to be compatible with Python 3

Prior to this change, running smartwd in a virtualenv with Python 3 gave
a syntax error due to the script treating `print` as a keyword, rather
than a function.

This change fixes the print to work as a function, and also cleans up
some of the comments and code to better comply with PEP8
master
nirenjan 2018-09-27 13:48:57 -07:00
parent 65fb291da3
commit 09b20d3a0a
1 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# Script to smartly chop off portions of the current working directory for """Script to smartly chop off portions of the current working directory for
# use in the shell prompt use in the shell prompt"""
from __future__ import print_function
import os import os
# Constants used to decide when to start chopping # Constants used to decide when to start chopping
@ -11,6 +12,7 @@ DIR_R = 2
PWDLEN = 14 PWDLEN = 14
def smartwd(): def smartwd():
"""Meat of the smartwd script"""
username = os.environ['USER'] username = os.environ['USER']
homedir = os.environ['HOME'] homedir = os.environ['HOME']
pwd = os.environ['PWD'] pwd = os.environ['PWD']
@ -53,5 +55,5 @@ def smartwd():
return pwd return pwd
if __name__ == "__main__": if __name__ == "__main__":
print smartwd() print(smartwd())