Utility functions for reading and parsing files in a variety of formats.
_get_filetype_parser
(file_path, parser_type)[source]¶Return a parser function for parsing the file.
Parameters: |
|
---|---|
Returns: | The parser function. |
Return type: | function |
_parse_json_file
(data)[source]¶Parse the data from a json file.
Parameters: | data (filepointer) – File-like object containing a Json document, to be parsed into json. |
---|---|
Returns: | The file successfully parsed into a dict. |
Return type: | dict |
Raises: | ValueError – If there was an error parsing the file. |
_parse_json_string
(data)[source]¶Parse the data from a string of json.
Parameters: | data (str) – String data to parse into json. |
---|---|
Returns: | The json string successfully parsed into a dict. |
Return type: | dict |
Raises: | ValueError – If there was an error parsing the data. |
_parse_yaml
(data)[source]¶Parse yaml data.
Parameters: | data (stream) – A yaml data stream to parse. |
---|---|
Returns: | The stream successfully parsed into a dict. |
Return type: | dict |
Raises: | YAMLError – If there was an error parsing the stream. |
_read_file_from_gcs
(file_path, storage_client=None)[source]¶Load file from GCS.
Parameters: |
|
---|---|
Returns: | The parsed dict from the loaded file. |
Return type: | dict |
_read_file_from_local
(file_path)[source]¶Load rules file from local path.
Parameters: | file_path (str) – The path to the file. |
---|---|
Returns: | The parsed dict from the loaded file. |
Return type: | dict |
copy_file_from_gcs
(file_path, output_path=None, storage_client=None)[source]¶Copy file from GCS to local file.
Parameters: |
|
---|---|
Returns: | The output_path the file was copied to. |
Return type: | str |