<commit_before># -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
#
# Astropy documentation build configuration file.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this file.
#
# All configuration values have a default. Some values are defined in
# the global Astropy configuration which is loaded here before anything else.
# See astropy.sphinx.conf for which values are set there.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('..'))
# IMPORTANT: the above commented section was generated by sphinx-quickstart, but
# is *NOT* appropriate for astropy or Astropy affiliated packages. It is left
# commented out with this explanation to make it clear why this should not be
# done. If the sys.path entry above is added, when the astropy.sphinx.conf
# import occurs, it will import the *source* version of astropy instead of the
# version installed (if invoked as "make html" or directly with sphinx), or the
# version in the build directory (if "python setup.py build_sphinx" is used).
# Thus, any C-extensions that are needed to build the documentation will *not*
# be accessible, and the documentation will not build correctly.

# Load all of the global Astropy configuration
from astropy.sphinx.conf import *

# -- General configuration ----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.1'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns.append('_templates')

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
rst_epilog += """
"""

# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = u'Packagename'
author = u'The Packagename Developers'
copyright = u'2012, ' + author

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

import packagename
# The short X.Y version.
version = packagename.__version__.split('-', 1)[0]
# The full version, including alpha/beta/rc tags.
release = packagename.__version__

# -- Options for HTML output ---------------------------------------------------

# A NOTE ON HTML THEMES
# The global astropy configuration uses a custom theme, 'bootstrap-astropy',
# which is installed along with astropy. A different theme can be used or
# the options for this theme can be modified by overriding some of the
# variables set in the global configuration. The variables set in the
# global configuration are listed below, commented out.

# Add any paths that contain custom themes here, relative to this directory.
# To use a different custom theme, add the directory containing the theme.
#html_theme_path = []

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes. To override the custom theme, set this to the
# name of a builtin theme or the name of a custom theme in html_theme_path.
#html_theme = None

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = ''

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = ''

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
html_title = '{0} v{1}'.format(project, release)

# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'

# -- Options for LaTeX output --------------------------------------------------

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [('index', project + '.tex', project + u' Documentation',
                    author, 'manual')]

# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', project.lower(), project + u' Documentation',
              [author], 1)]
<commit_msg>updated documentation for new project montage<commit_after># -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
#
# Astropy documentation build configuration file.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this file.
#
# All configuration values have a default. Some values are defined in
# the global Astropy configuration which is loaded here before anything else.
# See astropy.sphinx.conf for which values are set there.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('..'))
# IMPORTANT: the above commented section was generated by sphinx-quickstart, but
# is *NOT* appropriate for astropy or Astropy affiliated packages. It is left
# commented out with this explanation to make it clear why this should not be
# done. If the sys.path entry above is added, when the astropy.sphinx.conf
# import occurs, it will import the *source* version of astropy instead of the
# version installed (if invoked as "make html" or directly with sphinx), or the
# version in the build directory (if "python setup.py build_sphinx" is used).
# Thus, any C-extensions that are needed to build the documentation will *not*
# be accessible, and the documentation will not build correctly.

# Load all of the global Astropy configuration
from astropy.sphinx.conf import *

# -- General configuration ----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.1'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns.append('_templates')

# This is added to the end of RST files - a good place to put substitutions to
# be used globally.
rst_epilog += """
"""

# -- Project information ------------------------------------------------------

# This does not *have* to match the package name, but typically does
project = u'montage'
author = u'Thomas Robitaille'
copyright = u'2012, ' + author

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

import montage
# The short X.Y version.
version = montage.__version__.split('-', 1)[0]
# The full version, including alpha/beta/rc tags.
release = montage.__version__

# -- Options for HTML output ---------------------------------------------------

# A NOTE ON HTML THEMES
# The global astropy configuration uses a custom theme, 'bootstrap-astropy',
# which is installed along with astropy. A different theme can be used or
# the options for this theme can be modified by overriding some of the
# variables set in the global configuration. The variables set in the
# global configuration are listed below, commented out.

# Add any paths that contain custom themes here, relative to this directory.
# To use a different custom theme, add the directory containing the theme.
#html_theme_path = []

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes. To override the custom theme, set this to the
# name of a builtin theme or the name of a custom theme in html_theme_path.
#html_theme = None

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = ''

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = ''

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
html_title = '{0} v{1}'.format(project, release)

# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'

# -- Options for LaTeX output --------------------------------------------------

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [('index', project + '.tex', project + u' Documentation',
                    author, 'manual')]

# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', project.lower(), project + u' Documentation',
              [author], 1)]
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
#
# complexity documentation build configuration file, created by
# sphinx-quickstart on Tue Jul  9 22:26:36 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))

cwd = os.getcwd()
parent = os.path.dirname(cwd)
sys.path.append(parent)

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'django-functest'
copyright = u'2016, Luke Plant'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = "1.0.3-dev1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False

# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
#html_title = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}

# If false, no module index is generated.
#html_domain_indices = True

# If false, no index is generated.
#html_use_index = True

# If true, the index is split into individual pages for each letter.
#html_split_index = False

# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'django-functestdoc'

# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
  ('index', 'django-functest.tex', u'django-functest Documentation',
   u'Luke Plant', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True

# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'django-functest', u'django-functest Documentation',
     [u'Luke Plant'], 1)
]

# If true, show URL addresses after external links.
#man_show_urls = False

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'django-functest', u'django-functest Documentation',
   u'Luke Plant', 'django-functest', 'One line description of project.',
   'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
<commit_msg>Docs update<commit_after># -*- coding: utf-8 -*-
#
# complexity documentation build configuration file, created by
# sphinx-quickstart on Tue Jul  9 22:26:36 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))

cwd = os.getcwd()
parent = os.path.dirname(cwd)
sys.path.append(parent)

# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix of source filenames.
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'django-functest'
copyright = u'2016-2018, Luke Plant'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "1.0"
# The full version, including alpha/beta/rc tags.
release = "1.0.3-dev1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False

# -- Options for HTML output ---------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
#html_title = None

# A shorter title for the navigation bar.  Default is the same as html_title.
#html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}

# If false, no module index is generated.
#html_domain_indices = True

# If false, no index is generated.
#html_use_index = True

# If true, the index is split into individual pages for each letter.
#html_split_index = False

# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'django-functestdoc'

# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
  ('index', 'django-functest.tex', u'django-functest Documentation',
   u'Luke Plant', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True

# -- Options for manual page output --------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    ('index', 'django-functest', u'django-functest Documentation',
     [u'Luke Plant'], 1)
]

