Skip to content

Commit

Permalink
Minor cleanup and refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcnamara committed Oct 23, 2013
1 parent 038e40c commit eeb5b73
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 109 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -21,3 +21,5 @@ build/
objects.inv
__pycache__
.tox/
.idea

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -76,7 +76,7 @@ All patches and pull requests are welcome.

### Enabling Travis CI via your GitHub account

Travis CI is a free Continuous Integration service that will test any code you push to Github with Python 2.5, 2.6, 2.7, 3.2, 3.3 and PyPy.
Travis CI is a free Continuous Integration service that will test any code you push to GitHub with Python 2.5, 2.6, 2.7, 3.2, 3.3 and PyPy.

See the [Travis CI Getting Started](http://about.travis-ci.org/docs/user/getting-started/) instructions.

Expand Down
12 changes: 6 additions & 6 deletions Changes
@@ -1,23 +1,23 @@
Release 0.4.6 - October 26 2013
---------------------------------
Release 0.4.6 - October 23 2013
-------------------------------

* Added font formatting to chart legends.


Release 0.4.5 - October 21 2013
---------------------------------
-------------------------------

* Added ``position_axis`` chart axis option.

* Added optional list handling for chart names.


Release 0.4.4 - October 16 2013
---------------------------------
-------------------------------

* Documented use of :ref:`cell utility <cell_utility>` functions.

* Fix for tables added in non-sequential order. Closes #51 reported by
* Fix for tables added in non-sequential order. Closes #51 reported by
calfzhou.


Expand All @@ -39,7 +39,7 @@ Release 0.4.2 - August 30 2013
Release 0.4.1 - August 28 2013
------------------------------

* Fix for charts and images that cross rows and columns that are hidden or
* Fix for charts and images that cross rows and columns that are hidden or
formatted but which don't have size changes. Issue #42 reported by
Kristian Stobbe.

Expand Down
2 changes: 1 addition & 1 deletion dev/docs/source/worksheet.rst
Expand Up @@ -767,7 +767,7 @@ If you wish to set the format of a row without changing the height you can pass
worksheet.set_row(1, 15, cell_format) # Same as above.

The ``cell_format`` parameter will be applied to any cells in the row that
don't have a format. As with Excel it is overidden by an explicit cell format.
don't have a format. As with Excel it is overridden by an explicit cell format.
For example::

worksheet.set_row(0, None, format1) # Row 1 has format1.
Expand Down
22 changes: 13 additions & 9 deletions xlsxwriter/chart.py
Expand Up @@ -82,6 +82,10 @@ def __init__(self, options=None):
self.hi_low_lines = None
self.up_down_bars = None
self.smooth_allowed = False
self.title_font = None
self.title_name = None
self.title_formula = None
self.title_data_id = None

self._set_default_properties()

Expand Down Expand Up @@ -603,7 +607,7 @@ def _convert_axis_args(self, axis, user_options):
pass
else:
# Otherwise use the default value.
axis['position_axis']
axis['position_axis'] = None

# Set the font properties if present.
axis['num_font'] = self._convert_font_args(options.get('num_font'))
Expand Down Expand Up @@ -634,7 +638,7 @@ def _convert_font_args(self, options):
font['size'] *= 100

# Convert rotation into 60,000ths of a degree.
if (font['rotation']):
if font['rotation']:
font['rotation'] = 60000 * int(font['rotation'])

return font
Expand Down Expand Up @@ -676,7 +680,7 @@ def _get_data_type(self, data):
return 'none'

# Determine if data is numeric or strings.
for token in (data):
for token in data:
if token is None:
continue

Expand Down Expand Up @@ -924,7 +928,7 @@ def _get_gridline_properties(self, options):
gridline = {}

# Set the visible property for the gridline.
gridline['visible'] = options.get('visible')
gridline = {'visible': options.get('visible')}

# Set the line properties for the gridline.
gridline['line'] = self._get_line_properties(options.get('line'))
Expand Down Expand Up @@ -989,7 +993,7 @@ def _get_points_properties(self, user_points):
if not user_points:
return

for user_point in (user_points):
for user_point in user_points:
point = {}

if user_point is not None:
Expand All @@ -1015,7 +1019,7 @@ def _get_primary_axes_series(self):
# Returns series which use the primary axes.
primary_axes_series = []

for series in (self.series):
for series in self.series:
if not series['y2_axis']:
primary_axes_series.append(series)

Expand All @@ -1025,7 +1029,7 @@ def _get_secondary_axes_series(self):
# Returns series which use the secondary axes.
secondary_axes_series = []

for series in (self.series):
for series in self.series:
if series['y2_axis']:
secondary_axes_series.append(series)

Expand Down Expand Up @@ -2113,7 +2117,7 @@ def _write_legend(self):
self._write_legend_pos(position)

# Remove series labels from the legend.
for index in (delete_series):
for index in delete_series:
# Write the c:legendEntry element.
self._write_legend_entry(index)

Expand Down Expand Up @@ -2825,7 +2829,7 @@ def _write_d_pt(self, points):
if not points:
return

for point in (points):
for point in points:
index += 1
if not point:
continue
Expand Down
4 changes: 2 additions & 2 deletions xlsxwriter/comments.py
Expand Up @@ -79,7 +79,7 @@ def _write_authors(self, comment_data):

self._xml_start_tag('authors')

for comment in (comment_data):
for comment in comment_data:
author = comment[3]

if author is not None and not author in self.author_ids:
Expand All @@ -100,7 +100,7 @@ def _write_comment_list(self, comment_data):
# Write the <commentList> element.
self._xml_start_tag('commentList')

for comment in (comment_data):
for comment in comment_data:
row = comment[0]
col = comment[1]
text = comment[2]
Expand Down
1 change: 0 additions & 1 deletion xlsxwriter/contenttypes.py
Expand Up @@ -61,7 +61,6 @@ def _assemble_xml_file(self):
# Write the XML declaration.
self._xml_declaration()

self._xml_declaration
self._write_types()
self._write_defaults()
self._write_overrides()
Expand Down
12 changes: 6 additions & 6 deletions xlsxwriter/drawing.py
Expand Up @@ -148,7 +148,7 @@ def _write_two_cell_anchor(self, index, dimensions):

self._xml_end_tag('xdr:twoCellAnchor')

def _write_absolute_anchor(self, index):
def _write_absolute_anchor(self, frame_index):
self._xml_start_tag('xdr:absoluteAnchor')
# Write the <xdr:absoluteAnchor> element.

Expand All @@ -168,7 +168,7 @@ def _write_absolute_anchor(self, index):
self._write_ext(6162675, 6124575)

# Write the xdr:graphicFrame element.
self._write_graphic_frame(index)
self._write_graphic_frame(frame_index, 'Name')

# Write the xdr:clientData element.
self._write_client_data()
Expand Down Expand Up @@ -406,8 +406,8 @@ def _write_sp(self, index, col_absolute, row_absolute,

# Write the xdr:txBody element.
if shape.text:
self._write_txBody(col_absolute, row_absolute, width, height,
shape)
self._write_tx_body(col_absolute, row_absolute, width, height,
shape)

self._xml_end_tag('xdr:sp')

Expand Down Expand Up @@ -659,7 +659,7 @@ def _write_a_av_lst(self, shape={}):
suffix = ''

# Scale Adjustments: 100,000 = 100%.
adj_int = int(adj * 1000)
adj_int = str(int(adj * 1000))

attributes = [('name', 'adj' + suffix),
('fmla', 'val' + adj_int)]
Expand Down Expand Up @@ -716,7 +716,7 @@ def _write_a_ln(self, shape={}):

self._xml_end_tag('a:ln')

def _write_txBody(self, col_absolute, row_absolute, width, height, shape):
def _write_tx_body(self, col_absolute, row_absolute, width, height, shape):
# Write the <xdr:txBody> element.
attributes = [
('vertOverflow', "clip"),
Expand Down
1 change: 1 addition & 0 deletions xlsxwriter/format.py
Expand Up @@ -67,6 +67,7 @@ def __init__(self, properties={}, xf_indicies=None, dxf_indicies=None):
self.text_v_align = 0
self.text_justlast = 0
self.rotation = 0
self.center_across = 0

self.fg_color = 0
self.bg_color = 0
Expand Down
4 changes: 3 additions & 1 deletion xlsxwriter/packager.py
Expand Up @@ -86,6 +86,8 @@ def __init__(self):
self.chart_count = 0
self.drawing_count = 0
self.table_count = 0
self.num_vml_files = 0
self.num_comment_files = 0
self.named_ranges = []

###########################################################################
Expand Down Expand Up @@ -557,7 +559,7 @@ def _write_chartsheet_rels_files(self):
rels = Relationships()

for link_data in external_links:
rels._add_worksheet_relationship(link_data)
rels._add_worksheet_relationship(*link_data)

# Create .rels file such as /xl/chartsheets/_rels/sheet1.xml.rels.
rels._set_xml_writer(xlsx_dir + '/xl/chartsheets/_rels/sheet'
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/styles.py
Expand Up @@ -619,7 +619,7 @@ def _write_dxfs(self):
for xf_format in self.dxf_formats:
self._xml_start_tag('dxf')
if xf_format.has_dxf_font:
self._write_font(xf_format, 1)
self._write_font(xf_format, True)

if xf_format.num_format_index:
self._write_num_fmt(xf_format.num_format_index,
Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/table.py
Expand Up @@ -121,7 +121,7 @@ def _write_table_columns(self):

self._xml_start_tag('tableColumns', attributes)

for col_data in (columns):
for col_data in columns:
# Write the tableColumn element.
self._write_table_column(col_data)

Expand Down
5 changes: 2 additions & 3 deletions xlsxwriter/utility.py
Expand Up @@ -27,7 +27,6 @@ def xl_rowcol_to_cell(row, col, row_abs=False, col_abs=False):
"""
row += 1 # Change to 1-index.
row_abs = '$' if row_abs else ''
col_abs = '$' if col_abs else ''

col_str = xl_col_to_name(col, col_abs)

Expand Down Expand Up @@ -102,7 +101,7 @@ def xl_cell_to_rowcol(cell_str):
"""
if not cell_str:
return (0, 0)
return 0, 0

match = range_parts.match(cell_str)
col_str = match.group(2)
Expand Down Expand Up @@ -135,7 +134,7 @@ def xl_cell_to_rowcol_abs(cell_str):
"""
if not cell_str:
return (0, 0, False, False)
return 0, 0, False, False

match = range_parts.match(cell_str)

Expand Down
2 changes: 1 addition & 1 deletion xlsxwriter/vml.py
Expand Up @@ -81,7 +81,7 @@ def _pixels_to_points(self, vertices):
width *= 0.75
height *= 0.75

return (left, top, width, height)
return left, top, width, height

###########################################################################
#
Expand Down

0 comments on commit eeb5b73

Please sign in to comment.