Hello community, here is the log from the commit of package python-branca for openSUSE:Leap:15.2 checked in at 2020-03-16 12:21:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-branca (Old) and /work/SRC/openSUSE:Leap:15.2/.python-branca.new.3160 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-branca" Mon Mar 16 12:21:02 2020 rev:2 rq:782055 version:0.4.0 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-branca/python-branca.changes 2020-02-11 23:25:10.197262290 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-branca.new.3160/python-branca.changes 2020-03-16 12:21:03.587708532 +0100 @@ -1,0 +2,10 @@ +Thu Mar 5 09:12:06 UTC 2020 - pgaj...@suse.com + +- version update to 0.4.0 + - Dropped Python 2 support + - Store html content in a data-html attribute (#66) + - Colormap alpha #64 + - Fix caption being propagated in scale functions #62 + - Assert color type in color_brewer #52 + +------------------------------------------------------------------- Old: ---- v0.3.1.tar.gz New: ---- v0.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-branca.spec ++++++ --- /var/tmp/diff_new_pack.IShnZH/_old 2020-03-16 12:21:03.935708589 +0100 +++ /var/tmp/diff_new_pack.IShnZH/_new 2020-03-16 12:21:03.939708590 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-branca # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,8 +17,9 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} +%define skip_python2 1 Name: python-branca -Version: 0.3.1 +Version: 0.4.0 Release: 0 Summary: HTML+JS page generator License: MIT @@ -58,7 +59,7 @@ %pytest -k 'not test_rendering_utf8_iframe' -v %files %{python_files} -%doc CHANGES.txt README.rst +%doc CHANGES.txt README.md %license LICENSE.txt %{python_sitelib}/* ++++++ v0.3.1.tar.gz -> v0.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/.appveyor.yml new/branca-0.4.0/.appveyor.yml --- old/branca-0.3.1/.appveyor.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.4.0/.appveyor.yml 2020-02-17 15:46:35.000000000 +0100 @@ -0,0 +1,37 @@ +build: false + +environment: + PYTHON: "C:\\myminiconda3" + matrix: + - PY: 3.7 + - PY: 3.8 + +init: + - "ECHO %PYTHON_VERSION% %MINICONDA%" + +install: + # Add path, activate `conda` and update conda. + - set URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" + - curl -fsS -o miniconda3.exe %URL% + - start /wait "" miniconda3.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%PYTHON% + + - "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + - call %PYTHON%\Scripts\activate + + - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + - conda update conda --quiet + - conda config --add channels conda-forge --force + - conda config --set channel_priority strict + - conda config --set safety_checks disabled + + # Create the test env. + - conda create --name TEST python=%PY% --file requirements.txt --file requirements-dev.txt + - activate TEST + + # Debug. + - conda info --all + - conda list + +test_script: + - pip install -e . --no-deps --force-reinstall + - pytest -n 2 -rxXs -m "not headless" tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/.gitignore new/branca-0.4.0/.gitignore --- old/branca-0.3.1/.gitignore 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/.gitignore 2020-02-17 15:46:35.000000000 +0100 @@ -53,3 +53,8 @@ # documentation builds docs/_build + +geckodriver.log + +# Pycharm +.idea/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/.travis.yml new/branca-0.4.0/.travis.yml --- old/branca-0.3.1/.travis.yml 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/.travis.yml 2020-02-17 15:46:35.000000000 +0100 @@ -6,6 +6,10 @@ - MOZ_HEADLESS=1 addons: + apt: + packages: + # Without libgtk (as of 2019-11-6), firefox cannot run properly + - libgtk-3-0 firefox: latest env: @@ -15,46 +19,61 @@ matrix: fast_finish: true include: - - name: default-python2 - env: TEST_TARGET=default PY=2.7 - - name: default - env: TEST_TARGET=default PY=3.7 + - name: "python-3.6" + env: PY=3.6 + - name: "python-3.7" + env: PY=3.7 + - name: "python-3.8" + env: PY=3.8 - name: coding_standards - env: TEST_TARGET=coding_standards PY=3.7 + env: PY=3.8 - name: docs - env: TEST_TARGET=docs PY=3.7 + env: PY=3.8 + - name: "tarball" + env: PY=3.8 before_install: - - wget http://bit.ly/miniconda -O miniconda.sh - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true - - conda update conda - - conda config --remove channels defaults --force - - conda config --add channels conda-forge --force - - conda create --name TEST python=$PY --file requirements.txt --file requirements-dev.txt - - source activate TEST - # firefox headless driver - - wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz -O geckodriver.tar.gz - - mkdir geckodriver - - tar -xzf geckodriver.tar.gz -C geckodriver - - export PATH=$PATH:$PWD/geckodriver + # Install miniconda and create TEST env. + - | + wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + bash miniconda.sh -b -p $HOME/miniconda + export PATH="$HOME/miniconda/bin:$PATH" + conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + conda update --quiet conda + conda config --add channels conda-forge --force + conda config --set channel_priority strict + conda config --set safety_checks disabled + conda create --name TEST python=$PY --file requirements.txt --file requirements-dev.txt + source activate TEST + conda info --all + # Install firefox headless driver. + - | + wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz -O geckodriver.tar.gz + mkdir geckodriver + tar -xzf geckodriver.tar.gz -C geckodriver + export PATH=$PATH:$PWD/geckodriver install: - - python setup.py sdist && version=$(python setup.py --version) && pushd dist && pip install branca-${version}.tar.gz && popd + - pip install -e . --no-deps --force-reinstall script: - - if [[ $TEST_TARGET == 'default' ]]; then + - if [[ $TRAVIS_JOB_NAME == python-* ]]; then cp -r tests/ /tmp ; - pushd /tmp && pytest -vvv tests && popd ; + pushd /tmp && pytest -n 2 -rxs --cov=branca -vv tests && popd ; fi - - if [[ $TEST_TARGET == 'coding_standards' ]]; then - flake8 --max-line-length=105 branca --exclude=_version.py ; - flake8 --max-line-length=105 tests ; + - if [[ $TRAVIS_JOB_NAME == 'tarball' ]]; then + python setup.py --version ; + pip wheel . -w dist --no-deps ; + check-manifest --verbose ; + twine check dist/* ; fi - - if [[ $TEST_TARGET == 'docs' ]]; then + - if [[ $TRAVIS_JOB_NAME == 'coding_standards' ]]; then + pytest --flake8 -m flake8 ; + fi + + - if [[ $TRAVIS_JOB_NAME == 'docs' ]]; then set -e ; conda install doctr ; pushd docs ; @@ -70,13 +89,13 @@ deploy: skip_cleanup: true provider: pypi - user: ocefpaf + user: "__token__" password: - secure: "LzZ9ppBFcqskCeMos99eAmLPRiG2pX8n2Ghf7O5Nd5KgJruZBNVq+uOAFtLkCBTheG+59HS75dQwmc2n2E8hmt1WPCTRpz6bffPl8hUzxuTBIPMzfdor8RmXvnMY+c8zAuWXH2ws166GzRApKMhrIZMv7d5OmZyUZgHTKsA4kyd9Nhz1nZdJf1ox3TbODl4OuGfUkQ8gVhA5LwdlJtzxbZlbPTUpTeu42plJawa2JtY20jiSbnu2mujR1UUuzkcnaBHhStjWYYMUQNtXdKonV5irQ9gNACnmlFSwSqDf1Jb74f3n3ojBMWIlMgCJCsPgssAtSaePuIB6HpS+xc7NCORBS1tkFyU0IHlMNXEpHGKCNXvAZVHGgDW71rQ0Gdg9bNpFd9vQ8IL6D+iBohjuxXRjdK1DWf6XlC/7N1aJB443LFtFOT7184AwmL3YNrqeZsaA3HfuMt1CGf3kC91SUn3BypQu+J+irtV7Z8ugOr8mcLcDuTuSAA8zM/VUeZToF29Xs0pwBTUJszkKL4+cxoNj/pXoL8JHQztL7e0BmD+qa4PoK8J87P1RkH2UwV7XSRzV2oWpiwRqPxMKK0HGM8oOckZJ5OcwF3yuNXGMC0hCw9TTW931auiwr4UZ254jxRPg/+HsojutBL0+z67szr3qzTNlO+FmXvwTChS8PW8=" + secure: "ncVXDcUpadOXESusbUv/F5mhXqzjp0fFM+llYdBOWBGpipP2B1cU/cWRUU5fkhL1KZG/0DfVboJsRnNQCebZklJ0fczW2Z2QUzL8zCAK8KLOUqr0Nk8i8Oi5eC0h8Ew+HkDNORsZUCPCjKvqcFHRuSZnVYvEqqPPguSj1fwDdyBm9kW7lfZdPeR9mr79WJs+Miv5UKXGZcQAuzCU7g3AmaizRoUfhXnSgPXd9Yp2DY5nsBUZhmqFTj1xjQwLvqp5w/BiFZGkdqMuWVP9b/HbVJEeRxWgCaDPw+XLkQa+HdfUsDGBvPWaaQ+o6OwuADdCjIHLnVmfA2/E2FSU64IBaIZ1xOkHZpm74P8Y0NF5aRogyipkqhrm0WErRWFD4OYj8ud4y9AHLCAmyyLsKCka76NSxotbTd4W4Xu9MX7fkhGOVzhYXg1GNS6SDTIMn+bujFNg5fZrZUptn6FcNa8THkh7yKrduBv2kgbBcgx0/EodH4q2Ds7yfbFvPkQD+l0mBiOPXOXflcQDOiu0CZ70X2XmLe3v3zIEf51oigEtb/KRkf7B3r/Ab+ayNdS33xbHsE8JYE/6KKjGf+fEr0f4XiidadtCbUmNGCw8fgHo7dY4g7blYMPvab7z4zcHmqekzrSTTwxw2uRtmGLWWJupmOerasRIuLsKiJxnk9oiS+k=" distributions: sdist bdist_wheel upload_docs: no on: repo: python-visualization/branca tags: true all_branches: master - condition: '$TEST_TARGET == "default"' + condition: '$TRAVIS_JOB_NAME == "tarball"' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/CHANGES.txt new/branca-0.4.0/CHANGES.txt --- old/branca-0.3.1/CHANGES.txt 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/CHANGES.txt 2020-02-17 15:46:35.000000000 +0100 @@ -1,3 +1,16 @@ +0.4.0 +~~~~~ +- Dropped Python 2 support +- Store html content in a data-html attribute (#66) +- Colormap alpha #64 +- Fix caption being propagated in scale functions #62 +- Assert color type in color_brewer #52 + +0.3.1 +~~~~~ +- Added viridis scheme #47 (GillesC) +- Fixed testing, auto PyPI upload, and docs + 0.3.0 ~~~~~ - Add title to Figure (@fitoprincipe #33 and #39) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/README.md new/branca-0.4.0/README.md --- old/branca-0.3.1/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/branca-0.4.0/README.md 2020-02-17 15:46:35.000000000 +0100 @@ -0,0 +1,13 @@ +[![PyPI Package](https://img.shields.io/pypi/v/branca.svg)](https://pypi.python.org/pypi/branca) [![Build Status](https://travis-ci.org/python-visualization/branca.svg?branch=master)](https://travis-ci.org/python-visualization/branca) [![Gitter](https://badges.gitter.im/python-visualization/folium.svg)](https://gitter.im/python-visualization/folium) + +# Branca + +This library is a spinoff from [folium](https://github.com/python-visualization/folium), +that would host the non-map-specific features. + +It may become a HTML+JS generation library in the future. + +It is based on Jinja2 only. + +There's no documentation, +but you can [browse the examples](http://nbviewer.jupyter.org/github/python-visualization/branca/tree/master/examples) gallery. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/README.rst new/branca-0.4.0/README.rst --- old/branca-0.3.1/README.rst 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/README.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,27 +0,0 @@ -|PyPI| |Travis| |Gitter| - -.. |PyPI| image:: https://img.shields.io/pypi/v/branca.svg - :target: https://pypi.python.org/pypi/branca/ - :alt: PyPI Package - -.. |Travis| image:: https://travis-ci.org/python-visualization/branca.svg?branch=master - :target: https://travis-ci.org/python-visualization/branca - :alt: Travis Build Status - -.. |Gitter| image:: https://badges.gitter.im/python-visualization/folium.svg - :target: https://gitter.im/python-visualization/folium - :alt: Gitter - -Branca -====== - -This library is a spinoff from `folium`_, that would host the non-map-specific features. - -It may become a HTML+JS generation library in the future. - -It is based on Jinja2 only. - -There's no documentation, but you can browse the `examples`_ gallery. - -.. _`examples`: http://nbviewer.jupyter.org/github/python-visualization/branca/tree/master/examples -.. _`folium`: https://github.com/python-visualization/folium diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/branca/__init__.py new/branca-0.4.0/branca/__init__.py --- old/branca-0.3.1/branca/__init__.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/branca/__init__.py 2020-02-17 15:46:35.000000000 +0100 @@ -2,6 +2,8 @@ from __future__ import absolute_import +import sys + import branca.colormap as colormap import branca.element as element @@ -9,6 +11,26 @@ __version__ = get_versions()['version'] del get_versions +if sys.version_info < (3, 0): + raise ImportError( + """You are running branca {} on Python 2 + + branca 0.4 and above are no longer compatible with Python 2, but somehow + you got this version anyway. Make sure you have pip >= 9.0 to avoid this + kind of issue, as well as setuptools >= 24.2: + + $ pip install pip setuptools --upgrade + + Your choices: + + - Upgrade to Python 3. + + - Install an older version of branca: + + $ pip install 'branca<0.4.0' + + """.format(__version__)) # noqa + __all__ = [ 'colormap', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/branca/_version.py new/branca-0.4.0/branca/_version.py --- old/branca-0.3.1/branca/_version.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/branca/_version.py 2020-02-17 15:46:35.000000000 +0100 @@ -23,9 +23,9 @@ # setup.py/versioneer.py will grep for the variable names, so they must # each be defined on a line of their own. _version.py will just call # get_keywords(). - git_refnames = " (tag: v0.3.1)" - git_full = "2758370c61c32f528e6f58dfd1514ac50daefca7" - git_date = "2018-11-05 17:10:43 -0200" + git_refnames = " (HEAD -> master, tag: v0.4.0)" + git_full = "cd2224538aac5aeb6c0dfa145af3886f192f3537" + git_date = "2020-02-17 15:46:35 +0100" keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} return keywords diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/branca/colormap.py new/branca-0.4.0/branca/colormap.py --- old/branca-0.3.1/branca/colormap.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/branca/colormap.py 2020-02-17 15:46:35.000000000 +0100 @@ -10,28 +10,23 @@ import json import math +import os from branca.element import ENV, Figure, JavascriptLink, MacroElement from branca.utilities import legend_scaler from jinja2 import Template -import pkg_resources - from six import binary_type, text_type -resource_package = __name__ -resource_path_schemes = '/_schemes.json' -resource_path_cnames = '/_cnames.json' - -cnames_string = pkg_resources.resource_stream( - resource_package, resource_path_cnames).read().decode() -_cnames = json.loads(cnames_string) - -schemes_string = pkg_resources.resource_stream( - resource_package, resource_path_schemes).read().decode() -_schemes = json.loads(schemes_string) +rootpath = os.path.abspath(os.path.dirname(__file__)) + +with open(os.path.join(rootpath, '_cnames.json')) as f: + _cnames = json.loads(f.read()) + +with open(os.path.join(rootpath, '_schemes.json')) as f: + _schemes = json.loads(f.read()) def _is_hex(x): @@ -131,15 +126,21 @@ def rgb_hex_str(self, x): """Provides the color corresponding to value `x` in the - form of a string of hewadecimal values "#RRGGBB". + form of a string of hexadecimal values "#RRGGBB". """ return '#%02x%02x%02x' % self.rgb_bytes_tuple(x) + def rgba_hex_str(self, x): + """Provides the color corresponding to value `x` in the + form of a string of hexadecimal values "#RRGGBBAA". + """ + return '#%02x%02x%02x%02x' % self.rgba_bytes_tuple(x) + def __call__(self, x): """Provides the color corresponding to value `x` in the - form of a string of hewadecimal values "#RRGGBB". + form of a string of hexadecimal values "#RRGGBBAA". """ - return self.rgb_hex_str(x) + return self.rgba_hex_str(x) def _repr_html_(self): return ( @@ -148,8 +149,10 @@ [('<line x1="{i}" y1="0" x2="{i}" ' 'y2="20" style="stroke:{color};stroke-width:3;" />').format( i=i*1, - color=self.rgb_hex_str(self.vmin + - (self.vmax-self.vmin)*i/499.)) + color=self.rgba_hex_str( + self.vmin + + (self.vmax-self.vmin)*i/499.) + ) for i in range(500)]) + '<text x="0" y="35">{}</text>'.format(self.vmin) + '<text x="500" y="35" style="text-anchor:end;">{}</text>'.format( @@ -194,7 +197,7 @@ if index is None: self.index = [vmin + (vmax-vmin)*i*1./(n-1) for i in range(n)] else: - self.index = [x for x in index] + self.index = list(index) self.colors = [_parse_color(x) for x in colors] def rgba_floats_tuple(self, x): @@ -335,6 +338,7 @@ index=[vmin + (vmax-vmin)*(x-self.vmin)*1./(self.vmax-self.vmin) for x in self.index], # noqa vmin=vmin, vmax=vmax, + caption=self.caption, ) @@ -375,7 +379,7 @@ if index is None: self.index = [vmin + (vmax-vmin)*i*1./n for i in range(n+1)] else: - self.index = [x for x in index] + self.index = list(index) self.colors = [_parse_color(x) for x in colors] def rgba_floats_tuple(self, x): @@ -422,6 +426,7 @@ index=[vmin + (vmax-vmin)*(x-self.vmin)*1./(self.vmax-self.vmin) for x in self.index], # noqa vmin=vmin, vmax=vmax, + caption=self.caption, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/branca/element.py new/branca-0.4.0/branca/element.py --- old/branca-0.3.1/branca/element.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/branca/element.py 2020-02-17 15:46:35.000000000 +0100 @@ -322,30 +322,36 @@ return self._template.render(this=self, kwargs=kwargs) def _repr_html_(self, **kwargs): - """Displays the Figure in a Jupyter notebook. - - """ - html = self.render(**kwargs) - html = "data:text/html;charset=utf-8;base64," + base64.b64encode(html.encode('utf8')).decode('utf8') # noqa + """Displays the Figure in a Jupyter notebook.""" + # Base64-encoded HTML is stored in a data-html attribute, which is used to populate + # the iframe. This approach does not encounter the 2MB limit in Chrome for storing + # the HTML in the src attribute with a data URI. The alternative of using a srcdoc + # attribute is not supported in Microsoft Internet Explorer and Edge. + html = base64.b64encode(self.render(**kwargs).encode('utf8')).decode('utf8') + onload = ( + 'this.contentDocument.open();' + 'this.contentDocument.write(atob(this.getAttribute(\'data-html\')));' + 'this.contentDocument.close();' + ) if self.height is None: iframe = ( '<div style="width:{width};">' '<div style="position:relative;width:100%;height:0;padding-bottom:{ratio};">' # noqa - '<iframe src="{html}" style="position:absolute;width:100%;height:100%;left:0;top:0;' # noqa + '<iframe src="about:blank" style="position:absolute;width:100%;height:100%;left:0;top:0;' # noqa 'border:none !important;" ' + 'data-html={html} onload="{onload}" ' 'allowfullscreen webkitallowfullscreen mozallowfullscreen>' '</iframe>' '</div></div>').format - iframe = iframe(html=html, - width=self.width, - ratio=self.ratio) + iframe = iframe(html=html, onload=onload, width=self.width, ratio=self.ratio) else: - iframe = ('<iframe src="{html}" width="{width}" height="{height}"' + iframe = ('<iframe src="about:blank" width="{width}" height="{height}"' 'style="border:none !important;" ' + 'data-html={html} onload="{onload}" ' '"allowfullscreen" "webkitallowfullscreen" "mozallowfullscreen">' # noqa '</iframe>').format - iframe = iframe(html=html, width=self.width, height=self.height) + iframe = iframe(html=html, onload=onload, width=self.width, height=self.height) return iframe def add_subplot(self, x, y, n, margin=0.05): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/branca/utilities.py new/branca-0.4.0/branca/utilities.py --- old/branca-0.3.1/branca/utilities.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/branca/utilities.py 2020-02-17 15:46:35.000000000 +0100 @@ -12,12 +12,12 @@ import base64 import json import math +import os import struct import zlib from jinja2 import Environment, PackageLoader -import pkg_resources from six import binary_type, text_type @@ -32,6 +32,9 @@ np = None +rootpath = os.path.abspath(os.path.dirname(__file__)) + + def get_templates(): """Get Jinja templates.""" return Environment(loader=PackageLoader('branca', 'templates')) @@ -119,6 +122,9 @@ raise ValueError('The minimum number of colors in a' ' ColorBrewer sequential color series is 3') + if not isinstance(color_code, str): + raise ValueError('color should be a string, not a {}.' + .format(type(color_code))) if color_code[-2:] == '_r': base_code = color_code[:-2] core_color_code = base_code + '_' + str(n).zfill(2) @@ -128,22 +134,14 @@ core_color_code = base_code + '_' + str(n).zfill(2) color_reverse = False - resource_package = __name__ - resource_path_schemes = '/_schemes.json' - resource_path_scheme_info = '/_cnames.json' - resource_path_scheme_base_codes = '/scheme_base_codes.json' - - schemes_string = pkg_resources.resource_stream( - resource_package, resource_path_schemes).read().decode() - schemes = json.loads(schemes_string) - - scheme_info_string = pkg_resources.resource_stream( - resource_package, resource_path_scheme_info).read().decode() - scheme_info = json.loads(scheme_info_string) - - core_schemes_string = pkg_resources.resource_stream( - resource_package, resource_path_scheme_base_codes).read().decode() - core_schemes = json.loads(core_schemes_string)['codes'] + with open(os.path.join(rootpath, '_schemes.json')) as f: + schemes = json.loads(f.read()) + + with open(os.path.join(rootpath, '_cnames.json')) as f: + scheme_info = json.loads(f.read()) + + with open(os.path.join(rootpath, 'scheme_base_codes.json')) as f: + core_schemes = json.loads(f.read())['codes'] if base_code not in core_schemes: raise ValueError(base_code + ' is not a valid ColorBrewer code') @@ -301,8 +299,8 @@ height, width, nblayers = array.shape if nblayers not in [1, 3, 4]: - raise ValueError('Data must be NxM (mono), ' - 'NxMx3 (RGB), or NxMx4 (RGBA)') + raise ValueError('Data must be NxM (mono), ' + 'NxMx3 (RGB), or NxMx4 (RGBA)') assert array.shape == (height, width, nblayers) if nblayers == 1: @@ -334,10 +332,10 @@ for i in range(height)]) def png_pack(png_tag, data): - chunk_head = png_tag + data - return (struct.pack('!I', len(data)) + - chunk_head + - struct.pack('!I', 0xFFFFFFFF & zlib.crc32(chunk_head))) + chunk_head = png_tag + data + return (struct.pack('!I', len(data)) + + chunk_head + + struct.pack('!I', 0xFFFFFFFF & zlib.crc32(chunk_head))) return b''.join([ b'\x89PNG\r\n\x1a\n', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/requirements-dev.txt new/branca-0.4.0/requirements-dev.txt --- old/branca-0.3.1/requirements-dev.txt 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/requirements-dev.txt 2020-02-17 15:46:35.000000000 +0100 @@ -1,11 +1,17 @@ +check-manifest flake8 flake8-builtins flake8-comprehensions flake8-import-order flake8-mutable flake8-print -flake8-quotes nbsphinx +pylint pytest +pytest-cov +pytest-flake8 +pytest-xdist selenium sphinx +twine +wheel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/setup.cfg new/branca-0.4.0/setup.cfg --- old/branca-0.3.1/setup.cfg 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/setup.cfg 2020-02-17 15:46:35.000000000 +0100 @@ -9,3 +9,29 @@ versionfile_build = branca/_version.py tag_prefix = v parentdir_prefix = + +[tool:pytest] +flake8-max-line-length = 105 +flake8-ignore = + docs/* ALL + versioneer.py ALL + branca/_version.py ALL +markers = + headless: mark headless tests (deselect with '-m "not headless"') + +[metadata] +description-file = README.rst +license_file = LICENSE.txt + +[check-manifest] +ignore = + .*.yml + .coveragerc + Makefile + docs + docs/* + *.enc + examples + examples/* + tests + tests/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/setup.py new/branca-0.4.0/setup.py --- old/branca-0.3.1/setup.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/setup.py 2020-02-17 15:46:35.000000000 +0100 @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- - import os +import sys from setuptools import setup @@ -10,12 +9,12 @@ def read(*parts): - return open(os.path.join(rootpath, *parts), 'r').read() + return open(os.path.join(rootpath, *parts), "r").read() def walk_subpkg(name): data_files = [] - package_dir = 'branca' + package_dir = "branca" for parent, dirs, files in os.walk(os.path.join(package_dir, name)): # Remove package_dir from the path. sub_dir = os.sep.join(parent.split(os.sep)[1:]) @@ -24,47 +23,70 @@ return data_files -pkg_data = {'': ['*.js', - 'plugins/*.js', - 'plugins/*.html', - 'plugins/*.css', - 'plugins/*.tpl', - 'templates/*.html', - 'templates/*.js', - 'templates/*.txt']} -pkgs = ['branca', ] +if sys.version_info < (3, 5): + error = """ + branca 0.4+ supports Python 3.5 and above. + When using Python 2.7, please install branca 0.3.*. + + See branca `README.rst` file for more information: + + https://github.com/python-visualization/branca/blob/master/README.rst + + Python {py} detected. + + Try upgrading pip and retry. + """.format( + py=".".join([str(v) for v in sys.version_info[:3]]) + ) + print(error, file=sys.stderr) # noqa + sys.exit(1) + +pkg_data = { + "": [ + "*.js", + "plugins/*.js", + "plugins/*.html", + "plugins/*.css", + "plugins/*.tpl", + "templates/*.html", + "templates/*.js", + "templates/*.txt", + ] +} +pkgs = ["branca"] -LICENSE = read('LICENSE.txt') -long_description = '{}\n{}'.format(read('README.rst'), read('CHANGES.txt')) +LICENSE = read("LICENSE.txt") +long_description = "{}".format(read("README.md")) # Dependencies. -with open('requirements.txt') as f: +with open("requirements.txt") as f: tests_require = f.readlines() install_requires = [t.strip() for t in tests_require] setup( - name='branca', + name="branca", version=versioneer.get_version(), - description='Generate complex HTML+JS pages with Python', + description="Generate complex HTML+JS pages with Python", long_description=long_description, - author='Martin Journois', - url='https://github.com/python-visualization/branca', - keywords='data visualization', + long_description_content_type="text/markdown", + author="Martin Journois", + url="https://github.com/python-visualization/branca", + keywords="data visualization", classifiers=[ - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'License :: OSI Approved :: MIT License', - 'Development Status :: 5 - Production/Stable' + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "License :: OSI Approved :: MIT License", + "Development Status :: 5 - Production/Stable", ], packages=pkgs, package_data=pkg_data, include_package_data=True, cmdclass=versioneer.get_cmdclass(), - tests_require=['pytest'], + tests_require=["pytest"], license=LICENSE, install_requires=install_requires, + python_requires=">=3.5", zip_safe=False, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/tests/test_iframe.py new/branca-0.4.0/tests/test_iframe.py --- old/branca-0.3.1/tests/test_iframe.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/tests/test_iframe.py 2020-02-17 15:46:35.000000000 +0100 @@ -7,6 +7,8 @@ import branca.element as elem +import pytest + from selenium.webdriver import Firefox from selenium.webdriver.firefox.options import Options @@ -21,6 +23,7 @@ iframe.render() +@pytest.mark.headless def test_rendering_utf8_iframe(): iframe = elem.IFrame(html=u'<p>Cerrahpaşa Tıp Fakültesi</p>') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/branca-0.3.1/tests/test_notebooks.py new/branca-0.4.0/tests/test_notebooks.py --- old/branca-0.3.1/tests/test_notebooks.py 2018-11-05 20:10:43.000000000 +0100 +++ new/branca-0.4.0/tests/test_notebooks.py 2020-02-17 15:46:35.000000000 +0100 @@ -37,7 +37,8 @@ _nblist = [x for x in os.listdir(_filepath) if x.endswith('.ipynb')] for fn in TestNotebooks._nblist: - setattr(TestNotebooks, - 'test_'+branca.utilities._camelify(fn[:-6]), - NotebookTester(TestNotebooks._filepath+fn).__call__ - ) + setattr( + TestNotebooks, + 'test_'+branca.utilities._camelify(fn[:-6]), + NotebookTester(TestNotebooks._filepath+fn).__call__ + )