Skip to content

Instantly share code, notes, and snippets.

@nonylene
Last active October 23, 2024 17:01
Show Gist options
  • Select an option

  • Save nonylene/d95f1ff7b246a93a9b228536edf8a2d5 to your computer and use it in GitHub Desktop.

Select an option

Save nonylene/d95f1ff7b246a93a9b228536edf8a2d5 to your computer and use it in GitHub Desktop.
Read lyr objects using slyr_community library
# type: ignore
from slyr_community.parser import objects
from slyr_community.parser.object import Object
from slyr_community.parser.object_registry import REGISTRY
from slyr_community.parser.stream import Stream
LAYER_FILE = "/lyr/origin.lyr"
for i in dir(objects):
obj = getattr(objects, i)
if type(obj) is type and issubclass(obj, Object):
REGISTRY.register(obj)
with open(LAYER_FILE, "rb") as f:
stream = Stream(f, False, force_layer=True, offset=0)
print(stream.read_object())
FROM debian:12-slim
RUN apt update && apt install -y mdbtools python3-pip git
WORKDIR /work
RUN mkdir /work/lib
RUN git clone https://github.com/north-road/slyr.git /tmp/slyr
RUN mv /tmp/slyr/slyr_community /work/lib/slyr_community
ENV PYTHONPATH /work/lib
COPY colormap.py /work/colormap.py

Directory structure

- lyr
  - origin.lyr
- colormap.py
- Dockerfile

Command

$ docker build . -t colormap
$ docker run --rm -v `realpath lyr`:/lyr -it colormap python3 colormap.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment