Permalink
Browse files

removed a magic constant

  • Loading branch information...
1 parent 9d1367f commit 29c4499c462ff57c7f1f6df738b8b49596a7c311 @lavelle committed Feb 10, 2013
Showing with 9 additions and 3 deletions.
  1. +1 −1 dbox.py
  2. +8 −2 gridformat.py
View
2 dbox.py
@@ -66,7 +66,7 @@ def upload(self, path, filepath=None):
path - The path to the local copy of the file to be uploaded
filepath - The path, including the filename given to the remote copy of the file
- once it is uploaded to Dropbox. If omitted it defaults to be the same as path
+ once it is uploaded to Dropbox. If omitted it defaults to be the same as path
"""
if self.client is None:
View
10 gridformat.py
@@ -15,6 +15,13 @@ def format_grid(grid, divider_positions=[], truncatable_column=None):
widths = [max([len(cell) for cell in row]) for row in zip(*grid)]
total = sum(widths)
+ # Number of columns in the grid
+ num_columns = len(grid[0])
+ # Number of characters in the string used to separate columns
+ separator_width = 3
+ # Total number of characters used by all column separators in one row of the grid
+ separators_width = num_columns * separator_width
+
# Try to determine the width of the user's terminal window in characters
# so the rows can be truncated if they are too long
try:
@@ -34,8 +41,7 @@ def format_grid(grid, divider_positions=[], truncatable_column=None):
if total > terminal_width:
if truncatable_column is not None:
- # 12 is the number of dividers and spaces added
- terminal_diff = terminal_width - total - 12
+ terminal_diff = terminal_width - total - separators_width
# Reduce the width of the column by the difference
widths[2] += terminal_diff

0 comments on commit 29c4499

Please sign in to comment.