summaryrefslogtreecommitdiff
path: root/troveclient/utils.py
diff options
context:
space:
mode:
authorSushil Kumar <sushil.kumar2@globallogic.com>2014-01-13 17:04:50 +0000
committerSushil Kumar <sushil.kumar2@globallogic.com>2014-05-09 08:54:39 +0000
commit8bc695bd70853305bdd1009a69503728712f57a5 (patch)
tree315d6cb2c99ce9d610b32a6340d58b2decce60ad /troveclient/utils.py
parent4643f78a200aff5155e7029dfde0eebe9bef0e70 (diff)
downloadpython-troveclient-8bc695bd70853305bdd1009a69503728712f57a5.tar.gz
Enabled F821, H306, H402, and H404 flake8 rule
Reasons: - F821 is disabled. - H306 is disabled. - H402 is disabled. - H404 is disabled. Changes: - Updates tox.ini to enable F821, H306, H402 and H404 rules. - Updates code for F821, H306, H402 and H404 violation. Change-Id: I772270bb833ac774e080fc63e330d6b333f23de2
Diffstat (limited to 'troveclient/utils.py')
-rw-r--r--troveclient/utils.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/troveclient/utils.py b/troveclient/utils.py
index b5e3965..b7cbb02 100644
--- a/troveclient/utils.py
+++ b/troveclient/utils.py
@@ -17,12 +17,12 @@
from __future__ import print_function
import os
+import simplejson as json
import sys
import uuid
-import simplejson as json
-import six
import prettytable
+import six
from troveclient.openstack.common.apiclient import exceptions
from troveclient.openstack.common import strutils
@@ -37,8 +37,9 @@ def arg(*args, **kwargs):
def env(*vars, **kwargs):
- """
- returns the first environment variable set
+ """Returns environment variables.
+
+ Returns the first environment variable set
if none are non-empty, defaults to '' or keyword arg default
"""
for v in vars:
@@ -63,8 +64,8 @@ def add_arg(f, *args, **kwargs):
def unauthenticated(f):
- """
- Adds 'unauthenticated' attribute to decorated function.
+ """Adds 'unauthenticated' attribute to decorated function.
+
Usage:
@unauthenticated
def mymethod(f):
@@ -75,7 +76,8 @@ def unauthenticated(f):
def isunauthenticated(f):
- """
+ """Decorator to mark authentication-non-required.
+
Checks to see if the function is marked as not requiring authentication
with the @unauthenticated decorator. Returns True if decorator is
set to True, False otherwise.
@@ -84,8 +86,8 @@ def isunauthenticated(f):
def service_type(stype):
- """
- Adds 'service_type' attribute to decorated function.
+ """Adds 'service_type' attribute to decorated function.
+
Usage:
@service_type('database')
def mymethod(f):
@@ -98,9 +100,7 @@ def service_type(stype):
def get_service_type(f):
- """
- Retrieves service type from function
- """
+ """Retrieves service type from function."""
return getattr(f, 'service_type', None)
@@ -113,11 +113,12 @@ def translate_keys(collection, convert):
def _output_override(objs, print_as):
- """
+ """Output override flag checking.
+
If an output override global flag is set, print with override
raise BaseException if no printing was overridden.
"""
- if 'json_output' in globals() and json_output:
+ if 'json_output' in globals():
if print_as == 'list':
new_objs = []
for o in objs:
@@ -261,7 +262,8 @@ def safe_issubclass(*args):
# http://code.activestate.com/recipes/
# 577257-slugify-make-a-string-usable-in-a-url-or-filename/
def slugify(value):
- """
+ """Converts a string usable in a url or filename.
+
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.