Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/node-bunyan/tools/cutarelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Conventions:
- XXX
"""
from __future__ import print_function

__version_info__ = (1, 0, 7)
__version__ = '.'.join(map(str, __version_info__))
Expand Down Expand Up @@ -111,7 +112,7 @@ def cutarelease(project_name, version_files, dry_run=False):
"Are you sure you want cut a %s release?\n"
"This will involved commits and a push." % version,
default="no")
print "* * *"
print("* * *")
if answer != "yes":
log.info("user abort")
return
Expand All @@ -135,7 +136,7 @@ def cutarelease(project_name, version_files, dry_run=False):
"The changelog '%s' top section doesn't have the expected\n"
"'%s' marker. Has this been released already?"
% (changes_path, nyr), default="yes")
print "* * *"
print("* * *")
if answer != "no":
log.info("abort")
return
Expand Down Expand Up @@ -165,15 +166,15 @@ def cutarelease(project_name, version_files, dry_run=False):
# Optionally release.
if exists("package.json"):
answer = query_yes_no("\n* * *\nPublish to npm?", default="yes")
print "* * *"
print("* * *")
if answer == "yes":
if dry_run:
log.info("skipping npm publish (dry-run)")
else:
run('npm publish')
elif exists("setup.py"):
answer = query_yes_no("\n* * *\nPublish to pypi?", default="yes")
print "* * *"
print("* * *")
if answer == "yes":
if dry_run:
log.info("skipping pypi publish (dry-run)")
Expand Down
26 changes: 14 additions & 12 deletions tools/javascriptlint/javascriptlint/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# vim: ts=4 sw=4 expandtab
from __future__ import absolute_import

import os
import unittest

import fs
import util
import warnings
from . import fs
from . import util
from . import warnings

def _getwarningsconf():
lines = []
Expand Down Expand Up @@ -113,7 +115,7 @@ class DeprecatedSetting(Setting):
wants_parm = False
value = None
def load(self, enabled):
raise ConfError, 'This setting is deprecated.'
raise ConfError('This setting is deprecated.')

class BooleanSetting(Setting):
wants_parm = False
Expand All @@ -128,7 +130,7 @@ def __init__(self, default):
self.value = default
def load(self, enabled, parm):
if not enabled:
raise ConfError, 'Expected +.'
raise ConfError('Expected +.')
self.value = parm

class DeclareSetting(Setting):
Expand All @@ -137,7 +139,7 @@ def __init__(self):
self.value = []
def load(self, enabled, parm):
if not enabled:
raise ConfError, 'Expected +.'
raise ConfError('Expected +.')
self.value.append(parm)

class ProcessSetting(Setting):
Expand All @@ -156,11 +158,11 @@ class JSVersionSetting(Setting):
value = util.JSVersion.default()
def load(self, enabled, parm):
if not enabled:
raise ConfError, 'Expected +.'
raise ConfError('Expected +.')

self.value = util.JSVersion.fromtype(parm)
if not self.value:
raise ConfError, 'Invalid JavaScript version: %s' % parm
raise ConfError('Invalid JavaScript version: %s' % parm)

class Conf:
def __init__(self):
Expand Down Expand Up @@ -190,7 +192,7 @@ def loadfile(self, path):
conf = fs.readfile(path)
try:
self.loadtext(conf, dir=os.path.dirname(path))
except ConfError, error:
except ConfError as error:
error.path = path
raise

Expand All @@ -199,7 +201,7 @@ def loadtext(self, conf, dir=None):
for lineno in range(0, len(lines)):
try:
self.loadline(lines[lineno], dir)
except ConfError, error:
except ConfError as error:
error.lineno = lineno
raise

Expand All @@ -220,7 +222,7 @@ def loadline(self, line, dir=None):
elif line.startswith('-'):
enabled = False
else:
raise ConfError, 'Expected + or -.'
raise ConfError('Expected + or -.')
line = line[1:]

# Parse the key/parms
Expand All @@ -235,7 +237,7 @@ def loadline(self, line, dir=None):
if setting.wants_parm:
args['parm'] = parm
elif parm:
raise ConfError, 'The %s setting does not expect a parameter.' % name
raise ConfError('The %s setting does not expect a parameter.' % name)
if setting.wants_dir:
args['dir'] = dir
setting.load(**args)
Expand Down
26 changes: 14 additions & 12 deletions tools/javascriptlint/javascriptlint/jsl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
from __future__ import print_function
from __future__ import absolute_import
import codecs
import fnmatch
import glob
Expand All @@ -8,11 +10,11 @@
import unittest
from optparse import OptionParser

import conf
import htmlparse
import jsparse
import lint
import util
from . import conf
from . import htmlparse
from . import jsparse
from . import lint
from . import util

_lint_results = {
'warnings': 0,
Expand All @@ -27,8 +29,8 @@ def _dump(paths):
def _lint(paths, conf_, printpaths):
def lint_error(path, line, col, errname, errdesc):
_lint_results['warnings'] = _lint_results['warnings'] + 1
print util.format_error(conf_['output-format'], path, line, col,
errname, errdesc)
print(util.format_error(conf_['output-format'], path, line, col,
errname, errdesc))
lint.lint_files(paths, lint_error, conf=conf_, printpaths=printpaths)

def _resolve_paths(path, recurse):
Expand All @@ -48,8 +50,8 @@ def _resolve_paths(path, recurse):

def printlogo():
# TODO: Print version number.
print "JavaScript Lint"
print "Developed by Matthias Miller (http://www.JavaScriptLint.com)"
print("JavaScript Lint")
print("Developed by Matthias Miller (http://www.JavaScriptLint.com)")

def _profile_enabled(func, *args, **kwargs):
import tempfile
Expand Down Expand Up @@ -104,7 +106,7 @@ def main():
sys.exit()

if options.showdefaultconf:
print conf.DEFAULT_CONF
print(conf.DEFAULT_CONF)
sys.exit()

if options.printlogo:
Expand Down Expand Up @@ -142,8 +144,8 @@ def main():
profile_func(_lint, paths, conf_, options.printlisting)

if options.printsummary:
print '\n%i error(s), %i warnings(s)' % (_lint_results['errors'],
_lint_results['warnings'])
print('\n%i error(s), %i warnings(s)' % (_lint_results['errors'],
_lint_results['warnings']))

if _lint_results['errors']:
sys.exit(3)
Expand Down
34 changes: 18 additions & 16 deletions tools/javascriptlint/javascriptlint/jsparse.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
""" Parses a script into nodes. """
from __future__ import print_function
from __future__ import absolute_import
import bisect
import re
import unittest

import spidermonkey
from spidermonkey import tok, op
from util import JSVersion
from . import spidermonkey
from .spidermonkey import tok, op
from .util import JSVersion

_tok_names = dict(zip(
[getattr(tok, prop) for prop in dir(tok)],
Expand Down Expand Up @@ -253,27 +255,27 @@ def is_compilable_unit(script, jsversion):

def _dump_node(node, depth=0):
if node is None:
print ' '*depth,
print '(None)'
print
print(' '*depth, end=' ')
print('(None)')
print()
else:
print ' '*depth,
print '%s, %s' % (_tok_names[node.kind], _op_names[node.opcode])
print ' '*depth,
print '%s - %s' % (node.start_pos(), node.end_pos())
print(' '*depth, end=' ')
print('%s, %s' % (_tok_names[node.kind], _op_names[node.opcode]))
print(' '*depth, end=' ')
print('%s - %s' % (node.start_pos(), node.end_pos()))
if hasattr(node, 'atom'):
print ' '*depth,
print 'atom: %s' % node.atom
print(' '*depth, end=' ')
print('atom: %s' % node.atom)
if node.no_semi:
print ' '*depth,
print '(no semicolon)'
print
print(' '*depth, end=' ')
print('(no semicolon)')
print()
for node in node.kids:
_dump_node(node, depth+1)

def dump_tree(script):
def error_callback(line, col, msg):
print '(%i, %i): %s', (line, col, msg)
print('(%i, %i): %s', (line, col, msg))
node = parse(script, None, error_callback)
_dump_node(node)

Expand Down
24 changes: 13 additions & 11 deletions tools/javascriptlint/javascriptlint/lint.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
from __future__ import print_function
from __future__ import absolute_import
import os.path
import re

import conf
import fs
import htmlparse
import jsparse
import visitation
import warnings
from . import conf
from . import fs
from . import htmlparse
from . import jsparse
from . import visitation
from . import warnings
import unittest
import util
from . import util

from spidermonkey import tok, op
from .spidermonkey import tok, op

_newline_kinds = (
'eof', 'comma', 'dot', 'semi', 'colon', 'lc', 'rc', 'lp', 'rb', 'assign',
Expand Down Expand Up @@ -302,7 +304,7 @@ def _lint_error(*args):
if normpath in lint_cache:
return lint_cache[normpath]
if printpaths:
print normpath
print(normpath)
contents = fs.readfile(path)
lint_cache[normpath] = _Script()

Expand Down Expand Up @@ -524,7 +526,7 @@ def _report(pos, errname, errdesc, require_key):
try:
if not conf[errname]:
return
except KeyError, err:
except KeyError as err:
if require_key:
raise

Expand Down Expand Up @@ -568,7 +570,7 @@ def onpush(node):
try:
ret = visitor(node)
assert ret is None, 'visitor should raise an exception, not return a value'
except warnings.LintWarning, warning:
except warnings.LintWarning as warning:
# TODO: This is ugly hardcoding to improve the error positioning of
# "missing_semicolon" errors.
if visitor.warning in ('missing_semicolon', 'missing_semicolon_for_lambda'):
Expand Down
4 changes: 2 additions & 2 deletions tools/javascriptlint/javascriptlint/visitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def make_visitors(visitors, klasses):
# Intantiate an instance of each class
for klass in klasses:
if klass.__name__.lower() != klass.__name__:
raise ValueError, 'class names must be lowercase'
raise ValueError('class names must be lowercase')
if not klass.__doc__:
raise ValueError, 'missing docstring on class %s' % klass.__name__
raise ValueError('missing docstring on class %s' % klass.__name__)

# Look for functions with the "_visit_nodes" property.
visitor = klass()
Expand Down
Loading