Skip to content

Commit

Permalink
Merge pull request #7 from pytroll/feature-cis
Browse files Browse the repository at this point in the history
Add travis and appveyor test configs
  • Loading branch information
djhoese committed Aug 26, 2018
2 parents b033650 + 8ff3e68 commit 8afdcf5
Show file tree
Hide file tree
Showing 12 changed files with 292 additions and 246 deletions.
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
language: python
env:
global:
# Set defaults to avoid repeating in most cases
- NUMPY_VERSION=stable
- MAIN_CMD='python setup.py'
- CONDA_DEPENDENCIES='sphinx pillow coveralls coverage codecov mock trollimage aggdraw pytest pytest-cov'
- PIP_DEPENDENCIES=''
- SETUP_XVFB=False
- EVENT_TYPE='push pull_request'
- SETUP_CMD='test'
- CONDA_CHANNELS='conda-forge'
matrix:
include:
- env: PYTHON_VERSION=2.7
os: linux
language: generic
- env: PYTHON_VERSION=2.7
os: osx
language: generic
- env: PYTHON_VERSION=3.6
os: linux
language: generic
- env: PYTHON_VERSION=3.6
os: osx
language: generic
install:
- git clone --depth 1 git://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
# See https://github.com/conda/conda/issues/7626#issuecomment-412922028
- conda config --remove channels defaults
- conda install -y $CONDA_DEPENDENCIES
script:
- pytest --cov=pydecorate test.py
after_success:
- if [[ $PYTHON_VERSION == 3.6 ]]; then coveralls; codecov; fi
deploy:
- provider: pypi
user: dhoese
password:
secure: BpBu41whAVlAsWmfBBJ0sXod3tgqy5Wgy8j2Z5BthFt90l6JNKcyTJDYY4Zi7YzDruZtPDyBtFURI5NZTaFnFQKsxxG5f+n6dDZR7eQ5x/Nh3Zb+kdx42T8ZtGaJC0Q2QdjGdbulyFz8xQC/vGujEDbe+0dsSR9otampGUhvbdk=
distributions: sdist bdist_wheel
skip_existing: true
on:
tags: true
repo: pytroll/pydecorate
File renamed without changes.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
recursive-include docs/source *
include docs/Makefile
recursive-include pydecorate/fonts *
recursive-include pydecorate/fonts *
include LICENSE.txt
9 changes: 0 additions & 9 deletions README.md

This file was deleted.

17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pydecorate
==========

.. image:: https://travis-ci.org/pytroll/pydecorate.svg?branch=master
:target: https://travis-ci.org/pytroll/pydecorate

.. image:: https://ci.appveyor.com/api/projects/status/61r5wqu2j2ay07ns/branch/master?svg=true
:target: https://ci.appveyor.com/project/pytroll/pydecorate/branch/master

.. image:: https://coveralls.io/repos/github/pytroll/pydecorate/badge.svg?branch=master
:target: https://coveralls.io/github/pytroll/pydecorate?branch=master

Pydecorate is a package for decorating PIL images with logos, texts, and color
scales.

Originally created by Hrobjartur Thorsteinsson
November 2013, from Norrkoping, Sweden
44 changes: 44 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
environment:
global:
PYTHON: "C:\\conda"
MINICONDA_VERSION: "latest"
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
CONDA_DEPENDENCIES: "sphinx pillow coverage mock trollimage aggdraw pytest pytest-cov"
PIP_DEPENDENCIES: ""
CONDA_CHANNELS: "conda-forge"

matrix:
- PYTHON: "C:\\Python27_64"
PYTHON_VERSION: "2.7"
PYTHON_ARCH: "64"
NUMPY_VERSION: "stable"

- PYTHON: "C:\\Python36_64"
PYTHON_VERSION: "3.6"
PYTHON_ARCH: "64"
NUMPY_VERSION: "stable"

install:
- "git clone --depth 1 git://github.com/astropy/ci-helpers.git"
- "powershell ci-helpers/appveyor/install-miniconda.ps1"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "activate test"

build: false # Not a C# project, build stuff at the test step instead.

test_script:
# Build the compiled extension and run the project tests
- "%CMD_IN_ENV% pytest test.py"

after_test:
# If tests are successful, create a whl package for the project.
- "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst"
- ps: "ls dist"

artifacts:
# Archive the generated wheel package in the ci.appveyor.com build report.
- path: dist\*

#on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse
#
69 changes: 36 additions & 33 deletions doc/source/usage.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@

.. sectnum::
:depth: 4
:start: 2
:suffix: .

Usage
-----

Expand All @@ -26,12 +20,14 @@ instantiate a decorator object with the PIL image as argument,


features
^^^^^^^^^^
^^^^^^^^

Pydecorate supports adding features such as picures and logos,
text, color scales and legends to your PIL image.

logos
++++++
+++++

A simple use case is to add a couple of logos.
From the extracted source directory you can add a couple of
demonstration logos:
Expand All @@ -42,11 +38,12 @@ demonstration logos:
>>> img.show()

.. image:: images/logo_image.png
:width: 400px
:align: center
:width: 400px
:align: center

text
+++++
++++

To add text, you could do:

