Skip to content

Commit 95dad66

Browse files
committed
Move to black / docformatter
1 parent 2a7da2b commit 95dad66

File tree

10 files changed

+161
-110
lines changed

10 files changed

+161
-110
lines changed

client_cli/src/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This work was created by participants in the DataONE project, and is
4+
# jointly copyrighted by participating institutions in DataONE. For
5+
# more information on DataONE, see our web site at http://dataone.org.
6+
#
7+
# Copyright 2009-2016 DataONE
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
21+
from d1_cli.version import __version__ # noqa: F401

client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
18-
"""This client code is built from: http://svn.apache.org/viewvc/lucene/solr/tag
19-
s/release-1.2.0/client/python/solr.py.
2018

21-
though has been modified in many respects.
22-
"""
2319
# Licensed to the Apache Software Foundation (ASF) under one or more
2420
# contributor license agreements. See the NOTICE file distributed with
2521
# this work for additional information regarding copyright ownership.
@@ -50,6 +46,12 @@
5046
# data = c.search(q='id:500', wt='python')
5147
# print 'first match=', eval(data)['response']['docs'][0]
5248

49+
"""This client code is built from: http://svn.apache.org/viewvc/lucene/solr/tag
50+
s/release-1.2.0/client/python/solr.py.
51+
52+
though has been modified in many respects.
53+
"""
54+
5355
import codecs
5456
# ===============================================================================
5557
import datetime
@@ -595,8 +597,8 @@ def fieldAlphaHistogram(
595597
):
596598
"""Generates a histogram of values from a string field. Output is:
597599
598-
[[low, high, count, query], ... ] Bin edges is determined
599-
by equal division of the fields
600+
[[low, high, count, query], ... ] Bin edges is determined by
601+
equal division of the fields
600602
"""
601603
oldpersist = self.persistent
602604
self.persistent = True

dev_tools/src/d1_dev/src-format.py

+61-62
Original file line numberDiff line numberDiff line change
@@ -34,80 +34,79 @@
3434

3535

3636
def main():
37-
"""Format all tracked .py files.
38-
39-
Black + isort + docformatter.
40-
"""
41-
parser = argparse.ArgumentParser(
42-
description=__doc__,
43-
formatter_class=argparse.RawDescriptionHelpFormatter,
44-
)
45-
parser.add_argument('path', nargs='+', help='File or directory path')
46-
parser.add_argument('--exclude', nargs='+', help='Exclude glob patterns')
47-
parser.add_argument(
48-
'--no-recursive', dest='recursive', action='store_false',
49-
help='Search directories recursively'
50-
)
51-
parser.add_argument(
52-
'--ignore-invalid', action='store_true', help='Ignore invalid paths'
53-
)
54-
parser.add_argument(
55-
'--pycharm', action='store_true', help='Enable PyCharm integration'
56-
)
57-
parser.add_argument(
58-
'--debug', action='store_true', help='Debug level logging'
59-
)
60-
61-
args = parser.parse_args()
62-
d1_common.util.log_setup(args.debug)
63-
64-
repo_path = d1_dev.util.find_repo_root_by_path(__file__)
65-
repo = git.Repo(repo_path)
66-
67-
specified_file_path_list = get_specified_file_path_list(args)
68-
tracked_path_list = list(d1_dev.util.get_tracked_files(repo))
69-
format_path_list = sorted(
70-
set(specified_file_path_list).intersection(tracked_path_list)
71-
)
72-
format_all(args, format_path_list)
37+
"""Format all tracked .py files.
7338
39+
Black + isort + docformatter.
40+
"""
41+
parser = argparse.ArgumentParser(
42+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
43+
)
44+
parser.add_argument('path', nargs='+', help='File or directory path')
45+
parser.add_argument('--exclude', nargs='+', help='Exclude glob patterns')
46+
parser.add_argument(
47+
'--no-recursive',
48+
dest='recursive',
49+
action='store_false',
50+
help='Search directories recursively',
51+
)
52+
parser.add_argument(
53+
'--ignore-invalid', action='store_true', help='Ignore invalid paths'
54+
)
55+
parser.add_argument(
56+
'--pycharm', action='store_true', help='Enable PyCharm integration'
57+
)
58+
parser.add_argument('--debug', action='store_true', help='Debug level logging')
7459

