Skip to content

Commit

Permalink
Initial YAPF formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerdahl committed Mar 6, 2017
1 parent 65a1c7b commit d60e23f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 146 deletions.
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]

# We have YAPF set to wrap at 80, but that's not always possible, so we set the
# limit a bit higher here.
max-line-length = 100

# Ignore

# E111 indentation is not a multiple of four
# E121 continuation line under-indented for hanging indent
# E126 continuation line over-indented for hanging indent
# E261 at least two spaces before inline comment

ignore = E111,E121,E126,E261

14 changes: 11 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: a11d9314b22d8f8c7556443875b731ef05965464
hooks:
- id: trailing-whitespace
- repo: git://github.com/pre-commit/mirrors-yapf
sha: v0.16.0
sha: v0.16.0
hooks:
- id: yapf
args: [--in-place, --style=./yapf_style.cfg]

args:
- --in-place
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: a11d9314b22d8f8c7556443875b731ef05965464
hooks:
- id: flake8
50 changes: 50 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[style]
based_on_style = pep8

ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT = True

ALLOW_MULTILINE_DICTIONARY_KEYS = False
ALLOW_MULTILINE_LAMBDAS = True

BLANK_LINE_BEFORE_CLASS_DOCSTRING = False
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = False

COALESCE_BRACKETS = True

COLUMN_LIMIT = 80

CONTINUATION_INDENT_WIDTH = 2

DEDENT_CLOSING_BRACKETS = True

EACH_DICT_ENTRY_ON_SEPARATE_LINE = True

INDENT_DICTIONARY_VALUE = True
INDENT_WIDTH = 2

JOIN_MULTIPLE_LINES = False

SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET = False

SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN = False
SPACES_AROUND_POWER_OPERATOR = False
SPACES_BEFORE_COMMENT = 1

SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED = True

SPLIT_BEFORE_BITWISE_OPERATOR = False
SPLIT_BEFORE_DICT_SET_GENERATOR = False
SPLIT_BEFORE_FIRST_ARGUMENT = True
SPLIT_BEFORE_LOGICAL_OPERATOR = False
SPLIT_BEFORE_NAMED_ASSIGNS = False

SPLIT_PENALTY_AFTER_OPENING_BRACKET = 30
SPLIT_PENALTY_AFTER_UNARY_OPERATOR = 10000
SPLIT_PENALTY_BEFORE_IF_EXPR = 50
SPLIT_PENALTY_BITWISE_OPERATOR = 300
SPLIT_PENALTY_EXCESS_CHARACTER = 200
SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT = 30
SPLIT_PENALTY_IMPORT_NAMES = 0
SPLIT_PENALTY_LOGICAL_OPERATOR = 300

USE_TABS = False
9 changes: 3 additions & 6 deletions d1_common_python/src/d1_common/cert/subject_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""Extract a set of subjects from a DataONE SubjectInfo structure
Subjects are extracted from the SubjectInfo using the following algorithm:
- Start with empty set of subjects
- Perform recursive search with detection of circular dependencies, starting
with Subject.
Expand All @@ -38,9 +38,6 @@
- Recursively add those subjects.
"""

# Stdlib
import logging

# 3rd party
import pyxb

Expand All @@ -52,7 +49,7 @@

def extract_subjects(subject_info_xml, primary_str):
"""Extract a set of equivalent and group membership subjects from SubjectInfo
{primary_str} is a DataONE subject, typically a DataONE compliant
serialization of the DN of the DataONE X.509 v3 certificate extension from
which the SubjectInfo was extracted.
Expand Down Expand Up @@ -114,7 +111,7 @@ def _add_person_is_member_of(equivalent_set, subject_info_pyxb, person_pyxb):


def _add_person_equivalent_subjects(
equivalent_set, subject_info_pyxb, person_pyxb
equivalent_set, subject_info_pyxb, person_pyxb
):
for equivalent_pyxb in person_pyxb.equivalentIdentity:
_add_subject(equivalent_set, subject_info_pyxb, equivalent_pyxb.value())
Expand Down
14 changes: 6 additions & 8 deletions d1_common_python/src/d1_common/cert/x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ def _deserialize_pem(cert_pem):
def _extract_dataone_subject_from_dn(cert_obj):
return (
','.join(
reversed(
[
'{}={}'.format(
OID_TO_SHORT_NAME_DICT.
get(v.oid.dotted_string, v.oid.dotted_string), _escape(v.value)
) for v in cert_obj.subject
]
)
reversed([
'{}={}'.format(
OID_TO_SHORT_NAME_DICT.get(v.oid.dotted_string, v.oid.dotted_string),
_escape(v.value)
) for v in cert_obj.subject
])
)
)

Expand Down
129 changes: 0 additions & 129 deletions yapf_style.cfg

This file was deleted.

0 comments on commit d60e23f

Please sign in to comment.