Thread: [javascriptlint-commit] SF.net SVN: javascriptlint:[290] trunk/javascriptlint/jsl.py
Status: Beta
Brought to you by:
matthiasmiller
|
From: <mat...@us...> - 2009-11-18 11:11:18
|
Revision: 290
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=290&view=rev
Author: matthiasmiller
Date: 2009-11-18 11:11:00 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
Refactor the handling of wilcards on the command line.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2009-10-29 06:48:30 UTC (rev 289)
+++ trunk/javascriptlint/jsl.py 2009-11-18 11:11:00 UTC (rev 290)
@@ -1,6 +1,7 @@
#!/usr/bin/python
# vim: ts=4 sw=4 expandtab
import codecs
+import fnmatch
import glob
import os
import sys
@@ -31,27 +32,20 @@
lint.lint_files(paths, lint_error, conf=conf_)
def _resolve_paths(path, recurse):
- if os.path.isfile(path):
- return [path]
- elif os.path.isdir(path):
- dir = path
- pattern = '*'
- else:
- dir, pattern = os.path.split(path)
-
# Build a list of directories
- dirs = [dir]
- if recurse:
- for cur_root, cur_dirs, cur_files in os.walk(dir):
- for name in cur_dirs:
- dirs.append(os.path.join(cur_root, name))
-
- # Glob all files.
paths = []
- for dir in dirs:
- paths.extend(glob.glob(os.path.join(dir, pattern)))
- return paths
+ dir, pattern = os.path.split(path)
+ for cur_root, cur_dirs, cur_files in os.walk(dir):
+ paths.extend(os.path.join(cur_root, file) for file in \
+ fnmatch.filter(cur_files, pattern))
+ if not recurse:
+ break
+
+ # If no files have been found, return the original path/pattern. This will
+ # force an error to be thrown if no matching files were found.
+ return paths or [path]
+
def _profile_enabled(func, *args, **kwargs):
import tempfile
import hotshot
@@ -73,6 +67,14 @@
help="set the conf file")
add("--profile", dest="profile", action="store_true", default=False,
help="turn on hotshot profiling")
+ add("--recurse", dest="recurse", action="store_true", default=False,
+ help="recursively search directories on the command line")
+ if os.name == 'nt':
+ add("--disable-wildcards", dest="wildcards", action="store_false",
+ default=True, help="do not resolve wildcards in the command line")
+ else:
+ add("--enable-wildcards", dest="wildcards", action="store_true",
+ default=False, help="resolve wildcards in the command line")
add("--dump", dest="dump", action="store_true", default=False,
help="dump this script")
add("--unittest", dest="unittest", action="store_true", default=False,
@@ -114,7 +116,12 @@
for recurse, path in conf_['paths']:
paths.extend(_resolve_paths(path, recurse))
for arg in args:
- paths.extend(_resolve_paths(arg, False))
+ if options.wildcards:
+ paths.extend(_resolve_paths(arg, options.recurse))
+ elif options.recurse and os.path.isdir(arg):
+ paths.extend(_resolve_paths(os.path.join(arg, '*'), True))
+ else:
+ paths.append(arg)
if options.dump:
profile_func(_dump, paths)
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2010-04-23 21:10:04
|
Revision: 300
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=300&view=rev
Author: matthiasmiller
Date: 2010-04-23 21:09:57 +0000 (Fri, 23 Apr 2010)
Log Message:
-----------
Fix invalid exit code.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2010-04-23 20:58:11 UTC (rev 299)
+++ trunk/javascriptlint/jsl.py 2010-04-23 21:09:57 UTC (rev 300)
@@ -149,7 +149,7 @@
sys.exit(3)
if _lint_results['warnings']:
sys.exit(1)
- sys.exit(1)
+ sys.exit(0)
if __name__ == '__main__':
main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2011-12-02 18:49:16
|
Revision: 303
http://javascriptlint.svn.sourceforge.net/javascriptlint/?rev=303&view=rev
Author: matthiasmiller
Date: 2011-12-02 18:49:10 +0000 (Fri, 02 Dec 2011)
Log Message:
-----------
Fix --dump command line option.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2011-04-07 00:07:05 UTC (rev 302)
+++ trunk/javascriptlint/jsl.py 2011-12-02 18:49:10 UTC (rev 303)
@@ -9,6 +9,7 @@
from optparse import OptionParser
import conf
+import fs
import htmlparse
import jsparse
import lint
@@ -21,7 +22,7 @@
def _dump(paths):
for path in paths:
- script = util.readfile(path)
+ script = fs.readfile(path)
jsparse.dump_tree(script)
def _lint(paths, conf_, printpaths):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2013-10-03 19:39:11
|
Revision: 331
http://sourceforge.net/p/javascriptlint/code/331
Author: matthiasmiller
Date: 2013-10-03 19:39:07 +0000 (Thu, 03 Oct 2013)
Log Message:
-----------
Handle Ctrl+C.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2013-10-03 19:16:44 UTC (rev 330)
+++ trunk/javascriptlint/jsl.py 2013-10-03 19:39:07 UTC (rev 331)
@@ -66,7 +66,7 @@
def _profile_disabled(func, *args, **kwargs):
func(*args, **kwargs)
-def main():
+def _main():
parser = OptionParser(usage="%prog [options] [files]")
add = parser.add_option
add("--conf", dest="conf", metavar="CONF",
@@ -154,6 +154,12 @@
sys.exit(1)
sys.exit(0)
+def main():
+ try:
+ _main()
+ except KeyboardInterrupt:
+ raise SystemExit(130)
+
if __name__ == '__main__':
main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2018-01-02 21:36:46
|
Revision: 376
http://sourceforge.net/p/javascriptlint/code/376
Author: matthiasmiller
Date: 2018-01-02 21:36:45 +0000 (Tue, 02 Jan 2018)
Log Message:
-----------
Fix exception when running with blank command line.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2018-01-02 21:26:49 UTC (rev 375)
+++ trunk/javascriptlint/jsl.py 2018-01-02 21:36:45 UTC (rev 376)
@@ -18,7 +18,7 @@
_lint_results = {
'warning': 0,
- 'errors': 0
+ 'error': 0
}
def _dump(paths, encoding):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mat...@us...> - 2018-01-02 22:12:16
|
Revision: 379
http://sourceforge.net/p/javascriptlint/code/379
Author: matthiasmiller
Date: 2018-01-02 22:12:15 +0000 (Tue, 02 Jan 2018)
Log Message:
-----------
Fix to r378.
Modified Paths:
--------------
trunk/javascriptlint/jsl.py
Modified: trunk/javascriptlint/jsl.py
===================================================================
--- trunk/javascriptlint/jsl.py 2018-01-02 21:55:24 UTC (rev 378)
+++ trunk/javascriptlint/jsl.py 2018-01-02 22:12:15 UTC (rev 379)
@@ -77,9 +77,8 @@
add = parser.add_option
add("--conf", dest="conf", metavar="CONF",
help="set the conf file")
- if hotshot is not None:
- add("--profile", dest="profile", action="store_true", default=False,
- help="turn on hotshot profiling")
+ add("--profile", dest="profile", action="store_true", default=False,
+ help="turn on hotshot profiling" if hotshot is not None else optparse.SUPPRESS_HELP)
add("--recurse", dest="recurse", action="store_true", default=False,
help="recursively search directories on the command line")
if os.name == 'nt':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|