Skip to content

Commit 93a8265

Browse files
authored
Merge pull request #45 from statisticsnorway/clean_away_unfinshed_code
2 parents 7fb6a76 + d47fed9 commit 93a8265

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

src/ssb_utdanning/format/sas_format_parsing.py

+16-34
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@ def batch_process_folder_sasfiles(
1111
) -> None:
1212
"""Finds all .sas files in folder, tries to extract formats from these.
1313
14-
Parameters
15-
----------
16-
sas_files_path: str
17-
The path to the folder containing the .sas files.
18-
output_path: str
19-
The path to the folder where the formats will be stored.
20-
Not including the filename itself, only the base folder.
21-
22-
Returns:
23-
-------
24-
None
25-
Only writes to disk (side effect).
14+
Args:
15+
sas_files_path (str): The path to the folder containing the .sas files.
16+
output_path (str): The path to the folder where the formats will be stored.
17+
Not including the filename itself, only the base folder.
2618
"""
2719
for file in glob.glob(sas_files_path + "*.sas"):
2820
print(f"Processing {file}.")
@@ -32,23 +24,13 @@ def batch_process_folder_sasfiles(
3224
def process_single_sasfile(file: str, output_path: str = PROD_FORMATS_PATH) -> None:
3325
"""Get a single .sas file from storage, extracts formats and stores to disk as timestamped jsonfiles.
3426
35-
Parameters
36-
----------
37-
file: str
38-
The path to the .sas file.
39-
output_path: str
40-
The path to the folder where the formats will be stored.
41-
Not including the filename itself, only the base folder.
42-
43-
Returns:
44-
-------
45-
None
46-
Only writes to disk (side effect).
27+
Args:
28+
file (str): The path to the .sas file.
29+
output_path (str): The path to the folder where the formats will be stored.
30+
Not including the filename itself, only the base folder.
4731
4832
Raises:
49-
------
50-
ValueError
51-
If the file is not a .sas file.
33+
ValueError: If the file is not a .sas file.
5234
"""
5335
if not file.endswith(".sas"):
5436
raise ValueError("Dude, you gotta send in a .sas file.")
@@ -65,15 +47,15 @@ def process_single_sasfile(file: str, output_path: str = PROD_FORMATS_PATH) -> N
6547
def parse_sas_script(sas_script_content: str) -> dict[str, dict[str, str]]:
6648
"""Extract a format as a Python dictionary from a SAS script.
6749
68-
Parameters
69-
----------
70-
sas_script_content: str
71-
The content of the SAS script.
50+
Args:
51+
sas_script_content (str):The content of the SAS script.
7252
7353
Returns:
74-
-------
75-
dict[str, dict[str, str]]
76-
A nested dictionary containing the format-name as key, and the format-content as value.
54+
dict[str, dict[str, str]]: A nested dictionary containing the format-name as key,
55+
and the format-content as value.
56+
57+
Raises:
58+
Exception: If we are unable to parse the lines of a format correctly.
7759
"""
7860
formats_in_file: dict[str, dict[str, str]] = {}
7961
for proc_step in sas_script_content.split("proc format;")[1:]:

0 commit comments

Comments
 (0)