# If true, show URL addresses after external links.
#man_show_urls = False

# -- Options for Texinfo output ------------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
  ('index', 'django-functest', u'django-functest Documentation',
   u'Luke Plant', 'django-functest', 'One line description of project.',
   'Miscellaneous'),
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
<|endoftext|>


<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Camoco documentation build configuration file, created by
# sphinx-quickstart on Tue Dec 20 15:10:35 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.coverage',
    'sphinx.ext.mathjax',
    'sphinx.ext.ifconfig',
    'sphinx.ext.viewcode',
    'sphinx.ext.githubpages',
    'sphinx.ext.napoleon',
    'IPython.sphinxext.ipython_console_highlighting',
    'IPython.sphinxext.ipython_directive'
    ]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Camoco'
copyright = '2016, Rob Schaefer'
author = 'Rob Schaefer'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
import camoco
version = camoco.__version__
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
#html_theme = 'sphinx_materialdesign_theme'

# Html logo in drawer.
# Fit in the drawer at the width of image is 240 px.
#html_logo = '_static/logo.jpg'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
html_sidebars = {
    '**': [
        'globaltoc.html',
        'relations.html',  # needs 'show_related': True theme option to display
        'searchbox.html',
    ]
}

htmlhelp_basename = 'Camocodoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',

    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'Camoco.tex', 'Camoco Documentation',
     'Rob Schaefer', 'manual'),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, 'camoco', 'Camoco Documentation',
     [author], 1)
]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'Camoco', 'Camoco Documentation',
     author, 'Camoco', 'One line description of project.',
     'Miscellaneous'),
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
<commit_msg>update theme<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Camoco documentation build configuration file, created by
# sphinx-quickstart on Tue Dec 20 15:10:35 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.todo',
    'sphinx.ext.coverage',
    'sphinx.ext.mathjax',
    'sphinx.ext.ifconfig',
    'sphinx.ext.viewcode',
    'sphinx.ext.githubpages',
    'sphinx.ext.napoleon',
    'IPython.sphinxext.ipython_console_highlighting',
    'IPython.sphinxext.ipython_directive'
    ]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'Camoco'
copyright = '2016, Rob Schaefer'
author = 'Rob Schaefer'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
import camoco
version = camoco.__version__
# The full version, including alpha/beta/rc tags.
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
html_theme = 'sphinx_materialdesign_theme'

# Html logo in drawer.
# Fit in the drawer at the width of image is 240 px.
#html_logo = '_static/logo.jpg'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
html_sidebars = {
    '**': [
        'globaltoc.html',
        'relations.html',  # needs 'show_related': True theme option to display
        'searchbox.html',
    ]
}

htmlhelp_basename = 'Camocodoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',

    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'Camoco.tex', 'Camoco Documentation',
     'Rob Schaefer', 'manual'),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, 'camoco', 'Camoco Documentation',
     [author], 1)
]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'Camoco', 'Camoco Documentation',
     author, 'Camoco', 'One line description of project.',
     'Miscellaneous'),
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
<|endoftext|>


<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# sklearn-rri documentation build configuration file.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__name__), '..'))

# -- General configuration ------------------------------------------------
needs_sphinx = '1.4'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
    'sphinx.ext.todo',
    'sphinx.ext.viewcode',
    'sphinx.ext.intersphinx',
	'sphinx.ext.napoleon']

intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
import sklearn_rri
project = 'sklearn-rri'
copyright = '2017, Michał Ciesielczyk'
author = 'Michał Ciesielczyk'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = sklearn_rri.__version__[:sklearn_rri.__version__.rfind('.')]
# The full version, including alpha/beta/rc tags.
release = sklearn_rri.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
    '**': [
        'about.html',
        'navigation.html',
        'relations.html',  # needs 'show_related': True theme option to display
        'searchbox.html',
        'donate.html',
    ]
}

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'sklearn-rridoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',

    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'sklearn-rri.tex', 'sklearn-rri Documentation', author,
	'manual'),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, 'sklearn-rri', 'sklearn-rri Documentation',
     [author], 1)
]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'sklearn-rri', 'sklearn-rri Documentation',
     author, 'sklearn-rri', 'One line description of project.',
     'Miscellaneous'),
]

# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

<commit_msg>encoding fix<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# sklearn-rri documentation build configuration file.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__name__), '..'))

# -- General configuration ------------------------------------------------
needs_sphinx = '1.4'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
    'sphinx.ext.todo',
    'sphinx.ext.viewcode',
    'sphinx.ext.intersphinx',
	'sphinx.ext.napoleon']

intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
import sklearn_rri
project = 'sklearn-rri'
copyright = '2017, Michal Ciesielczyk'
author = 'Michal Ciesielczyk'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = sklearn_rri.__version__[:sklearn_rri.__version__.rfind('.')]
# The full version, including alpha/beta/rc tags.
release = sklearn_rri.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
    '**': [
        'about.html',
        'navigation.html',
        'relations.html',  # needs 'show_related': True theme option to display
        'searchbox.html',
        'donate.html',
    ]
}

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'sklearn-rridoc'

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',

    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'sklearn-rri.tex', 'sklearn-rri Documentation', author,
	'manual'),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
    (master_doc, 'sklearn-rri', 'sklearn-rri Documentation',
     [author], 1)
]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (master_doc, 'sklearn-rri', 'sklearn-rri Documentation',
     author, 'sklearn-rri', 'One line description of project.',
     'Miscellaneous'),
]

# -- Options for Epub output ----------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']

<|endoftext|>


<commit_before>import os
import shutil
import sys
import time
from selenium import webdriver
from seleniumbase.config import settings
from seleniumbase.core.style_sheet import style
from seleniumbase.fixtures import page_actions

LATEST_REPORT_DIR = settings.LATEST_REPORT_DIR
ARCHIVE_DIR = settings.REPORT_ARCHIVE_DIR
HTML_REPORT = settings.HTML_REPORT
RESULTS_TABLE = settings.RESULTS_TABLE

def get_timestamp():
    return str(int(time.time() * 1000))

def process_successes(test, test_count):
    return(
        '"%s","%s","%s","%s","%s","%s","%s","%s","%s"' % (
            test_count,
            "Success",
            "-",
            "-",
            "-",
            test.browser,
            get_timestamp()[:-3],
            test.id(),
            "*"))

