44import sys
55from pathlib import Path
66
7- from rich import print
8- from rich .console import Console
9- from rich .table import Table
10-
117import click
128import inquirer
139import yaml
10+ from rich import print
11+ from rich .console import Console
12+ from rich .table import Table
1413
1514from resources .scenarios .ln_framework .ln import Policy
1615
1716from .constants import (
17+ DEFAULT_IMAGE_REPO ,
1818 DEFAULT_TAG ,
19- SUPPORTED_TAGS ,
2019 FORK_OBSERVER_RPCAUTH ,
21- DEFAULT_IMAGE_REPO ,
20+ SUPPORTED_TAGS ,
2221)
2322
2423
@@ -49,7 +48,7 @@ def custom_graph(
4948 index = 0
5049
5150 for entry in tanks :
52- for i in range (int (entry ["count" ])):
51+ for _ in range (int (entry ["count" ])):
5352 if ":" in entry ["version" ] and "/" in entry ["version" ]:
5453 repo , tag = entry ["version" ].split (":" )
5554 image = {"repository" : repo , "tag" : tag }
@@ -98,11 +97,10 @@ def custom_graph(
9897 "repository" : DEFAULT_IMAGE_REPO ,
9998 "pullPolicy" : "IfNotPresent" ,
10099 },
101- "defaultConfig" :
102- f"rpcauth={ FORK_OBSERVER_RPCAUTH } \n " +
103- "rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n " +
104- "rpcwhitelistdefault=0\n " +
105- "debug=rpc\n "
100+ "defaultConfig" : f"rpcauth={ FORK_OBSERVER_RPCAUTH } \n "
101+ + "rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n "
102+ + "rpcwhitelistdefault=0\n "
103+ + "debug=rpc\n " ,
106104 }
107105
108106 # Configure logging
@@ -118,12 +116,15 @@ def custom_graph(
118116
119117
120118def inquirer_create_network (project_path : Path ):
121- network_name_prompt = inquirer .prompt ([
122- inquirer .Text (
123- "network_name" ,
124- message = click .style ("Enter your network name" , fg = "blue" , bold = True ),
125- validate = lambda _ , x : len (x ) > 0 ,
126- )])
119+ network_name_prompt = inquirer .prompt (
120+ [
121+ inquirer .Text (
122+ "network_name" ,
123+ message = click .style ("Enter your network name" , fg = "blue" , bold = True ),
124+ validate = lambda _ , x : len (x ) > 0 ,
125+ )
126+ ]
127+ )
127128 if not network_name_prompt :
128129 click .secho ("Setup cancelled by user." , fg = "yellow" )
129130 return False
@@ -140,81 +141,108 @@ def inquirer_create_network(project_path: Path):
140141
141142 Console ().print (table )
142143
143- add_more_prompt = inquirer .prompt ([
144- inquirer .List (
145- "add_more" ,
146- message = click .style (f"How many nodes to add? (0 = done)" , fg = "blue" , bold = True ),
147- choices = ["0" , "4" , "8" , "12" , "20" , "50" , "other" ],
148- default = "12" )])
144+ add_more_prompt = inquirer .prompt (
145+ [
146+ inquirer .List (
147+ "add_more" ,
148+ message = click .style ("How many nodes to add? (0 = done)" , fg = "blue" , bold = True ),
149+ choices = ["0" , "4" , "8" , "12" , "20" , "50" , "other" ],
150+ default = "12" ,
151+ )
152+ ]
153+ )
149154 if not add_more_prompt :
150155 click .secho ("Setup cancelled by user." , fg = "yellow" )
151156 return False
152157 if add_more_prompt ["add_more" ].startswith ("0" ):
153158 break
154159
155160 if add_more_prompt ["add_more" ] == "other" :
156- how_many_prompt = inquirer .prompt ([
157- inquirer .Text (
158- "how_many" ,
159- message = click .style ("Enter the number of nodes" , fg = "blue" , bold = True ),
160- validate = lambda _ , x : int (x ) > 0 )])
161+ how_many_prompt = inquirer .prompt (
162+ [
163+ inquirer .Text (
164+ "how_many" ,
165+ message = click .style ("Enter the number of nodes" , fg = "blue" , bold = True ),
166+ validate = lambda _ , x : int (x ) > 0 ,
167+ )
168+ ]
169+ )
161170 if not how_many_prompt :
162171 click .secho ("Setup cancelled by user." , fg = "yellow" )
163172 return False
164173 how_many = how_many_prompt ["how_many" ]
165174 else :
166175 how_many = add_more_prompt ["add_more" ]
167176
168- tank_details_prompt = inquirer .prompt ([
169- inquirer .List (
170- "version" ,
171- message = click .style ("Which version would you like to add to network?" , fg = "blue" , bold = True ),
172- choices = ["other" ] + SUPPORTED_TAGS ,
173- default = DEFAULT_TAG ,
177+ tank_details_prompt = inquirer .prompt (
178+ [
179+ inquirer .List (
180+ "version" ,
181+ message = click .style (
182+ "Which version would you like to add to network?" , fg = "blue" , bold = True
183+ ),
184+ choices = ["other" ] + SUPPORTED_TAGS ,
185+ default = DEFAULT_TAG ,
174186 ),
175- inquirer .List (
176- "connections" ,
177- message = click .style (
178- "How many connections would you like each of these nodes to have?" ,
179- fg = "blue" ,
180- bold = True ,
187+ inquirer .List (
188+ "connections" ,
189+ message = click .style (
190+ "How many connections would you like each of these nodes to have?" ,
191+ fg = "blue" ,
192+ bold = True ,
193+ ),
194+ choices = ["0" , "1" , "2" , "8" , "12" , "other" ],
195+ default = "8" ,
181196 ),
182- choices = ["0" , "1" , "2" , "8" , "12" , "other" ],
183- default = "8" ,
184- )])
197+ ]
198+ )
185199 if not tank_details_prompt :
186200 click .secho ("Setup cancelled by user." , fg = "yellow" )
187201 return False
188202 break
189203 if tank_details_prompt ["version" ] == "other" :
190- custom_version_prompt = inquirer .prompt ([
191- inquirer .Text (
192- "version" ,
193- message = click .style ("Provide dockerhub repository/image:tag" , fg = "blue" , bold = True ),
194- validate = lambda _ , x : "/" in x and ":" in x )])
204+ custom_version_prompt = inquirer .prompt (
205+ [
206+ inquirer .Text (
207+ "version" ,
208+ message = click .style (
209+ "Provide dockerhub repository/image:tag" , fg = "blue" , bold = True
210+ ),
211+ validate = lambda _ , x : "/" in x and ":" in x ,
212+ )
213+ ]
214+ )
195215 if not custom_version_prompt :
196216 click .secho ("Setup cancelled by user." , fg = "yellow" )
197217 return False
198218 tank_details_prompt ["version" ] = custom_version_prompt ["version" ]
199219
200220 if tank_details_prompt ["connections" ] == "other" :
201- how_many_conn_prompt = inquirer .prompt ([
202- inquirer .Text (
203- "how_many_conn" ,
204- message = click .style ("Enter the number of connections" , fg = "blue" , bold = True ),
205- validate = lambda _ , x : int (x ) > 0 )])
221+ how_many_conn_prompt = inquirer .prompt (
222+ [
223+ inquirer .Text (
224+ "how_many_conn" ,
225+ message = click .style (
226+ "Enter the number of connections" , fg = "blue" , bold = True
227+ ),
228+ validate = lambda _ , x : int (x ) > 0 ,
229+ )
230+ ]
231+ )
206232 if not how_many_conn_prompt :
207233 click .secho ("Setup cancelled by user." , fg = "yellow" )
208234 return False
209235 how_many_conn = how_many_conn_prompt ["how_many_conn" ]
210236 else :
211237 how_many_conn = tank_details_prompt ["connections" ]
212238
213- tanks .append ({
214- "version" : tank_details_prompt ["version" ],
215- "count" : how_many ,
216- "connections" : how_many_conn
217- })
239+ tanks .append (
240+ {
241+ "version" : tank_details_prompt ["version" ],
242+ "count" : how_many ,
243+ "connections" : how_many_conn ,
244+ }
245+ )
218246
219247 fork_observer = click .prompt (
220248 click .style (
0 commit comments