Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make printer width configurable #1247

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ def read_profile(profiles_dir):


class UserConfig(object):
def __init__(self, send_anonymous_usage_stats, use_colors):
def __init__(self, send_anonymous_usage_stats, use_colors, printer_width):
self.send_anonymous_usage_stats = send_anonymous_usage_stats
self.use_colors = use_colors
self.printer_width = printer_width

@classmethod
def from_dict(cls, cfg=None):
Expand All @@ -75,7 +76,10 @@ def from_dict(cls, cfg=None):
'use_colors',
DEFAULT_USE_COLORS
)
return cls(send_anonymous_usage_stats, use_colors)
printer_width = cfg.get(
'printer_width'
)
return cls(send_anonymous_usage_stats, use_colors, printer_width)

def to_dict(self):
return {
Expand Down
2 changes: 2 additions & 0 deletions core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def initialize_config_values(parsed):
if cfg.use_colors:
dbt.ui.printer.use_colors()

if cfg.printer_width:
dbt.ui.printer.printer_width(cfg.printer_width)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8: can you add an extra newline here (there should be two lines between functions)


def handle_and_check(args):
parsed = parse_args(args)
Expand Down
7 changes: 6 additions & 1 deletion core/dbt/ui/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
COLOR_FG_YELLOW = dbt.ui.colors.COLORS['yellow']
COLOR_RESET_ALL = dbt.ui.colors.COLORS['reset_all']

PRINTER_WIDTH = 80


def use_colors():
global USE_COLORS
USE_COLORS = True

def printer_width(printer_width):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8: can you add an extra newline above and below this function?

global PRINTER_WIDTH
PRINTER_WIDTH = printer_width

def get_timestamp():
return time.strftime("%H:%M:%S")
Expand Down Expand Up @@ -59,7 +64,7 @@ def print_fancy_output_line(msg, status, index, total, execution_time=None):
progress=progress,
message=msg)

justified = prefix.ljust(80, ".")
justified = prefix.ljust(PRINTER_WIDTH, ".")

if execution_time is None:
status_time = ""
Expand Down