def process_failures(test, err, test_count, browser_type):
    bad_page_image = "failure_test_%s.jpg" % test_count
    bad_page_data = "failure_test_%s.txt" % test_count
    page_actions.save_screenshot(
        test.driver, bad_page_image, folder=LATEST_REPORT_DIR)
    page_actions.save_test_failure_data(
        test.driver, bad_page_data, browser_type, folder=LATEST_REPORT_DIR)
    exc_info = '(Unknown Failure)'
    if sys.exc_info()[1]:
        exc_info = sys.exc_info()[1]
        if hasattr(exc_info, 'message'):
            exc_info = exc_info.message
    return(
        '"%s","%s","%s","%s","%s","%s","%s","%s","%s"' % (
            test_count,
            "FAILED!",
            bad_page_data,
            bad_page_image,
            test.driver.current_url,
            test.browser,
            get_timestamp()[:-3],
            test.id(),
            exc_info))

def clear_out_old_report_logs(archive_past_runs=True, get_log_folder=False):
        abs_path = os.path.abspath('.')
        file_path = abs_path + "/%s" % LATEST_REPORT_DIR
        if not os.path.exists(file_path):
            os.makedirs(file_path)

        if archive_past_runs:
            archive_timestamp = int(time.time())
            if not os.path.exists("%s/../%s/" % (file_path, ARCHIVE_DIR)):
                os.makedirs("%s/../%s/" % (file_path, ARCHIVE_DIR))
            archive_dir = "%s/../%s/report_%s" % (
                file_path, ARCHIVE_DIR, archive_timestamp)
            shutil.move(file_path, archive_dir)
            os.makedirs(file_path)
            if get_log_folder:
                return archive_dir
        else:
            # Just delete bad pages to make room for the latest run.
            filelist = [f for f in os.listdir(
                "./%s" % LATEST_REPORT_DIR) if f.startswith("failure_") or (
                f == HTML_REPORT) or (f.startswith("automation_failure")) or (
                f == RESULTS_TABLE)]
            for f in filelist:
                os.remove("%s/%s" % (file_path, f))

def add_bad_page_log_file(page_results_list):
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % LATEST_REPORT_DIR
    log_file = "%s/%s" % (file_path, RESULTS_TABLE)
    f = open(log_file, 'w')
    h_p1 = '''"Num","Result","Failure Info","Screenshot",'''
    h_p2 = '''"URL","Browser","Epoch Time",'''
    h_p3 = '''"Test Case Address","Additional Info"\n'''
    page_header = h_p1 + h_p2 + h_p3
    f.write(page_header)
    for line in page_results_list:
        f.write("%s\n" % line)
    f.close()

def archive_new_report_logs():
    log_string = clear_out_old_report_logs(get_log_folder=True)
    log_folder = log_string.split('/')[-1]
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % ARCHIVE_DIR
    report_log_path = "%s/%s" % (file_path, log_folder)
    return report_log_path

def add_results_page(html):
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % LATEST_REPORT_DIR
    results_file_name = HTML_REPORT
    results_file = "%s/%s" % (file_path, results_file_name)
    f = open(results_file, 'w')
    f.write(html)
    f.close()
    return results_file

def build_report(report_log_path, page_results_list,
                 successes, failures, browser_type,
                 hide_report):

    web_log_path = "file://%s" % report_log_path
    successes_count = len(successes)
    failures_count = len(failures)
    total_test_count = successes_count + failures_count

    tf_color = "#11BB11"
    if failures_count > 0:
        tf_color = "#EE3A3A"

    new_data = '''

TEST REPORT SUMMARY

TESTS PASSING: %s

     TESTS FAILING: %s

TOTAL TESTS RUN: %s

''' % (successes_count,
                               tf_color,
                               failures_count,
                               total_test_count)

    new_view_1 = '''

        %s
''' % new_data

    log_link_shown = '../%s%s/' % (
        ARCHIVE_DIR, web_log_path.split(ARCHIVE_DIR)[1])
    csv_link = '%s/%s' % (web_log_path, RESULTS_TABLE)
    csv_link_shown = '%s' % RESULTS_TABLE
    new_view_2 = '''

LOG FILES LINK:  %s

RESULTS TABLE:  %s

''' % (
        web_log_path, log_link_shown, csv_link, csv_link_shown)

    new_view_3 = '

'
    any_screenshots = False
    for line in page_results_list:
        line = line.split(',')
        if line[1] == '"FAILED!"':
            if not any_screenshots:
                any_screenshots = True
                new_view_3 += '''

                    FAILURE DATA
                    SCREENSHOT
                    LOCATION OF FAILURE

'''
            line = '%s' % (
                "file://" + report_log_path + '/' + line[2], line[2]) + '''

                ''' + '%s' % (
                "file://" + report_log_path + '/' + line[3], line[3]) + '''

                ''' + '%s' % (line[4], line[4])
            line = line.replace('"', '')
            new_view_3 += '
%s
\n' % line
    new_view_3 += '

'

    new_view_4 = ''
    if failures:
        new_view_4 = '

'
        new_view_4 += '''

LIST OF FAILING TESTS

'''
        for failure in failures:
            new_view_4 += '
%s
\n' % failure
        new_view_4 += '

'

    new_view_5 = ''
    if successes:
        new_view_5 = '

'
        new_view_5 += '''

LIST OF PASSING TESTS

'''
        for success in successes:
            new_view_5 += '
%s
\n' % success
        new_view_5 += '

'

    new_view = '%s%s%s%s%s' % (
        new_view_1, new_view_2, new_view_3, new_view_4, new_view_5)
    results_content = '%s' % new_view
    new_source = '%s%s' % (
        style, results_content)
    results_file = add_results_page(new_source)
    archived_results_file = report_log_path + '/' + HTML_REPORT
    shutil.copyfile(results_file, archived_results_file)
    print "\n* The latest html report page is located at:\n" + results_file
    print "\n* Files saved for this report are located at:\n" + report_log_path
    print ""
    if not hide_report:
        if browser_type == 'chrome':
            browser = webdriver.Chrome()
        else:
            browser = webdriver.Firefox()
        browser.get("file://%s" % archived_results_file)
        print "\n*** Close the html report window to continue. ***"
        while len(browser.window_handles):
            time.sleep(0.1)
        browser.quit()
<commit_msg>Format the exception with traceback<commit_after>import os
import shutil
import sys
import time
import traceback
from selenium import webdriver
from seleniumbase.config import settings
from seleniumbase.core.style_sheet import style
from seleniumbase.fixtures import page_actions

