Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layers not initialised when loading existing opf #227

Open
10zintopjor opened this issue Dec 26, 2022 · 8 comments
Open

Layers not initialised when loading existing opf #227

10zintopjor opened this issue Dec 26, 2022 · 8 comments

Comments

@10zintopjor
Copy link
Contributor

10zintopjor commented Dec 26, 2022

Is your feature request related to a problem? Please describe.
i am trying to get the layers from openpechaFS given a created opf Path to it,however the layers attribute is empty when accessing through the object.

Describe the solution you'd like
if the given path is already created,then the layers can be initialise.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context

  • Add any other context or screenshots about the feature request here.

Screenshot 2022-12-26 at 2 38 11 PM

@10zintopjor 10zintopjor changed the title Layers not initialised Layers not initialised when loading existing opf Dec 26, 2022
@eroux
Copy link
Contributor

eroux commented Dec 26, 2022

The description is a bit unclear... in the case you're looking at, are there existing layer files? If not, it seems quite normal that the layer object is empty

@10zintopjor
Copy link
Contributor Author

10zintopjor commented Dec 26, 2022

I am passing an already created opf that is downloaded from Openpecha-Data to openpechaFS and it has layers.The main problem is that i need what type of layer exist in a particular opf.

@eroux
Copy link
Contributor

eroux commented Dec 26, 2022

ok yes, then that seems like an issue, can you create a minimal working example demonstrating your bug?

@10zintopjor
Copy link
Contributor Author

The function returns empty list even though the pecha has layers.

from openpecha.core.pecha import OpenPechaFS

def get_opf_layers(pecha_path):
    opf = OpenPechaFS(pecha_path)
    opf_layers = opf.layers
    return opf_layers

@eroux
Copy link
Contributor

eroux commented Dec 26, 2022

A minimal working example is an example that actually works if I test it but if I run your code nothing will happen. Please provide some code that I can run to reproduce the issue

@10zintopjor
Copy link
Contributor Author

I have added the MRE in this repo.The main function gets the layer types of opf and then it updates a catalog.

MRE

@eroux
Copy link
Contributor

eroux commented Dec 26, 2022

wonderful, thanks!

@eroux
Copy link
Contributor

eroux commented Dec 30, 2022

I can't push code to your repo, but here's a mre.py that works:

from openpecha.core.pecha import OpenPechaFS

def get_opf_layers(opf_path):
    opf = OpenPechaFS(opf_path)
    layers = []
    for base in opf.meta.bases:
        layers = list(opf.get_layers(base))
    return layers

if __name__ == "__main__":
    pecha_id = "I4AEA9D55"
    opf_path = "./I4AEA9D55/I4AEA9D55.opf"
    print("opf has %d layers" % len(get_opf_layers(opf_path)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants