Utils
Miscellaneous util functions.
            graceful_exit(exit_code=0, error_msg=None)
    Gracefully exits the program with an exit code.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
exit_code | 
            
                  int
             | 
            
               The exit code.  | 
            
                  0
             | 
          
error_msg | 
            
                  str | None
             | 
            
               The error message to print before exiting.  | 
            
                  None
             | 
          
Source code in bcorag/misc_functions.py
              
            load_json(filepath)
    Loads a JSON file and returns the deserialized data (or an empty dict if the file doesn't exist).
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
filepath | 
            
                  str
             | 
            
               File path to the JSON file to load.  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  dict | None
             | 
            
               The deserialized JSON data or None if the file doesn't exist.  | 
          
Source code in bcorag/misc_functions.py
              
            load_config_data(filepath='./conf.json')
    Loads the config JSON object file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
filepath | 
            
                  str
             | 
            
               File path to the config JSON file.  | 
            
                  './conf.json'
             | 
          
Returns:
| Type | Description | 
|---|---|
                  ConfigObject | None
             | 
            
               Casted ConfigObject or None on some type of error.  | 
          
Source code in bcorag/misc_functions.py
              
            load_output_tracker(filepath)
    Loads the JSON output tracker file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
filepath | 
            
                  str
             | 
            
               File path to the JSON file to load.  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  OutputTrackerFile | None
             | 
            
               Casted OutputTrackerFile or None on some type of error.  | 
          
Source code in bcorag/misc_functions.py
              
            write_json(output_path, data)
    Writes JSON out to the output path. Will create the file if it doesn't exist.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
output_path | 
            
                  str
             | 
            
               The output file path.  | 
            required | 
data | 
            
                  dict | list | OutputTrackerFile
             | 
            
               The data to dump.  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  bool
             | 
            
               Whether the process was successful.  | 
          
Source code in bcorag/misc_functions.py
              
            dump_output_file_map_tsv(output_path, data)
    Dumps the OutputTrackerFile object into a TSV table for better human readability.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
output_path | 
            
                  str
             | 
            
               The output file path.  | 
            required | 
data | 
            
                  OutputTrackerFile
             | 
            
               The OutputTrackerFile object to format for a TSV file.  | 
            required | 
Source code in bcorag/misc_functions.py
              
            dump_string(output_path, data)
    Dumps a string to a text file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
output_path | 
            
                  str
             | 
            
               The output file path.  | 
            required | 
data | 
            
                  str
             | 
            
               The string to dump.  | 
            required | 
Source code in bcorag/misc_functions.py
              
            check_dir(path)
    Checks whether a directory creates and if it doesn't, create it. Note, this really only works for checking/creating the last level direcotry. Will fail if there are issues in the parent level directories in the path.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
path | 
            
                  str
             | 
            
               Directory filepath to check.  | 
            required | 
Source code in bcorag/misc_functions.py
              
            setup_root_logger(log_path, name='bcorag')
    Configures the root logger.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
log_path | 
            
                  str
             | 
            
               The filepath to the log handler.  | 
            required | 
name | 
            
                  str
             | 
            
               The name of the root logger.  | 
            
                  'bcorag'
             | 
          
Returns:
| Type | Description | 
|---|---|
                  Logger
             | 
            
               The root logger.  | 
          
Source code in bcorag/misc_functions.py
              
            setup_document_logger(name, parent_logger='bcorag')
    Configures a document specific logger.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
name | 
            
                  str
             | 
            
               The name of the document to setup the logger for.  | 
            required | 
parent_logger | 
            
                  str
             | 
            
               Name of the parent logger to setup under.  | 
            
                  'bcorag'
             | 
          
Returns:
| Type | Description | 
|---|---|
                  Logger
             | 
            
               The document logger.  | 
          
Source code in bcorag/misc_functions.py
              
            create_timestamp()
    Creates a current timestamp.
Returns:
| Type | Description | 
|---|---|
                  str
             | 
            
               The current timestamp as a string.  | 
          
Source code in bcorag/misc_functions.py
              
            
            extract_repo_data(url)
    Extracts the repository information from the repo URL.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
url | 
            
                  str
             | 
            
               The Github repository URL.  | 
            required | 
Returns:
| Type | Description | 
|---|---|
                  (str, str) | None
             | 
            
               Returns the tuple containing the extracted github user and repo or None on failure to parse the URL.  | 
          
Source code in bcorag/misc_functions.py
              
            get_file_list(path, filetype='pdf')
    Gets the files from a glob pattern.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
path | 
            
                  str
             | 
            
               The file path to the target directory.  | 
            required | 
filetype | 
            
                  str
             | 
            
               The file type to capture.  | 
            
                  'pdf'
             | 
          
Returns:
| Type | Description | 
|---|---|
                  list[str]
             | 
            
               List of the file paths found from the glob pattern.  |