cctbx / cctbx_project

Computational Crystallography Toolbox
https://cci.lbl.gov/docs/cctbx
Other
216 stars 114 forks source link

mod_input searches for tar in the whole pathname of files instead the filetype #733

Open ravescovi opened 2 years ago

ravescovi commented 2 years ago

I have files named: random_start/test_raf/Cocoa_proc/int-2-Cocoa_3_37023.pickle because of the 'tar' in start mod_input keeps trying to open the pickles as tar.

https://github.com/cctbx/cctbx_project/blob/c6e33af78a268d0d867080fcb70ae0b682d1e133/prime/postrefine/mod_input.py#L598

A solution would be to look for

if p.endswith('tar') : is_tar = True
dwpaley commented 2 years ago

The "normal" way would be using os.path.splitext, but should this also be true for .tar.gz etc?

ravescovi commented 2 years ago

I think the splittext would fail on tar.gz indeed. Some possible solutions would be to use os.path.basename() (that would remove the path for the file, similar to splittext) or tarfile.is_tarfile() which would be more generic.

bkpoon commented 2 years ago

I like the tarfile.is_tarfile() approach. @ravescovi can you make a pull request?

ravescovi commented 2 years ago

Hey, Sorry for the late response. Yes, I will do a PR later this month if that is ok with you.

On Tue, Feb 22, 2022 at 1:48 PM Billy K. Poon @.***> wrote:

I like the tarfile.is_tarfile() approach. @ravescovi https://github.com/ravescovi can you make a pull request?

— Reply to this email directly, view it on GitHub https://github.com/cctbx/cctbx_project/issues/733#issuecomment-1048153479, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFMPQ777QMTS24QCNFQCMLU4PSCFANCNFSM5OWS5R3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>