- if not config.get_bool('USE_US_TIGER_DATA'):
- sql = sql.replace('-- %NOTIGERDATA% ', '')
-
- if not config.get_bool('USE_AUX_LOCATION_DATA'):
- sql = sql.replace('-- %NOAUXDATA% ', '')
-
- reverse_only = 'false' if conn.table_exists('search_name') else 'true'
-
- return sql.replace('%REVERSE-ONLY%', reverse_only)
-
-
-def replace_partition_string(sql, partitions):
- """ Replace a partition template with the actual partition code.
- """
- for match in re.findall('^-- start(.*?)^-- end', sql, re.M | re.S):
- repl = ''
- for part in partitions:
- repl += match.replace('-partition-', str(part))
- sql = sql.replace(match, repl)
-
- return sql
-
-def _get_partition_function_sql(conn, sql_dir):
- """ Create functions that work on partition tables.
- """
- with conn.cursor() as cur:
- cur.execute('SELECT distinct partition FROM country_name')
- partitions = set([0])
- for row in cur:
- partitions.add(row[0])
-
- with (sql_dir / 'partition-functions.src.sql').open('r') as fdesc:
- sql = fdesc.read()
-
- return replace_partition_string(sql, sorted(partitions))
-
-def create_functions(conn, config, sql_dir,
- enable_diff_updates=True, enable_debug=False):
+def create_functions(conn: Connection, config: Configuration,
+ enable_diff_updates: bool = True,
+ enable_debug: bool = False) -> None: