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

Attribute error when trying to instantiate the graph object in python3.5 #158

Open
kevinisaac opened this issue Oct 18, 2015 · 2 comments
Open

Comments

@kevinisaac
Copy link

I am using OrientDB and Rexster with the latest release of Bulb in python3.5

When I try:

from bulbs.config import Config
from bulbs.rexster import Graph

g = Graph(Config('http://localhost:8182/graphs/Freeth'))

I get the following error:

  File "/home/kevin/Code/python/falcon/freeth/app/models.py", line 7, in <module>
    graph = Graph(Config('http://localhost:8182/graphs/Freeth/'))
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/rexster/graph.py", line 56, in __init__
    super(Graph, self).__init__(config)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/base/graph.py", line 53, in __init__
    self.client = self.client_class(config)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/rexster/client.py", line 324, in __init__
    self.scripts = GroovyScripts(self.config)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 74, in __init__
    self.update(file_path, self.default_namespace)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 120, in update
    methods = self._get_methods(file_path)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 160, in _get_methods
    return Parser(file_path).get_methods()
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 255, in __init__
    Scanner(handlers).scan(groovy_file)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 193, in __init__
    self.group_pattern = self._get_group_pattern(flags)
  File "/home/kevin/Code/python/falcon/freeth/venv/lib/python3.5/site-packages/bulbs/groovy.py", line 204, in _get_group_pattern
    sub_pattern.groups = len(patterns) + 1
AttributeError: can't set attribute

However, there is no problem with python3.4.

@mariomcginley
Copy link

Here is the updated function in groovy.py:

def _get_group_pattern(self,flags):
    # combine phrases into a compound pattern
    patterns = []
    sub_pattern = sre_parse.Pattern()
    sub_pattern.flags = flags
    for phrase, action in self.lexicon:
        gid = sub_pattern.opengroup()
        patterns.append(sre_parse.SubPattern(sub_pattern, [
            (SUBPATTERN, (len(patterns) + 1, sre_parse.parse(phrase, flags)$
            ]))
        sub_pattern.closegroup(gid, patterns[-1])
    #sub_pattern.groups = len(patterns) + 1
    group_pattern = sre_parse.SubPattern(sub_pattern, [(BRANCH, (None, patt$
    return sre_compile.compile(group_pattern)

@kevinisaac
Copy link
Author

@mariomcginley That works. Will be great if added to the repo.

mogui added a commit to mogui/pyorient that referenced this issue Jun 23, 2016
- stepped travis to use python 3.5
- close #160
- close #196
- close #162 with fix as per espeed/bulbs#158 (comment)
teleological pushed a commit to teleological/bulbs that referenced this issue Jan 1, 2019
* Adapted fix for issue espeed#158 by @mariomcginley (Pattern.groups RO)
* Fixed SUBPATTERN data structure for Python >= 3.6
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