nwroyer / Python-Military-Symbols

A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names
MIT License
19 stars 5 forks source link

Error on SIDC 30012000001200000000 #7

Open banderlog opened 2 weeks ago

banderlog commented 2 weeks ago

Hi, I encounter some SIDS which throws an error FileNotFoundError, for example:

user@localhost:./venv/bin/military_symbol 30012000001200000000
This SIDC is for an APP-6 standard greater than this program is intended for;" +                   output may be unexpected
Traceback (most recent call last):
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/symbol_schema.py", line 882, in get_svg_by_filename
    raw_string_data = self.symbol_svg_json.get_contents_at_path(svg_name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/_json_filesystem.py", line 34, in get_contents_at_path
    raise FileNotFoundError(path)
FileNotFoundError: Symbol sets/20/Entities/120000.svg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/./venv/bin/military_symbol", line 8, in <module>
    sys.exit(command_line_main())
             ^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/command_line.py", line 269, in command_line_main
    print(get_symbol_svg_string_from_sidc(input_arg, bounding_padding=arguments.padding,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/command_line.py", line 42, in get_symbol_svg_string_from_sidc
    return get_svg_string(sidc, True, pixel_padding=bounding_padding, verbose=verbose, use_variants=use_variants,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/command_line.py", line 109, in get_svg_string
    return symbol_cache.get_svg_string(creator_var, is_sidc, padding=pixel_padding, style=style,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/symbol_cache.py", line 113, in get_svg_string
    return self.get_symbol_and_svg_string(creator_val, is_sidc, padding, style, use_variants, use_background, background_color, create_if_missing)[1]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/symbol_cache.py", line 104, in get_symbol_and_svg_string
    svg_string = symbol.get_svg(style=style, pixel_padding=padding, use_variants=use_variants, use_background=use_background, background_color=background_color)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/individual_symbol.py", line 270, in get_svg
    overlay_svgs.append(self.symbol_schema.get_svg_by_code('E-%s-%s' % (self.symbol_set.id_code,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/symbol_schema.py", line 1048, in get_svg_by_code
    return self.get_svg_by_filename(self.get_svg_filename_by_code(code, standard_identity, use_variants))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venv/lib/python3.12/site-packages/military_symbol/symbol_schema.py", line 887, in get_svg_by_filename
    raise FileNotFoundError
FileNotFoundError
banderlog commented 1 week ago

tmp2

this is image what https://github.com/spatialillusions/milsymbol provides

nwroyer commented 1 week ago

@banderlog 2aa9d846cb7c4a1ab84787804d0334574072ccec should address this - if a symbol isn't defined for a particular entity, it'll now simply draw nothing instead of raising an error. If you can test this with the other SIDCs that were throwing errors for you, or let me know which SIDCs you were testing so I can see if the issue is resolved for those, I can make sure this is good to go.

banderlog commented 1 week ago

Look's like it fixes the problem, thank you