Commits

Jason R. Coombs committed f69fea4

Extracted printing obligations

Comments (0)

Files changed (1)

jaraco/financial/merchant.py

 			self.setdefault(agent, ledger.Ledger())
 
 	def add_obligations(self):
-		print("Agent obligations are:")
-		for agent in self:
-			if not agent.obligations:
-				continue
-			print(agent)
-			for merchant in agent.obligations:
-				print('  For', merchant)
-				obl = agent.obligations[merchant]
-				for obl in agent.obligations[merchant]:
-					print('    ', obl)
+		self._print_obligations()
 		while True:
 			if raw_input('Add new obligation? ') != 'y':
 				break
 			agent.obligations.add(merchant=merchant, agent=obl_agent,
 				share=amount)
 
+	def _print_obligations(self):
+		if not any(agent.obligations for agent in self):
+			print("no Agent obligations set")
+			return
+		print("Agent obligations are:")
+		for agent in self:
+			if not agent.obligations:
+				continue
+			print(agent)
+			for merchant in agent.obligations:
+				print('  For', merchant)
+				obl = agent.obligations[merchant]
+				for obl in agent.obligations[merchant]:
+					print('    ', obl)
+
 	def process_residuals(self):
 		for agent in self:
 			self._process_agent_residuals(agent)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.