Metadata-Version: 2.4
Name: xmextras
Version: 2026.135.1294
Summary: Extra utility functions for X-Midas.
License: Apache-2.0
License-File: LICENSE.txt
Author: Spectric Labs
Author-email: foss@spectric.com
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: numpy (>=1.20.1,<2.0.0)
Project-URL: Homepage, https://github.com/spectriclabs/xmextras
Description-Content-Type: text/markdown

# xmextras

Extra helper functionality for X-Midas.

## XMSessionContext

Wraps an `XMSession` in with a context manager to ensure it gets ended correctly when exiting.

```python
import xmextras as xmx

with xmx.XMSessionContext() as session:
    session.xm('res answer 42')

    # or
    from pymidas.xmidas import xm
    xm.res('answer', 42)

    answer = session.xmpy.res['answer']
```

## info

Returns a dictionary of information about the X-Midas instance, which can be useful for tagging metrics and benchmarks for comparison.

```python
import xmextras as xmx

with xmx.XMSessionContext() as session:
    info = xmx.info(session)  # also works with a normal XMSession instance
```

## J1950

Conversion functions for dealing with J1950 times (seconds since January 1, 1950).

```python
dt = j1950_to_datetime(2191001400.0)
```

```python
j = datetime_to_j1950(dt)
```

```python
e = j1950_to_epoch(2191001400.0)
```

```python
j = epoch_to_to_j1950(1559849400.0)
```

## power2

Calculates the next power of two greater than or equal to x.

```python
power2(3)  # returns 4
```

## bluefile

xmextras locates the system installation of bluefile.py so it can be imported outside of an X-Midas environment.

```python
from xmextras import bluefile
header = bluefile.readheader('some_bluefile.tmp')
```

## mcrlint

The `mcrlint` command is also included as part of xmextras.  It can be used for linting X-Midas macro code.  Use `mcrlint --help` for more information.

