text
stringlengths
0
828
"""""" Generate a readme with all the generators
""""""
print(""## Examples of settings runtime params"")
print(""### Command-line parameters"")
print(""```"")
self.generate_command()
print(""```"")
print(""### Environment variables"")
print(""```"")
self.generate_env()
print(""```"")
print(""### ini file"")
print(""```"")
self.generate_ini()
print(""```"")
print(""### docker run"")
print(""```"")
self.generate_docker_run()
print(""```"")
print(""### docker compose"")
print(""```"")
self.generate_docker_compose()
print(""```"")
print(""### kubernetes"")
print(""```"")
self.generate_kubernetes()
print(""```"")
print(""### drone plugin"")
print(""```"")
self.generate_drone_plugin()
print(""```"")"
1529,"def file_exists(self, subdir, prefix, suffix):
""""""Returns true if the resource file exists, else False.
Positional arguments:
subdir -- sub directory name under the resource's main directory (e.g. css or js, or an empty string if the
resource's directory structure is flat).
prefix -- file name without the file extension.
suffix -- file extension (if self.minify = True, includes .min before the extension).
""""""
real_path = os.path.join(self.STATIC_DIR, self.DIR, subdir, prefix + suffix)
return os.path.exists(real_path)"
1530,"def add_css(self, subdir, file_name_prefix):
""""""Add a css file for this resource.
If self.minify is True, checks if the .min.css file exists. If not, falls back to non-minified file. If that
file also doesn't exist, IOError is raised.
Positional arguments:
subdir -- sub directory name under the resource's main directory (e.g. css or js, or an empty string).
file_name_prefix -- file name without the file extension.
""""""
suffix_maxify = '.css'
suffix_minify = '.min.css'
if self.minify and self.file_exists(subdir, file_name_prefix, suffix_minify):
self.resources_css.append(posixpath.join(self.DIR, subdir, file_name_prefix + suffix_minify))
elif self.file_exists(subdir, file_name_prefix, suffix_maxify):
self.resources_css.append(posixpath.join(self.DIR, subdir, file_name_prefix + suffix_maxify))
else:
file_path = os.path.join(self.STATIC_DIR, self.DIR, subdir, file_name_prefix + suffix_maxify)
raise IOError('Resource file not found: {0}'.format(file_path))"
1531,"def read_dataframe_from_xls(desired_type: Type[T], file_path: str, encoding: str,
logger: Logger, **kwargs) -> pd.DataFrame:
""""""
We register this method rather than the other because pandas guesses the encoding by itself.
Also, it is easier to put a breakpoint and debug by trying various options to find the good one (in streaming mode
you just have one try and then the stream is consumed)
:param desired_type:
:param file_path:
:param encoding:
:param logger:
:param kwargs:
:return:
""""""
return pd.read_excel(file_path, **kwargs)"
1532,"def read_df_or_series_from_csv(desired_type: Type[pd.DataFrame], file_path: str, encoding: str,
logger: Logger, **kwargs) -> pd.DataFrame:
""""""
Helper method to read a dataframe from a csv file. By default this is well suited for a dataframe with
headers in the first row, for example a parameter dataframe.
:param desired_type:
:param file_path:
:param encoding:
:param logger:
:param kwargs:
:return:
""""""
if desired_type is pd.Series:
# as recommended in http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.from_csv.html
# and from http://stackoverflow.com/questions/15760856/how-to-read-a-pandas-series-from-a-csv-file
# TODO there should be a way to decide between row-oriented (squeeze=True) and col-oriented (index_col=0)
# note : squeeze=true only works for row-oriented, so we dont use it. We rather expect that a row-oriented
# dataframe would be convertible to a series using the df to series converter below
if 'index_col' not in kwargs.keys():
one_col_df = pd.read_csv(file_path, encoding=encoding, index_col=0, **kwargs)
else: