Преглед изворни кода

Some small pep8 corrections.

Jeroen пре 12 година
родитељ
комит
d207051ff4
2 измењених фајлова са 22 додато и 20 уклоњено
  1. 6 5
      3-tier.py
  2. 16 15
      mvc.py

+ 6 - 5
3-tier.py

@@ -1,12 +1,13 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+
 class Data(object):
 
     products = {
-            'milk': { 'price': 1.50, 'quantity': 10 },
-            'eggs': { 'price': 0.20, 'quantity': 100 },
-            'cheese': { 'price': 2.00, 'quantity': 10 }
+        'milk': {'price': 1.50, 'quantity': 10},
+        'eggs': {'price': 0.20, 'quantity': 100},
+        'cheese': {'price': 2.00, 'quantity': 10}
     }
 
 
@@ -37,8 +38,8 @@ class Ui(object):
         product_info = self.business_logic.product_information(product)
         if product_info is not None:
             print('PRODUCT INFORMATION:')
-            print('Name: %s, Price: %.2f, Quantity: %d\n' % \
-                  (product.title(), product_info.get('price', 0), \
+            print('Name: %s, Price: %.2f, Quantity: %d\n' %
+                  (product.title(), product_info.get('price', 0),
                    product_info.get('quantity', 0)))
         else:
             print('That product "%s" does not exist in the records' % product)

+ 16 - 15
mvc.py

@@ -1,27 +1,28 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
- 
+
+
 class Model(object):
- 
+
     products = {
-            'milk': { 'price': 1.50, 'quantity': 10 },
-            'eggs': { 'price': 0.20, 'quantity': 100 },
-            'cheese': { 'price': 2.00, 'quantity': 10 }
+        'milk': {'price': 1.50, 'quantity': 10},
+        'eggs': {'price': 0.20, 'quantity': 100},
+        'cheese': {'price': 2.00, 'quantity': 10}
     }
 
 
 class View(object):
- 
+
     def product_list(self, product_list):
         print('PRODUCT LIST:')
         for product in product_list:
             print(product)
         print('')
- 
+
     def product_information(self, product, product_info):
         print('PRODUCT INFORMATION:')
-        print('Name: %s, Price: %.2f, Quantity: %d\n' % \
-              (product.title(), product_info.get('price', 0), \
+        print('Name: %s, Price: %.2f, Quantity: %d\n' %
+              (product.title(), product_info.get('price', 0),
                product_info.get('quantity', 0)))
 
     def product_not_found(self, product):
@@ -29,25 +30,25 @@ class View(object):
 
 
 class Controller(object):
- 
+
     def __init__(self):
         self.model = Model()
         self.view = View()
- 
+
     def get_product_list(self):
         product_list = self.model.products.keys()
         self.view.product_list(product_list)
- 
+
     def get_product_information(self, product):
         product_info = self.model.products.get(product, None)
         if product_info is not None:
             self.view.product_information(product, product_info)
         else:
             self.view.product_not_found(product)
- 
- 
+
+
 if __name__ == '__main__':
- 
+
     controller = Controller()
     controller.get_product_list()
     controller.get_product_information('cheese')