twilson90 / openformat-to-obj

Converts OPENIV .odr to wavefront obj files
20 stars 5 forks source link

Python 3.11+ compatibility #1

Open mundiplaga opened 1 week ago

mundiplaga commented 1 week ago

Hello!

Thank you so much for this script! It has helped me create a bunch of GTA 5 content in VRChat!

I noticed that when using this script in Python 3.11 or 3.12, I get an error from the glob2 module:

Traceback (most recent call last):
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\openformat-to-obj.py", line 325, in <module>
    odr_paths = glob2.glob(args.glob)
                ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\glob2\impl.py", line 58, in glob
    return list(self.iglob(pathname, with_matches, include_hidden))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\glob2\impl.py", line 120, in _iglob
    for name, groups in self.resolve_pattern(
                        ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\glob2\impl.py", line 177, in resolve_pattern
    return fnmatch.filter(names, pattern)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\glob2\fnmatch.py", line 55, in filter
    match = _compile_pattern(pat)
            ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\projects\python\temp\openformat-to-obj\glob2\fnmatch.py", line 49, in _compile_pattern
    return re.compile(res).match
           ^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\__init__.py", line 228, in compile
    return _compile(pattern, flags)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\__init__.py", line 307, in _compile
    p = _compiler.compile(pattern, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\_compiler.py", line 745, in compile
    p = _parser.parse(p, flags)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\_parser.py", line 979, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\_parser.py", line 460, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jay\AppData\Local\Programs\Python\Python312\Lib\re\_parser.py", line 840, in _parse
    raise source.error('global flags not at the start '
re.error: global flags not at the start of the expression at position 11

This led me to try just changing the glob2 import and usage to glob and delete the glob2 directory and the script worked just fine for my limited use case of GTA5 Pedestrian models. I am unsure if the glob2 is maybe necessary for some other .odr files I'm not aware of, or other files in general.

I went through some compatibility testing in my own forked repo and found the .odr files extracted just fine with this change in Python 3.3 -> 3.12

twilson90 commented 1 week ago

I barely remember writing this to be honest. I'm sure there must have been a reason I used glob2 and embedded it locally instead of using the builtin glob module. Perhaps it was something wrong with my python installation at the time. Can't say for certain but it was probably something like that.