text
stringlengths 0
828
|
---|
:param str err: Error file |
:return: True if cmd was executed, False otherwise |
:rtype: boolean |
"""""" |
if fname is None or not os.path.exists(fname): |
run_cmd(cmd, out, err) |
return True |
else: |
return False" |
4890,"def merge_files(sources, destination): |
""""""Copy content of multiple files into a single file. |
:param list(str) sources: source file names (paths) |
:param str destination: destination file name (path) |
:return: |
"""""" |
with open(destination, 'w') as hout: |
for f in sources: |
if os.path.exists(f): |
with open(f) as hin: |
shutil.copyfileobj(hin, hout) |
else: |
logger.warning('File is missing: {}'.format(f))" |
4891,"def add_path(self, path): |
"""""" Adds a new path to the list of searchable paths |
:param path: new path |
"""""" |
if os.path.exists(path): |
self.paths.add(path) |
return path |
else: |
#logger.debug('Path {} doesn\'t exist'.format(path)) |
return None" |
4892,"def get(self, name): |
"""""" Looks for a name in the path. |
:param name: file name |
:return: path to the file |
"""""" |
for d in self.paths: |
if os.path.exists(d) and name in os.listdir(d): |
return os.path.join(d, name) |
logger.debug('File not found {}'.format(name)) |
return None" |
4893,"def overwrite_fits(hdulist, filename): |
"""""" |
Saves a FITS file. Combined file rename, save new, delete renamed for FITS files |
Why: HDUlist.writeto() does not overwrite existing files |
Why(2): It is also a standardized way to save FITS files |
"""""" |
assert isinstance(hdulist, (fits.HDUList, fits.PrimaryHDU)) |
temp_name = None |
flag_delete_temp = False |
if os.path.isfile(filename): |
# PyFITS does not overwrite file |
temp_name = a99.rename_to_temp(filename) |
try: |
hdulist.writeto(filename, output_verify='warn') |
flag_delete_temp = temp_name is not None |
except: |
# Writing failed, reverts renaming |
os.rename(temp_name, filename) |
raise |
if flag_delete_temp: |
os.unlink(temp_name)" |
4894,"def load_conf(yml_file, conf={}): |
"""""" |
To load the config |
:param yml_file: the config file path |
:param conf: dict, to override global config |
:return: dict |
"""""" |
with open(yml_file) as f: |
data = yaml.load(f) |
if conf: |
data.update(conf) |
return dictdot(data)" |
4895,"def table_exists( |
dbConn, |
log, |
dbTableName): |
""""""*Probe a database to determine if a given table exists* |
**Key Arguments:** |
- ``dbConn`` -- mysql database connection |
- ``log`` -- logger |
- ``dbTableName`` -- the database tablename |
**Return:** |
- ``tableExists`` -- True or False |
**Usage:** |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.