Skip to main content

hazelnut hazelnut

PyPI Version Python Versions CI

hazelnut is an Apache licensed library written in Python designed to provide a simple and pythonic way to parse /proc/meminfo on Linux based systems.

Installation

pip install hazelnut

Usage

>>> from hazelnut import MemInfo
>>> mem = MemInfo()
>>> repr(mem)
"MemInfo(path='/proc/meminfo')"

Print all meminfo contents:

>>> print(mem)
MemTotal:        8092460 kB
MemFree:          499880 kB
...

Return output as dict:

>>> mem.to_dict()
{
    "MemTotal": "8092460 kB",
    "MemFree": "499880 kB",
    "Buffers": "219088 kB",
    "HugePages_Total": "0",
    ...
}

Search keys (case-insensitive, matches anywhere in the key — anchor with ^ if needed):

>>> mem.search('total')
['MemTotal:        8092460 kB', 'SwapTotal:      16776188 kB', 'VmallocTotal:   34359738367 kB', 'HugePages_Total:       0']

Get memory value as int (exact key match):

>>> mem.get('MemTotal')
8092460
>>> mem.get('Active(anon)')
1794356
>>> mem.get('NoSuchKey') is None
True

Values are returned as bare integers with the unit dropped: most fields are expressed in kB (kibibytes), a few (e.g. HugePages_Total) are plain counts.

License

Copyright 2015-2026 Martin Simon

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Buy me a coffee?

If you feel like buying me a coffee (or a beer?), donations are welcome:

BTC : bc1qq04jnuqqavpccfptmddqjkg7cuspy3new4sxq9
DOGE: DRBkryyau5CMxpBzVmrBAjK6dVdMZSBsuS
ETH : 0x2238A11856428b72E80D70Be8666729497059d95
LTC : MQwXsBrArLRHQzwQZAjJPNrxGS1uNDDKX6

Download files

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

Source Distribution

hazelnut-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

hazelnut-1.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file hazelnut-1.0.0.tar.gz.

File metadata

  • Download URL: hazelnut-1.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hazelnut-1.0.0.tar.gz
Algorithm Hash digest
SHA256 817df81c8edee858bcfd05e479401d110d14f39912542abe494eb50618a9e49f
MD5 910e62407a2c797fb913e0e6c2f60a74
BLAKE2b-256 0a0119d755719d794cc365ac68c2582f13d6f4dbe699bd312006b27c03551105

See more details on using hashes here.

Provenance

The following attestation bundles were made for hazelnut-1.0.0.tar.gz:

Publisher: release.yml on barnumbirr/hazelnut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hazelnut-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hazelnut-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hazelnut-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0aca2cbc328b2d7f7325ab831f1d244560afc487db766cf3c42a3033bb4a5d82
MD5 4229db017e383f672bd7c2dde2441b72
BLAKE2b-256 1ddbefc8800f6934e49079bd3b462d64503cce57d6c94a7be5f459e5e906c7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for hazelnut-1.0.0-py3-none-any.whl:

Publisher: release.yml on barnumbirr/hazelnut

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.4.1

1 file

0.4

1 file

0.3

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page