format main.py
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 18 May 2021 01:02:53 +0000 (18:02 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 18 May 2021 01:02:53 +0000 (18:02 -0700)
src/budget_sync/main.py

index 292c449a28bebe03b7d4f9b6552e105abf666436..3e5135729468eef5161f7867ac6334d7321d7802 100644 (file)
@@ -9,13 +9,15 @@ from budget_sync.budget_graph import BudgetGraph, BudgetGraphBaseError
 from budget_sync.write_budget_markdown import write_budget_markdown
 from collections import OrderedDict
 
-# Write an array of dictionaries to the CSV file name
+
 def write_csv(name, items, headers):
+    """ Write an array of dictionaries to the CSV file name """
     with open(name, 'w') as csvfile:
         writer = csv.DictWriter(csvfile, headers, lineterminator="\n")
         writer.writeheader()
         writer.writerows(items)
 
+
 mdwn_csv_template = """\
 # %s
 
@@ -26,6 +28,7 @@ mdwn_people_template = """\
  * [%s](%s)
 """
 
+
 def main():
     parser = argparse.ArgumentParser(
         description="Check for errors in "
@@ -57,7 +60,7 @@ def main():
 
     # quick hack to display total payment amounts per-milestone
     for milestone, payments in budget_graph.milestone_payments.items():
-        print (milestone)
+        print(milestone)
         total = 0
         total_requested = 0
         total_req_or_paid = 0
@@ -72,16 +75,16 @@ def main():
             if payment.submitted or payment.paid is not None:
                 total_req_or_paid += payment.amount
 
-        print ("\t %-9s" % total,
-                "submitted %-9s" % total_requested,
-                "paid %-9s" % total_paid,
-                "submitted or paid %-9s" % total_req_or_paid)
-        print ()
+        print("\t %-9s" % total,
+              "submitted %-9s" % total_requested,
+              "paid %-9s" % total_paid,
+              "submitted or paid %-9s" % total_req_or_paid)
+        print()
 
     # and one to display peole
     milestones_people = budget_graph.get_milestone_people()
     for milestone, people in milestones_people.items():
-        print (milestone)
+        print(milestone)
         for person in people:
             print("\t", person)
 
@@ -91,7 +94,7 @@ def main():
     all_people = OrderedDict()
     # pre-initialise the CSV lists (to avoid overwrite)
     for milestone, payments in budget_graph.milestone_payments.items():
-        milestone_csvs[milestone] = {} # rows in the CSV file
+        milestone_csvs[milestone] = {}  # rows in the CSV file
 
     for milestone, payments in budget_graph.milestone_payments.items():
         # first get the list of people, then create some columns
@@ -126,15 +129,15 @@ def main():
             row[name+"_req"] = requested
             row[name+"_paid"] = paid
 
-            print (row)
+            print(row)
             milestone_csvs[milestone][payment.node.bug.id] = row
 
     if args.output_dir is not None:
         with open("%s/csvs.mdwn" % args.output_dir, "w") as f:
             # write out the people pages
             # TODO, has to be done by the markdown page name
-            #f.write("# People\n\n")
-            #for name, person in all_people.items():
+            # f.write("# People\n\n")
+            # for name, person in all_people.items():
             #    fname = "%s/%s" % (args.output_dir, name)
             #    f.write(mdwn_people_template % (person, fname))
             # and the CSV files
@@ -142,9 +145,10 @@ def main():
                 ident = milestone.identifier
                 header = milestone_headings[milestone]
                 fname = "%s/%s.csv" % (args.output_dir, ident)
-                rows = rows.values() # turn into list
+                rows = rows.values()  # turn into list
                 write_csv(fname, rows, header)
                 f.write(mdwn_csv_template % (ident, fname))
 
+
 if __name__ == "__main__":
     main()