Classify¶
pkglite.classify
¶
is_text_file(path, n=None)
¶
Classify any file as text or binary.
Algorithm adopted from "A Fast Method for Identifying Plain Text Files"
in zlib (doc/txtvsbin.txt
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
File path. |
required |
n
|
int | None
|
Maximal number of bytes to read. Defaults to file size. |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if the file is text, False if binary. |
classify_file(path)
¶
Classify file as text or binary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Path to the file to classify. |
required |
Returns:
Type | Description |
---|---|
str
|
|