>>> dc.add_text("MSG SEVIRI\nThermal blue marble\n1/1/1977 00:00")
Expand All @@ -56,8 +53,8 @@ To add text, you could do:
>>> img.show()

.. image:: images/text_and_logo_image.png
:width: 400px
:align: center
:width: 400px
:align: center

Notice how the height style of the logos follow the height of the
text that was entered. This is because the current height style of
Expand All @@ -74,7 +71,8 @@ To use this font you must pass it as an optional argument as so,
>>> dc.add_text("MSG SEVIRI\nThermal blue marble\n1/1/1977 00:00",font=font)

scales and legends (DRAFT)
+++++++++++++++++++++++
++++++++++++++++++++++++++

PyDecorate can work with trollimage colormap objects to add colour scales.
To add some logos along with a standard scale feature based on the 'rdbu'
scale from trollmap one might do as follows,
Expand All @@ -87,8 +85,8 @@ scale from trollmap one might do as follows,
>>> dc.add_scale(rdbu,extend=True)

.. image:: images/logo_and_scale1.png
:width: 400px
:align: center
:width: 400px
:align: center

Note that the extend=True option sets the scale feature to extend to the full
available space. Without this option the scale will inherit the previous width,
Expand All @@ -107,8 +105,8 @@ directive,
>>> dc.add_scale(rdbu,extend=True)

.. image:: images/logo_and_scale2.png
:width: 400px
:align: center
:width: 400px
:align: center

To separate the color scale to the right hand side, simply
throw in an alignment directive between the logos and the scale,
Expand All @@ -123,20 +121,22 @@ throw in an alignment directive between the logos and the scale,
>>> dc.add_scale(rdbu,extend=True)

.. image:: images/logo_and_scale3.png
:width: 400px
:align: center
:width: 400px
:align: center

More on feature placement options in the following section.

placement
^^^^^^^^^^^^^^
^^^^^^^^^

The decorator allows the cursor to be relocated and alligned to different sides of the image.
By default the cursor writes horizontally from the top-left corner. The cursor can however be
easily relocated at any other side of the image, and the vertical and horizontal write orientation
can be changed.

alignment
++++++++++++++
+++++++++

Continuing from the previous example,
we can align the cursor to the bottom-right corner, by executing

Expand All @@ -150,8 +150,8 @@ progressing leftwards. E.g.
>>> dc.add_logo("logos/NASA_Logo.gif")

.. image:: images/alignment_image1.png
:width: 400px
:align: center
:width: 400px
:align: center

Note: Currently the decorator does not provide an easy option for centered placement
of features. However the cursor position may be set manually as part of the style
Expand All @@ -160,11 +160,12 @@ arguments to achieve this kind of placement, e.g.
>>> dc.add_text("This is a manually\nplaced text\nover here.", cursor=[400,480])

.. image:: images/alignment_image2.png
:width: 400px
:align: center
:width: 400px
:align: center

new line
+++++++++

As with typewriters, the decorator can also progress to a new line of features.
Starting from our first example,

Expand All @@ -173,11 +174,12 @@ Starting from our first example,
>>> dc.add_logo("logos/pytroll_light_big.png")

.. image:: images/alignment_image3.png
:width: 400px
:align: center
:width: 400px
:align: center

horizontal/vertical writing
++++++++++++++++++++++++++++

The orientation of the cursor writes can be changed from vertical to horizontal writing.
The following statements will write some features vertically,

Expand All @@ -192,11 +194,12 @@ Note that resetting the height of text to zero prevents the text feature from in
of the previously added feature and allows it to expand to the necessary height.

.. image:: images/alignment_image4.png
:width: 400px
:align: center
:width: 400px
:align: center

styles
^^^^^^^^^^^^^^
^^^^^^

The decorator style settings is a dictionary of
options that is retentive between successive operations
(state machine), all except for the :attr:`cursor` attribute
Expand Down Expand Up @@ -237,7 +240,7 @@ to be repeated on successive calls,
>>> dc.add_text("Some text",font=font)

.. image:: images/style_retention.png
:width: 400px
:align: center
:width: 400px
:align: center


2 changes: 2 additions & 0 deletions pydecorate/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
except ImportError:
print("ImportError: Missing module: ImageDraw")

from .decorator_base import DecoratorBase


class Decorator(DecoratorBase):

Expand Down
2 changes: 1 addition & 1 deletion pydecorate/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"""
"""

__version__ = '0.1.0'
__version__ = '0.2.0a0.dev0'
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
version = imp.load_source('pydecorate.version', 'pydecorate/version.py')

setup(name='pydecorate',
version="v0.1.0",
version=version.__version__,
description='Decorating PIL images: logos, texts, pallettes',
author='Hrobjartur Thorsteinsson',
author_email='thorsteinssonh@gmail.com',
Expand All @@ -56,12 +56,12 @@

# Project should use reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=['docutils>=0.3',
'pillow'],
install_requires=['pillow', 'aggdraw'],
scripts=[],
data_files=[],
test_suite="nose.collector",
tests_require=[],
# test_suite="",
tests_require=['pytest', 'mock'],
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',

zip_safe=False
)

0 comments on commit 8afdcf5

Please sign in to comment.