def _find_files(self, file_amr): """ Given the AMR base filename, attempt to find the particle header, star files, etc. """ base_prefix, base_suffix = filename_pattern['amr'] numericstr = file_amr.rsplit('_',1)[1].replace(base_suffix,'') possibles = glob.glob(os.path.dirname(os.path.abspath(file_amr))+"/*") for filetype, (prefix, suffix) in filename_pattern.items(): # if this attribute is already set skip it if getattr(self, "_file_"+filetype, None) is not None: continue match = None for possible in possibles: if possible.endswith(numericstr+suffix): if os.path.basename(possible).startswith(prefix): match = possible elif possible.endswith(suffix): if os.path.basename(possible).startswith(prefix): match = possible if match is not None: mylog.info('discovered %s:%s', filetype, match) setattr(self, "_file_"+filetype, match) else: setattr(self, "_file_"+filetype, None)
def _find_files(self, file_particle): """ Given the particle base filename, attempt to find the particle header and star files. """ base_prefix, base_suffix = filename_pattern["particle_data"] aexpstr = file_particle.rsplit("s0", 1)[1].replace(base_suffix, "") possibles = glob.glob(os.path.dirname(os.path.abspath(file_particle)) + "/*") for filetype, (prefix, suffix) in filename_pattern.items(): # if this attribute is already set skip it if getattr(self, "_file_" + filetype, None) is not None: continue match = None for possible in possibles: if possible.endswith(aexpstr + suffix): if os.path.basename(possible).startswith(prefix): match = possible if match is not None: mylog.info("discovered %s:%s", filetype, match) setattr(self, "_file_" + filetype, match) else: setattr(self, "_file_" + filetype, None)