File: util.py

package info (click to toggle)
python-orjson 3.11.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,220 kB
  • sloc: ansic: 11,268; python: 6,984; sh: 106; makefile: 9
file content (20 lines) | stat: -rw-r--r-- 520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# Copyright ijl (2018-2022), Aarni Koskela (2021)

import lzma
import os
from pathlib import Path

dirname = os.path.join(os.path.dirname(__file__), "../data")

if hasattr(os, "sched_setaffinity"):
    os.sched_setaffinity(os.getpid(), {0, 1})


def read_fixture(filename: str) -> bytes:
    path = Path(dirname, filename)
    if path.suffix == ".xz":
        contents = lzma.decompress(path.read_bytes())
    else:
        contents = path.read_bytes()
    return contents