cctbx_project icon indicating copy to clipboard operation
cctbx_project copied to clipboard

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

Open ravescovi opened this issue 3 years ago • 4 comments

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

ravescovi avatar Feb 18 '22 03:02 ravescovi

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

dwpaley avatar Feb 22 '22 17:02 dwpaley

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.

ravescovi avatar Feb 22 '22 18:02 ravescovi

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

bkpoon avatar Feb 22 '22 19:02 bkpoon

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: @.***>

ravescovi avatar Mar 11 '22 15:03 ravescovi