Skip to content

Commit

Permalink
pre-commit, black
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Nov 3, 2019
1 parent 12b2589 commit d0eda76
Show file tree
Hide file tree
Showing 26 changed files with 889 additions and 787 deletions.
10 changes: 10 additions & 0 deletions .flake8
@@ -0,0 +1,10 @@
[flake8]
max-line-length = 80
max-complexity = 16
# B = bugbear
# B9 = bugbear opinionated (incl line length)
select = C,E,F,W,B,B9
# E203: whitespace before ':' (black behaviour)
# E501: flake8 line length (covered by bugbear B950)
# W503: line break before binary operator (black behaviour)
ignore = E203,E501,W503
9 changes: 9 additions & 0 deletions .isort.cfg
@@ -0,0 +1,9 @@
[settings]
; see https://github.com/psf/black
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
use_parentheses=True
line_length=88
known_third_party=pkg_resources,pytest,setuptools
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,39 @@
exclude: ^tests/data/
default_language_version:
python: python3
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- id: flake8
additional_dependencies: ["flake8-bugbear==19.8.0"]
- id: fix-encoding-pragma
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://github.com/asottile/pyupgrade
rev: v1.25.1
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
name: isort except __init__.py
exclude: /__init__\.py$
6 changes: 4 additions & 2 deletions .travis.yml
Expand Up @@ -5,12 +5,14 @@ python:
- "2.7"
- "3.5"
- "3.6"
- "3.7-dev"
- "3.7"

matrix:
include:
- python: 3.5
- python: 3.7
env: TOXENV=check_readme
- python: 3.7
env: TOXENV=pre_commit

install:
- pip install tox-travis
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -35,7 +35,7 @@ The following prerequisites apply:
* For any advanced use such as installing from source, installing from
git, packaging wheels etc, you need a recent version of pip (>= 9.0.1).
* Finally, you need to install `odoo-autodiscover
<https://pypi.python.org/pypi/odoo-autodiscover>`_
<https://pypi.python.org/pypi/odoo-autodiscover>`_
(``pip install odoo-autodiscover``) to provide automatic extension
of the addons path (and workaround a bug with setuptools > 31 and Odoo 10).

Expand Down Expand Up @@ -356,7 +356,7 @@ Available options::
other Odoo versions, remove metapackage setup if there
are no installable addons.
--commit Git commit changes, if any.


Versioning
~~~~~~~~~~
Expand Down
56 changes: 32 additions & 24 deletions docs/conf.py
Expand Up @@ -21,6 +21,7 @@
# sys.path.insert(0, os.path.abspath('.'))

from datetime import date

from pkg_resources import get_distribution

# -- General configuration ------------------------------------------------
Expand All @@ -33,36 +34,36 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
"sphinx.ext.autodoc",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
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'
source_suffix = ".rst"

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

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'setuptools-odoo'
copyright = u'2015-%s, Stéphane Bidoul (ACSONE)' % (date.today().year,)
author = u'Stéphane Bidoul (ACSONE)'
project = u"setuptools-odoo"
copyright = u"2015-{}, Stéphane Bidoul (ACSONE)".format(date.today().year)
author = u"Stéphane Bidoul (ACSONE)"

# 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.
#
release = get_distribution('setuptools-odoo').version
version = '.'.join(release.split('.')[:2])
release = get_distribution("setuptools-odoo").version
version = ".".join(release.split(".")[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -83,7 +84,7 @@
# 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']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -105,7 +106,7 @@
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -122,7 +123,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# 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
Expand Down Expand Up @@ -156,7 +157,7 @@
# 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']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -236,23 +237,20 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'setuptools-odoodoc'
htmlhelp_basename = "setuptools-odoodoc"

# -- 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',
Expand All @@ -262,8 +260,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'setuptools-odoo.tex', u'setuptools-odoo Documentation',
u'Stéphane Bidoul (ACSONE)', 'manual'),
(
master_doc,
"setuptools-odoo.tex",
u"setuptools-odoo Documentation",
u"Stéphane Bidoul (ACSONE)",
"manual",
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -304,8 +307,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'setuptools-odoo', u'setuptools-odoo Documentation',
[author], 1)
(master_doc, "setuptools-odoo", u"setuptools-odoo Documentation", [author], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -319,9 +321,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'setuptools-odoo', u'setuptools-odoo Documentation',
author, 'setuptools-odoo', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"setuptools-odoo",
u"setuptools-odoo Documentation",
author,
"setuptools-odoo",
"One line description of project.",
"Miscellaneous",
),
]

# Documents to append as an appendix to all manuals.
Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Expand Up @@ -8,4 +8,3 @@
.. include:: ../CHANGES.rst

.. include:: ../DEVELOP.rst

59 changes: 34 additions & 25 deletions mk_base_addons
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import subprocess
import tempfile
Expand All @@ -8,28 +9,28 @@ from setuptools_odoo import manifest

SERIES = [
# branch, suffix, enterprise
('master', '14', True),
('13.0', '13', True),
('12.0', '12', True),
('11.0', '11', True),
#('10.0', '10', True),
#('9.0', '9', True),
#('8.0', '8', False),
#('7.0', '7', False),
("master", "14", True),
("13.0", "13", True),
("12.0", "12", True),
("11.0", "11", True),
# ('10.0', '10', True),
# ('9.0', '9', True),
# ('8.0', '8', False),
# ('7.0', '7', False),
]


def _list_addons(addons_dir, add_base):
if add_base:
yield 'base'
yield "base"
for addon_name in os.listdir(addons_dir):
addon_dir = os.path.join(addons_dir, addon_name)
if manifest.get_manifest_path(addon_dir):
yield addon_name


def _write_addons_list(addons_dir, suffix, add_base):
with open('addons-%s.txt' % suffix, 'w') as f:
with open("addons-%s.txt" % suffix, "w") as f:
print("# generated on", time.asctime(), file=f)
for addon_name in sorted(_list_addons(addons_dir, add_base)):
print(addon_name, file=f)
Expand All @@ -43,24 +44,32 @@ def check_call(cmd):
def main():
for branch, suffix, enterprise in SERIES:
with tempfile.TemporaryDirectory() as tmpdir:
check_call([
'git', 'clone',
'--branch', branch,
'https://github.com/odoo/odoo',
tmpdir,
])
addons_dir = os.path.join(tmpdir, 'addons')
_write_addons_list(addons_dir, suffix + 'c', add_base=True)
check_call(
[
"git",
"clone",
"--branch",
branch,
"https://github.com/odoo/odoo",
tmpdir,
]
)
addons_dir = os.path.join(tmpdir, "addons")
_write_addons_list(addons_dir, suffix + "c", add_base=True)
if enterprise:
with tempfile.TemporaryDirectory() as tmpdir:
check_call([
'git', 'clone',
'--branch', branch,
'git@github.com:odoo/enterprise',
tmpdir,
])
check_call(
[
"git",
"clone",
"--branch",
branch,
"git@github.com:odoo/enterprise",
tmpdir,
]
)
addons_dir = tmpdir
_write_addons_list(addons_dir, suffix + 'e', add_base=False)
_write_addons_list(addons_dir, suffix + "e", add_base=False)


main()

0 comments on commit d0eda76

Please sign in to comment.