Skip to content

Commit 5d794ce

Browse files
committed
Your code is too weak for PEP8. You lack DISCIPLINE
1 parent dc29feb commit 5d794ce

27 files changed

+83
-15
lines changed

3-tier.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def main():
6262
# eggs
6363
# milk
6464
# cheese
65-
#
65+
#
6666
# PRODUCT INFORMATION:
6767
# Name: Cheese, Price: 2.00, Quantity: 10
6868
# PRODUCT INFORMATION:

abstract_factory.py

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
class PetShop:
12+
1213
"""A pet shop"""
1314

1415
def __init__(self, animal_factory=None):
@@ -30,6 +31,7 @@ def show_pet(self):
3031
# Stuff that our factory makes
3132

3233
class Dog:
34+
3335
def speak(self):
3436
return "woof"
3537

@@ -38,6 +40,7 @@ def __str__(self):
3840

3941

4042
class Cat:
43+
4144
def speak(self):
4245
return "meow"
4346

@@ -48,6 +51,7 @@ def __str__(self):
4851
# Factory classes
4952

5053
class DogFactory:
54+
5155
def get_pet(self):
5256
return Dog()
5357

@@ -56,6 +60,7 @@ def get_food(self):
5660

5761

5862
class CatFactory:
63+
5964
def get_pet(self):
6065
return Cat()
6166

adapter.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
class Dog(object):
10+
1011
def __init__(self):
1112
self.name = "Dog"
1213

@@ -15,6 +16,7 @@ def bark(self):
1516

1617

1718
class Cat(object):
19+
1820
def __init__(self):
1921
self.name = "Cat"
2022

@@ -23,6 +25,7 @@ def meow(self):
2325

2426

2527
class Human(object):
28+
2629
def __init__(self):
2730
self.name = "Human"
2831

@@ -31,6 +34,7 @@ def speak(self):
3134

3235

3336
class Car(object):
37+
3438
def __init__(self):
3539
self.name = "Car"
3640

@@ -39,6 +43,7 @@ def make_noise(self, octane_level):
3943

4044

4145
class Adapter(object):
46+
4247
"""
4348
Adapts an object by replacing methods.
4449
Usage:
@@ -63,6 +68,7 @@ class Adapter(object):
6368
A Human goes 'hello'
6469
A Car goes vroom!!!
6570
"""
71+
6672
def __init__(self, obj, adapted_methods):
6773
"""We set the adapted methods in the object's dict"""
6874
self.obj = obj

bridge.py

+3
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66

77
# ConcreteImplementor 1/2
88
class DrawingAPI1(object):
9+
910
def draw_circle(self, x, y, radius):
1011
print('API1.circle at {}:{} radius {}'.format(x, y, radius))
1112

1213

1314
# ConcreteImplementor 2/2
1415
class DrawingAPI2(object):
16+
1517
def draw_circle(self, x, y, radius):
1618
print('API2.circle at {}:{} radius {}'.format(x, y, radius))
1719

1820

1921
# Refined Abstraction
2022
class CircleShape(object):
23+
2124
def __init__(self, x, y, radius, drawing_api):
2225
self._x = x
2326
self._y = y

builder.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# Director
1111
class Director(object):
12+
1213
def __init__(self):
1314
self.builder = None
1415

@@ -23,6 +24,7 @@ def get_building(self):
2324

2425
# Abstract Builder
2526
class Builder(object):
27+
2628
def __init__(self):
2729
self.building = None
2830

@@ -32,6 +34,7 @@ def new_building(self):
3234

3335
# Concrete Builder
3436
class BuilderHouse(Builder):
37+
3538
def build_floor(self):
3639
self.building.floor = 'One'
3740

@@ -40,15 +43,17 @@ def build_size(self):
4043

4144

4245
class BuilderFlat(Builder):
46+
4347
def build_floor(self):
4448
self.building.floor = 'More than One'
45-
49+
4650
def build_size(self):
4751
self.building.size = 'Small'
4852

4953

5054
# Product
5155
class Building(object):
56+
5257
def __init__(self):
5358
self.floor = None
5459
self.size = None

