@@ -6,46 +6,54 @@ import re
66
77
88def compile (service , version , alias , scheme , ports , unimplemented , dokku_version ):
9- return "\n \n " .join ([
10- header (service ),
11- description (service , version ),
12- requirements_section (dokku_version ),
13- installation_section (service , dokku_version ),
14- commands_section (service , alias , scheme , ports , unimplemented ),
15- usage_section (service , alias , scheme , ports , unimplemented ),
16- ]).replace ("\n \n \n \n \n " , "\n " ).replace ("\n \n \n \n " , "\n " ).replace ("\n \n \n " , "\n \n " )
9+ return (
10+ "\n \n " .join (
11+ [
12+ header (service ),
13+ description (service , version ),
14+ requirements_section (dokku_version ),
15+ installation_section (service , dokku_version ),
16+ commands_section (service , alias , scheme , ports , unimplemented ),
17+ usage_section (service , alias , scheme , ports , unimplemented ),
18+ ]
19+ )
20+ .replace ("\n \n \n \n \n " , "\n " )
21+ .replace ("\n \n \n \n " , "\n " )
22+ .replace ("\n \n \n " , "\n \n " )
23+ )
1724
1825
1926def header (service ):
20- return " " .join ([
21- f"# dokku { service } " ,
22- f"[](https://circleci.com/gh/dokku/dokku-{ service } /tree/master)" ,
23- f"[](https://webchat.freenode.net/?channels=dokku)" ,
24- ])
27+ return " " .join (
28+ [
29+ f"# dokku { service } " ,
30+ f'[](https://circleci.com/gh/dokku/dokku-{ service } /tree/master)' ,
31+ f'[](https://webchat.freenode.net/?channels=dokku)' ,
32+ ]
33+ )
2534
2635
2736def description (service , version ):
2837 return f"Official { service } plugin for dokku. Currently defaults to installing [{ service } { version } ](https://hub.docker.com/_/{ service } /)."
2938
3039
3140def requirements_section (dokku_version ):
32- return "\n " .join ([
33- "## Requirements" ,
34- "" ,
35- f"- dokku { dokku_version } " ,
36- "- docker 1.8.x" ,
37- ])
41+ return "\n " .join (
42+ ["## Requirements" , "" , f"- dokku { dokku_version } " , "- docker 1.8.x" ,]
43+ )
3844
3945
4046def installation_section (service , dokku_version ):
41- return "\n " .join ([
42- "## Installation" ,
43- "" ,
44- "```shell" ,
45- f"# on { dokku_version } " ,
46- f"sudo dokku plugin:install https://github.com/dokku/dokku-{ service } .git { service } " ,
47- "```" ,
48- ])
47+ return "\n " .join (
48+ [
49+ "## Installation" ,
50+ "" ,
51+ "```shell" ,
52+ f"# on { dokku_version } " ,
53+ f"sudo dokku plugin:install https://github.com/dokku/dokku-{ service } .git { service } " ,
54+ "```" ,
55+ ]
56+ )
4957
5058
5159def commands_section (service , alias , scheme , ports , unimplemented ):
@@ -82,35 +90,51 @@ def commands_section(service, alias, scheme, ports, unimplemented):
8290
8391
8492def usage_section (service , alias , scheme , ports , unimplemented ):
85- return "\n \n " .join ([
86- "## Usage" ,
87- f"Help for any commands can be displayed by specifying the command as an argument to { service } :help. Please consult the `{ service } :help` command for any undocumented commands." ,
88- usage_intro (service , alias , scheme , ports , unimplemented ),
89- usage_lifecycle (service , alias , scheme , ports , unimplemented ),
90- usage_automation (service , alias , scheme , ports , unimplemented ),
91- usage_data_management (service , alias , scheme , ports , unimplemented ),
92- usage_backup (service , alias , scheme , ports , unimplemented ),
93- usage_docker_pull (service , alias , scheme , ports , unimplemented ),
94- ])
93+ return "\n \n " .join (
94+ [
95+ "## Usage" ,
96+ f"Help for any commands can be displayed by specifying the command as an argument to { service } :help. Please consult the `{ service } :help` command for any undocumented commands." ,
97+ usage_intro (service , alias , scheme , ports , unimplemented ),
98+ usage_lifecycle (service , alias , scheme , ports , unimplemented ),
99+ usage_automation (service , alias , scheme , ports , unimplemented ),
100+ usage_data_management (service , alias , scheme , ports , unimplemented ),
101+ usage_backup (service , alias , scheme , ports , unimplemented ),
102+ usage_docker_pull (service , alias , scheme , ports , unimplemented ),
103+ ]
104+ )
95105
96106
97107def usage_intro (service , alias , scheme , ports , unimplemented ):
98108 commands = ["create" , "info" , "list" , "logs" , "link" , "unlink" ]
99109 content = ["### Basic Usage" ]
100110
101- return fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content )
111+ return fetch_commands_content (
112+ service , alias , scheme , ports , unimplemented , commands , content
113+ )
102114
103115
104116def usage_lifecycle (service , alias , scheme , ports , unimplemented ):
105- commands = ["connect" , "enter" , "expose" , "unexpose" , "promote" , "start" , "stop" , "restart" , "upgrade" ]
117+ commands = [
118+ "connect" ,
119+ "enter" ,
120+ "expose" ,
121+ "unexpose" ,
122+ "promote" ,
123+ "start" ,
124+ "stop" ,
125+ "restart" ,
126+ "upgrade" ,
127+ ]
106128 content = [
107129 "### Service Lifecycle" ,
108130 "" ,
109131 "The lifecycle of each service can be managed through the following commands:" ,
110132 "" ,
111133 ]
112134
113- return fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content )
135+ return fetch_commands_content (
136+ service , alias , scheme , ports , unimplemented , commands , content
137+ )
114138
115139
116140def usage_automation (service , alias , scheme , ports , unimplemented ):
@@ -122,7 +146,9 @@ def usage_automation(service, alias, scheme, ports, unimplemented):
122146 "" ,
123147 ]
124148
125- return fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content )
149+ return fetch_commands_content (
150+ service , alias , scheme , ports , unimplemented , commands , content
151+ )
126152
127153
128154def usage_data_management (service , alias , scheme , ports , unimplemented ):
@@ -134,11 +160,22 @@ def usage_data_management(service, alias, scheme, ports, unimplemented):
134160 "" ,
135161 ]
136162
137- return fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content )
163+ return fetch_commands_content (
164+ service , alias , scheme , ports , unimplemented , commands , content
165+ )
138166
139167
140168def usage_backup (service , alias , scheme , ports , unimplemented ):
141- commands = ["backup-auth" , "backup-deauth" , "backup" , "backup-set-encryption" , "backup-unset-encryption" , "backup-schedule" , "backup-schedule-cat" , "backup-unschedule" ,]
169+ commands = [
170+ "backup-auth" ,
171+ "backup-deauth" ,
172+ "backup" ,
173+ "backup-set-encryption" ,
174+ "backup-unset-encryption" ,
175+ "backup-schedule" ,
176+ "backup-schedule-cat" ,
177+ "backup-unschedule" ,
178+ ]
142179 content = [
143180 "### Backups" ,
144181 "" ,
@@ -150,21 +187,27 @@ def usage_backup(service, alias, scheme, ports, unimplemented):
150187 "" ,
151188 ]
152189
153- return fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content )
190+ return fetch_commands_content (
191+ service , alias , scheme , ports , unimplemented , commands , content
192+ )
154193
155194
156195def usage_docker_pull (service , alias , scheme , ports , unimplemented ):
157196 service_prefix = service .upper ()
158- return "\n " .join ([
159- "### Disabling `docker pull` calls" ,
160- "" ,
161- f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{ service_prefix } _DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output." ,
162- "" ,
163- "Please ensure the proper images are in place when `docker pull` is disabled." ,
164- ])
165-
166-
167- def fetch_commands_content (service , alias , scheme , ports , unimplemented , commands , content ):
197+ return "\n " .join (
198+ [
199+ "### Disabling `docker pull` calls" ,
200+ "" ,
201+ f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{ service_prefix } _DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output." ,
202+ "" ,
203+ "Please ensure the proper images are in place when `docker pull` is disabled." ,
204+ ]
205+ )
206+
207+
208+ def fetch_commands_content (
209+ service , alias , scheme , ports , unimplemented , commands , content
210+ ):
168211 i = 0
169212 for command in commands :
170213 output = command_help (command , service , alias , scheme , ports , unimplemented )
@@ -350,7 +393,9 @@ def command_data(command, service, alias, scheme, ports):
350393
351394def process_sentence (sentence_lines ):
352395 sentence_lines = " " .join (sentence_lines )
353- sentences = ". " .join (i .strip ().capitalize () for i in sentence_lines .split ("." )).strip ()
396+ sentences = ". " .join (
397+ i .strip ().capitalize () for i in sentence_lines .split ("." )
398+ ).strip ()
354399 if not sentences .endswith ("." ) and not sentences .endswith (":" ):
355400 sentences += ":"
356401 return sentences
@@ -386,17 +431,17 @@ def main():
386431 if "PLUGIN_SCHEME=" in line :
387432 scheme = re .search ('"(.+)"' , line ).group (1 )
388433 if "PLUGIN_DATASTORE_PORTS=" in line :
389- ports = re .search (' \((.+)\)' , line ).group (1 ).split (" " )
434+ ports = re .search (" \((.+)\)" , line ).group (1 ).split (" " )
390435 if "PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=" in line :
391- match = re .search (' \((.+)\)' , line )
436+ match = re .search (" \((.+)\)" , line )
392437 if match is not None :
393438 unimplemented = [s .strip ('"' ) for s in match .group (1 ).split (" " )]
394439
395440 text = compile (service , version , alias , scheme , ports , unimplemented , "0.12.x+" )
396441
397442 base_path = os .path .dirname (os .path .dirname (os .path .realpath (__file__ )))
398- readme_file = os .path .join (base_path , ' README.md' )
399- with open (readme_file , 'w' ) as f :
443+ readme_file = os .path .join (base_path , " README.md" )
444+ with open (readme_file , "w" ) as f :
400445 f .write (text )
401446
402447
0 commit comments