LATEST_REPORT_DIR = settings.LATEST_REPORT_DIR
ARCHIVE_DIR = settings.REPORT_ARCHIVE_DIR
HTML_REPORT = settings.HTML_REPORT
RESULTS_TABLE = settings.RESULTS_TABLE

def get_timestamp():
    return str(int(time.time() * 1000))

def process_successes(test, test_count):
    return(
        '"%s","%s","%s","%s","%s","%s","%s","%s","%s"' % (
            test_count,
            "Success",
            "-",
            "-",
            "-",
            test.browser,
            get_timestamp()[:-3],
            test.id(),
            "*"))

def process_failures(test, err, test_count, browser_type):
    bad_page_image = "failure_test_%s.jpg" % test_count
    bad_page_data = "failure_test_%s.txt" % test_count
    page_actions.save_screenshot(
        test.driver, bad_page_image, folder=LATEST_REPORT_DIR)
    page_actions.save_test_failure_data(
        test.driver, bad_page_data, browser_type, folder=LATEST_REPORT_DIR)
    exc_info = '(Unknown Failure)'
    if sys.exc_info()[1]:
        exc_info = traceback.format_exception(
            sys.exc_info()[0],
            sys.exc_info()[1],
            sys.exc_info()[2])[-1]
        exc_info = exc_info.replace('\n', ' ')
        exc_info = exc_info.replace(': Message: ', ': ')
        exc_info = exc_info.strip()
    return(
        '"%s","%s","%s","%s","%s","%s","%s","%s","%s"' % (
            test_count,
            "FAILED!",
            bad_page_data,
            bad_page_image,
            test.driver.current_url,
            test.browser,
            get_timestamp()[:-3],
            test.id(),
            exc_info))

def clear_out_old_report_logs(archive_past_runs=True, get_log_folder=False):
        abs_path = os.path.abspath('.')
        file_path = abs_path + "/%s" % LATEST_REPORT_DIR
        if not os.path.exists(file_path):
            os.makedirs(file_path)

        if archive_past_runs:
            archive_timestamp = int(time.time())
            if not os.path.exists("%s/../%s/" % (file_path, ARCHIVE_DIR)):
                os.makedirs("%s/../%s/" % (file_path, ARCHIVE_DIR))
            archive_dir = "%s/../%s/report_%s" % (
                file_path, ARCHIVE_DIR, archive_timestamp)
            shutil.move(file_path, archive_dir)
            os.makedirs(file_path)
            if get_log_folder:
                return archive_dir
        else:
            # Just delete bad pages to make room for the latest run.
            filelist = [f for f in os.listdir(
                "./%s" % LATEST_REPORT_DIR) if f.startswith("failure_") or (
                f == HTML_REPORT) or (f.startswith("automation_failure")) or (
                f == RESULTS_TABLE)]
            for f in filelist:
                os.remove("%s/%s" % (file_path, f))

def add_bad_page_log_file(page_results_list):
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % LATEST_REPORT_DIR
    log_file = "%s/%s" % (file_path, RESULTS_TABLE)
    f = open(log_file, 'w')
    h_p1 = '''"Num","Result","Failure Info","Screenshot",'''
    h_p2 = '''"URL","Browser","Epoch Time",'''
    h_p3 = '''"Test Case Address","Additional Info"\n'''
    page_header = h_p1 + h_p2 + h_p3
    f.write(page_header)
    for line in page_results_list:
        f.write("%s\n" % line)
    f.close()

def archive_new_report_logs():
    log_string = clear_out_old_report_logs(get_log_folder=True)
    log_folder = log_string.split('/')[-1]
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % ARCHIVE_DIR
    report_log_path = "%s/%s" % (file_path, log_folder)
    return report_log_path

def add_results_page(html):
    abs_path = os.path.abspath('.')
    file_path = abs_path + "/%s" % LATEST_REPORT_DIR
    results_file_name = HTML_REPORT
    results_file = "%s/%s" % (file_path, results_file_name)
    f = open(results_file, 'w')
    f.write(html)
    f.close()
    return results_file

def build_report(report_log_path, page_results_list,
                 successes, failures, browser_type,
                 hide_report):

    web_log_path = "file://%s" % report_log_path
    successes_count = len(successes)
    failures_count = len(failures)
    total_test_count = successes_count + failures_count

    tf_color = "#11BB11"
    if failures_count > 0:
        tf_color = "#EE3A3A"

    new_data = '''

TEST REPORT SUMMARY

TESTS PASSING: %s

     TESTS FAILING: %s

TOTAL TESTS RUN: %s

''' % (successes_count,
                               tf_color,
                               failures_count,
                               total_test_count)

    new_view_1 = '''

        %s
''' % new_data

    log_link_shown = '../%s%s/' % (
        ARCHIVE_DIR, web_log_path.split(ARCHIVE_DIR)[1])
    csv_link = '%s/%s' % (web_log_path, RESULTS_TABLE)
    csv_link_shown = '%s' % RESULTS_TABLE
    new_view_2 = '''

LOG FILES LINK:  %s

RESULTS TABLE:  %s

''' % (
        web_log_path, log_link_shown, csv_link, csv_link_shown)

    new_view_3 = '

'
    any_screenshots = False
    for line in page_results_list:
        line = line.split(',')
        if line[1] == '"FAILED!"':
            if not any_screenshots:
                any_screenshots = True
                new_view_3 += '''

                    FAILURE DATA
                    SCREENSHOT
                    LOCATION OF FAILURE

'''
            line = '%s' % (
                "file://" + report_log_path + '/' + line[2], line[2]) + '''

                ''' + '%s' % (
                "file://" + report_log_path + '/' + line[3], line[3]) + '''

                ''' + '%s' % (line[4], line[4])
            line = line.replace('"', '')
            new_view_3 += '
%s
\n' % line
    new_view_3 += '

'

    new_view_4 = ''
    if failures:
        new_view_4 = '

'
        new_view_4 += '''

LIST OF FAILING TESTS

'''
        for failure in failures:
            new_view_4 += '
%s
\n' % failure
        new_view_4 += '

'

    new_view_5 = ''
    if successes:
        new_view_5 = '

'
        new_view_5 += '''

LIST OF PASSING TESTS

'''
        for success in successes:
            new_view_5 += '
%s
\n' % success
        new_view_5 += '

