[javascriptlint-commit] SF.net SVN: javascriptlint:[302] trunk/javascriptlint
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2011-04-07 00:07:12
|
Revision: 302 http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=302&view=rev Author: matthiasmiller Date: 2011-04-07 00:07:05 +0000 (Thu, 07 Apr 2011) Log Message: ----------- Move file system functions into separate module in preparation for online lint. Modified Paths: -------------- trunk/javascriptlint/conf.py trunk/javascriptlint/lint.py trunk/javascriptlint/util.py Added Paths: ----------- trunk/javascriptlint/fs.py Modified: trunk/javascriptlint/conf.py =================================================================== --- trunk/javascriptlint/conf.py 2010-10-03 20:18:10 UTC (rev 301) +++ trunk/javascriptlint/conf.py 2011-04-07 00:07:05 UTC (rev 302) @@ -2,6 +2,7 @@ import os import unittest +import fs import util import warnings @@ -186,7 +187,7 @@ def loadfile(self, path): path = os.path.abspath(path) - conf = open(path, 'r').read() + conf = fs.readfile(path) try: self.loadtext(conf, dir=os.path.dirname(path)) except ConfError, error: Added: trunk/javascriptlint/fs.py =================================================================== --- trunk/javascriptlint/fs.py (rev 0) +++ trunk/javascriptlint/fs.py 2011-04-07 00:07:05 UTC (rev 302) @@ -0,0 +1,17 @@ +# vim: ts=4 sw=4 expandtab +import codecs +import os + +def readfile(path): + file = codecs.open(path, 'r', 'utf-8') + contents = file.read() + if contents and contents[0] == unicode(codecs.BOM_UTF8, 'utf8'): + contents = contents[1:] + return contents + +def normpath(path): + path = os.path.abspath(path) + path = os.path.normcase(path) + path = os.path.normpath(path) + return path + Property changes on: trunk/javascriptlint/fs.py ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/javascriptlint/lint.py =================================================================== --- trunk/javascriptlint/lint.py 2010-10-03 20:18:10 UTC (rev 301) +++ trunk/javascriptlint/lint.py 2011-04-07 00:07:05 UTC (rev 302) @@ -4,6 +4,7 @@ import re import conf +import fs import htmlparse import jsparse import visitation @@ -295,12 +296,12 @@ def _lint_error(*args): return lint_error(normpath, *args) - normpath = util.normpath(path) + normpath = fs.normpath(path) if normpath in lint_cache: return lint_cache[normpath] if printpaths: print normpath - contents = util.readfile(path) + contents = fs.readfile(path) lint_cache[normpath] = _Script() script_parts = [] Modified: trunk/javascriptlint/util.py =================================================================== --- trunk/javascriptlint/util.py 2010-10-03 20:18:10 UTC (rev 301) +++ trunk/javascriptlint/util.py 2011-04-07 00:07:05 UTC (rev 302) @@ -1,6 +1,5 @@ # vim: ts=4 sw=4 expandtab import cgi -import codecs import os.path import re import unittest @@ -101,19 +100,6 @@ return re.sub(regexp, lambda match: replacements[match.group(0)], formatted_error) -def readfile(path): - file = codecs.open(path, 'r', 'utf-8') - contents = file.read() - if contents and contents[0] == unicode(codecs.BOM_UTF8, 'utf8'): - contents = contents[1:] - return contents - -def normpath(path): - path = os.path.abspath(path) - path = os.path.normcase(path) - path = os.path.normpath(path) - return path - class TestUtil(unittest.TestCase): def testIdentifier(self): assert not isidentifier('') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |