projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: bt2: _trim_docstring(): docstring can have 0 or 1 line
[babeltrace.git]
/
src
/
bindings
/
python
/
bt2
/
bt2
/
component.py
diff --git
a/src/bindings/python/bt2/bt2/component.py
b/src/bindings/python/bt2/bt2/component.py
index b8ca19f24bfcb840bff421adaaaaeb942d2d5535..5395e0b6b59ccf11699d5a1c76461e928c5c0671 100644
(file)
--- a/
src/bindings/python/bt2/bt2/component.py
+++ b/
src/bindings/python/bt2/bt2/component.py
@@
-327,17
+327,22
@@
def _create_component_class_from_const_ptr_and_get_ref(ptr, comp_cls_type):
def _trim_docstring(docstring):
lines = docstring.expandtabs().splitlines()
def _trim_docstring(docstring):
lines = docstring.expandtabs().splitlines()
+
+ if len(lines) == 0:
+ return ''
+
indent = sys.maxsize
indent = sys.maxsize
- for line in lines[1:]:
- stripped = line.lstrip()
+ if len(lines) > 1:
+ for line in lines[1:]:
+ stripped = line.lstrip()
- if stripped:
- indent = min(indent, len(line) - len(stripped))
+
if stripped:
+
indent = min(indent, len(line) - len(stripped))
trimmed = [lines[0].strip()]
trimmed = [lines[0].strip()]
- if indent < sys.maxsize:
+ if indent < sys.maxsize
and len(lines) > 1
:
for line in lines[1:]:
trimmed.append(line[indent:].rstrip())
for line in lines[1:]:
trimmed.append(line[indent:].rstrip())
This page took
0.032525 seconds
and
4
git commands to generate.