'

    new_view = '%s%s%s%s%s' % (
        new_view_1, new_view_2, new_view_3, new_view_4, new_view_5)
    results_content = '%s' % new_view
    new_source = '%s%s' % (
        style, results_content)
    results_file = add_results_page(new_source)
    archived_results_file = report_log_path + '/' + HTML_REPORT
    shutil.copyfile(results_file, archived_results_file)
    print "\n* The latest html report page is located at:\n" + results_file
    print "\n* Files saved for this report are located at:\n" + report_log_path
    print ""
    if not hide_report:
        if browser_type == 'chrome':
            browser = webdriver.Chrome()
        else:
            browser = webdriver.Firefox()
        browser.get("file://%s" % archived_results_file)
        print "\n*** Close the html report window to continue. ***"
        while len(browser.window_handles):
            time.sleep(0.1)
        browser.quit()
<|endoftext|>


<commit_before># -*- coding: utf-8 -*-
#
'''
I/O for Ansys's msh format, cf.
<https://www.sharcnet.ca/Software/TGrid/pdf/ug/appb.pdf>.
'''
from . __about__ import __version__

from itertools import islice
import numpy
import re
import warnings

def read(filename):
    # Initialize the data optional data fields
    field_data = {}
    cell_data = {}
    point_data = {}

    points = None
    cells = {}

    with open(filename) as f:
        while True:
            try:
                line = next(islice(f, 1))
            except StopIteration:
                break

            # expect the line to have the form
            #  (<index> [...]
            out = re.match('\s*\(\s*([0-9]+).*', line)
            assert out
            index = int(out.group(1))

            if index == 1:
                # header
                # (1 "<text>")
                pass
            elif index == 2:
                # dimensionality
                # (2 3)
                pass
            elif index == 10:
                # points
                # (10 (zone-id first-index last-index type ND)
                out = re.match('\s*\(\s*10\s+\(([^\)]+)\).*', line)
                a = [int(num, 16) for num in out.group(1).split()]
                zone_id = a[0]
                if zone_id == 0:
                    # a declaration of the total number of points
                    continue

                assert len(a) > 4
                first_index = a[1]
                last_index = a[2]
                num_points = last_index - first_index + 1
                dim = a[4]

                # read point data
                points = numpy.empty((num_points, dim))
                for k in range(num_points):
                    line = next(islice(f, 1))
                    dat = line.split()
                    assert len(dat) == dim
                    for d in range(dim):
                        points[k][d] = float(dat[d])

                # make sure that the point data set is properly closed
                line = next(islice(f, 1))
                assert re.match('\s*\)\s*\)\s*', line)
            elif index == 12:
                # cells
                # (12 (zone-id first-index last-index type element-type))
                out = re.match('\s*\(\s*12\s+\(([^\)]+)\).*', line)
                a = [int(num, 16) for num in out.group(1).split()]
                zone_id = a[0]
                if zone_id == 0:
                    # a declaration of the total number of cells
                    continue

                assert len(a) > 4
                first_index = a[1]
                last_index = a[2]
                num_cells = last_index - first_index + 1
                element_type = a[4]

                if element_type == 1:
                    key = 'triangle'
                    num_nodes_per_cell = 3
                elif element_type == 2:
                    key = 'tetra'
                    num_nodes_per_cell = 4
                elif element_type == 3:
                    key = 'quad'
                    num_nodes_per_cell = 4
                elif element_type == 4:
                    key = 'hexa'
                    num_nodes_per_cell = 8
                elif element_type == 5:
                    key = 'pyra'
                    num_nodes_per_cell = 5
                elif element_type == 6:
                    key = 'wedge'
                    num_nodes_per_cell = 6
                else:
                    raise ValueError('Unknown element type %d.' % element_type)

                # read cell data
                data = numpy.empty((num_cells, num_nodes_per_cell), dtype=int)
                for k in range(num_cells):
                    line = next(islice(f, 1))
                    dat = line.split()
                    assert len(dat) == num_nodes_per_cell
                    data[k] = [int(d, 16) for d in dat]

                cells[key] = data

                # make sure that the point data set is properly closed
                line = next(islice(f, 1))
                assert re.match('\s*\)\s*\)\s*', line)
            else:
                warnings.warn('Unknown index \'%d\'. Skipping.' % index)
                # Skipping ahead to the closing bracket. Assume that, if the
                # line ends with a closing bracket, that's the one. Otherwise
                # skip to the next "))" line.
                if line[-1] == ')':
                    continue
                while re.match('\s*\)\s*\)\s*', line) is None:
                    line = next(islice(f, 1))

    return points, cells, point_data, cell_data, field_data

def write(
        filename,
        points,
        cells,
        point_data=None,
        cell_data=None,
        field_data=None
        ):
    point_data = {} if point_data is None else point_data
    cell_data = {} if cell_data is None else cell_data
    field_data = {} if field_data is None else field_data

    with open(filename, 'wb') as fh:
        # header
        fh.write(('(1 "meshio %s")\n' % __version__).encode('utf8'))

        # dimension
        dim = 2 if all(points[:, 2] == 0.0) else 3
        fh.write(('(2 %d)\n' % dim).encode('utf8'))

        # total number of nodes
        fh.write(('(10 (0 1 %x 0))\n' % len(points)).encode('utf8'))

        # total number of cells
        total_num_cells = sum([len(c) for c in cells])
        fh.write(('(12 (0 1 %x 0))\n' % total_num_cells).encode('utf8'))

        # Write nodes
        fh.write(('(10 (1 1 %x 1 %d))(\n' % points.shape).encode('utf8'))
        numpy.savetxt(fh, points, fmt='%.15e')
        fh.write(('))\n').encode('utf8'))

        # Write cells
        meshio_to_ansys_type = {
                'triangle': 1,
                'tetra': 2,
                'quad': 3,
                'hex': 4,
                'pyra': 5,
                'wedge': 6,
                }
        first_index = 0
        for key, values in cells.items():
            last_index = first_index + len(values) - 1
            fh.write((
                '(12 (1 %x %x 1 %d)(\n' %
                (first_index, last_index, meshio_to_ansys_type[key])
                ).encode('utf8'))
            numpy.savetxt(fh, values, fmt='%x')
            fh.write(('))\n').encode('utf8'))
            first_index = last_index + 1

    return
