Skip to content

Commit 8232920

Browse files
committed
Better documentation for inspect_format.
1 parent 07440b8 commit 8232920

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

xlrd/__init__.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .xldate import XLDateError, xldate_as_datetime, xldate_as_tuple
2121

2222

23-
#: descriptions of the version file types :mod:`xlrd` can :func:`inspect <inspect_format>`.
23+
#: descriptions of the file types :mod:`xlrd` can :func:`inspect <inspect_format>`.
2424
FILE_FORMAT_DESCRIPTIONS = {
2525
'xls': 'Excel xls',
2626
'xlsb': 'Excel 2007 xlsb file',
@@ -37,8 +37,21 @@
3737

3838
def inspect_format(path=None, content=None):
3939
"""
40-
Inspect the supplied path or content stream and return the
41-
file's type as a :class:`str` or ``None`` if it cannot be determined.
40+
Inspect the content at the supplied path or the :class:`bytes` content provided
41+
and return the file's type as a :class:`str`, or ``None`` if it cannot
42+
be determined.
43+
44+
:param path:
45+
A :class:`string <str>` path containing the content to inspect.
46+
``~`` will be expanded.
47+
48+
:param content:
49+
The :class:`bytes` content to inspect.
50+
51+
:returns:
52+
A :class:`str`, or ``None`` if the format cannot be determined.
53+
The return value can always be looked up in :data:`FILE_FORMAT_DESCRIPTIONS`
54+
to return a human-readable description of the format found.
4255
"""
4356
if content:
4457
peek = content[:PEEK_SIZE]

0 commit comments

Comments
 (0)