I tried just running nosetests , and it has some bizzare error message about
indentation, and after I fixed the first one, another bizzare error message 
about
indentation. The fixes are below - and after those two, the errors get more
incomprehensible, which is probably a good thing(!).

Anyway, I am concerned why things like indentation errors happen. For the 
benefit
of others reading who are less familiar with python, python is strange in that
indentations are used to indicate control blocks - i.e. what {} does in 
C/perl/java.
So indentation errors in python is somewhat equivalent to not having
matching braces in other languages. Having more than one of those, at different
and far-way places, indicates that codes are being written (and committed)
which has never been run or even checked for basic syntax correctness. This is 
worrying.

So I suggest:

- runs "python -m " on the file you are editing from time to time - this checks 
for
syntax correctness among other things, without actually running the code. (for
codes that can't run on its own). That's another reason to use the 
"if __name__ == '__main__':" trick for python modules to unit test, to make sure
that each file in a module can run on its own and do something simple.

- do *not* get into the habit of keep writing and writing, and believing that 
you can correct
any errors or typos later. It is not a good habit, just don't get into it.

- use the right tools to help you - this sort of syntax errors shouldn't happen
if you use an editor which can systax-highlight and auto-indent according
to language. I am not going to be drawn into the emacs-vs-vi war; but I do use
emacs (mostly because it was unique/first in being able to edit/view CJK back
in 90's - I am willing to bet that vi could not, in those days, but I am
willing to accept that it probably can now).
It can normally auto-detect the content being python code
(from *.py name, or "#!/usr/bin/env python", and a few other means),
and colorise python-specific keywords, like "try" and "except"; and it would
indent at 4 instead of the usual 8 in python mode. So the
2nd of the indentation error below really shouldn't happen if you are reading
what you type. I believe vim have similiar functionalities, and so does
kate (of kde) but I have no personal experience of those, and
probably eclipse also. I also routinely run emacs with "-nw" (do no start
new window) - both for speed, as well
as to disable mouse usage - I found shifting cursor location annoying
when I accidentally move the mouse or when I click switch to another
application else than back. Anyway, use the right tool, and there
are editors which have features that make programming easier.

diff --git a/spdx/parsers/tagvalue.py b/spdx/parsers/tagvalue.py
index edd35a0..f8e139e 100644
--- a/spdx/parsers/tagvalue.py
+++ b/spdx/parsers/tagvalue.py
@@ -165,7 +165,7 @@ class Parser(object):
             self.logger.log('SPDXVersion must be SPDX-1.2 found 
{0}.'.format(value))
             
     def p_spdx_version(self, p):
-            '''spdx_version : DOC_VERSION error'''
+        '''spdx_version : DOC_VERSION error'''
         self.error = True
         msg = ERROR_MESSAGES['DOC_VERSION_VALUE_TYPE'].format(p.lineno(1))
         self.logger.log(msg)
@@ -232,7 +232,7 @@ class Parser(object):
         '''entity : PERSON_VALUE
         '''
         try:
-        p[0] = self.builder.build_person(doc=self.document, entity=p[1])
+            p[0] = self.builder.build_person(doc=self.document, entity=p[1])
         except ValueError, e:
             msg = ERROR_MESSAGES['PERSON_VALUE'].format(p[1], p.lineno(1))
             self.logger.log(msg)

_______________________________________________
Spdx-tech mailing list
[email protected]
https://lists.spdx.org/mailman/listinfo/spdx-tech

Reply via email to