Skip to content

Commit 1d9aeae

Browse files
Joe Jevnikllllllllll
authored andcommitted
MAINT: move bulleted_list
1 parent 6d68ccd commit 1d9aeae

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

zipline/pipeline/domain.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from trading_calendars import get_calendar
2626

2727
from zipline.country import CountryCode
28+
from zipline.utils.formatting import bulleted_list
2829
from zipline.utils.input_validation import expect_types, optional
2930
from zipline.utils.memoize import lazyval
3031
from zipline.utils.pandas_utils import days_at_time
@@ -313,12 +314,6 @@ def infer_domain(terms):
313314
raise AmbiguousDomain(sorted(domains, key=repr))
314315

315316

316-
def bulleted_list(items):
317-
"""Format a bulleted list of values.
318-
"""
319-
return "\n".join(map(" - {}".format, items))
320-
321-
322317
# This would be better if we provided more context for which domains came from
323318
# which terms.
324319
class AmbiguousDomain(Exception):
@@ -335,7 +330,9 @@ def __init__(self, domains):
335330
self.domains = domains
336331

337332
def __str__(self):
338-
return self._TEMPLATE.format(domains=bulleted_list(self.domains))
333+
return self._TEMPLATE.format(
334+
domains=bulleted_list(self.domains, indent=2),
335+
)
339336

340337

341338
class EquitySessionDomain(Domain):

zipline/utils/formatting.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ def plural(singular, plural, seq):
4343
return singular
4444

4545
return plural
46+
47+
48+
def bulleted_list(items, indent=0, bullet_type='-'):
49+
"""Format a bulleted list of values.
50+
51+
Parameters
52+
----------
53+
items : sequence
54+
The items to make a list.
55+
indent : int, optional
56+
The number of spaces to add before each bullet.
57+
bullet_type : str, optional
58+
The bullet type to use.
59+
60+
Returns
61+
-------
62+
formatted_list : str
63+
The formatted list as a single string.
64+
"""
65+
format_string = ' ' * indent + bullet_type + ' {}'
66+
return "\n".join(map(format_string.format, items))

0 commit comments

Comments
 (0)