<commit_msg>ansys: don't convert index to int<commit_after># -*- coding: utf-8 -*-
#
'''
I/O for Ansys's msh format, cf.
<https://www.sharcnet.ca/Software/TGrid/pdf/ug/appb.pdf>.
'''
from . __about__ import __version__

from itertools import islice
import numpy
import re
import warnings

def read(filename):
    # Initialize the data optional data fields
    field_data = {}
    cell_data = {}
    point_data = {}

    points = None
    cells = {}

    with open(filename) as f:
        while True:
            try:
                line = next(islice(f, 1))
            except StopIteration:
                break

            # expect the line to have the form
            #  (<index> [...]
            out = re.match('\s*\(\s*([0-9]+).*', line)
            assert out
            index = out.group(1)

            if index == '1':
                # header
                # (1 "<text>")
                pass
            elif index == '2':
                # dimensionality
                # (2 3)
                pass
            elif index == '10':
                # points
                # (10 (zone-id first-index last-index type ND)
                out = re.match('\s*\(\s*10\s+\(([^\)]+)\).*', line)
                a = [int(num, 16) for num in out.group(1).split()]
                zone_id = a[0]
                if zone_id == 0:
                    # a declaration of the total number of points
                    continue

                assert len(a) > 4
                first_index = a[1]
                last_index = a[2]
                num_points = last_index - first_index + 1
                dim = a[4]

                # read point data
                points = numpy.empty((num_points, dim))
                for k in range(num_points):
                    line = next(islice(f, 1))
                    dat = line.split()
                    assert len(dat) == dim
                    for d in range(dim):
                        points[k][d] = float(dat[d])

                # make sure that the point data set is properly closed
                line = next(islice(f, 1))
                assert re.match('\s*\)\s*\)\s*', line)
            elif index == '12':
                # cells
                # (12 (zone-id first-index last-index type element-type))
                out = re.match('\s*\(\s*12\s+\(([^\)]+)\).*', line)
                a = [int(num, 16) for num in out.group(1).split()]
                zone_id = a[0]
                if zone_id == 0:
                    # a declaration of the total number of cells
                    continue

                assert len(a) > 4
                first_index = a[1]
                last_index = a[2]
                num_cells = last_index - first_index + 1
                element_type = a[4]

                if element_type == 1:
                    key = 'triangle'
                    num_nodes_per_cell = 3
                elif element_type == 2:
                    key = 'tetra'
                    num_nodes_per_cell = 4
                elif element_type == 3:
                    key = 'quad'
                    num_nodes_per_cell = 4
                elif element_type == 4:
                    key = 'hexa'
                    num_nodes_per_cell = 8
                elif element_type == 5:
                    key = 'pyra'
                    num_nodes_per_cell = 5
                elif element_type == 6:
                    key = 'wedge'
                    num_nodes_per_cell = 6
                else:
                    raise ValueError('Unknown element type %d.' % element_type)

                # read cell data
                data = numpy.empty((num_cells, num_nodes_per_cell), dtype=int)
                for k in range(num_cells):
                    line = next(islice(f, 1))
                    dat = line.split()
                    assert len(dat) == num_nodes_per_cell
                    data[k] = [int(d, 16) for d in dat]

                cells[key] = data

                # make sure that the point data set is properly closed
                line = next(islice(f, 1))
                assert re.match('\s*\)\s*\)\s*', line)
            else:
                warnings.warn('Unknown index \'%d\'. Skipping.' % index)
                # Skipping ahead to the closing bracket. Assume that, if the
                # line ends with a closing bracket, that's the one. Otherwise
                # skip to the next "))" line.
                if line[-1] == ')':
                    continue
                while re.match('\s*\)\s*\)\s*', line) is None:
                    line = next(islice(f, 1))

    return points, cells, point_data, cell_data, field_data

def write(
        filename,
        points,
        cells,
        point_data=None,
        cell_data=None,
        field_data=None
        ):
    point_data = {} if point_data is None else point_data
    cell_data = {} if cell_data is None else cell_data
    field_data = {} if field_data is None else field_data

    with open(filename, 'wb') as fh:
        # header
        fh.write(('(1 "meshio %s")\n' % __version__).encode('utf8'))

        # dimension
        dim = 2 if all(points[:, 2] == 0.0) else 3
        fh.write(('(2 %d)\n' % dim).encode('utf8'))

        # total number of nodes
        fh.write(('(10 (0 1 %x 0))\n' % len(points)).encode('utf8'))

        # total number of cells
        total_num_cells = sum([len(c) for c in cells])
        fh.write(('(12 (0 1 %x 0))\n' % total_num_cells).encode('utf8'))

        # Write nodes
        fh.write(('(10 (1 1 %x 1 %d))(\n' % points.shape).encode('utf8'))
        numpy.savetxt(fh, points, fmt='%.15e')
        fh.write(('))\n').encode('utf8'))

        # Write cells
        meshio_to_ansys_type = {
                'triangle': 1,
                'tetra': 2,
                'quad': 3,
                'hex': 4,
                'pyra': 5,
                'wedge': 6,
                }
        first_index = 0
        for key, values in cells.items():
            last_index = first_index + len(values) - 1
            fh.write((
                '(12 (1 %x %x 1 %d)(\n' %
                (first_index, last_index, meshio_to_ansys_type[key])
                ).encode('utf8'))
            numpy.savetxt(fh, values, fmt='%x')
            fh.write(('))\n').encode('utf8'))
            first_index = last_index + 1

    return
<|endoftext|>


<commit_before>import xml.etree.ElementTree as ET

import numpy

from .._exceptions import WriteError
from .._helpers import register

