Skip to content

Commit

Permalink
Merge pull request #122 from SciTools-incubator/bin_imt_delete
Browse files Browse the repository at this point in the history
Documentation rebuild and version update to include the new util script
  • Loading branch information
Malcolm Brooks authored Oct 29, 2018
2 parents ee02160 + bc9eb6e commit f9b0b51
Show file tree
Hide file tree
Showing 71 changed files with 15,549 additions and 2,206 deletions.
2 changes: 1 addition & 1 deletion ImageMetaTag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Set constants/properties of ImageMetaTag (before any of it is imported)
# see release_process for details on incrementing the version
__version__ = '0.7.5'
__version__ = '0.7.6'
__documentation__ = 'http://scitools-incubator.github.io/image-meta-tag/build/html/'
# list fo file formats which are valid for saving metadata to:
META_IMG_FORMATS = ['png']
Expand Down
34 changes: 17 additions & 17 deletions ImageMetaTag/img_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ def sort_keys(self, sort_methods, devmode=False):
Valid sort methods so far are mostly focused on meteorological terms,
and include:
* 'sort' - just an ordinary sort
* 'level' or 'numeric' - starting with the surface and working \
upwards, then 'special' levels like cross \
Expand Down Expand Up @@ -797,14 +798,13 @@ def dict_split(in_dict, n_split=None, size_split=None, extra_opts=None):
in_dict - the dictionary to split
Options:
* n_split - the number of dictionaries to break the in_dict up into.
* size_split - the size of the required output dictionaries.
* extra_opts - If supplied as an iterable, this routine will yield a \
tuple containing the output sub-dictionary and then each \
of the elements of extra_opts.
* n_split - the number of dictionaries to break the in_dict up into.
* size_split - the size of the required output dictionaries.
* extra_opts - If supplied as an iterable, this routine will yield a \
tuple containing the output sub-dictionary and then each \
of the elements of extra_opts.
.. note:: One, and only one, of n_slpit, or size_split must be specified,
.. note:: One, and only one, of n_slpit, or size_split must be specified,\
as an integer.
'''
Expand Down Expand Up @@ -864,13 +864,15 @@ def simple_dict_filter(simple_dict, tests, raise_key_mismatch=False):
against a set of tests.
An example set of tests:
tests = {'number of rolls': ['6 simulated rolls',
'216 simulated rolls',
'1296 simulated rolls'],
'plot color': None,
'image compression': None,
'plot type': ['Histogram', ('All', ['Histogram', 'Line plots'])],
'image trim': None}
::
tests = {'number of rolls': ['6 simulated rolls',
'216 simulated rolls',
'1296 simulated rolls'],
'plot color': None,
'image compression': None,
'plot type': ['Histogram', ('All', ['Histogram', 'Line plots'])],
'image trim': None}
Here, the 'number of rolls' is restricted to a simple list.
The plot type is filtered according to 'Histogram', and there is also a
Expand All @@ -880,13 +882,11 @@ def simple_dict_filter(simple_dict, tests, raise_key_mismatch=False):
The other image characteristics are not filtered.
Options:
* raise_key_mismatch - if True, then attempting to test a dictionary \
with a missing key will raise and exception. \
Default is to return all False
Default is to return all False.
Returns three logicals:
* The first indicates whether the input dict passes the simple tests
* The second indicates whether the input dict is part of the grouped \
elements of the test (the ['Histogram', 'Line plots'] list).
Expand Down
2 changes: 1 addition & 1 deletion ImageMetaTag/javascript/imt_dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ImageMetaTag dropdown menu scripting - vn0.7.5
// ImageMetaTag dropdown menu scripting - vn0.7.6
// ImageMetaTag is a python package built around a wrapper for savefig in
// matplotlib, which adds metadata tags to supported image file formats.
// See https://github.com/SciTools-incubator/image-meta-tag for details.
Expand Down
124 changes: 67 additions & 57 deletions ImageMetaTag/webpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,45 +75,48 @@ def write_full_page(img_dict, filepath, title, page_filename=None, tab_s_name=No
Currently only able to write out a page with horizontal dropdown menus, but other
webpage styles could be added.
* page_filename - the file name, within the directory (defaults to the name of the file) \
but can be set if tab_s_name is also used.
* tab_s_name : used to denote the name of the page, when it is used as a frame \
of a larger page.
* preamble : html text added at the top of the <body> text, but before the ImageMetaTag \
section. Can be quite extensive.
* postable : html text added after the ImageMetaTag section. A link to the ImageMetaTag \
documentation will be appended unless postamble_no_imt_link is True.
* postamble_no_imt_link : if True, no link to the ImageMetaTag documentation will be added \
to the postamble.
* initial_selectors - A list of initial values for the selectors, to be passed into \
:func:`ImageMetaTag.webpage.write_js_setup`.
* show_selector_names - switches on displaying the selector full names defined by the \
:class:`ImageMetaTag.ImageDict`.full_name_mapping
* show_singleton_selectors - When set to False, selectors that have only one element are \
not displayed (default=True).
* optgroups - The contents of selectors can be grouped together to make large lists \
more readable. This is passed into \
:func:`ImageMetaTag.webpage.write_js_to_header`.
* url_type - determines the type of URL at the bottom of the ImageMetaTag section. Can be \
'int' or 'str'.
* only_show_rel_url - If True, the wepage will only show relative urls in is link section.
* verbose - If True, stdout will be more verbose
* style - the style of output page to write, currently only 'horiz dropdowns' is valid
* write_intmed_tmpfile - If True, files are written out to temporary filenames and then \
moved when completed.
* description - html description metadata
* keywords - html keyword metadata
* compression - default False. If True, then the json data object will be compressed \
using zlib string compression. When read into the browser, we will use \
pako to inflate it (https://github.com/nodeca/pako)
* css - Optional CSS file used to style webpage. By default a small amount of css is \
written out in the page header.
* load_err_msg - additional message to show after 'Please wait while the page is loading'. \
default is None, but very large pages can crash with Internet Explorer so \
a message along the lines of this may be useful:
'If the page does not load correctly in Internet Explorer, please try using firefox or Chrome.'
Returns a list of files that the the created webpage is dependent upon
Options:
* page_filename - the file name, within the directory (defaults to the name of the file) \
but can be set if tab_s_name is also used.
* tab_s_name : used to denote the name of the page, when it is used as a frame \
of a larger page.
* preamble : html text added at the top of the <body> text, but before the ImageMetaTag \
section. Can be quite extensive.
* postable : html text added after the ImageMetaTag section. A link to the ImageMetaTag \
documentation will be appended unless postamble_no_imt_link is True.
* postamble_no_imt_link : if True, no link to the ImageMetaTag documentation will be added \
to the postamble.
* initial_selectors - A list of initial values for the selectors, to be passed into \
:func:`ImageMetaTag.webpage.write_js_setup`.
* show_selector_names - switches on displaying the selector full names defined by the \
:class:`ImageMetaTag.ImageDict`.full_name_mapping
* show_singleton_selectors - When set to False, selectors that have only one element are \
not displayed (default=True).
* optgroups - The contents of selectors can be grouped together to make large lists \
more readable. This is passed into \
:func:`ImageMetaTag.webpage.write_js_to_header`.
* url_type - determines the type of URL at the bottom of the ImageMetaTag section. Can be \
'int' or 'str'.
* only_show_rel_url - If True, the wepage will only show relative urls in is link section.
* verbose - If True, stdout will be more verbose
* style - the style of output page to write, currently only 'horiz dropdowns' is valid
* write_intmed_tmpfile - If True, files are written out to temporary filenames and then \
moved when completed.
* description - html description metadata
* keywords - html keyword metadata
* compression - default False. If True, then the json data object will be compressed \
using zlib string compression. When read into the browser, we will use \
pako to inflate it (https://github.com/nodeca/pako)
* css - Optional CSS file used to style webpage. By default a small amount of css is \
written out in the page header.
* load_err_msg - additional message to show after 'Please wait while the page is loading'. \
default is None, but very large pages can crash with Internet Explorer so \
a message along the lines of this may be useful: 'If the page does not \
load correctly in Internet Explorer, please try using firefox or Chrome.'
Returns a list of files that the the created webpage is dependent upon.
'''

