Skip to content

Commit b88d1c2

Browse files
committed
Fixed loading of the yaml file to load directly from the URL, instead of saving it as a tmp file first. Created a new function to create an output file.
1 parent 4488251 commit b88d1c2

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

common_functions.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ def download_file(url):
9797
def read_sig_yaml(sig_file):
9898
import yaml
9999

100-
stream = open(sig_file, 'r')
101-
sigs_wgs = yaml.safe_load(stream)
100+
#stream = open(sig_file, 'r')
101+
sigs_wgs = yaml.safe_load(sig_file)
102102

103103
return sigs_wgs
104104

105105
def process_sig_yaml():
106106

107-
sig_file = download_file('https://raw.githubusercontent.com/kubernetes/community/master/sigs.yaml', '/tmp/sigs.yaml')
107+
sig_file = download_file('https://raw.githubusercontent.com/kubernetes/community/master/sigs.yaml')
108108

109109
sigs_wgs = read_sig_yaml(sig_file)
110110

@@ -307,4 +307,33 @@ def expand_name(nested_name):
307307
return object_name
308308

309309
df[new_col] = df[old_col].apply(expand_name)
310-
return df
310+
return df
311+
312+
def create_file(pre_string):
313+
"""Creates an output file in an "output" directory with today's date
314+
as part of the filename and prints the file_path to the terminal to
315+
make it easier to open the output file.
316+
317+
Parameters
318+
----------
319+
pre_string : str
320+
This is the string that will preface today's date in the filename
321+
Returns
322+
-------
323+
file : file object
324+
file_path : str
325+
This is the full path to the file name for the output.
326+
327+
"""
328+
from datetime import datetime
329+
from os.path import dirname, join
330+
331+
today = datetime.today().strftime('%Y-%m-%d')
332+
output_filename = "./output/" + pre_string + "_" + today + ".csv"
333+
current_dir = dirname(__file__)
334+
file_path = join(current_dir, output_filename)
335+
file = open(file_path, 'w', newline ='')
336+
337+
print("Output file:\n", file_path, sep="")
338+
339+
return file, file_path

0 commit comments

Comments
 (0)