Skip to content

Use cssdecl package for resolving CSS #16170

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

Closed
wants to merge 18 commits into from
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
1 change: 1 addition & 0 deletions ci/requirements-2.7_LOCALE.run
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ numpy=1.8.2
xlwt=0.7.5
openpyxl=1.6.2
xlsxwriter=0.4.6
cssdecl
Copy link
Contributor

Choose a reason for hiding this comment

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

don't add this to all of these
just 2.7 and 3.6 is enough
u can add the os x build if u want
windows prob 2 (only need to add to 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay. I meant to clarify but forgot.

xlrd=0.9.2
bottleneck=0.8.0
matplotlib=1.3.1
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-2.7_SLOW.run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ patsy
xlwt
openpyxl
xlsxwriter
cssdecl
xlrd
numexpr
pytables
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-2.7_WIN.run
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ numexpr
pytables==3.2.2
matplotlib
openpyxl
cssdecl
xlrd
sqlalchemy
lxml=3.2.1
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.4.run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pytz=2015.7
numpy=1.8.1
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
html5lib
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.4_SLOW.run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytz
numpy=1.10*
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
html5lib
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.5.run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytz
numpy=1.11.3
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
scipy
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.5_DOC.run
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ openpyxl=1.8.5
xlrd
xlwt
xlsxwriter
cssdecl
sqlalchemy
numexpr
bottleneck
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.5_OSX.run
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pytz
numpy=1.10.4
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
numexpr
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.6.run
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ numpy
scipy
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
numexpr
Expand Down
1 change: 1 addition & 0 deletions ci/requirements-3.6_WIN.run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytz
numpy=1.12*
openpyxl
xlsxwriter
cssdecl
xlrd
xlwt
scipy
Expand Down
1 change: 1 addition & 0 deletions ci/requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ python-dateutil
pytz
openpyxl
xlsxwriter
cssdecl
Copy link
Contributor

Choose a reason for hiding this comment

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

this is for developement and not necessary to have this, pls remove.

xlrd
xlwt
html5lib
Expand Down
1 change: 1 addition & 0 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ Optional Dependencies
* `openpyxl <http://packages.python.org/openpyxl/>`__: openpyxl version 1.6.1
or higher (but lower than 2.0.0), or version 2.2 or higher, for writing .xlsx files (xlrd >= 0.9.0)
* `XlsxWriter <https://pypi.python.org/pypi/XlsxWriter>`__: Alternative Excel writer
* `cssdecl <https://pypi.python.org/pypi/cssdecl>`__: along with one of openpyxl or XlsxWriter for exporting styled DataFrames
Copy link
Contributor

Choose a reason for hiding this comment

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

if you have a min version requirement we can put it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've decided I can probably keep the interface backwards compatible. There may, in the future, be min versions for certain features, e.g. gradient fills used for bar charts, but there will also be a min version of openpyxl for that (and I don't think xlsxwriter supports)

Copy link
Contributor Author

@jnothman jnothman May 8, 2017

Choose a reason for hiding this comment

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

xlsxwriter support mentioned here depends largely on #16149 being merged


* `Jinja2 <http://jinja.pocoo.org/>`__: Template engine for conditional HTML formatting.
* `s3fs <http://s3fs.readthedocs.io/>`__: necessary for Amazon S3 access (s3fs >= 0.0.7).
Expand Down
248 changes: 0 additions & 248 deletions pandas/io/formats/css.py

This file was deleted.

6 changes: 3 additions & 3 deletions pandas/io/formats/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import numpy as np

from pandas.compat import reduce, string_types
from pandas.io.formats.css import CSSResolver, CSSWarning
from pandas.io.formats.printing import pprint_thing
from pandas.core.dtypes.common import is_float
import pandas._libs.lib as lib
Expand Down Expand Up @@ -61,14 +60,14 @@ class CSSToExcelConverter(object):
# without monkey-patching.

def __init__(self, inherited=None):
from cssdecl import CSS22Resolver
self.compute_css = CSS22Resolver().resolve_string
if inherited is not None:
inherited = self.compute_css(inherited,
self.compute_css.INITIAL_STYLE)

self.inherited = inherited

compute_css = CSSResolver()

def __call__(self, declarations_str):
"""Convert CSS declarations to ExcelWriter style

Expand Down Expand Up @@ -302,6 +301,7 @@ def color_to_excel(self, val):
try:
return self.NAMED_COLORS[val]
except KeyError:
from cssdecl import CSSWarning
warnings.warn('Unhandled colour format: %r' % val, CSSWarning)


Expand Down
Loading