Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinTalbert committed Jun 21, 2019
0 parents commit 2e5e9dc
Show file tree
Hide file tree
Showing 22 changed files with 1,732 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.py[cod]
__pycache__

# Sphinx
docs/_build

.idea

guanoeditor_venv
guanomdeditor/gui/build
guanomdeditor/gui/dist
32 changes: 32 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
License
-------

This software is licensed under CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/) and is in the public domain
because it contains materials that originally came from the U.S. Geological Survey (USGS), an agency of the United
States Department of Interior. For more information, see the official USGS copyright policy
(http://www2.usgs.gov/visual-id/credit_usgs.html#copyright/).


Disclaimer
----------

This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely
best science. The software has not received final approval by the U.S. Geological Survey (USGS). No warranty, expressed
or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor
shall the fact of release constitute any such warranty. The software is provided on the condition that neither the USGS
nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the
software.

The USGS provides no warranty, expressed or implied, as to the correctness of the furnished software or the suitability
for any purpose. The software has been tested, but as with any complex software, there could be undetected errors. Users
who find errors are requested to report them to the USGS.

References to non-USGS products, trade names, and (or) services are provided for information purposes only and do not
constitute endorsement or warranty, express or implied, by the USGS, U.S. Department of Interior, or U.S. Government, as
to their suitability, content, usefulness, functioning, completeness, or accuracy.

Although this program has been used by the USGS, no warranty, expressed or implied, is made by the USGS or the United
States Government as to the accuracy and functioning of the program and related program material nor shall the fact of
distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.

This software is provided "AS IS."
80 changes: 80 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. image:: https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/USGS_logo_green.svg/320px-USGS_logo_green.svg.png
:target: http://www.usgs.gov/
:alt: U.S. Geological Survey logo

guanomdeditor
===============================

A simple open-source viewer and editor for Guano Metadata embedded in bat echolocation wav files.

.. image:: docs/Images/screengrab.png
:width: 600


Features
--------
Drag and drop or browse to a wav file to see the Guano Contents. Schema tags, required tags, and picklists of
accepted values are displayed on form, easing data entry requirements and QA/QC of contents.




License
-------

This software is licensed under `CC0 1.0`_ and is in the `public domain`_ because it contains materials that originally
came from the `U.S. Geological Survey (USGS)`_, an agency of the `United States Department of Interior`_. For more
information, see the `official USGS copyright policy`_.

.. image:: http://i.creativecommons.org/p/zero/1.0/88x31.png
:target: http://creativecommons.org/publicdomain/zero/1.0/
:alt: Creative Commons logo


Disclaimer
----------

This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely
best science. The software has not received final approval by the U.S. Geological Survey (USGS). No warranty, expressed
or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor
shall the fact of release constitute any such warranty. The software is provided on the condition that neither the USGS
nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the
software.

The USGS provides no warranty, expressed or implied, as to the correctness of the furnished software or the suitability
for any purpose. The software has been tested, but as with any complex software, there could be undetected errors. Users
who find errors are requested to report them to the USGS.

References to non-USGS products, trade names, and (or) services are provided for information purposes only and do not
constitute endorsement or warranty, express or implied, by the USGS, U.S. Department of Interior, or U.S. Government, as
to their suitability, content, usefulness, functioning, completeness, or accuracy.

Although this program has been used by the USGS, no warranty, expressed or implied, is made by the USGS or the United
States Government as to the accuracy and functioning of the program and related program material nor shall the fact of
distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.

This software is provided "AS IS."


Author
------

Colin Talbert <[email protected]>


.. _Python: https://www.python.org/
.. _pytest: http://pytest.org/latest/
.. _Sphinx: http://sphinx-doc.org/
.. _public domain: https://en.wikipedia.org/wiki/Public_domain
.. _CC0 1.0: http://creativecommons.org/publicdomain/zero/1.0/
.. _U.S. Geological Survey: https://www.usgs.gov/
.. _USGS: https://www.usgs.gov/
.. _U.S. Geological Survey (USGS): https://www.usgs.gov/
.. _United States Department of Interior: https://www.doi.gov/
.. _official USGS copyright policy: http://www.usgs.gov/visual-id/credit_usgs.html#copyright/
.. _U.S. Geological Survey (USGS) Software User Rights Notice: http://water.usgs.gov/software/help/notice/
.. _Python's download page: https://www.python.org/downloads/
.. _git: https://git-scm.com/
.. _Distutils: https://docs.python.org/3/library/distutils.html
.. _Installing Python Modules: https://docs.python.org/3.5/install/
.. _How Installation Works: https://docs.python.org/3.5/install/#how-installation-works
Binary file added docs/Images/screengrab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions guanomdeditor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
"""
guanomdeditor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A simple open-source viewer and editor for Guano Metadata embedded in bat call wav files.
Nutshell
--------
Here a small example of using guanomdeditor
:authors: 2019 by Colin Talbert, see AUTHORS
:license: CC0 1.0, see LICENSE file for details
"""

__version__ = "0.0.1"
216 changes: 216 additions & 0 deletions guanomdeditor/core/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""
The MetadataWizard(pymdwizard) software was developed by the
U.S. Geological Survey Fort Collins Science Center.
See: https://github.com/usgs/fort-pymdwizard for current project source code
See: https://usgs.github.io/fort-pymdwizard/ for current user documentation
See: https://github.com/usgs/fort-pymdwizard/tree/master/examples
for examples of use in other scripts
License: Creative Commons Attribution 4.0 International (CC BY 4.0)
http://creativecommons.org/licenses/by/4.0/
PURPOSE
------------------------------------------------------------------------------
Module contains a variety of miscellaneous functions
SCRIPT DEPENDENCIES
------------------------------------------------------------------------------
This script is part of the pymdwizard package and is not intented to be
used independently. All pymdwizard package requirements are needed.
See imports section for external packages used in this script as well as
inter-package dependencies
U.S. GEOLOGICAL SURVEY DISCLAIMER
------------------------------------------------------------------------------
This software has been approved for release by the U.S. Geological Survey (USGS).
Although the software has been subjected to rigorous review,
the USGS reserves the right to update the software as needed pursuant to
further analysis and review. No warranty, expressed or implied, is made by
the USGS or the U.S. Government as to the functionality of the software and
related material nor shall the fact of release constitute any such warranty.
Furthermore, the software is released on condition that neither the USGS nor
the U.S. Government shall be held liable for any damages resulting from
its authorized or unauthorized use.
Any use of trade, product or firm names is for descriptive purposes only and
does not imply endorsement by the U.S. Geological Survey.
Although this information product, for the most part, is in the public domain,
it also contains copyrighted material as noted in the text. Permission to
reproduce copyrighted items for other than personal use must be secured from
the copyright owner.
------------------------------------------------------------------------------
"""

import sys
import os
import traceback
import pkg_resources

try:
from urllib.parse import urlparse
except:
from urlparse import urlparse

import pandas as pd

from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QTextBrowser
from PyQt5.QtWidgets import QPlainTextEdit
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QComboBox
from PyQt5.QtCore import QAbstractTableModel
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QBrush
from PyQt5.QtGui import QColor
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QSettings


def set_text(widget, text):
"""
set the text of a widget regardless of it's base type
Parameters
----------
widget : QtGui:QWidget
This widget is a QlineEdit or QPlainText edit
text : str
The text that will be inserted
Returns
-------
None
"""
if isinstance(widget, QLineEdit):
widget.setText(text)
widget.setCursorPosition(0)

if isinstance(widget, QPlainTextEdit):
widget.setPlainText(text)

if isinstance(widget, QTextBrowser):
widget.setText(text)

if isinstance(widget, QComboBox):
index = widget.findText(text, Qt.MatchFixedString)
if index >= 0:
widget.setCurrentIndex(index)
else:
widget.setEditText(text)


def launch_widget(Widget, title="", **kwargs):
"""
run a widget within it's own application
Parameters
----------
widget : QWidget
title : str
The title to use for the application
Returns
-------
None
"""

try:
app = QApplication([])
app.title = title
widget = Widget(**kwargs)
print('blah')
widget.setWindowTitle(title)
widget.show()
sys.exit(app.exec_())
# return widget
except:
e = sys.exc_info()[0]
print('problem encountered', e)
print(traceback.format_exc())


def get_resource_path(fname):
"""
Parameters
----------
fname : str
filename that you would like to find
Returns
-------
the full file path to the resource specified
"""
return pkg_resources.resource_filename('guanoeditor',
'resources/{}'.format(fname))


def set_window_icon(widget, remove_help=True):
"""
Add our default ducky icon to a widget
Parameters
----------
widget : PyQt widget
remove_help : Bool
Whether to show the help question mark icon.
Returns
-------
None
"""
icon = QIcon(get_resource_path('icons/Ducky.ico'))
widget.setWindowIcon(icon)
if remove_help:
widget.setWindowFlags(Qt.Window |
Qt.CustomizeWindowHint |
Qt.WindowTitleHint |
Qt.WindowCloseButtonHint |
Qt.WindowStaysOnTopHint)


def get_setting(which, default=None):
"""
return a pymdwizard application setting
Parameters
----------
which: str
name of setting to return
Returns
-------
setting in native format, string, integer, etc
"""
settings = QSettings('USGS', 'guanoeditor')
if default is None:
return settings.value(which)
else:
return settings.value(which, default)


def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath('.'), relative_path)


def read_namespace(fname):
namespace_df = pd.read_csv(fname)

namespace_df = namespace_df[['tag', 'description', 'required', 'data_type', 'picklist']]
# namespace_df = namespace_df[namespace_df.tag.str.startswith('NABat|')]
namespace_df.picklist = namespace_df.picklist.fillna('')
namespace_dict = namespace_df.to_dict('records')

for thing in namespace_dict:
if thing['picklist']:
thing['picklist'] = thing['picklist'].split('|')

return namespace_dict

31 changes: 31 additions & 0 deletions guanomdeditor/guanomdeditor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
"""
guanomdeditor.guanomdeditor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A short description.
:authors: 2019 by Colin Talbert, see AUTHORS
:license: CC0 1.0, see LICENSE file for details
"""

def hello(msg="World"):
"""Function that prints a message.
:param msg: message to say
:type msg: string
:returns: string
:raises: something
.. note::
You can note something here.
.. warning::
You can warn about something here.
>>> hello()
Hello World!
>>> hello(msg="there")
Hello there!
"""
return "Hello {}!".format(msg)
Loading

0 comments on commit 2e5e9dc

Please sign in to comment.