Skip to main content

Foxhole save file parser - extracts stockpile data from .sav files

Project description

fs-sav

Foxhole save file parser - extracts stockpile data from .sav files.

Features

  • Parse Foxhole save files (.sav) using the uesave library
  • Extract stockpile information: items, locations, types, quantities
  • Watch files for changes with diff modes (NDJSON output)
  • Filter by hex, stockpile type, public/reserve status
  • Output compatible with foxhole-stockpiles
  • Python bindings via PyO3

Installation

Python (from PyPI)

pip install fs-sav

Rust CLI (from source)

cargo install --path .

Python (from source)

pip install maturin
maturin develop --features python

CLI Usage

Parse command

# Parse a save file
fs-sav parse path/to/War.sav

# Parse with compact output (no pretty printing)
fs-sav parse path/to/War.sav --compact

# Read from stdin
cat War.sav | fs-sav parse

Filter options

# Only public stockpiles (non-reserve)
fs-sav parse War.sav --public

# Only reserve stockpiles
fs-sav parse War.sav --reserves

# Filter by hex
fs-sav parse War.sav --hex TerminusHex

# Filter by stockpile type
fs-sav parse War.sav --type Seaport

# Only stockpiles with items
fs-sav parse War.sav --with-items

# Combine filters
fs-sav parse War.sav --hex TerminusHex --public --with-items

Watch command

# Watch for changes (outputs all stockpiles on each change)
fs-sav watch path/to/War.sav

# Watch with custom poll interval (seconds)
fs-sav watch path/to/War.sav --poll 2.0

# Only output stockpiles that changed (any field)
fs-sav watch path/to/War.sav --diff

# Only output stockpiles where items changed
fs-sav watch path/to/War.sav --diff-items

# Watch with filters
fs-sav watch path/to/War.sav --hex TerminusHex --public

Version

fs-sav version

Python Usage

import fs_sav

# Parse a save file
stockpiles = fs_sav.parse_save("path/to/War.sav")
print(f"Found {len(stockpiles)} stockpiles")

for stockpile in stockpiles:
    print(f"  {stockpile['name']} ({stockpile['type']}): {len(stockpile['items'])} items")

# Parse with filters
seaports = fs_sav.parse_save("War.sav", stockpile_type="Seaport")
reserves = fs_sav.parse_save("War.sav", reserves=True)
terminus_public = fs_sav.parse_save("War.sav", hex="TerminusHex", public=True)

# Parse from bytes
with open("War.sav", "rb") as f:
    data = f.read()
stockpiles = fs_sav.parse_save_bytes(data)

# Get parser info
info = fs_sav.info()
print(f"Implementation: {info['implementation']}, Version: {info['version']}")

Filter parameters

Parameter Type Description
public bool Only public stockpiles (non-reserve)
reserves bool Only reserve stockpiles
hex str Filter by hex name (e.g., "TerminusHex")
stockpile_type str Filter by type (e.g., "Seaport")
with_items bool Only stockpiles with items

Rust Library Usage

use fs_sav::{parse_save, ParseResult};

fn main() -> fs_sav::Result<()> {
    let result = parse_save("path/to/War.sav")?;
    println!("Found {} stockpiles", result.stockpiles.len());

    for stockpile in &result.stockpiles {
        println!("  {} ({:?}): {} items",
            stockpile.name,
            stockpile.stockpile_type,
            stockpile.items.len()
        );
    }

    Ok(())
}

Output Format

The output is a JSON array of stockpiles:

[
  {
    "name": "",
    "type": "Seaport",
    "hex": "TerminusHex",
    "coords": { "x": 0.457, "y": 0.664 },
    "is_reserve": false,
    "items": [
      { "code": "Rifle", "quantity": 100, "crated": false },
      { "code": "RifleAmmo", "quantity": 50, "crated": true }
    ],
    "timestamp": "2024-01-15T10:29:00Z"
  }
]

Stockpile Types

The parser recognizes all Foxhole stockpile types:

Category Types
Bases GarrisonStation, Keep, ForwardBase1, RelicBase1, FortBase (T1-T3), BorderBase, TownBase (T1-T3), FortGarrisonStation
Storage StorageFacility, Seaport, AircraftDepot
Facilities Hospital, Refinery, MaintenanceTunnel, FacilityFactorySmallArms, FacilityModificationCenter, FacilityTransfer (Liquid/Material/Resource), FacilityVehicleFactory (T1-T3)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fs_sav-0.2.2.tar.gz (36.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fs_sav-0.2.2-cp310-abi3-win_amd64.whl (654.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

fs_sav-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (706.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

fs_sav-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (679.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

fs_sav-0.2.2-cp310-abi3-macosx_11_0_arm64.whl (618.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

fs_sav-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl (640.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file fs_sav-0.2.2.tar.gz.

File metadata

  • Download URL: fs_sav-0.2.2.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for fs_sav-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c2c080708f695aa50b7c2264cdd3bd493b6a85c6d0cbb852a6e59d43eafca4bf
MD5 508e03a449f89a6768923d8b9c6bedc6
BLAKE2b-256 e9b062c9e7beb6f894e1875605dc1dec94d8ba6eadc3d36e8d3dc33486be18cb

See more details on using hashes here.

File details

Details for the file fs_sav-0.2.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: fs_sav-0.2.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 654.7 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for fs_sav-0.2.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 23b18da8b58a4a0192d0c351832dec823512cfd23731f55b6be9c332767cc782
MD5 6ed45b0a1a5b36cf5060341292624d05
BLAKE2b-256 ac1b49c9c9073408ea81f926d658079c95dd68aaddd9b51971d691a32d2d406c

See more details on using hashes here.

File details

Details for the file fs_sav-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fs_sav-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22198beb5a8e01c3663eb4282dcb7d7785c6ac147ed0099d5e6cc2708ce368e2
MD5 b7be0de53a8940ac6aa26ed8af4041a2
BLAKE2b-256 1bc1133a05892d73df29ce1ea603602762d8c75d19fe9c5eaab35aa1c6248961

See more details on using hashes here.

File details

Details for the file fs_sav-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fs_sav-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 320b5b66d458a2a5c35b2701ec72949da6d50ebe3b8bf00361904217f1ed91a3
MD5 e83f21c96ad34e1646fd58832454b999
BLAKE2b-256 713e714f85cf007f234499820cd18438489d92543c9f70492e676ff2c729544b

See more details on using hashes here.

File details

Details for the file fs_sav-0.2.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fs_sav-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c33bfe812c8bf22eae9282532515de3322cb9df03c90d34fe88f0d564605ae9a
MD5 d32ff681173b2ed7832494465dfc9329
BLAKE2b-256 8ffcd1a50c93f99d2b67e48095bdf7dbfc60f74f75a952842ec84e3ce87917ed

See more details on using hashes here.

File details

Details for the file fs_sav-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for fs_sav-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0252fc596d6bffd0fdf58ba84427340505f56315e8cf83c8d3caa09be73d65d6
MD5 7df54ba035b006972f1c16972271b351
BLAKE2b-256 e843f3549dc0a1456e6446dcc50027917a30622048a1ed51b5d69ef68550b657

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page