Conditions | 4 |
Total Lines | 10 |
Lines | 0 |
Ratio | 0 % |
1 | #!/usr/bin/env python |
||
21 | @mimetype_methods.append |
||
22 | def unix_file(path): |
||
23 | try: |
||
24 | output = subprocess.check_output(("file", "-ib", path)).decode('utf8').strip() |
||
25 | if re_mime_validate.match(output) and not output in generic_mimetypes: |
||
26 | # 'file' command can return status zero with invalid output |
||
27 | return output |
||
28 | except (subprocess.CalledProcessError, FileNotFoundError): |
||
29 | pass |
||
30 | return None |
||
31 | |||
37 |