@@ -341,7 +341,7 @@ def get_table_cols(table, conn_handler=None):
341341 list of str
342342 The column headers of `table`
343343 """
344- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
344+ conn_handler = SQLConnectionHandler ()
345345 headers = conn_handler .execute_fetchall (
346346 "SELECT column_name FROM information_schema.columns WHERE "
347347 "table_name=%s AND table_schema='qiita'" , (table , ))
@@ -363,7 +363,7 @@ def get_table_cols_w_type(table, conn_handler=None):
363363 list of tuples of (str, str)
364364 The column headers and data type of `table`
365365 """
366- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
366+ conn_handler = SQLConnectionHandler ()
367367 return conn_handler .execute_fetchall (
368368 "SELECT column_name, data_type FROM information_schema.columns WHERE "
369369 "table_name=%s" , (table ,))
@@ -412,8 +412,8 @@ def get_db_files_base_dir(conn_handler=None):
412412 str
413413 The path to the base directory of all db files
414414 """
415- conn_handler = ( conn_handler if conn_handler is not None
416- else SQLConnectionHandler ())
415+ conn_handler = SQLConnectionHandler ()
416+
417417 return conn_handler .execute_fetchone (
418418 "SELECT base_data_dir FROM settings" )[0 ]
419419
@@ -426,8 +426,8 @@ def get_work_base_dir(conn_handler=None):
426426 str
427427 The path to the base directory of all db files
428428 """
429- conn_handler = ( conn_handler if conn_handler is not None
430- else SQLConnectionHandler ())
429+ conn_handler = SQLConnectionHandler ()
430+
431431 return conn_handler .execute_fetchone (
432432 "SELECT base_work_dir FROM settings" )[0 ]
433433
@@ -555,8 +555,8 @@ def get_mountpoint(mount_type, conn_handler=None, retrieve_all=False):
555555 list
556556 List of tuple, where: [(id_mountpoint, filepath_of_mountpoint)]
557557 """
558- conn_handler = ( conn_handler if conn_handler is not None
559- else SQLConnectionHandler ())
558+ conn_handler = SQLConnectionHandler ()
559+
560560 if retrieve_all :
561561 result = conn_handler .execute_fetchall (
562562 "SELECT data_directory_id, mountpoint, subdirectory FROM "
@@ -586,7 +586,7 @@ def get_mountpoint_path_by_id(mount_id, conn_handler=None):
586586 str
587587 The mountpoint path
588588 """
589- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
589+ conn_handler = SQLConnectionHandler ()
590590 mountpoint , subdirectory = conn_handler .execute_fetchone (
591591 """SELECT mountpoint, subdirectory FROM qiita.data_directory
592592 WHERE data_directory_id=%s""" , (mount_id ,))
@@ -676,7 +676,7 @@ def purge_filepaths(conn_handler=None):
676676 conn_handler : SQLConnectionHandler, optional
677677 The connection handler object connected to the DB
678678 """
679- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
679+ conn_handler = SQLConnectionHandler ()
680680
681681 # Get all the (table, column) pairs that reference to the filepath table
682682 # Code adapted from http://stackoverflow.com/q/5347050/3746629
@@ -733,7 +733,7 @@ def move_filepaths_to_upload_folder(study_id, filepaths, conn_handler=None):
733733 conn_handler : SQLConnectionHandler, optional
734734 The connection handler object connected to the DB
735735 """
736- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
736+ conn_handler = SQLConnectionHandler ()
737737 uploads_fp = join (get_mountpoint ("uploads" )[0 ][1 ], str (study_id ))
738738
739739 # We can now go over and remove all the filepaths
@@ -848,7 +848,7 @@ def convert_to_id(value, table, conn_handler=None):
848848 IncompetentQiitaDeveloperError
849849 The passed string has no associated id
850850 """
851- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
851+ conn_handler = SQLConnectionHandler ()
852852 sql = "SELECT {0}_id FROM qiita.{0} WHERE {0} = %s" .format (table )
853853 _id = conn_handler .execute_fetchone (sql , (value , ))
854854 if _id is None :
@@ -879,7 +879,7 @@ def convert_from_id(value, table, conn_handler=None):
879879 ValueError
880880 The passed id has no associated string
881881 """
882- conn_handler = conn_handler if conn_handler else SQLConnectionHandler ()
882+ conn_handler = SQLConnectionHandler ()
883883 string = conn_handler .execute_fetchone (
884884 "SELECT {0} FROM qiita.{0} WHERE {0}_id = %s" .format (table ),
885885 (value , ))
@@ -989,8 +989,9 @@ def get_environmental_packages(conn_handler=None):
989989 environmental package name and the second string is the table where
990990 the metadata for the environmental package is stored
991991 """
992- conn = conn_handler if conn_handler else SQLConnectionHandler ()
993- return conn .execute_fetchall ("SELECT * FROM qiita.environmental_package" )
992+ conn_handler = SQLConnectionHandler ()
993+ return conn_handler .execute_fetchall (
994+ "SELECT * FROM qiita.environmental_package" )
994995
995996
996997def get_timeseries_types (conn_handler = None ):
@@ -1007,8 +1008,8 @@ def get_timeseries_types(conn_handler=None):
10071008 The available timeseries types. Each timeseries type is defined by the
10081009 tuple (timeseries_id, timeseries_type, intervention_type)
10091010 """
1010- conn = conn_handler if conn_handler else SQLConnectionHandler ()
1011- return conn .execute_fetchall (
1011+ conn_handler = SQLConnectionHandler ()
1012+ return conn_handler .execute_fetchall (
10121013 "SELECT * FROM qiita.timeseries_type ORDER BY timeseries_type_id" )
10131014
10141015
0 commit comments