@@ -24,7 +24,7 @@ def to_dict(self):
2424 "title" : self .title ,
2525 "description" : self .description ,
2626 "columns" : [col .to_dict () for col in self .columns ],
27- "relations" : [rel .to_dict () for rel in self .relations ]
27+ "relations" : [rel .to_dict () for rel in self .relations ],
2828 }
2929
3030
@@ -40,7 +40,7 @@ def to_dict(self):
4040 "name" : self .name ,
4141 "type" : self .type ,
4242 "is_primary_key" : self .is_primary_key ,
43- "is_incremental_key" : self .is_incremental_key
43+ "is_incremental_key" : self .is_incremental_key ,
4444 }
4545
4646
@@ -58,9 +58,9 @@ def generate(self, directory: str, format: str):
5858
5959 def _generate_json (self , directory : str ):
6060 json_tables = self ._jsonify_tables (self ._tables )
61- buffer = bytes (json .dumps (json_tables , indent = 2 , ensure_ascii = False ), ' utf-8' )
61+ buffer = bytes (json .dumps (json_tables , indent = 2 , ensure_ascii = False ), " utf-8" )
6262 output_path = pathlib .Path (directory ) / "__tables.json"
63- with output_path .open ('wb' ) as f :
63+ with output_path .open ("wb" ) as f :
6464 f .write (buffer )
6565 return None
6666
@@ -88,10 +88,12 @@ def _jsonify_tables(self, tables):
8888
8989 def _generate_markdown (self , directory : str ):
9090 env = jinja2 .Environment ()
91- env .globals [' indent_to_depth' ] = self ._indent_to_depth
92- env .globals [' all_tables_entry' ] = self ._all_tables_entry
91+ env .globals [" indent_to_depth" ] = self ._indent_to_depth
92+ env .globals [" all_tables_entry" ] = self ._all_tables_entry
9393 all_tables_template = env .from_string (ALL_TABLES )
94- rendered_all_tables = all_tables_template .render (plugin_name = self ._plugin_name , tables = self ._tables )
94+ rendered_all_tables = all_tables_template .render (
95+ plugin_name = self ._plugin_name , tables = self ._tables
96+ )
9597 formatted_all_tables = self ._format_markdown (rendered_all_tables )
9698
9799 with open (os .path .join (directory , "README.md" ), "w" ) as f :
@@ -111,9 +113,9 @@ def _render_table(self, directory: str, env: jinja2.Environment, table: Table):
111113
112114 def _all_tables_entry (self , table : Table ):
113115 env = jinja2 .Environment ()
114- env .globals [' indent_to_depth' ] = self ._indent_to_depth
115- env .globals [' all_tables_entry' ] = self ._all_tables_entry
116- env .globals [' indent_table_to_depth' ] = self ._indent_table_to_depth
116+ env .globals [" indent_to_depth" ] = self ._indent_to_depth
117+ env .globals [" all_tables_entry" ] = self ._all_tables_entry
118+ env .globals [" indent_table_to_depth" ] = self ._indent_table_to_depth
117119 entry_template = env .from_string (ALL_TABLES_ENTRY )
118120 return entry_template .render (table = table )
119121
@@ -129,15 +131,15 @@ def _indent_table_to_depth(table: Table) -> str:
129131 @staticmethod
130132 def _indent_to_depth (text : str , depth : int ) -> str :
131133 indentation = depth * 4 # You can adjust the number of spaces as needed
132- lines = text .split (' \n ' )
133- indented_lines = [(' ' * indentation ) + line for line in lines ]
134- return ' \n ' .join (indented_lines )
134+ lines = text .split (" \n " )
135+ indented_lines = [(" " * indentation ) + line for line in lines ]
136+ return " \n " .join (indented_lines )
135137
136138 @staticmethod
137139 def _format_markdown (text : str ) -> str :
138- re_match_newlines = re .compile (r' \n{3,}' )
139- re_match_headers = re .compile (r' (#{1,6}.+)\n+' )
140+ re_match_newlines = re .compile (r" \n{3,}" )
141+ re_match_headers = re .compile (r" (#{1,6}.+)\n+" )
140142
141- text = re_match_newlines .sub (r' \n\n' , text )
142- text = re_match_headers .sub (r' \1\n\n' , text )
143+ text = re_match_newlines .sub (r" \n\n" , text )
144+ text = re_match_headers .sub (r" \1\n\n" , text )
143145 return text
0 commit comments