page_dependencies = []
Expand Down Expand Up @@ -746,28 +749,35 @@ def compress_string(in_str):
file_mode = 'w'
return comp_str, file_mode

def write_js_placeholders(img_dict, file_obj=None, dict_depth=None, selector_prefix=None,
def write_js_placeholders(img_dict, file_obj=None, dict_depth=None,
selector_prefix=None,
style='horiz dropdowns', level_names=False,
show_singleton_selectors=True,
animated_level=None, load_err_msg=None):
'''
Writes the placeholders into the page body, for the javascript to manipulate
* file_obj - an open file object to write to
* dict_dept - the depth of the :class:`ImageMetaTag.ImageDict` being written
* selector_prefix - prefix for the variable names of the selectors (these are visible to \
those people viewing the webpage!)
* style - In future, it would be great to write out different types of webpages. For now \
they are always horizontal dropdown menus: 'horiz dropdowns'.
* show_singleton_selectors - When set to False, selectors that have only one element are \
not displayed (default=True).
* level_names - if supplied, this need to be a list of full names, for the selectors, of \
length dict_depth.
* animated_level - if supplied, as a string, this will be used to label the animator buttons.
* load_err_msg - additional message to show after 'Please wait while the page is loading'. \
default is None, but very large pages can crash with Internet Explorer so \
a message along the lines of this may be useful:
'If the page does not load correctly in Internet Explorer, please try using firefox or Chrome.'
Writes the placeholders into the page body, for the javascript to
manipulate
* file_obj - an open file object to write to
* dict_dept - the depth of the :class:`ImageMetaTag.ImageDict` \
being written
* selector_prefix - prefix for the variable names of the selectors \
(these are visible to people viewing the webpage!)
* style - In future, it would be great to write out different types of \
webpages. For now they are always horizontal dropdown menus.
* show_singleton_selectors - When set to False, selectors that have \
only one element are not displayed \
(default=True).
* level_names - if supplied, this need to be a list of full names, for \
the selectors, of length dict_depth.
* animated_level - if supplied, as a string, this will be used to label \
the animator buttons.
* load_err_msg - additional message to show after 'Please wait while the \
page is loading'. default is None, but very large pages \
can crash with Internet Explorer so a message along the \
lines of this may be useful: 'If the page does not load \
correctly in Internet Explorer, please try using \
firefox or Chrome.'
'''

if not show_singleton_selectors:
Expand Down
2 changes: 1 addition & 1 deletion bin/rm_imt_images
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and http://scitools-incubator.github.io/image-meta-tag/build/html/index.html
This script operates on a ImageMetaTag database file (imt.db in any examples).
Basic example:
imt_rm_images imt.db file.png file2.png
rm_imt_images imt.db file.png file2.png
this would delete file1.png and file2.png from disk and the imt.db file
Usage with wildcards:
Expand Down
Binary file modified docs/build/doctrees/ImageDict.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/db.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/savefig.doctree
Binary file not shown.
Binary file added docs/build/doctrees/scripts.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/simple.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/test.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/versions.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/webpage.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 2af4d4202d15de90f1a1df833f6c38d4
config: 6c1c8e305c34b912ce797626954b4f73
tags: 645f666f9bcd5a90fca523b33c5a78b7
Loading

0 comments on commit f9b0b51

Please sign in to comment.