def get_configuration(self, module_id, run_number=None):
def find_file(run_number):<EOL><INDENT>module_path = self.get_module_path(module_id)<EOL>for root, _, files in os.walk(module_path):<EOL><INDENT>for cfgfile in files:<EOL><INDENT>cfg_root, cfg_ext = os.path.splitext(cfgfile)<EOL>if cfg_root.startswith('<STR_LIT>'.join([str(run_number), '<STR_LIT:_>', module_id])) and cfg_ext.endswith("<STR_LIT>"):<EOL><INDENT>return os.path.join(root, cfgfile)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if not run_number:<EOL><INDENT>run_numbers = sorted(list(self._get_run_numbers(status='<STR_LIT>').keys()), reverse=True)<EOL>found_fin_run_cfg = True<EOL>if not run_numbers:<EOL><INDENT>return None<EOL><DEDENT>last_fin_run = run_numbers[<NUM_LIT:0>]<EOL>for run_number in run_numbers:<EOL><INDENT>cfg_file = find_file(run_number)<EOL>if cfg_file:<EOL><INDENT>if not found_fin_run_cfg:<EOL><INDENT>logging.warning("<STR_LIT>", module_id, last_fin_run, run_number)<EOL><DEDENT>return cfg_file<EOL><DEDENT>else:<EOL><INDENT>found_fin_run_cfg = False<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>cfg_file = find_file(run_number)<EOL>if cfg_file:<EOL><INDENT>return cfg_file<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % run_number)<EOL><DEDENT><DEDENT>
Returns the configuration for a given module ID.

        The working directory is searched for a file matching the module_id with the
        given run number. If no run number is defined the last successfull run defines
        the run number.