catalog.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
class Catalog():
13+
1314
"""
1415
catalog of multiple static methods that are executed depending on an init
1516
parameter

chain.py

+5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66

77
class Handler:
8+
89
def successor(self, successor):
910
self.successor = successor
1011

1112

1213
class ConcreteHandler1(Handler):
14+
1315
def handle(self, request):
1416
if 0 < request <= 10:
1517
print('request {} handled in handler 1'.format(request))
@@ -18,6 +20,7 @@ def handle(self, request):
1820

1921

2022
class ConcreteHandler2(Handler):
23+
2124
def handle(self, request):
2225
if 10 < request <= 20:
2326
print('request {} handled in handler 2'.format(request))
@@ -26,6 +29,7 @@ def handle(self, request):
2629

2730

2831
class ConcreteHandler3(Handler):
32+
2933
def handle(self, request):
3034
if 20 < request <= 30:
3135
print('request {} handled in handler 3'.format(request))
@@ -34,6 +38,7 @@ def handle(self, request):
3438

3539

3640
class Client:
41+
3742
def __init__(self):
3843
h1 = ConcreteHandler1()
3944
h2 = ConcreteHandler2()

command.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class MoveFileCommand(object):
8+
89
def __init__(self, src, dest):
910
self.src = src
1011
self.dest = dest

composite.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def denormalize(val):
3737

3838

3939
class SpecialDict(dict):
40+
4041
""" A dictionary type which allows direct attribute
4142
access to its keys """
4243

@@ -71,6 +72,7 @@ def __setattr__(self, name, value):
7172

7273

7374
class CompositeDict(SpecialDict):
75+
7476
""" A class which works like a hierarchical dictionary.
7577
This class is based on the Composite design-pattern """
7678

decorator.py

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
class foo_decorator(object):
8+
89
def __init__(self, decoratee):
910
self._decoratee = decoratee
1011

@@ -17,6 +18,7 @@ def __getattr__(self, name):
1718

1819

1920
class undecorated_foo(object):
21+
2022
def f1(self):
2123
print("original f1")
2224

@@ -26,6 +28,7 @@ def f2(self):
2628

2729
@foo_decorator
2830
class decorated_foo(object):
31+
2932
def f1(self):
3033
print("original f1")
3134

facade.py

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Complex Parts
1010
class TC1:
11+
1112
def run(self):
1213
print("###### In Test 1 ######")
1314
time.sleep(SLEEP)
@@ -21,6 +22,7 @@ def run(self):
2122

2223

2324
class TC2:
25+
2426
def run(self):
2527
print("###### In Test 2 ######")
2628
time.sleep(SLEEP)
@@ -34,6 +36,7 @@ def run(self):
3436

3537

3638
class TC3:
39+
3740
def run(self):
3841
print("###### In Test 3 ######")
3942
time.sleep(SLEEP)
@@ -48,6 +51,7 @@ def run(self):
4851

4952
# Facade
5053
class TestRunner:
54+
5155
def __init__(self):
5256
self.tc1 = TC1()
5357
self.tc2 = TC2()

factory_method.py

+4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66

77
class GreekGetter:
8+
89
"""A simple localizer a la gettext"""
10+
911
def __init__(self):
1012
self.trans = dict(dog="σκύλος", cat="γάτα")
1113

@@ -18,7 +20,9 @@ def get(self, msgid):
1820

1921

2022
class EnglishGetter:
23+
2124
"""Simply echoes the msg ids"""
25+
2226
def get(self, msgid):
2327
return str(msgid)
2428

flyweight.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88

99
class Card(object):
10+
1011
"""The object pool. Has builtin reference counting"""
1112
_CardPool = weakref.WeakValueDictionary()
1213

graph_search.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44

55
class GraphSearch:
6+
67
"""Graph search emulation in python, from source
78
http://www.python.org/doc/essays/graphs/"""
89

@@ -62,7 +63,7 @@ def find_shortest_path(self, start, end, path=[]):
6263
shortest = newpath
6364
return shortest
6465

65-
#example of graph usage
66+
# example of graph usage
6667
graph = {'A': ['B', 'C'],
6768
'B': ['C', 'D'],
6869
'C': ['D'],
@@ -71,7 +72,7 @@ def find_shortest_path(self, start, end, path=[]):
7172
'F': ['C']
7273
}
7374

74-
#initialization of new graph search object
75+
# initialization of new graph search object
7576
graph1 = GraphSearch(graph)
7677

7778

iterator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def count_to(count):
3232

3333
### OUTPUT ###
3434
# Counting to two...
35-
# one two
35+
# one two
3636
# Counting to five...
37-
# one two three four five
37+
# one two three four five

mediator.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
class TC:
11+
1112
def __init__(self):
1213
self._tm = None
1314
self._bProblem = 0
@@ -40,6 +41,7 @@ def setProblem(self, value):
4041

4142

4243
class Reporter:
44+
4345
def __init__(self):
4446
self._tm = None
4547

@@ -56,13 +58,14 @@ def setTM(self, tm):
5658

5759

5860
class DB:
61+
5962
def __init__(self):
6063
self._tm = None
6164

6265
def insert(self):
6366
print("Inserting the execution begin status in the Database")
6467
time.sleep(0.1)
65-
#Following code is to simulate a communication from DB to TC
68+
# Following code is to simulate a communication from DB to TC
6669
if random.randrange(1, 4) == 3:
6770
return -1
6871

@@ -75,6 +78,7 @@ def setTM(self, tm):
7578

7679

7780
class TestManager:
81+
7882
def __init__(self):
7983
self._reporter = None
8084
self._db = None

0 commit comments

Comments
 (0)