desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return True iff this function should be considered public.'
| @property
def is_public(self):
| if (self.all is not None):
return (self.name in self.all)
else:
return (not self.name.startswith('_'))
|
'Return True if this function is a test function/method.
We exclude tests from the imperative mood check, because to phrase
their docstring in the imperative mood, they would have to start with
a highly redundant "Test that ...".'
| @property
def is_test(self):
| return (self.name.startswith('test') or (self.name == 'runTest'))
|
'Return True iff this method is a magic method (e.g., `__str__`).'
| @property
def is_magic(self):
| return (self.name.startswith('__') and self.name.endswith('__') and (self.name not in VARIADIC_MAGIC_METHODS))
|
'Return True iff this method should be considered public.'
| @property
def is_public(self):
| for decorator in self.decorators:
if re('^{}\\.'.format(self.name)).match(decorator.name):
return False
name_is_public = ((not self.name.startswith('_')) or (self.name in VARIADIC_MAGIC_METHODS) or self.is_magic)
return (self.parent.is_public and name_is_public)
|
'Return True iff this class should be considered public.'
| @property
def is_public(self):
| return ((not self.name.startswith('_')) and self.parent.is_class and self.parent.is_public)
|
'Initialize the error with a more specific message.'
| def __init__(self, message):
| Exception.__init__(self, (message + textwrap.dedent("\n That means pydocstyle cannot decide which definitions are\n public. Variable __all__ should be pre... |
'Parse the given file-like object and return its Module object.'
| def parse(self, filelike, filename):
| self.log = log
self.source = filelike.readlines()
src = ''.join(self.source)
try:
compile(src, filename, 'exec')
except SyntaxError as error:
six.raise_from(ParseError(), error)
self.stream = TokenStream(StringIO(src))
self.filename = filename
self.all = None
self.fut... |
'Call the parse method.'
| def __call__(self, *args, **kwargs):
| return self.parse(*args, **kwargs)
|
'Consume one token and verify it is of the expected kind.'
| def consume(self, kind):
| next_token = self.stream.move()
assert (next_token.kind == kind)
|
'Skip tokens in the stream until a certain token kind is reached.
If `value` is specified, tokens whose values are different will also
be skipped.'
| def leapfrog(self, kind, value=None):
| while (self.current is not None):
if ((self.current.kind == kind) and ((value is None) or (self.current.value == value))):
self.consume(kind)
return
self.stream.move()
|
'Parse a single docstring and return its value.'
| def parse_docstring(self):
| self.log.debug('parsing docstring, token is %r (%s)', self.current.kind, self.current.value)
while (self.current.kind in (tk.COMMENT, tk.NEWLINE, tk.NL)):
self.stream.move()
self.log.debug('parsing docstring, token is %r (%s)', self.current.kind, self.current.value)... |
'Called after first @ is found.
Parse decorators into self._accumulated_decorators.
Continue to do so until encountering the \'def\' or \'class\' start token.'
| def parse_decorators(self):
| name = []
arguments = []
at_arguments = False
while (self.current is not None):
self.log.debug('parsing decorators, current token is %r (%s)', self.current.kind, self.current.value)
if ((self.current.kind == tk.NAME) and (self.current.value in ['def', 'class'])):
... |
'Parse multiple definitions and yield them.'
| def parse_definitions(self, class_, all=False):
| while (self.current is not None):
self.log.debug('parsing definition list, current token is %r (%s)', self.current.kind, self.current.value)
self.log.debug('got_newline: %s', self.stream.got_logical_newline)
if (all and (self.current.value == '__all__')):
... |
'Parse the __all__ definition in a module.'
| def parse_all(self):
| assert (self.current.value == '__all__')
self.consume(tk.NAME)
if (self.current.value != '='):
raise AllError('Could not evaluate contents of __all__. ')
self.consume(tk.OP)
if (self.current.value not in '(['):
raise AllError('Could not evaluate contents ... |
'Parse a module (and its children) and return a Module object.'
| def parse_module(self):
| self.log.debug('parsing module.')
start = self.line
docstring = self.parse_docstring()
children = list(self.parse_definitions(Module, all=True))
assert (self.current is None), self.current
end = self.line
cls = Module
if self.filename.endswith('__init__.py'):
cls = Package
... |
'Parse a definition and return its value in a `class_` object.'
| def parse_definition(self, class_):
| start = self.line
self.consume(tk.NAME)
name = self.current.value
self.log.debug("parsing %s '%s'", class_.__name__, name)
self.stream.move()
if ((self.current.kind == tk.OP) and (self.current.value == '(')):
parenthesis_level = 0
while True:
if (self.current.ki... |
'Parse a definition comment for noqa skips.'
| def parse_skip_comment(self):
| skipped_error_codes = ''
if (self.current.kind == tk.COMMENT):
if ('noqa: ' in self.current.value):
skipped_error_codes = ''.join(self.current.value.split('noqa: ')[1:])
elif self.current.value.startswith('# noqa'):
skipped_error_codes = 'all'
return skipped_... |
'Verify the current token is of type `kind` and equals `value`.'
| def check_current(self, kind=None, value=None):
| msg = textwrap.dedent('\n Unexpected token at line {self.line}:\n\n In file: {self.filename}\n\n Got kind {self.current.kind!r}\n Got value {self.current.value}\n... |
'Parse a \'from x import y\' statement.
The purpose is to find __future__ statements.'
| def parse_from_import_statement(self):
| self.log.debug('parsing from/import statement.')
is_future_import = self._parse_from_import_source()
self._parse_from_import_names(is_future_import)
|
'Parse the \'from x import\' part in a \'from x import y\' statement.
Return true iff `x` is __future__.'
| def _parse_from_import_source(self):
| assert (self.current.value == 'from'), self.current.value
self.stream.move()
is_future_import = (self.current.value == '__future__')
self.stream.move()
while ((self.current is not None) and (self.current.kind in (tk.DOT, tk.NAME, tk.OP)) and (self.current.value != 'import')):
self.stream.mov... |
'Parse the \'y\' part in a \'from x import y\' statement.'
| def _parse_from_import_names(self, is_future_import):
| if (self.current.value == '('):
self.consume(tk.OP)
expected_end_kinds = (tk.OP,)
else:
expected_end_kinds = (tk.NEWLINE, tk.ENDMARKER)
while ((self.current.kind not in expected_end_kinds) and (not ((self.current.kind == tk.OP) and (self.current.value == ';')))):
if (self.cur... |
'Initialize the object.
`parameters` are specific to the created error.'
| def __init__(self, *parameters):
| self.parameters = parameters
self.definition = None
self.explanation = None
|
'Set the source code context for this error.'
| def set_context(self, definition, explanation):
| self.definition = definition
self.explanation = explanation
|
'Return the message to print to the user.'
| @property
def message(self):
| ret = '{}: {}'.format(self.code, self.short_desc)
if (self.context is not None):
ret += ((' (' + self.context.format(*self.parameters)) + ')')
return ret
|
'Return the source code lines for this error.'
| @property
def lines(self):
| source = ''
lines = self.definition._source[self.definition._slice]
offset = self.definition.start
lines_stripped = list(reversed(list(dropwhile(is_blank, reversed(lines)))))
numbers_width = 0
for (n, line) in enumerate(lines_stripped):
numbers_width = max(numbers_width, (n + offset))
... |
'Initialize the object.
`Prefix` should be the common prefix for errors in this group,
e.g., "D1".
`name` is the name of the group (its subject).'
| def __init__(self, prefix, name):
| self.prefix = prefix
self.name = name
self.errors = []
|
'Create an error, register it to this group and return it.'
| def create_error(self, error_code, error_desc, error_context=None):
| class _Error(Error, ):
code = error_code
short_desc = error_desc
context = error_context
self.errors.append(_Error)
return _Error
|
'Create a new error group and return it.'
| @classmethod
def create_group(cls, prefix, name):
| group = cls.ErrorGroup(prefix, name)
cls.groups.append(group)
return group
|
'Yield all registered codes.'
| @classmethod
def get_error_codes(cls):
| for group in cls.groups:
for error in group.errors:
(yield error.code)
|
'Output the registry as reStructuredText, for documentation.'
| @classmethod
def to_rst(cls):
| sep_line = (((('+' + (6 * '-')) + '+') + ('-' * 71)) + '+\n')
blank_line = (('|' + (78 * ' ')) + '|\n')
table = ''
for group in cls.groups:
table += sep_line
table += blank_line
table += (('|' + '**{}**'.format(group.name).center(78)) + '|\n')
table += blank_line
... |
'Do preorder walk of tree using visitor'
| def preorder(self, tree, visitor, *args):
| self.visitor = visitor
visitor.visit = self.dispatch
self.dispatch(tree, *args)
|
'Return the McCabe complexity for the graph.
V-E+2'
| def complexity(self):
| num_edges = sum([len(n) for n in self.nodes.values()])
num_nodes = len(self.nodes)
return ((num_edges - num_nodes) + 2)
|
'create the subgraphs representing any `if` and `for` statements'
| def _subgraph(self, node, name, extra_blocks=()):
| if (self.graph is None):
self.graph = PathGraph(name, name, node.lineno, node.col_offset)
pathnode = PathNode(name)
self._subgraph_parse(node, pathnode, extra_blocks)
self.graphs[('%s%s' % (self.classname, name))] = self.graph
self.reset()
else:
pathnode = self.ap... |
'parse the body and any `else` block of `if` and `for` statements'
| def _subgraph_parse(self, node, pathnode, extra_blocks):
| loose_ends = []
self.tail = pathnode
self.dispatch_list(node.body)
loose_ends.append(self.tail)
for extra in extra_blocks:
self.tail = pathnode
self.dispatch_list(extra.body)
loose_ends.append(self.tail)
if node.orelse:
self.tail = pathnode
self.dispatch_l... |
'Check if the syntax is valid.'
| def report_invalid_syntax(self):
| (exc_type, exc) = sys.exc_info()[:2]
if (len(exc.args) > 1):
offset = exc.args[1]
if (len(offset) > 2):
offset = offset[1:3]
else:
offset = (1, 0)
self.report_error(offset[0], (offset[1] or 0), ('E901 %s: %s' % (exc_type.__name__, exc.args[0])), self.report_inva... |
'Get the next line from the input buffer.'
| def readline(self):
| if (self.line_number >= self.total_lines):
return ''
line = self.lines[self.line_number]
self.line_number += 1
if ((self.indent_char is None) and (line[:1] in WHITESPACE)):
self.indent_char = line[0]
return line
|
'Run a check plugin.'
| def run_check(self, check, argument_names):
| arguments = []
for name in argument_names:
arguments.append(getattr(self, name))
return check(*arguments)
|
'Prepare custom state for the specific checker plugin.'
| def init_checker_state(self, name, argument_names):
| if ('checker_state' in argument_names):
self.checker_state = self._checker_states.setdefault(name, {})
|
'Run all physical checks on a raw input line.'
| def check_physical(self, line):
| self.physical_line = line
for (name, check, argument_names) in self._physical_checks:
self.init_checker_state(name, argument_names)
result = self.run_check(check, argument_names)
if (result is not None):
(offset, text) = result
self.report_error(self.line_number, ... |
'Build a logical line from tokens.'
| def build_tokens_line(self):
| logical = []
comments = []
length = 0
prev_row = prev_col = mapping = None
for (token_type, text, start, end, line) in self.tokens:
if (token_type in SKIP_TOKENS):
continue
if (not mapping):
mapping = [(0, start)]
if (token_type == tokenize.COMMENT):
... |
'Build a line from tokens and run all logical checks on it.'
| def check_logical(self):
| self.report.increment_logical_line()
mapping = self.build_tokens_line()
if (not mapping):
return
(start_row, start_col) = mapping[0][1]
start_line = self.lines[(start_row - 1)]
self.indent_level = expand_indent(start_line[:start_col])
if (self.blank_before < self.blank_lines):
... |
'Build the file\'s AST and run all AST checks.'
| def check_ast(self):
| try:
tree = compile(''.join(self.lines), '', 'exec', PyCF_ONLY_AST)
except (ValueError, SyntaxError, TypeError):
return self.report_invalid_syntax()
for (name, cls, __) in self._ast_checks:
checker = cls(tree, self.filename)
for (lineno, offset, text, check) in checker.run():... |
'Tokenize the file, run physical line checks and yield tokens.'
| def generate_tokens(self):
| if self._io_error:
self.report_error(1, 0, ('E902 %s' % self._io_error), readlines)
tokengen = tokenize.generate_tokens(self.readline)
try:
for token in tokengen:
if (token[2][0] > self.total_lines):
return
self.noqa = (token[4] and noqa(token[4]))
... |
'If appropriate (based on token), check current physical line(s).'
| def maybe_check_physical(self, token):
| if _is_eol_token(token):
self.check_physical(token[4])
elif ((token[0] == tokenize.STRING) and ('\n' in token[1])):
if noqa(token[4]):
return
self.multiline = True
self.line_number = token[2][0]
for line in token[1].split('\n')[:(-1)]:
self.check_p... |
'Run all checks on the input file.'
| def check_all(self, expected=None, line_offset=0):
| self.report.init_file(self.filename, self.lines, expected, line_offset)
self.total_lines = len(self.lines)
if self._ast_checks:
self.check_ast()
self.line_number = 0
self.indent_char = None
self.indent_level = self.previous_indent_level = 0
self.previous_logical = ''
self.previou... |
'Start the timer.'
| def start(self):
| self._start_time = time.time()
|
'Stop the timer.'
| def stop(self):
| self.elapsed = (time.time() - self._start_time)
|
'Signal a new file.'
| def init_file(self, filename, lines, expected, line_offset):
| self.filename = filename
self.lines = lines
self.expected = (expected or ())
self.line_offset = line_offset
self.file_errors = 0
self.counters['files'] += 1
self.counters['physical lines'] += len(lines)
|
'Signal a new logical line.'
| def increment_logical_line(self):
| self.counters['logical lines'] += 1
|
'Report an error, according to options.'
| def error(self, line_number, offset, text, check):
| code = text[:4]
if self._ignore_code(code):
return
if (code in self.counters):
self.counters[code] += 1
else:
self.counters[code] = 1
self.messages[code] = text[5:]
if (code in self.expected):
return
if (self.print_filename and (not self.file_errors)):
... |
'Return the count of errors and warnings for this file.'
| def get_file_results(self):
| return self.file_errors
|
'Return the total count of errors and warnings.'
| def get_count(self, prefix=''):
| return sum([self.counters[key] for key in self.messages if key.startswith(prefix)])
|
'Get statistics for message codes that start with the prefix.
prefix=\'\' matches all errors and warnings
prefix=\'E\' matches all errors
prefix=\'W\' matches all warnings
prefix=\'E4\' matches all errors that have to do with imports'
| def get_statistics(self, prefix=''):
| return [('%-7s %s %s' % (self.counters[key], key, self.messages[key])) for key in sorted(self.messages) if key.startswith(prefix)]
|
'Print overall statistics (number of errors and warnings).'
| def print_statistics(self, prefix=''):
| for line in self.get_statistics(prefix):
print line
|
'Print benchmark numbers.'
| def print_benchmark(self):
| print ('%-7.2f %s' % (self.elapsed, 'seconds elapsed'))
if self.elapsed:
for key in self._benchmark_keys:
print ('%-7d %s per second (%d total)' % ((self.counters[key] / self.elapsed), key, self.counters[key]))
|
'Signal a new file.'
| def init_file(self, filename, lines, expected, line_offset):
| self._deferred_print = []
return super(StandardReport, self).init_file(filename, lines, expected, line_offset)
|
'Report an error, according to options.'
| def error(self, line_number, offset, text, check):
| code = super(StandardReport, self).error(line_number, offset, text, check)
if (code and ((self.counters[code] == 1) or self._repeat)):
self._deferred_print.append((line_number, offset, code, text[5:], check.__doc__))
return code
|
'Print the result and return the overall count for this file.'
| def get_file_results(self):
| self._deferred_print.sort()
for (line_number, offset, code, text, doc) in self._deferred_print:
print (self._fmt % {'path': self.filename, 'row': (self.line_offset + line_number), 'col': (offset + 1), 'code': code, 'text': text})
if self._show_source:
if (line_number > len(self.lines... |
'Initialize the report instance.'
| def init_report(self, reporter=None):
| self.options.report = (reporter or self.options.reporter)(self.options)
return self.options.report
|
'Run all checks on the paths.'
| def check_files(self, paths=None):
| if (paths is None):
paths = self.paths
report = self.options.report
runner = self.runner
report.start()
try:
for path in paths:
if os.path.isdir(path):
self.input_dir(path)
elif (not self.excluded(path)):
runner(path)
except... |
'Run all checks on a Python source file.'
| def input_file(self, filename, lines=None, expected=None, line_offset=0):
| if self.options.verbose:
print ('checking %s' % filename)
fchecker = self.checker_class(filename, lines=lines, options=self.options)
return fchecker.check_all(expected=expected, line_offset=line_offset)
|
'Check all files in this directory and all subdirectories.'
| def input_dir(self, dirname):
| dirname = dirname.rstrip('/')
if self.excluded(dirname):
return 0
counters = self.options.report.counters
verbose = self.options.verbose
filepatterns = self.options.filename
runner = self.runner
for (root, dirs, files) in os.walk(dirname):
if verbose:
print ('dire... |
'Check if the file should be excluded.
Check if \'options.exclude\' contains a pattern that matches filename.'
| def excluded(self, filename, parent=None):
| if (not self.options.exclude):
return False
basename = os.path.basename(filename)
if filename_match(basename, self.options.exclude):
return True
if parent:
filename = os.path.join(parent, filename)
filename = os.path.abspath(filename)
return filename_match(filename, self.... |
'Check if the error code should be ignored.
If \'options.select\' contains a prefix of the error code,
return False. Else, if \'options.ignore\' contains a prefix of
the error code, return True.'
| def ignore_code(self, code):
| if ((len(code) < 4) and any((s.startswith(code) for s in self.options.select))):
return False
return (code.startswith(self.options.ignore) and (not code.startswith(self.options.select)))
|
'Get all the checks for this category.
Find all globally visible functions where the first argument name
starts with argument_name and which contain selected tests.'
| def get_checks(self, argument_name):
| checks = []
for (check, attrs) in _checks[argument_name].items():
(codes, args) = attrs
if any(((not (code and self.ignore_code(code))) for code in codes)):
checks.append((check.__name__, check, args))
return sorted(checks)
|
'set output stream'
| def set_output(self, output=None):
| self.out = (output or sys.stdout)
|
'write a line in the output buffer'
| def writeln(self, string=''):
| print(self.encode(string), file=self.out)
|
'display results encapsulated in the layout tree'
| def display_reports(self, layout):
| self.section = 0
if hasattr(layout, 'report_id'):
layout.children[0].children[0].data += (' (%s)' % layout.report_id)
self._display(layout)
|
'display the layout'
| def _display(self, layout):
| raise NotImplementedError()
|
'Manage message of different type and in the context of path.'
| def handle_message(self, msg):
| self.messages.append({'type': msg.category, 'module': msg.module, 'obj': msg.obj, 'line': msg.line, 'column': msg.column, 'path': msg.path, 'symbol': msg.symbol, 'message': cgi.escape((msg.msg or ''))})
|
'Launch layouts display'
| def display_messages(self, layout):
| if self.messages:
print(json.dumps(self.messages, indent=4), file=self.out)
|
'Convenience method to write a formated message with class default template'
| def write_message(self, msg):
| self.writeln(msg.format(self._template))
|
'manage message of different type and in the context of path'
| def handle_message(self, msg):
| if (msg.module not in self._modules):
if msg.module:
self.writeln(('************* Module %s' % msg.module))
self._modules.add(msg.module)
else:
self.writeln('************* ')
self.write_message(msg)
|
'launch layouts display'
| def _display(self, layout):
| print(file=self.out)
TextWriter().format(layout, self.out)
|
'Returns the tuple color, style associated with msg_id as defined
in self.color_mapping'
| def _get_decoration(self, msg_id):
| try:
return self.color_mapping[msg_id[0]]
except KeyError:
return (None, None)
|
'manage message of different types, and colorize output
using ansi escape codes'
| def handle_message(self, msg):
| if (msg.module not in self._modules):
(color, style) = self._get_decoration('S')
if msg.module:
modsep = colorize_ansi(('************* Module %s' % msg.module), color, style)
else:
modsep = colorize_ansi(('************* %s' % msg.module), color, style)
... |
'format and write the given layout into the stream object
unicode policy: unicode strings may be found in the layout;
try to call stream.write with it, but give it back encoded using
the given encoding if it fails'
| def format(self, layout, stream=None, encoding=None):
| if (stream is None):
stream = sys.stdout
if (not encoding):
encoding = getattr(stream, 'encoding', 'UTF-8')
self.encoding = (encoding or 'UTF-8')
self.out = stream
self.begin_format()
layout.accept(self)
self.end_format()
|
'recurse on the layout children and call their accept method
(see the Visitor pattern)'
| def format_children(self, layout):
| for child in getattr(layout, 'children', ()):
child.accept(self)
|
'write a line in the output buffer'
| def writeln(self, string=u''):
| self.write((string + os.linesep))
|
'write a string in the output buffer'
| def write(self, string):
| self.out.write(string)
|
'begin to format a layout'
| def begin_format(self):
| self.section = 0
|
'trick to get table content without actually writing it
return an aligned list of lists containing table cells values as string'
| def get_table_content(self, table):
| result = [[]]
cols = table.cols
for cell in self.compute_content(table):
if (cols == 0):
result.append([])
cols = table.cols
cols -= 1
result[(-1)].append(cell)
while (len(result[(-1)]) < cols):
result[(-1)].append(u'')
return result
|
'trick to compute the formatting of children layout before actually
writing it
return an iterator on strings (one for each child element)'
| def compute_content(self, layout):
| out = self.out
try:
for child in layout.children:
stream = six.StringIO()
self.out = stream
child.accept(self)
(yield stream.getvalue())
finally:
self.out = out
|
'add a node to children'
| def append(self, child):
| self.children.append(child)
child.parent = self
|
'insert a child node'
| def insert(self, index, child):
| self.children.insert(index, child)
child.parent = self
|
'return the visit name for the mixed class. When calling \'accept\', the
method <\'visit_\' + name returned by this method> will be called on the
visitor'
| def _get_visit_name(self):
| try:
return self.TYPE.replace('-', '_')
except Exception:
return self.__class__.__name__.lower()
|
'overridden to detect problems easily'
| def append(self, child):
| assert (child not in self.parents())
VNode.append(self, child)
|
'return the ancestor nodes'
| def parents(self):
| assert (self.parent is not self)
if (self.parent is None):
return []
return ([self.parent] + self.parent.parents())
|
'shortcut to add text data'
| def add_text(self, text):
| self.children.append(Text(text))
|
'display a section as text'
| def visit_section(self, layout):
| self.section += 1
self.writeln()
self.format_children(layout)
self.section -= 1
self.writeln()
|
'Display an evaluation section as a text.'
| def visit_evaluationsection(self, layout):
| self.section += 1
self.format_children(layout)
self.section -= 1
self.writeln()
|
'enter a paragraph'
| def visit_paragraph(self, layout):
| self.format_children(layout)
self.writeln()
|
'display a table as text'
| def visit_table(self, layout):
| table_content = self.get_table_content(layout)
cols_width = ([0] * len(table_content[0]))
for row in table_content:
for (index, col) in enumerate(row):
cols_width[index] = max(cols_width[index], len(col))
self.default_table(layout, table_content, cols_width)
self.writeln()
|
'format a table'
| def default_table(self, layout, table_content, cols_width):
| cols_width = [(size + 1) for size in cols_width]
format_strings = u' '.join(([u'%%-%ss'] * len(cols_width)))
format_strings = (format_strings % tuple(cols_width))
format_strings = format_strings.split(u' ')
table_linesep = ((u'\n+' + u'+'.join([(u'-' * w) for w in cols_width])) + u'+\n')
h... |
'display a verbatim layout as text (so difficult ;)'
| def visit_verbatimtext(self, layout):
| self.writeln(u'::\n')
for line in layout.data.splitlines():
self.writeln((u' ' + line))
self.writeln()
|
'add some text'
| def visit_text(self, layout):
| self.write((u'%s' % layout.data))
|
'Disable abbreviations.'
| def _match_long_opt(self, opt):
| if (opt not in self._long_opt):
raise optparse.BadOptionError(opt)
return opt
|
'register an options provider'
| def register_options_provider(self, provider, own_group=True):
| assert (provider.priority <= 0), "provider's priority can't be >= 0"
for i in range(len(self.options_providers)):
if (provider.priority > self.options_providers[i].priority):
self.options_providers.insert(i, provider)
break
else:
self.options_providers.... |
'get our personal option definition and return a suitable form for
use with optik/optparse'
| def optik_option(self, provider, opt, optdict):
| optdict = copy.copy(optdict)
if ('action' in optdict):
self._nocallback_options[provider] = opt
else:
optdict['action'] = 'callback'
optdict['callback'] = self.cb_set_provider_option
if ('default' in optdict):
if (('help' in optdict) and (optdict.get('default') is not Non... |
'optik callback for option setting'
| def cb_set_provider_option(self, option, opt, value, parser):
| if opt.startswith('--'):
opt = opt[2:]
else:
opt = self._short_options[opt[1:]]
if (value is None):
value = 1
self.global_set_option(opt, value)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.