thriftpy icon indicating copy to clipboard operation
thriftpy copied to clipboard

Local .thrift file don't get picked up on Windows.

Open ErKatz opened this issue 8 years ago • 1 comments

On windows when the path start with the "file://" scheme, I get the following error: (path is 'file://C:\Users\MrT\UserSegmentation\lib\site-packages\happybase\Hbase.thrift')

Traceback (most recent call last): File "", line 1, in File "C:\Users\Erez.Katz\UserSegmentation\Lib\site-packages\happybase_init_.py", line 10, in 'Hbase_thrift') File "C:\Users\Erez.Katz\UserSegmentation\Lib\site-packages\thriftpy\parser_init_.py", line 30, in load include_dir=include_dir) File "C:\Users\Erez.Katz\UserSegmentation\Lib\site-packages\thriftpy\parser\parser.py", line 496, in parse url_scheme)) thriftpy.parser.exc.ThriftParserError: ThriftPy does not support generating module with path in protocol 'file'

workaround that I added in my environment in thriftpy\parser\parser.py", around starting at line 540

url_scheme = urlparse(path).scheme
if url_scheme == 'file':
    with open(urlparse(path).netloc) as fh:
        data = fh.read()
elif url_scheme == '':
    with open(path) as fh:
        data = fh.read()
elif url_scheme in ('http', 'https'):
    data = urlopen(path).read()
else:
    raise ThriftParserError('ThriftPy does not support generating module '
                            'with path in protocol \'{}\''.format(
                                url_scheme))

ErKatz avatar Dec 06 '16 11:12 ErKatz

this also impacts https://github.com/wbolster/happybase/issues/148

ErKatz avatar Dec 06 '16 11:12 ErKatz