Skip to content

Commit a7d4ca1

Browse files
committed
refactor: moved the summary function to igraph.summary so PyDoctor generates nicer filenames in the API docs
1 parent 568958b commit a7d4ca1

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/igraph/__init__.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
quantile,
126126
power_law_fit,
127127
)
128-
from igraph.summary import GraphSummary
128+
from igraph.summary import GraphSummary, summary
129129
from igraph.utils import (
130130
dbl_epsilon,
131131
multidict,
@@ -5292,24 +5292,5 @@ def write(graph, filename, *args, **kwds):
52925292
save = write
52935293

52945294

5295-
def summary(obj, stream=None, *args, **kwds):
5296-
"""Prints a summary of object o to a given stream
5297-
5298-
Positional and keyword arguments not explicitly mentioned here are passed
5299-
on to the underlying C{summary()} method of the object if it has any.
5300-
5301-
@param obj: the object about which a human-readable summary is requested.
5302-
@param stream: the stream to be used. If C{None}, the standard output
5303-
will be used.
5304-
"""
5305-
if stream is None:
5306-
stream = sys.stdout
5307-
if hasattr(obj, "summary"):
5308-
stream.write(obj.summary(*args, **kwds))
5309-
else:
5310-
stream.write(str(obj))
5311-
stream.write("\n")
5312-
5313-
53145295
config = init_configuration()
53155296
del construct_graph_from_formula

src/igraph/summary.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from texttable import Texttable
99
from textwrap import TextWrapper
1010

11-
__all__ = ("GraphSummary",)
11+
__all__ = ("GraphSummary", "summary")
1212

1313
__license__ = """\
1414
Copyright (C) 2006-2012 Tamás Nepusz <ntamas@gmail.com>
@@ -373,3 +373,22 @@ def __str__(self):
373373
return "\n".join("\n".join(self.wrapper.wrap(line)) for line in output)
374374

375375
return "\n".join(output)
376+
377+
378+
def summary(obj, stream=None, *args, **kwds):
379+
"""Prints a summary of object o to a given stream
380+
381+
Positional and keyword arguments not explicitly mentioned here are passed
382+
on to the underlying C{summary()} method of the object if it has any.
383+
384+
@param obj: the object about which a human-readable summary is requested.
385+
@param stream: the stream to be used. If C{None}, the standard output
386+
will be used.
387+
"""
388+
if stream is None:
389+
stream = sys.stdout
390+
if hasattr(obj, "summary"):
391+
stream.write(obj.summary(*args, **kwds))
392+
else:
393+
stream.write(str(obj))
394+
stream.write("\n")

0 commit comments

Comments
 (0)