USCodeKit

Documentation for Setup the data resources

Overview

This script provides utility functions to set up the configuration files required by the package. It checks for the existence of essential files (encryption key, geo database, and NAICS database) and assists in setting them up by copying and renaming files to their appropriate locations. You can download the resources here.


Importing the setup module

from uscodekit.setup import (
    setup_file_stats,
    setup_geo_database,
    setup_naics_database,
    setup_encryption_key,
    setup_all
)

Functions

1. setup_file_stats

Checks the existence of configuration files and provides their status.

Parameters:

Returns:


2. setup_geo_database

Sets up the Geo database by copying a .gz file to the specified directory.

Parameters:

Returns:

Raises:

Notes:


3. setup_naics_database

Sets up the NAICS database by copying a .bin file to the specified directory.

Parameters:

Returns:

Raises:

Notes:


4. setup_encryption_key

Sets up the encryption key by copying a .key file to the specified directory.

Parameters:

Returns:

Raises:

Notes:


5. setup_all

Prompts the user for paths to the required files and sets them up.

Behavior:


Usage

  1. Check File Status:

    stats = setup_file_stats()
    print(stats)
    

    Output:

    Encryption key...OK
    Geo database...MISSING
    NAICS database...OK
    {'encryption_key': True, 'geo_database': False, 'naics_database': True}
    
  2. Set Up Geo Database:

    result = setup_geo_database("/path/to/geo_database.gz")
    print(result)  # True if successful
    
  3. Set Up NAICS Database:

    result = setup_naics_database("/path/to/naics_database.bin")
    print(result)  # True if successful
    
  4. Set Up Encryption Key:

    result = setup_encryption_key("/path/to/encryption_key.key")
    print(result)  # True if successful
    
  5. Set Up All Files:

    setup_all()
    

    This will prompt for file paths and set up all files interactively.


Notes