Return True is the file at `location` is some kind of markup, such as HTML, XML, PHP, etc.
(location)
| 54 | |
| 55 | |
| 56 | def is_markup(location): |
| 57 | """ |
| 58 | Return True is the file at `location` is some kind of markup, such as HTML, |
| 59 | XML, PHP, etc. |
| 60 | """ |
| 61 | T = get_type(location) |
| 62 | |
| 63 | # do not care for small files |
| 64 | if T.size < 64: |
| 65 | return False |
| 66 | |
| 67 | if not T.is_text: |
| 68 | return False |
| 69 | |
| 70 | if location.endswith(extensions): |
| 71 | return True |
| 72 | |
| 73 | with open(location, "rb") as f: |
| 74 | start = as_unicode(f.read(1024)) |
| 75 | |
| 76 | return is_markup_text(start) |
| 77 | |
| 78 | |
| 79 | def is_markup_text(text): |
nothing calls this directly
no test coverage detected