diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..29ef4dd --- /dev/null +++ b/.coveragerc @@ -0,0 +1,27 @@ +# .coveragerc to control coverage.py + +[run] +branch = True +source = + mitmstack + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +ignore_errors = True + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d2a74a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,97 @@ +# Created by .ignore support plugin (hsz.mobi) +### Python template +# 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/ + +# 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 + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject + diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..e48043f --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), + '..', '..'))) + +# -- General configuration ---------------------------------------------------- + +# 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.intersphinx', + 'oslosphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'mitmstack' +copyright = u'2017, OpenStack Foundation' + +# 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 + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] + +# Example configuration for intersphinx: refer to the Python standard library. +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..7056003 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,22 @@ +.. mitmstack documentation master file, created by + sphinx-quickstart on Tue Feb 28 16:38:38 2017. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to mitmstack's documentation! +===================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/mitmstack/__init__.py b/mitmstack/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/mitmstack/mitmstack.py b/mitmstack/mitmstack.py new file mode 100644 index 0000000..d544820 --- /dev/null +++ b/mitmstack/mitmstack.py @@ -0,0 +1,13 @@ +# Copyright 2017 ZTE Corporation and others +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/mitmstack/tests/.gitkeep b/mitmstack/tests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..14c03ad --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +mitmproxy>=1.0.2;python_version>'3.0' # MIT + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..938a225 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,37 @@ +[metadata] +name = mitmstack +summary = Man-In-The-Middle OpenStack Service Faker +author = OpenStack +author-email = zhang.yujunz@zte.com.cn +home-page = https://wiki.openstack.org/wiki/MitmStack +classifier = + Environment :: OpenStack + Intended Audience :: Information Technology + Intended Audience :: Developer + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.5 + Topic :: System :: Testing + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] + +[files] +packages = + mitmstack + +[build_sphinx] +source-dir = doc/source +build-dir = doc/build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/build/html + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..ce14d42 --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup( + setup_requires=['pbr>=1.9', 'setuptools>=17.1'], + pbr=True, +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..e08f303 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +sphinx>=1.5.1 # BSD +oslosphinx>=4.7.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..f2107bd --- /dev/null +++ b/tox.ini @@ -0,0 +1,32 @@ +[tox] +envlist = py35,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} +setenv = + VIRTUAL_ENV={envdir} + DISCOVER_DIRECTORY=mitmstack/tests +deps = -r{toxinidir}/test-requirements.txt +commands = + python -m unittest discover mitmstack/tests + +[testenv:pep8] +deps = flake8 +commands = flake8 + +[testenv:venv] +commands = {posargs} + +[testenv:docs] +commands = python setup.py build_sphinx + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build +