marvin-zhao / pyang

Automatically exported from code.google.com/p/pyang
0 stars 0 forks source link

attribute error w/ keyword uses: is_gramatically_valid does not exist #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Admittedly, this was probably bad .yang.  But a validating parser should not 
die given bad yang files.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pya.py", line 229, in run
    expect_failure_error=False)
  File "pyang/__init__.py", line 93, in add_module
    return self.add_parsed_module(module)
  File "pyang/__init__.py", line 121, in add_parsed_module
    statements.validate_module(self, module)
  File "pyang/statements.py", line 91, in validate_module
    iterate(module, phase)
  File "pyang/statements.py", line 86, in iterate
    iterate(s, phase)
  File "pyang/statements.py", line 49, in iterate
    res = f(ctx, stmt)
  File "pyang/statements.py", line 168, in <lambda>
    ('type', 'grouping'):lambda ctx, s: v_type_grouping(ctx, s),
  File "pyang/statements.py", line 888, in v_type_grouping
    iterate_stmt(stmt, validate_uses)
  File "pyang/statements.py", line 2078, in iterate_stmt
    _iterate(stmt)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2075, in _iterate
    _iterate(s)
  File "pyang/statements.py", line 2067, in _iterate
    res = f(stmt)
  File "pyang/statements.py", line 885, in validate_uses
    if s.keyword == "uses" and s.is_grammatically_valid == True:
AttributeError: 'Statement' object has no attribute 'is_grammatically_valid'

I changed the code near pyang/statements.py", line 885 to this which worked.  
But I am not sure if ignoring grammatically valid at this point is the right 
thing to do.

    # search for circular grouping definitions
    def validate_uses(s):
        if s.keyword == "uses" and ( (not hasattr(s, 'is_grammatically_valid')) or s.is_grammatically_valid == True):
            v_type_uses(ctx, s, no_error_report=True)

What version of the product are you using? 

svn checkout dated 3/13/2013

Original issue reported on code.google.com by G.Andrew...@gmail.com on 14 Mar 2013 at 1:37

GoogleCodeExporter commented 9 years ago
Could you attach an example YANG module which gives this error?

You solution is probably correct, but there might be a better way to fix this 
as well.

/martin

Original comment by mbj4...@gmail.com on 14 Mar 2013 at 2:25

GoogleCodeExporter commented 9 years ago
Sorry, the problem "magically" fixed itself as I was tweaking the .yang file.  
I should have saved the file.

Original comment by G.Andrew...@gmail.com on 15 Mar 2013 at 8:27

GoogleCodeExporter commented 9 years ago
Closing for now.

Original comment by mbj4...@gmail.com on 23 Oct 2013 at 1:34