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

returns error #3

Closed
ch-sander opened this issue Nov 25, 2021 · 5 comments
Closed

returns error #3

ch-sander opened this issue Nov 25, 2021 · 5 comments

Comments

@ch-sander
Copy link
Collaborator

Sander@W10NB27 MINGW64 ~/Documents/GitHub/raramagnetica_pyIIIFpres (main)
$ python generatemanifestv4.py
C:\Python39\lib\site-packages\urllib3\connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dlib2.biblhertz.it'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
C:\Python39\lib\site-packages\urllib3\connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dlib2.biblhertz.it'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
The type property must be the default string ▒Agent▒.
Traceback (most recent call last):
File "C:\Users\Sander\Documents\GitHub\raramagnetica_pyIIIFpres\generatemanifestv4.py", line 102, in
strdic[currentlevel] = strdic[previouslevel].add_range_to_items()
KeyError: -1

@ch-sander
Copy link
Collaborator Author

tried with forked version (see pull requests)

@ch-sander
Copy link
Collaborator Author

I assume the error occurs as the new CSV has level 0 assigned instead of starting with level 1.

@ch-sander
Copy link
Collaborator Author

If I cange line 94 into currentlevel = int(d['level']) + 1, it works. Not sure if this is the best way.

@giacomomarchioro
Copy link
Owner

giacomomarchioro commented Nov 26, 2021

Yes, this is because level 0 would be the table of contents, the ratio of having the table of contents as a first range is that you can define custom ranges for structuring some composite text that does not follow the table of contents.

If you need to start from 0, I think it's better to do like this:

manifest.structures = []
rng = manifest.add_range_to_structures()
rng.set_id(extendbase_url="range/")
rng.add_label('en',"Tables of Contents")
strdic = {-1:rng}. # first range (table of contents) is now labelled -1 (called range in the URI)
last_label = None
rngind = defaultdict(int)
idx = 0
with open('metadata_v4.csv') as csv_file, open('imageurllist.txt') as url_list:
    data = csv.DictReader(csv_file, delimiter=',')
    lastlevel = 0 # the first usable range is now 0

@ch-sander
Copy link
Collaborator Author

yes, better this way

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