mirror of https://github.com/apache/cassandra
resolve several pylint issues in cqlsh.py and pylib
patch by Brad Schoening; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-17480
This commit is contained in:
parent
e137c7c34c
commit
f28dd90feb
|
|
@ -1,4 +1,5 @@
|
|||
4.1
|
||||
* resolve several pylint issues in cqlsh.py and pylib (CASSANDRA-17480)
|
||||
* Streaming sessions longer than 3 minutes fail with timeout (CASSANDRA-17510)
|
||||
* Add ability to track state in repair (CASSANDRA-15399)
|
||||
* Remove unused 'parse' module (CASSANDRA-17484)
|
||||
|
|
|
|||
21
bin/cqlsh.py
21
bin/cqlsh.py
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
import cmd
|
||||
import codecs
|
||||
import configparser
|
||||
import csv
|
||||
import errno
|
||||
import getpass
|
||||
|
|
@ -33,6 +34,7 @@ import warnings
|
|||
import webbrowser
|
||||
from contextlib import contextmanager
|
||||
from glob import glob
|
||||
from io import StringIO
|
||||
from uuid import UUID
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
|
|
@ -118,9 +120,6 @@ for lib in third_parties:
|
|||
if lib_zip:
|
||||
sys.path.insert(0, lib_zip)
|
||||
|
||||
import configparser
|
||||
from io import StringIO
|
||||
|
||||
warnings.filterwarnings("ignore", r".*blist.*")
|
||||
try:
|
||||
import cassandra
|
||||
|
|
@ -225,8 +224,8 @@ parser.add_option('-v', action="version", help='Print the current version of cql
|
|||
parser.add_option("--insecure-password-without-warning", action='store_true', dest='insecure_password_without_warning',
|
||||
help=optparse.SUPPRESS_HELP)
|
||||
|
||||
optvalues = optparse.Values()
|
||||
(options, arguments) = parser.parse_args(sys.argv[1:], values=optvalues)
|
||||
opt_values = optparse.Values()
|
||||
(options, arguments) = parser.parse_args(sys.argv[1:], values=opt_values)
|
||||
|
||||
# BEGIN history/config definition
|
||||
|
||||
|
|
@ -878,7 +877,7 @@ class Shell(cmd.Cmd):
|
|||
return
|
||||
yield newline
|
||||
|
||||
def cmdloop(self):
|
||||
def cmdloop(self, intro=None):
|
||||
"""
|
||||
Adapted from cmd.Cmd's version, because there is literally no way with
|
||||
cmd.Cmd.cmdloop() to tell the difference between "EOF" showing up in
|
||||
|
|
@ -1115,11 +1114,11 @@ class Shell(cmd.Cmd):
|
|||
def print_all(result, table_meta, tty):
|
||||
# Return the number of rows in total
|
||||
num_rows = 0
|
||||
isFirst = True
|
||||
is_first = True
|
||||
while True:
|
||||
# Always print for the first page even it is empty
|
||||
if result.current_rows or isFirst:
|
||||
with_header = isFirst or tty
|
||||
if result.current_rows or is_first:
|
||||
with_header = is_first or tty
|
||||
self.print_static_result(result, table_meta, with_header, tty, num_rows)
|
||||
num_rows += len(result.current_rows)
|
||||
if result.has_more_pages:
|
||||
|
|
@ -1131,7 +1130,7 @@ class Shell(cmd.Cmd):
|
|||
if not tty:
|
||||
self.writeresult("")
|
||||
break
|
||||
isFirst = False
|
||||
is_first = False
|
||||
return num_rows
|
||||
|
||||
num_rows = print_all(result, table_meta, self.tty)
|
||||
|
|
@ -2067,7 +2066,7 @@ class SwitchCommandWithValue(SwitchCommand):
|
|||
binary_switch_value = True
|
||||
except (ValueError, TypeError):
|
||||
value = None
|
||||
return (binary_switch_value, value)
|
||||
return binary_switch_value, value
|
||||
|
||||
|
||||
def option_with_default(cparser_getter, section, option, default=None):
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ def printmsg(msg, eol='\n', encoding='utf8'):
|
|||
|
||||
# Keep arguments in sync with printmsg
|
||||
def swallowmsg(msg, eol='', encoding=''):
|
||||
None
|
||||
pass
|
||||
|
||||
|
||||
class OneWayPipe(object):
|
||||
|
|
@ -288,7 +288,7 @@ class CopyTask(object):
|
|||
return opts
|
||||
|
||||
configs = configparser.RawConfigParser()
|
||||
configs.readfp(open(config_file))
|
||||
configs.read_file(open(config_file))
|
||||
|
||||
ret = dict()
|
||||
config_sections = list(['copy', 'copy-%s' % (direction,),
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ from cassandra.metadata import maybe_escape_name
|
|||
from cqlshlib import helptopics
|
||||
from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
|
||||
|
||||
simple_cql_types = set(('ascii', 'bigint', 'blob', 'boolean', 'counter', 'date', 'decimal', 'double', 'duration', 'float',
|
||||
'inet', 'int', 'smallint', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'uuid', 'varchar', 'varint'))
|
||||
simple_cql_types = {'ascii', 'bigint', 'blob', 'boolean', 'counter', 'date', 'decimal', 'double', 'duration', 'float',
|
||||
'inet', 'int', 'smallint', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'uuid', 'varchar',
|
||||
'varint'}
|
||||
simple_cql_types.difference_update(('set', 'map', 'list'))
|
||||
|
||||
cqldocs = helptopics.CQL3HelpTopics()
|
||||
|
|
@ -450,7 +451,7 @@ def ks_prop_val_mapkey_completer(ctxt, cass):
|
|||
else:
|
||||
return ["'class'"]
|
||||
if repclass == 'SimpleStrategy':
|
||||
opts = set(('replication_factor',))
|
||||
opts = {'replication_factor'}
|
||||
elif repclass == 'NetworkTopologyStrategy':
|
||||
return [Hint('<dc_name>')]
|
||||
return list(map(escape_value, opts.difference(keysseen)))
|
||||
|
|
|
|||
|
|
@ -24,13 +24,12 @@ from cqlshlib import pylexotron, util
|
|||
|
||||
Hint = pylexotron.Hint
|
||||
|
||||
cql_keywords_reserved = set((
|
||||
'add', 'allow', 'alter', 'and', 'apply', 'asc', 'authorize', 'batch', 'begin', 'by', 'columnfamily', 'create',
|
||||
'delete', 'desc', 'describe', 'drop', 'entries', 'execute', 'from', 'full', 'grant', 'if', 'in', 'index',
|
||||
'infinity', 'insert', 'into', 'is', 'keyspace', 'limit', 'materialized', 'modify', 'nan', 'norecursive', 'not',
|
||||
'null', 'of', 'on', 'or', 'order', 'primary', 'rename', 'revoke', 'schema', 'select', 'set', 'table', 'to', 'token',
|
||||
'truncate', 'unlogged', 'update', 'use', 'using', 'view', 'where', 'with'
|
||||
))
|
||||
cql_keywords_reserved = {'add', 'allow', 'alter', 'and', 'apply', 'asc', 'authorize', 'batch', 'begin', 'by',
|
||||
'columnfamily', 'create', 'delete', 'desc', 'describe', 'drop', 'entries', 'execute', 'from',
|
||||
'full', 'grant', 'if', 'in', 'index', 'infinity', 'insert', 'into', 'is', 'keyspace', 'limit',
|
||||
'materialized', 'modify', 'nan', 'norecursive', 'not', 'null', 'of', 'on', 'or', 'order',
|
||||
'primary', 'rename', 'revoke', 'schema', 'select', 'set', 'table', 'to', 'token', 'truncate',
|
||||
'unlogged', 'update', 'use', 'using', 'view', 'where', 'with'}
|
||||
"""
|
||||
Set of reserved keywords in CQL.
|
||||
|
||||
|
|
@ -60,7 +59,7 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
|
|||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
pylexotron.ParsingRuleSet.__init__(self, *args, **kwargs)
|
||||
pylexotron.ParsingRuleSet.__init__(self)
|
||||
|
||||
# note: commands_end_with_newline may be extended by callers.
|
||||
self.commands_end_with_newline = set()
|
||||
|
|
@ -152,10 +151,10 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
|
|||
in_batch = True
|
||||
return output, in_batch or in_pg_string
|
||||
|
||||
def cql_complete_single(self, text, partial, init_bindings={}, ignore_case=True,
|
||||
def cql_complete_single(self, text, partial, init_bindings=None, ignore_case=True,
|
||||
startsymbol='Start'):
|
||||
tokens = (self.cql_split_statements(text)[0] or [[]])[-1]
|
||||
bindings = init_bindings.copy()
|
||||
bindings = {} if init_bindings is None else init_bindings.copy()
|
||||
|
||||
# handle some different completion scenarios- in particular, completing
|
||||
# inside a string literal
|
||||
|
|
|
|||
Loading…
Reference in New Issue