def write(filename, mesh, stroke_width="2%", float_fmt=".3f", force_width=None):
    if mesh.points.shape[1] == 3 and not numpy.allclose(
        mesh.points[:, 2], 0.0, rtol=0.0, atol=1.0e-14
    ):
        raise WriteError(
            "SVG can only handle flat 2D meshes (shape: {})".format(mesh.points.shape)
        )

    pts = mesh.points[:, :2].copy()
    pts[:, 1] = numpy.max(pts[:, 1]) - pts[:, 1]

    min_x = numpy.min(pts[:, 0])
    min_y = numpy.min(pts[:, 1])
    width = numpy.max(pts[:, 0]) - min_x
    height = numpy.max(pts[:, 1]) - min_y

    if force_width is not None:
        scaling_factor = force_width / width
        min_x *= scaling_factor
        min_y *= scaling_factor
        width *= scaling_factor
        height *= scaling_factor
        pts *= scaling_factor

    fmt = " ".join(4 * ["{{:{}}}".format(float_fmt)])
    svg = ET.Element(
        "svg",
        xmlns="http://www.w3.org/2000/svg",
        version="1.1",
        viewBox=fmt.format(min_x, min_y, width, height),
    )

    style = ET.SubElement(svg, "style")
    opts = [
        "fill: none",
        "stroke: black",
        "stroke-width: {}".format(stroke_width),
        "stroke-linejoin:bevel",
    ]
    style.text = "polygon {" + "; ".join(opts) + "}"

    fmt = ",".join(2 * ["{{:{}}}".format(float_fmt)])
    for cell_block in mesh.cells:
        if cell_block.type not in ["line", "triangle", "quad"]:
            continue
        for cell in cell_block.data:
            ET.SubElement(
                svg,
                "polygon",
                points=" ".join([fmt.format(pts[c, 0], pts[c, 1]) for c in cell]),
            )

    tree = ET.ElementTree(svg)
    tree.write(filename)

register("svg", [".svg"], None, {"svg": write})
<commit_msg>svg: polygon -> path<commit_after>import xml.etree.ElementTree as ET

import numpy

from .._exceptions import WriteError
from .._helpers import register

def write(filename, mesh, float_fmt=".3f", stroke_width="1", force_width=None):
    if mesh.points.shape[1] == 3 and not numpy.allclose(
        mesh.points[:, 2], 0.0, rtol=0.0, atol=1.0e-14
    ):
        raise WriteError(
            "SVG can only handle flat 2D meshes (shape: {})".format(mesh.points.shape)
        )

    pts = mesh.points[:, :2].copy()
    pts[:, 1] = numpy.max(pts[:, 1]) - pts[:, 1]

    min_x = numpy.min(pts[:, 0])
    min_y = numpy.min(pts[:, 1])
    width = numpy.max(pts[:, 0]) - min_x
    height = numpy.max(pts[:, 1]) - min_y

    if force_width is not None:
        scaling_factor = force_width / width
        min_x *= scaling_factor
        min_y *= scaling_factor
        width *= scaling_factor
        height *= scaling_factor
        pts *= scaling_factor

    fmt = " ".join(4 * ["{{:{}}}".format(float_fmt)])
    svg = ET.Element(
        "svg",
        xmlns="http://www.w3.org/2000/svg",
        version="1.1",
        viewBox=fmt.format(min_x, min_y, width, height),
    )

    style = ET.SubElement(svg, "style")
    opts = [
        "fill: none",
        "stroke: black",
        "stroke-width: {}".format(stroke_width),
        "stroke-linejoin:bevel",
    ]
    # Use path, not polygon, because svgo converts polygons to paths and doesn't convert
    # the style alongside. No problem it's paths all along.
    style.text = "path {" + "; ".join(opts) + "}"

    fmt = (
        "M {{:{}}} {{:{}}}".format(float_fmt, float_fmt)
        + "L {{:{}}} {{:{}}}".format(float_fmt, float_fmt)
        + "L {{:{}}} {{:{}}}".format(float_fmt, float_fmt)
        + "Z"
    )
    for cell_block in mesh.cells:
        if cell_block.type not in ["line", "triangle", "quad"]:
            continue
        for cell in cell_block.data:
            ET.SubElement(
                svg, "path", d=fmt.format(*pts[cell].flatten()),
            )

    tree = ET.ElementTree(svg)
    tree.write(filename)

register("svg", [".svg"], None, {"svg": write})
<|endoftext|>


<commit_before>import csv
import logging
import re
import glob
import os

class IllegalPropertyName(Exception):
    pass

def load_metadata_from_csv(path, directory):
    """
    Grabs properties from the given csv file. The csv should be organised as follows:
    filename (without extension), property1, property2, ...

    Example:
    id_no,class,category,binomial
    my_file_1,GASTROPODA,EN,Aaadonta constricta
    my_file_2,GASTROPODA,CR,Aaadonta irregularis

    The corresponding files are my_file_1.tif and my_file_2.tif.

    The program will turn the above into a json object:

    { id_no: my_file_1, class: GASTROPODA, category: EN, binomial: Aaadonta constricta},
    { id_no: my_file_2, class: GASTROPODA, category: CR, binomial: Aaadonta irregularis}

    Checks the images in the specified directory to ensure that a metadata entry exists for each one
    if this is not the case, remove that image from the upload list.
    Also check for blank values in the metadata fields, which will cause Property KeyErrors on GEE
    Behaviour at the moment is to stop the upload if blank fields are found, to allow the user to edit the file.
    If images are present without metadata, the user can inspect the warnings to generate metadata rows for those images.
    :param met - a dictionary of dictionaries containing the metadata entries:

    :param path to csv:
    :return: dictionary of dictionaries:
    :return: list of full filepaths to upload
    """
    with open(path, mode='r') as metadata_file:
        reader = csv.reader(metadata_file)
        header = reader.next()

        if not properties_allowed(properties=header, validator=allowed_property_key):
            raise IllegalPropertyName()

        metadata = {row[0]: dict(zip(header, row)) for row in reader
                    if properties_allowed(properties=row, validator=allowed_property_value)}

        all_images_paths = glob.glob(os.path.join(directory, '*.tif'))
        filter_list = []
        for filepath in all_images_paths:
            if os.path.splitext(os.path.basename(os.path.normpath(filepath)))[0] not in metadata:

                filter_list.append(filepath)
                logging.warning("No metadata exists for image %s: it will not be ingested", filepath)

        all_images_paths = filter(lambda x: x not in filter_list, all_images_paths)

        return metadata, all_images_paths

def properties_allowed(properties, validator):
    return all(validator(prop) for prop in properties)

def allowed_property_value(prop):
    if prop:
        return True
    else:
        logging.warning('Illegal property: empty string')
        return False

def allowed_property_key(prop):
    google_special_properties = ('system:description',
                                 'system:provider_url',
                                 'system:tags',
                                 'system:time_end',
                                 'system:time_start',
                                 'system:title')

    if prop in google_special_properties or re.match("^[A-Za-z0-9_]+$", prop):
        return True
    else:
        logging.warning('Property name %s is invalid. Special properties [system:description, system:provider_url, '
                        'system:tags, system:time_end, system:time_start, system:title] are allowed; other property '
                        'keys must contain only letters, digits and underscores.')
        return False

