From 8bc5b838a892b3d9188825608771dd0d82d93ac4 Mon Sep 17 00:00:00 2001
From: Maeva Pourpoint <maeva@passcal.nmt.edu>
Date: Fri, 27 Aug 2021 10:50:31 -0600
Subject: [PATCH] Backbone files

---
 .gitignore             |  91 ++++++++++++++++++++++++++++++++
 .gitlab-ci.yml         |  64 +++++++++++++++++++++++
 AUTHORS.rst            |   8 +++
 CONTRIBUTING.rst       | 115 +++++++++++++++++++++++++++++++++++++++++
 HISTORY.rst            |   8 +++
 LICENSE                |  32 ++++++++++++
 MANIFEST.in            |  10 ++++
 README.md              |   3 --
 README.rst             |  20 +++++++
 conda.recipe/meta.yaml |  34 ++++++++++++
 lemi2seed/__init__.py  |   7 +++
 setup.cfg              |  18 +++++++
 setup.py               |  56 ++++++++++++++++++++
 tests/__init__.py      |   3 ++
 tox.ini                |  16 ++++++
 15 files changed, 482 insertions(+), 3 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 .gitlab-ci.yml
 create mode 100644 AUTHORS.rst
 create mode 100644 CONTRIBUTING.rst
 create mode 100644 HISTORY.rst
 create mode 100644 LICENSE
 create mode 100644 MANIFEST.in
 delete mode 100644 README.md
 create mode 100644 README.rst
 create mode 100644 conda.recipe/meta.yaml
 create mode 100644 lemi2seed/__init__.py
 create mode 100644 setup.cfg
 create mode 100644 setup.py
 create mode 100644 tests/__init__.py
 create mode 100644 tox.ini

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..76420c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,91 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# pyenv
+.python-version
+
+# virtualenv
+.venv
+venv/
+ENV/
+
+# mypy
+.mypy_cache/
+
+#pycharm
+.idea/
+
+.DS_Store
+
+# pylint
+.pylintrc
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..c139d76
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,64 @@
+image: python
+
+# Change pip's cache directory to be inside the project directory since we can
+# only cache local items.
+variables:
+  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache"
+
+# Pip's cache doesn't store the python packages
+# https://pip.pypa.io/en/stable/reference/pip_install/#caching
+#
+# If you want to also cache the installed packages, you have to install
+# them in a virtualenv and cache it as well.
+cache:
+  paths:
+    - .cache/pip
+
+stages:
+- Static Analysis and Test
+
+before_script:
+- uname -a
+- apt-get update && apt install -y libgl1-mesa-glx
+- pip install -e .[dev]
+
+flake8:
+  image: python:3.8
+  tags:
+  - passoft
+  stage: Static Analysis and Test
+  script:
+  - flake8 --ignore=E501,W503 lemi2seed
+  - flake8 tests
+
+mypy:
+  image: python:3.8
+  tags:
+  - passoft
+  stage: Static Analysis and Test
+  script:
+  - python -m mypy --config-file ./setup.cfg lemi2seed
+
+python3.7:
+  image: python:3.7
+  tags:
+  - passoft
+  stage: Static Analysis and Test
+  script:
+  - python -m unittest
+
+python3.8:
+  image: python:3.8
+  tags:
+  - passoft
+  stage: Static Analysis and Test
+  script:
+  - python -m unittest
+
+python3.9:
+  image: python:3.9
+  tags:
+  - passoft
+  stage: Static Analysis and Test
+  script:
+  - python -m unittest
diff --git a/AUTHORS.rst b/AUTHORS.rst
new file mode 100644
index 0000000..33bb038
--- /dev/null
+++ b/AUTHORS.rst
@@ -0,0 +1,8 @@
+=======
+Credits
+=======
+
+Development Lead
+----------------
+
+* IRIS PASSCAL <software-support@passcal.nmt.edu>
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
new file mode 100644
index 0000000..84ded9f
--- /dev/null
+++ b/CONTRIBUTING.rst
@@ -0,0 +1,115 @@
+.. highlight:: shell
+
+============
+Contributing
+============
+
+Contributions are welcome, and they are greatly appreciated! Every little bit
+helps, and credit will always be given.
+
+You can contribute in many ways:
+
+Types of Contributions
+----------------------
+
+Report Bugs
+~~~~~~~~~~~
+
+Report bugs at https://git.passcal.nmt.edu/maeva/lemi2seed/issues.
+
+If you are reporting a bug, please include:
+
+* Your operating system name and version.
+* Any details about your local setup that might be helpful in troubleshooting.
+* Detailed steps to reproduce the bug.
+
+Fix Bugs
+~~~~~~~~
+
+Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
+wanted" is open to whoever wants to implement it.
+
+Implement Features
+~~~~~~~~~~~~~~~~~~
+
+Look through the GitLab issues for features. Anything tagged with "enhancement"
+and "help wanted" is open to whoever wants to implement it.
+
+Write Documentation
+~~~~~~~~~~~~~~~~~~~
+
+lemi2seed could always use more documentation, whether as part of the
+official lemi2seed docs, in docstrings, or even on the web in blog posts,
+articles, and such.
+
+Submit Feedback
+~~~~~~~~~~~~~~~
+
+The best way to send feedback is to file an issue at
+https://git.passcal.nmt.edu/maeva/lemi2seed/issues.
+
+If you are proposing a feature:
+
+* Explain in detail how it would work.
+* Keep the scope as narrow as possible, to make it easier to implement.
+* Remember that this is a volunteer-driven project, and that contributions
+  are welcome :)
+
+Get Started!
+------------
+
+Ready to contribute? Here's how to set up `lemi2seed` for local development.
+
+1. Clone the `lemi2seed` repo:
+
+ * $ git clone https://git.passcal.nmt.edu/maeva/lemi2seed.git
+
+2. Install your local copy:
+
+ * $ pip install -e .[dev]
+
+3. Create a branch for local development:
+
+ * $ git checkout -b name-of-your-bugfix-or-feature
+
+ Now you can make your changes locally.
+
+4. When you're done making changes, check that your changes pass the
+   tests:
+
+ * $ python -m unittest
+
+5. Commit your changes and push your branch to GitHub:
+
+ * $ git add .
+ * $ git commit -m "Your detailed description of your changes."
+ * $ git push origin name-of-your-bugfix-or-feature
+
+6. Submit a merge request through the Gitlab website.
+
+Pull Request Guidelines
+-----------------------
+
+Before you submit a merge request, check that it meets these guidelines:
+
+1. The merge request should include tests.
+2. If the merge request adds functionality, the docs should be updated. Put
+   your new functionality into a function with a docstring, and add the
+   feature to the list in README.rst.
+3. The pull request should work for Python 3.[6,7,8]
+
+Tips
+----
+
+To run a subset of tests, for the lemi2seed module for example, run:
+  * $ python -m unittest tests/test_lemi2seed.py
+
+Deploying
+---------
+
+A reminder for the maintainers on how to deploy.
+Make sure all your changes are committed (including an entry in HISTORY.rst).
+Then run:
+
+* $ git push
+* $ git push --tags
diff --git a/HISTORY.rst b/HISTORY.rst
new file mode 100644
index 0000000..36c6110
--- /dev/null
+++ b/HISTORY.rst
@@ -0,0 +1,8 @@
+=======
+History
+=======
+
+2021.?
+--------
+
+* First release on new build system.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bd41136
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,32 @@
+GNU GENERAL PUBLIC LICENSE
+                      Version 3, 29 June 2007
+
+    Convert LEMI data and metadata into day-long mseed and StationXML files.
+    Copyright (C) 2018  IRIS PASSCAL
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..a217fea
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,10 @@
+include AUTHORS.rst
+include CONTRIBUTING.rst
+include HISTORY.rst
+include LICENSE
+include README.rst
+
+graft lemi2seed
+graft tests
+recursive-exclude * __pycache__
+recursive-exclude * *.py[co]
diff --git a/README.md b/README.md
deleted file mode 100644
index 8e02c2b..0000000
--- a/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# lemi2obspy
-
-Program to convert MT data to mseed
\ No newline at end of file
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..23aeee5
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,20 @@
+==========
+lemi2seed
+==========
+
+- **Description**:
+    - Convert LEMI data and metadata into day-long mseed and StationXML files.
+
+- **Usage**:
+    - ``lemi2seed -h``
+    - ``lemi2seed -d path2data -qc`` *(run lemi2seed in "quality control" mode)*
+    - ``lemi2seed -d path2data -g`` *(run lemi2seed in "gui only" mode)*
+    - ``lemi2seed -d path2data -m path2metadata`` *(run lemi2seed in "field sheet and gui" mode)*
+
+  The "quality control" mode allows to quickly convert LEMI data to day-long mseed files. The GUI and handling of metadata are bypassed.
+
+  In the "gui only" mode, metadata are entered only using the GUI.
+
+  In the "field sheet and gui" mode, metadata are prepopulated from parsing the provided field sheets.
+
+- **License**: GNU General Public License v3 (GPLv3)
diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml
new file mode 100644
index 0000000..3cbedad
--- /dev/null
+++ b/conda.recipe/meta.yaml
@@ -0,0 +1,34 @@
+package:
+  name: lemi2seed
+  version: 2021.239
+
+source:
+  path: ../
+
+build:
+  noarch: python
+  number: 0
+  script: {{ PYTHON }} -m pip install --no-deps -vv .
+
+requirements:
+  build:
+    - python >=3.7
+    - pip
+  run:
+    - python >=3.7
+    - configobj
+    - obspy
+    - openpyxl
+    - PySide2
+
+test:
+  source_files:
+    - tests
+  commands:
+    - python -m unittest
+
+about:
+  home: https://git.passcal.nmt.edu/maeva/lemi2seed
+  license: GPLv3
+  license_file: LICENSE
+  summary: Convert LEMI data and metadata into day-long mseed and StationXML files.
diff --git a/lemi2seed/__init__.py b/lemi2seed/__init__.py
new file mode 100644
index 0000000..ecd3cbd
--- /dev/null
+++ b/lemi2seed/__init__.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+
+"""Top-level package for lemi2seed."""
+
+__author__ = """IRIS PASSCAL"""
+__email__ = 'software-support@passcal.nmt.edu'
+__version__ = '2021.239'
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..413492c
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,18 @@
+[flake8]
+exclude = docs, *_rc.py
+max-line-length = 120
+
+[mypy-*.lemi_gui]
+ignore_errors = True
+
+[mypy-configobj]
+ignore_missing_imports = True
+
+[mypy-numpy]
+ignore_missing_imports = True
+
+[mypy-obspy.*]
+ignore_missing_imports = True
+
+[mypy-openpyxl]
+ignore_missing_imports = True
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..c7f500a
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""The setup script."""
+
+from setuptools import setup, find_packages
+
+with open('README.rst', 'rt') as readme_file:
+    readme = readme_file.read()
+
+with open('HISTORY.rst', 'rt') as history_file:
+    history = history_file.read()
+
+
+setup(
+    author="IRIS PASSCAL",
+    author_email='software-support@passcal.nmt.edu',
+    classifiers=[
+        'Development Status :: 5 - Production/Stable',
+        'Intended Audience :: Developers',
+        'License :: OSI Approved ::  GNU General Public License v3 (GPLv3)',
+        'Natural Language :: English',
+        'Programming Language :: Python :: 3.7',
+        'Programming Language :: Python :: 3.8',
+        'Programming Language :: Python :: 3.9',
+    ],
+    description="Convert LEMI data and metadata into day-long mseed and "
+                "StationXML files.",
+    entry_points={
+        'console_scripts': [
+            'lemi2seed=lemi2seed.lemi2seed:main',
+        ],
+    },
+    install_requires=['configobj',
+                      'obspy',
+                      'openpyxl',
+                      'openpyxl-stubs',
+                      'PySide2'],
+    setup_requires=[],
+    extras_require={
+        'dev': [
+            'flake8',
+            'tox',
+            'mypy',
+        ]
+    },
+    license="GNU General Public License v3",
+    long_description=readme + '\n\n' + history,
+    include_package_data=True,
+    keywords='lemi2seed',
+    name='lemi2seed',
+    packages=find_packages(include=['lemi2seed']),
+    url='https://git.passcal.nmt.edu/maeva/lemi2seed',
+    version='2021.007',
+    zip_safe=False,
+)
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..d6ee1da
--- /dev/null
+++ b/tests/__init__.py
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+"""Unit test package for lemi2seed."""
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..6424740
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,16 @@
+[tox]
+envlist = py37, py38, py39, flake8, mypy
+
+[testenv:flake8]
+basepython = python
+deps = flake8
+commands = flake8 --ignore=E501,W503 lemi2seed
+           flake8 tests
+
+[testenv:mypy]
+basepython = python
+deps = mypy
+commands = python -m mypy --config-file ./setup.cfg lemi2seed
+
+[testenv]
+commands = python -m unittest
-- 
GitLab