Skip to content
Permalink
Browse files

Fix up formatting to pass flake8

  • Loading branch information...
Jesse Myers
Jesse Myers committed Aug 26, 2016
1 parent 9482277 commit c91a03385191090c2125fbc4229fe8739de74e3e
Showing with 18 additions and 14 deletions.
  1. +7 −6 credstash.py
  2. +3 −0 setup.cfg
  3. +1 −1 setup.py
  4. +7 −7 tests/runtests.py
@@ -20,7 +20,6 @@
import os
import os.path
import sys
import time
import re
import boto3
import botocore.exceptions
@@ -44,7 +43,7 @@
from Crypto.Util import Counter

DEFAULT_REGION = "us-east-1"
PAD_LEN = 19 # number of digits in sys.maxint
PAD_LEN = 19 # number of digits in sys.maxint
WILDCARD_CHAR = "*"


@@ -80,10 +79,12 @@ def printStdErr(s):
sys.stderr.write(str(s))
sys.stderr.write("\n")


def fatal(s):
printStdErr(s)
sys.exit(1)


def key_value_pair(string):
output = string.split('=')
if len(output) != 2:
@@ -118,7 +119,7 @@ def value_or_filename(string):
try:
with open(os.path.expanduser(filename)) as f:
output = f.read()
except IOError as e:
except IOError:
raise argparse.ArgumentTypeError("Unable to read file %s" %
filename)
else:
@@ -327,7 +328,7 @@ def createDdbTable(region=None, table="credential-store", **kwargs):
return

print("Creating table...")
response = dynamodb.create_table(
dynamodb.create_table(
TableName=table,
KeySchema=[
{
@@ -521,7 +522,7 @@ def main():
session = get_session(**session_params)
session.resource('dynamodb', region_name=region)
except botocore.exceptions.NoRegionError:
if not 'AWS_DEFAULT_REGION' in os.environ:
if 'AWS_DEFAULT_REGION' not in os.environ:
region = DEFAULT_REGION

if "action" in vars(args):
@@ -555,7 +556,7 @@ def main():
version = paddedInt(int(latestVersion) + 1)
except ValueError:
fatal("Can not autoincrement version. The current "
"version: %s is not an int" % latestVersion)
"version: %s is not an int" % latestVersion)
else:
version = args.version
try:
@@ -0,0 +1,3 @@
[flake8]
ignore = T001
max-line-length = 120
@@ -1,4 +1,4 @@
from setuptools import setup, find_packages
from setuptools import setup

setup(
name='credstash',
@@ -8,16 +8,16 @@
class TestKeyValuePairExtraction(unittest.TestCase):

def test_key_value_pair_has_two_equals(self):
self.assertRaises(argparse.ArgumentTypeError, key_value_pair , "==")
self.assertRaises(argparse.ArgumentTypeError, key_value_pair, "==")

def test_key_value_pair_has_zero_equals(self):
self.assertRaises(argparse.ArgumentTypeError, key_value_pair, "")

def test_key_value_pair_has_one_equals(self):
self.assertEqual(key_value_pair("="), ["",""])
self.assertEqual(key_value_pair("="), ["", ""])

def test_key_value_pair_has_one_equals_with_values(self):
self.assertEqual(key_value_pair("key1=value1"), ["key1","value1"])
self.assertEqual(key_value_pair("key1=value1"), ["key1", "value1"])


class TestExpandingWildcard(unittest.TestCase):
@@ -29,7 +29,7 @@ def test_start_regex(self):

def test_end_regex(self):
self.assertEqual(expand_wildcard("ba", self.secrets_set), ["ba"])

def test_exact_match_regex(self):
self.assertEqual(expand_wildcard("abc", self.secrets_set), ["abc"])

@@ -49,7 +49,7 @@ def test_three_wild_card_with_many_matches(self):
class TestPadLeft(unittest.TestCase):
def test_zero(self):
i = 0
self.assertEqual(paddedInt(i), "0"*19)
self.assertEqual(paddedInt(i), "0" * 19)

def test_ten(self):
i = 10
@@ -65,4 +65,4 @@ def test_huge_number(self):


if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit c91a033

Please sign in to comment.
You can’t perform that action at this time.