Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.path.commonpath or os.path.commonprefix ?? #1

Closed
s0fx2 opened this issue Dec 5, 2016 · 5 comments
Closed

os.path.commonpath or os.path.commonprefix ?? #1

s0fx2 opened this issue Dec 5, 2016 · 5 comments

Comments

@s0fx2
Copy link

s0fx2 commented Dec 5, 2016

➜ python tar_fix.py --input archlinux-bootstrap-2016.12.01-x86_64.tar.gz --output bootstrap.tar.gz
Traceback (most recent call last):
File "tar_fix.py", line 67, in
tarball.drop_lead_comp()
File "tar_fix.py", line 22, in drop_lead_comp
lead_comp_name = os.path.commonpath(tarin.getnames())
AttributeError: 'module' object has no attribute 'commonpath'

@czka
Copy link
Owner

czka commented Dec 5, 2016

Works like a charm here. Aren't you using Python 2 by any chance? This script assumes Python 3. What does python --version print for you?

commonpath method is present in Python 3 os.path - https://docs.python.org/3/library/os.path.html#os.path.commonpath. In 2 it's apparently absent - https://docs.python.org/2/library/os.path.html.

@bebehei
Copy link

bebehei commented Dec 13, 2016

@czka What about changing the shebang to #!/usr/bin/env python3?

And also changing the README.md from tar_fix.py to ./tar_fix.py to indicate the usage without python?

@czka
Copy link
Owner

czka commented Dec 13, 2016

I thought about it, but I'm not 100% sure each and every GNU/Linux distro installation out there will have that python3 executable when they have Python 3 installed. Haven't had time for looking that information up, it's on my TODO. Or maybe you can verify in some authorative source whether the assumption of python3 availability is really a safer default than me assumimg python = python3?

As for tar_fix.py vs ./tar_fix.py: will do.

@czka
Copy link
Owner

czka commented Dec 22, 2016

Recently in README.md I have documented the usage as I mean it in a more explicit way, hinted about Python 3 requirement and added the ./ prefix suggestion.

@czka
Copy link
Owner

czka commented May 14, 2017

As to my #1 (comment), I did my homework and it shows that https://www.python.org/dev/peps/pep-0394 recommends python3 shebang over python, for Python 3 code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants