Merge "Check python with flake8 instead of dib-lint"

This commit is contained in:
Jenkins 2014-11-25 02:56:57 +00:00 committed by Gerrit Code Review
commit 3b0130ed79
5 changed files with 43 additions and 11 deletions

View File

@ -71,12 +71,17 @@ for i in $(find elements -type f); do
fi fi
# Ensure 4 spaces indent are used # Ensure 4 spaces indent are used
if ! excluded indent; then
if [ "$(file -b --mime-type $i)" = "text/x-python" ]; then
flake8 $i
else
if ! excluded indent ; then
if grep -q "^ \{4\}* \{1,3\}[^ ]" ${i}; then if grep -q "^ \{4\}* \{1,3\}[^ ]" ${i}; then
error "$i should use 4 spaces indent" error "$i should use 4 spaces indent"
fi fi
fi fi
fi fi
fi
# Check alphabetical ordering of element-deps # Check alphabetical ordering of element-deps
if [ $(basename $i) = "element-deps" ]; then if [ $(basename $i) = "element-deps" ]; then

View File

@ -1,7 +1,20 @@
#!/usr/bin/env python #!/usr/bin/env python
#
# 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.path import os.path
def main(): def main():
home = os.path.expanduser("~") home = os.path.expanduser("~")
backup_configs(home) backup_configs(home)
@ -42,4 +55,3 @@ def backup_configs(home):
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -1,6 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
# dib-lint: disable=indent
# dib-lint indent requirements causes issue with pep8
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # 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 # not use this file except in compliance with the License. You may obtain

View File

@ -16,6 +16,7 @@
# under the License. # under the License.
import os import os
import sys import sys
import yaml import yaml

View File

@ -1,11 +1,25 @@
#!/usr/bin/env python #!/usr/bin/env python
#
# 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 os
import sys import sys
import yaml import yaml
def os_family(distro): def os_family(distro):
"""Given a distribution, returns a operating system family.""" "Given a distribution, returns a operating system family."
family = None family = None
if distro in ['centos7', 'fedora', 'rhel', 'rhel7']: if distro in ['centos7', 'fedora', 'rhel', 'rhel7']:
family = 'redhat' family = 'redhat'
@ -17,8 +31,10 @@ def os_family(distro):
def merge_data(source, destination, distro): def merge_data(source, destination, distro):
"""Merges two dictionaries and filters on distro, family, or default """Merges two dictionaries and filters on distro.
(in order)."""
Merges two dictionaries and filters on distro family, or default (in order)
"""
result = dict() result = dict()
result.update(destination) result.update(destination)
family = os_family(distro) family = os_family(distro)
@ -61,8 +77,8 @@ def main():
service_names, service_names,
os.environ.get("DISTRO_NAME")) os.environ.get("DISTRO_NAME"))
except Exception as err: except Exception as err:
print("%s. Check %s for duplicate \ print("%s. Check %s for duplicate"
service name." % (err, element)) " service name." % (err, element))
sys.exit(1) sys.exit(1)
write_data_to_file(service_names, os.path.join("/tmp", 'svc-map-services')) write_data_to_file(service_names, os.path.join("/tmp", 'svc-map-services'))