Coverage for src/crimepy/options.py: 100%
8 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 18:01 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-30 18:01 +0000
1"""Default settings of crimepy.
3They can be changed for a whole session (for example,
4`crimepy.options.DATA_FOLDER = 'D:/crime'`), and every function that uses one
5also takes it as an argument.
7Contents:
8 CHUNK_SIZE: the number of records that are parsed at once.
9 DATA_FOLDER: where downloads and converted tables are saved, if not in
10 amos's workspace.
11 DATA_SUBFOLDER: the folder of the data folder of amos's workspace in
12 which they are saved otherwise.
13 TIMEOUT: seconds to wait for a server before giving up.
14 USER_AGENT: how crimepy introduces itself to servers.
16"""
18from __future__ import annotations
20import os
21import pathlib
23# The number of records of a master file that are parsed at once. A NIBRS
24# master file has tens of millions of records, so they are parsed in chunks to
25# limit the memory used. Larger chunks are a little faster and use more
26# memory (about 1 GB for 2 million records).
27CHUNK_SIZE: int = 1_000_000
28# Where downloads and converted tables are saved: the "CRIMEPY_DATA"
29# environment variable, if it is set. Otherwise (`None`), they are saved in
30# the `DATA_SUBFOLDER` of the data folder of amos's workspace, beside the
31# "code" folder (see `utilities.data_folder`), where amos projects look for
32# data too.
33DATA_FOLDER: pathlib.Path | str | None = os.environ.get('CRIMEPY_DATA')
34# The folder of the data folder of amos's workspace in which crimepy saves
35# data (so NIBRS is in "data/crime/nibrs").
36DATA_SUBFOLDER: str = 'crime'
37# Seconds to wait for a server to respond before giving up.
38TIMEOUT: float = 60.0
39# Sent with every request, since some servers refuse requests without one.
40USER_AGENT: str = 'crimepy (https://github.com/WithPrecedent/crimepy)'