75-
def get_specified_file_path_list(args):
76-
specified_file_path_list = [
77-
os.path.realpath(p)
78-
for p in d1_common.iter.path.path_generator(
79-
path_list=args.path,
80-
include_glob_list=['*.py'],
81-
exclude_glob_list=args.exclude,
82-
recursive=args.recursive,
83-
ignore_invalid=args.ignore_invalid,
84-
default_excludes=False,
85-
return_dir_paths=True,
60+
args = parser.parse_args()
61+
d1_common.util.log_setup(args.debug)
62+
63+
repo_path = d1_dev.util.find_repo_root_by_path(__file__)
64+
repo = git.Repo(repo_path)
65+
66+
specified_file_path_list = get_specified_file_path_list(args)
67+
tracked_path_list = list(d1_dev.util.get_tracked_files(repo))
68+
format_path_list = sorted(
69+
set(specified_file_path_list).intersection(tracked_path_list)
8670
)
87-
]
88-
return specified_file_path_list
71+
format_all(args, format_path_list)
72+
73+
74+
def get_specified_file_path_list(args):
75+
specified_file_path_list = [
76+
os.path.realpath(p)
77+
for p in d1_common.iter.path.path_generator(
78+
path_list=args.path,
79+
include_glob_list=['*.py'],
80+
exclude_glob_list=args.exclude,
81+
recursive=args.recursive,
82+
ignore_invalid=args.ignore_invalid,
83+
default_excludes=False,
84+
return_dir_paths=True,
85+
)
86+
]
87+
return specified_file_path_list
8988

9089

9190
def format_all(args, format_path_list):
92-
for format_path in format_path_list:
93-
logging.info('Formatting file. path="{}"'.format(format_path))
94-
format_single(args, format_path)
91+
for format_path in format_path_list:
92+
logging.info('Formatting file. path="{}"'.format(format_path))
93+
format_single(args, format_path)
9594

9695

9796
def format_single(args, format_path):
98-
run_cmd('black', '--skip-string-normalization', format_path)
99-
run_cmd('isort', format_path)
100-
run_cmd('docformatter', '-i', format_path)
97+
run_cmd('black', '--skip-string-normalization', format_path)
98+
run_cmd('isort', format_path)
99+
run_cmd('docformatter', '-i', format_path)
101100

102101

103102
def run_cmd(*cmd_list):
104-
print('Running command: {}'.format(' '.join(cmd_list)))
105-
try:
106-
subprocess.check_call(cmd_list)
107-
except subprocess.CalledProcessError as e:
108-
print('Failed: {}'.format(str(e)))
109-
raise
103+
print('Running command: {}'.format(' '.join(cmd_list)))
104+
try:
105+
subprocess.check_call(cmd_list)
106+
except subprocess.CalledProcessError as e:
107+
print('Failed: {}'.format(str(e)))
108+
raise
110109

111110

112111
if __name__ == '__main__':
113-
sys.exit(main())
112+
sys.exit(main())

gmn/src/d1_gmn/tests/gmn_test_case.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# -*- coding: utf-8 -*-
22

3+
# This work was created by participants in the DataONE project, and is
4+
# jointly copyrighted by participating institutions in DataONE. For
5+
# more information on DataONE, see our web site at http://dataone.org.
6+
#
7+
# Copyright 2009-2016 DataONE
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
321
import copy
422
import datetime
523
import io
@@ -22,23 +40,6 @@
2240

2341
import d1_common.checksum
2442
import d1_common.const
25-
# This work was created by participants in the DataONE project, and is
26-
# jointly copyrighted by participating institutions in DataONE. For
27-
# more information on DataONE, see our web site at http://dataone.org.
28-
#
29-
# Copyright 2009-2016 DataONE
30-
#
31-
# Licensed under the Apache License, Version 2.0 (the "License");
32-
# you may not use this file except in compliance with the License.
33-
# You may obtain a copy of the License at
34-
#
35-
# http://www.apache.org/licenses/LICENSE-2.0
36-
#
37-
# Unless required by applicable law or agreed to in writing, software
38-
# distributed under the License is distributed on an "AS IS" BASIS,
39-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40-
# See the License for the specific language governing permissions and
41-
# limitations under the License.
4243
import d1_common.resource_map
4344
import d1_common.types
4445
import d1_common.types.dataoneTypes
@@ -344,6 +345,7 @@ def call_d1_client(self, api_func, *arg_list, **arg_dict):
344345
pytest.fail(
345346
'Make sure: Test function is decorated with "@responses.activate", '
346347
'class derives from GMNTestCase, '
348+
'The correct client fixture is used (mn_client / gmn_client), '
347349
'class setup_method() calls super(). '
348350
'error="{}"'.format(str(e))
349351
)

gmn/src/d1_gmn/tests/test_cors.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ def test_1000(self, gmn_client_v1_v2):
4444
@responses.activate
4545
def test_1010(self, gmn_client_v1_v2):
4646
"""Invalid method against endpoint raises 405 Method Not Allowed and
47-
returns regular and CORS headers with allowed methods (POST
48-
/object/invalid_pid)"""
47+
returns regular and CORS headers with allowed methods (POST.
48+
49+
/object/invalid_pid)
50+
"""
4951
with d1_gmn.tests.gmn_mock.disable_auth():
5052
response = gmn_client_v1_v2.POST(['object', 'invalid_pid'])
5153
self.sample.assert_equals(response, 'post_object_pid', gmn_client_v1_v2)

lib_client/src/d1_client/baseclient_1_1.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def queryResponse(
6161
"""CNRead.query(session, queryEngine, query) → OctetStream
6262
https://releases.dataone.org/online/api-
6363
documentation-v2.0.1/apis/CN_APIs.html#CNRead.query
64-
MNQuery.query(session, queryEngine, query) → OctetStream http://jenkins
64+
MNQuery.query(session, queryEngine, query) → OctetStream
65+
http://jenkins.
66+
6567
-1.dataone.org/jenkins/job/API%20Documentation%20-%20trunk/ws/api-
6668
documentation/build/html/apis/MN_APIs.html#MNQuery.query.
6769

lib_client/src/d1_client/cnclient.py

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def getQueryEngineDescription(self, queryEngine, vendorSpecific=None, **kwargs):
410410

411411
def setRightsHolderResponse(self, pid, userId, serialVersion, vendorSpecific=None):
412412
"""CNAuthorization.setRightsHolder(session, pid, userId, serialVersion)
413+
413414
→ Identifier https://releases.dataone.org/online/api-
414415
documentation-v2.0.1/apis/CN_APIs.html#CNAuthorization.setRightsHolder.
415416

lib_common/src/d1_common/types/generated/dataoneTypes_v1.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ class CrontabEntrySeconds(pyxb.binding.datatypes.token):
167167
# Atomic simple type: {http://ns.dataone.org/service/types/v1}Event
168168
class Event(pyxb.binding.datatypes.string, pyxb.binding.basis.enumeration_mixin):
169169

170-
"""The controlled list of events that are logged, which will include
170+
"""The controlled list of events that are logged, which will include.
171+
171172
*create*, *update*, *delete*, *read*, *replicate*,
172173
173174
*synchronization_failed* and *replication_failed*
@@ -561,7 +562,8 @@ class AccessRule(pyxb.binding.basis.complexTypeDefinition):
561562
If a subject is granted multiple permissions, the highest level of access
562563
applies. The resource on which the access control rules are being applied
563564
is determined by the containing :term:`SystemMetadata` document, or in the
564-
case of methods such as :func:`CNAuthorization.setAccessPolicy`, by the
565+
case of methods such as :func:`CNAuthorization.setAccessPolicy`, by the.
566+
565567
:term:`pid` in the method parameters.Access control rules are specified by
566568
the.
567569
@@ -1146,7 +1148,9 @@ class NodeList(pyxb.binding.basis.complexTypeDefinition):
11461148

11471149
# Complex type {http://ns.dataone.org/service/types/v1}ObjectFormat with content type ELEMENT_ONLY
11481150
class ObjectFormat(pyxb.binding.basis.complexTypeDefinition):
1149-
"""One value from the DataONE Object Format Vocabulary which is returned by
1151+
"""One value from the DataONE Object Format Vocabulary which is returned
1152+
by.
1153+
11501154
:func:`CNCore.getFormat()`.An *ObjectFormat* is the structure returned from
11511155
the.
11521156
@@ -1245,8 +1249,11 @@ class ObjectFormat(pyxb.binding.basis.complexTypeDefinition):
12451249

12461250
# Complex type {http://ns.dataone.org/service/types/v1}ObjectInfo with content type ELEMENT_ONLY
12471251
class ObjectInfo(pyxb.binding.basis.complexTypeDefinition):
1248-
"""Metadata about an object, representing a subset of the metadata found in
1249-
:class:`Types.SystemMetadata`."""
1252+
"""Metadata about an object, representing a subset of the metadata found
1253+
in.
1254+
1255+
:class:`Types.SystemMetadata`.
1256+
"""
12501257

12511258
_TypeDefinition = None
12521259
_ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY
@@ -1359,7 +1366,8 @@ class ObjectLocation(pyxb.binding.basis.complexTypeDefinition):
13591366
"""Portion of an :class:`Types.ObjectLocationList` indicating the node from
13601367
which the object can be retrieved. The principal information on each
13611368
location is found in the *nodeIdentifier*, all other fields are provided
1362-
for convenience, but could also be looked up from the
1369+
for convenience, but could also be looked up from the.
1370+
13631371
:class:`Types.NodeList` information obtained from.
13641372
13651373
:func:`CNCore.listNodes`.
@@ -1496,7 +1504,8 @@ class ObjectLocation(pyxb.binding.basis.complexTypeDefinition):
14961504

14971505
# Complex type {http://ns.dataone.org/service/types/v1}ObjectLocationList with content type ELEMENT_ONLY
14981506
class ObjectLocationList(pyxb.binding.basis.complexTypeDefinition):
1499-
"""An *ObjectLocationList* is the structure returned from the
1507+
"""An *ObjectLocationList* is the structure returned from the.
1508+
15001509
:func:`CNRead.resolve` method of the CN REST interface.
15011510
15021511
It provides a list of locations from which the specified object can
@@ -2264,7 +2273,8 @@ class Slice(pyxb.binding.basis.complexTypeDefinition):
22642273
class Synchronization(pyxb.binding.basis.complexTypeDefinition):
22652274
"""Configuration information for the process by which metadata is harvested
22662275
from Member Nodes to Coordinating Nodes, including the schedule on which
2267-
harvesting should occur, and information about the last
2276+
harvesting should occur, and information about the last.
2277+
22682278
:term:`synchronization` attempts for the node. Member Nodes providing
22692279
*Synchronization* information only need to provide the.
22702280
@@ -3699,7 +3709,8 @@ class Schedule(pyxb.binding.basis.complexTypeDefinition):
36993709

37003710
# Complex type {http://ns.dataone.org/service/types/v1}Subject with content type SIMPLE
37013711
class Subject(pyxb.binding.basis.complexTypeDefinition):
3702-
"""An identifier for a Person (user), Group, Organization, or System.The
3712+
"""An identifier for a Person (user), Group, Organization, or System.The.
3713+
37033714
:term:`Subject` is a string that provides a formal name to identify a user
37043715
or group in the DataONE Identity Management Service. The *subject* is
37053716
represented by a unique, persistent, non-reassignable identifier string

0 commit comments

Comments
 (0)