Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Track utils with pycodestyle #677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions kubernetes/utils/create_from_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os import path

import re
import sys

from six import iteritems
from os import path

import yaml
from six import iteritems

from kubernetes import client


def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
"""
Perform an action from a yaml file. Pass True for verbose to
print confirmation information.

Input:
yaml_file: string. Contains the path to yaml file.
k8s_cline: an ApiClient object, initialized with the client args.
Expand All @@ -40,7 +40,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):

with open(path.abspath(yaml_file)) as f:
yml_object = yaml.load(f)
#TODO: case of yaml file containing multiple objects
# TODO: case of yaml file containing multiple objects
group, _, version = yml_object["apiVersion"].partition("/")
if version == "":
version = group
Expand All @@ -49,7 +49,7 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
# Only replace the last instance
group = "".join(group.rsplit(".k8s.io", 1))
fcn_to_call = "{0}{1}Api".format(group.capitalize(),
version.capitalize())
version.capitalize())
k8s_api = getattr(client, fcn_to_call)(k8s_client)
# Replace CamelCased action_type into snake_case
kind = yml_object["kind"]
Expand All @@ -71,4 +71,3 @@ def create_from_yaml(k8s_client, yaml_file, verbose=False, **kwargs):
if verbose:
print("{0} created. status='{1}'".format(kind, str(resp.status)))
return k8s_api

2 changes: 1 addition & 1 deletion scripts/update-pycodestyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SAVEIFS=$IFS
trap "IFS=$SAVEIFS" EXIT SIGINT
IFS=,

SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"
SOURCES="${SCRIPT_ROOT}/../setup.py,${CLIENT_ROOT}/config/*.py,${CLIENT_ROOT}/watch/*.py,${CLIENT_ROOT}/utils/*.py,${SCRIPT_ROOT}/*.py,${CLIENT_ROOT}/../examples/*.py"

echo "--- applying autopep8"
for SOURCE in $SOURCES; do
Expand Down