def is_legal_gee_metadata(row):
    key = row[0]
    values = row[1:]
    re.match("^[A-Za-z0-9_]+$", ' asss_sasa')
<commit_msg>improved commenting<commit_after>import csv
import logging
import re
import glob
import os

class IllegalPropertyName(Exception):
    pass

def load_metadata_from_csv(path, directory):
    """
    Grabs properties from the given csv file. The csv should be organised as follows:
    filename (without extension), property1, property2, ...

    Example:
    id_no,class,category,binomial
    my_file_1,GASTROPODA,EN,Aaadonta constricta
    my_file_2,GASTROPODA,CR,Aaadonta irregularis

    The corresponding files are my_file_1.tif and my_file_2.tif.

    The program will turn the above into a json object:

    { id_no: my_file_1, class: GASTROPODA, category: EN, binomial: Aaadonta constricta},
    { id_no: my_file_2, class: GASTROPODA, category: CR, binomial: Aaadonta irregularis}

    Checks the images in the specified directory to ensure that a metadata entry exists for each one
    if this is not the case, remove that image from the upload list.
    Also check for blank values in the metadata fields, which will cause Property KeyErrors on GEE
    Behaviour at the moment is to stop the upload if blank fields are found, to allow the user to edit the file.
    If images are present without metadata, the user can inspect the warnings to generate metadata rows for those images.

    :param path to csv:
    :param directory - the directory in which the images are to be found:
    :return: a dictionary of dictionaries containing the metadata entries:
    :return: list of full filepaths to upload
    """
    with open(path, mode='r') as metadata_file:
        reader = csv.reader(metadata_file)
        header = reader.next()

        if not properties_allowed(properties=header, validator=allowed_property_key):
            raise IllegalPropertyName()

        metadata = {row[0]: dict(zip(header, row)) for row in reader
                    if properties_allowed(properties=row, validator=allowed_property_value)}

        all_images_paths = glob.glob(os.path.join(directory, '*.tif'))
        filter_list = []
        for filepath in all_images_paths:
            if os.path.splitext(os.path.basename(os.path.normpath(filepath)))[0] not in metadata:

                filter_list.append(filepath)
                logging.warning("No metadata exists for image %s: it will not be ingested", filepath)

        all_images_paths = filter(lambda x: x not in filter_list, all_images_paths)

        return metadata, all_images_paths

def properties_allowed(properties, validator):
    return all(validator(prop) for prop in properties)

def allowed_property_value(prop):
    if prop:
        return True
    else:
        logging.warning('Illegal property: empty string')
        return False

def allowed_property_key(prop):
    google_special_properties = ('system:description',
                                 'system:provider_url',
                                 'system:tags',
                                 'system:time_end',
                                 'system:time_start',
                                 'system:title')

    if prop in google_special_properties or re.match("^[A-Za-z0-9_]+$", prop):
        return True
    else:
        logging.warning('Property name %s is invalid. Special properties [system:description, system:provider_url, '
                        'system:tags, system:time_end, system:time_start, system:title] are allowed; other property '
                        'keys must contain only letters, digits and underscores.')
        return False

def is_legal_gee_metadata(row):
    key = row[0]
    values = row[1:]
    re.match("^[A-Za-z0-9_]+$", ' asss_sasa')
<|endoftext|>


<commit_before>#!/usr/bin/env python

import functools
import json
import os
import signal
import socket
import sys

import docker_utils
from info import NODE_INFO

def handler(name, signum, frame):
    print('Should kill', name)
    try:
        cid = open('/child_{}'.format(name)).read().strip()
        docker_utils.client.remove_container(cid, force=True)
    except Exception:
        pass
    sys.exit(0)

def launch(name, args):
    try:
        cid = open('/child_{}'.format(name)).read().strip()
    except IOError:
        cid = name
    try:
        os.unlink('/child_{}'.format(name))
    except OSError:
        pass
    try:
        docker_utils.client.remove_container(cid, force=True)
    except Exception:
        pass
    args.insert(0, '--cidfile=/child_{}'.format(name))
    docker_utils.docker('run',
                        '--volumes-from={}'.format(socket.gethostname()),
                        *args)

def inject_ip():
    with open('/serfnode/parent_info', 'w') as parent_info:
        json.dump(NODE_INFO, parent_info)

def wait(name):
    cid = open('/child_{}'.format(name)).read().strip()
    docker_utils.docker('wait', cid)

if __name__ == '__main__':
    name = sys.argv[1]
    args = sys.argv[2:]
    signal.signal(signal.SIGINT, functools.partial(handler, name))
    inject_ip()
    launch(name, args)
<commit_msg>Add more info about parent and children<commit_after>#!/usr/bin/env python

import functools
import json
import os
import signal
import socket
import sys

import docker_utils
from info import NODE_INFO

def handler(name, signum, frame):
    print('Should kill', name)
    try:
        cid = open('/child_{}'.format(name)).read().strip()
        docker_utils.client.remove_container(cid, force=True)
    except Exception:
        pass
    sys.exit(0)

def launch(name, args):
    try:
        cid = open('/child_{}'.format(name)).read().strip()
    except IOError:
        cid = name
    try:
        os.unlink('/child_{}'.format(name))
    except OSError:
        pass
    try:
        docker_utils.client.remove_container(cid, force=True)
    except Exception:
        pass
    args.insert(0, '--cidfile=/child_{}'.format(name))
    return docker_utils.docker(
        'run', '-d',
        '--volumes-from={}'.format(socket.gethostname()),
        *args)

def inject_ip():
    with open('/serfnode/parent_info', 'w') as parent_info:
        json.dump(NODE_INFO, parent_info)

def inject_parent_info():
    with open('/serfnode/parent.json', 'w') as f:
        info = json.loads(
            docker_utils.docker('inspect', socket.gethostname()))
        json.dump(info[0], f)

def inject_child_info(cid):
    info = json.loads(docker_utils.docker('inspect', cid))
    docker_utils.docker(
        'exec', cid, 'bash', '-c',
        "echo '{}' > /me.json".format(json.dumps(info[0])))

def wait(name):
    cid = open('/child_{}'.format(name)).read().strip()
    docker_utils.docker('wait', cid)

if __name__ == '__main__':
    name = sys.argv[1]
    args = sys.argv[2:]
    signal.signal(signal.SIGINT, functools.partial(handler, name))
    inject_ip()
    inject_parent_info()
    child = launch(name, args)
    inject_child_info(child)
    docker_utils.docker('wait', child)
<|endoftext|>