Lines Matching +full:- +full:- +full:style
7 # http://www.apache.org/licenses/LICENSE-2.0
14 """Python formatting style settings."""
25 """Raised when there's a problem reading the style configuration."""
30 """Get a style setting."""
35 """Return dict mapping style names to help strings."""
39 def SetGlobalStyle(style): argument
40 """Set a style dict."""
43 factory = _GetStyleFactory(style)
46 _style = style
69 # <------ this blank line
73 Insert a blank line before a class-level docstring."""),
77 Number of blank lines surrounding top-level function and class
99 The style for continuation alignment. Possible values are:
101 - SPACE: Use spaces for continuation alignment. This is default behavior.
102 - FIXED: Use fixed number (CONTINUATION_INDENT_WIDTH) of columns
105 - LESS: Slightly left if cannot vertically align continuation lines with
107 - VALIGN-RIGHT: Vertically align continuation lines with indent
111 For options FIXED, and VALIGN-RIGHT are only available when USE_TABS is
123 } # <--- this bracket is dedented and on a separate line
129 start_ts=now()-timedelta(days=3),
131 ) # <--- this bracket is dedented and on a separate line"""),
134 if the list is comma-terminated."""),
162 1 + 2 * 3 - 4 / 5
166 1 + 2*3 - 4/5
211 non-trivial expressions and multiple clauses before each of these
259 # BASED_ON_STYLE='Which predefined style this style is based on',
314 style = CreatePEP8Style()
315 style['ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT'] = False
316 style['BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF'] = True
317 style['COLUMN_LIMIT'] = 80
318 style['INDENT_WIDTH'] = 4
319 style['I18N_COMMENT'] = r'#\..*'
320 style['I18N_FUNCTION_CALL'] = ['N_', '_']
321 style['SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET'] = False
322 style['SPLIT_BEFORE_BITWISE_OPERATOR'] = False
323 style['SPLIT_BEFORE_DICT_SET_GENERATOR'] = False
324 style['SPLIT_BEFORE_LOGICAL_OPERATOR'] = False
325 style['SPLIT_COMPLEX_COMPREHENSION'] = True
326 style['SPLIT_PENALTY_COMPREHENSION'] = 2100
327 return style
331 style = CreateGoogleStyle()
332 style['ALLOW_MULTILINE_DICTIONARY_KEYS'] = True
333 style['INDENT_DICTIONARY_VALUE'] = True
334 style['INDENT_WIDTH'] = 2
335 style['JOIN_MULTIPLE_LINES'] = False
336 style['SPLIT_BEFORE_BITWISE_OPERATOR'] = True
337 style['SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN'] = True
338 return style
342 style = CreatePEP8Style()
343 style['ALIGN_CLOSING_BRACKET_WITH_VISUAL_INDENT'] = False
344 style['COLUMN_LIMIT'] = 80
345 style['DEDENT_CLOSING_BRACKETS'] = True
346 style['INDENT_DICTIONARY_VALUE'] = True
347 style['JOIN_MULTIPLE_LINES'] = False
348 style['SPACES_BEFORE_COMMENT'] = 2
349 style['SPLIT_PENALTY_AFTER_OPENING_BRACKET'] = 0
350 style['SPLIT_PENALTY_BEFORE_IF_EXPR'] = 30
351 style['SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT'] = 30
352 style['SPLIT_BEFORE_LOGICAL_OPERATOR'] = False
353 style['SPLIT_BEFORE_BITWISE_OPERATOR'] = False
354 return style
372 def _GetStyleFactory(style): argument
374 if style == def_style:
380 """Option value converter for a continuation align style string."""
381 accepted_styles = ('SPACE', 'FIXED', 'VALIGN-RIGHT')
385 raise ValueError('unknown continuation align style: %r' % (s,))
392 """Option value converter for a comma-separated list of strings."""
397 """Option value converter for a comma-separated set of strings."""
406 # Different style options need to have their values interpreted differently when
412 # Note: this dict has to map all the supported style options.
463 """Create a style dict from the given config.
466 style_config: either a style name or a file name. The file is expected to
468 style which it derives from. If no such setting is found, it derives from
469 the default style. When style_config is None, the _GLOBAL_STYLE_FACTORY
473 A style dict.
476 StyleConfigError: if an unknown style option was encountered.
480 for style, _ in _DEFAULT_STYLE_TO_FACTORY:
481 yield style
485 for style in GlobalStyles():
486 if _style == style:
499 # Most likely a style specification from the command line.
509 config.add_section('style')
511 config.set('style', key, str(value))
517 if config_string[0] != '{' or config_string[-1] != '}':
519 "Invalid style dict syntax: '{}'.".format(config_string))
521 config.add_section('style')
522 for key, value in re.findall(r'([a-zA-Z0-9_]+)\s*[:=]\s*([a-zA-Z0-9_]+)',
524 config.set('style', key, value)
533 '"{0}" is not a valid style or file path'.format(config_filename))
542 if not config.has_section('style'):
544 'Unable to find section [style] in {0}'.format(config_filename))
546 if not config.has_section('style'):
548 'Unable to find section [style] in {0}'.format(config_filename))
553 """Create a style dict from a configuration file.
559 A style dict.
562 StyleConfigError: if an unknown style option was encountered.
564 # Initialize the base style.
565 section = 'yapf' if config.has_section('yapf') else 'style'
566 if config.has_option('style', 'based_on_style'):
567 based_on = config.get('style', 'based_on_style').lower()
575 # Read all options specified in the file and update the style.
578 # Now skip this one - we've already handled it and it's not one of the
579 # recognized style options.
583 raise StyleConfigError('Unknown style option "{0}"'.format(option))
592 # The default style - used if yapf is not invoked without specifically
593 # requesting a formatting style.
598 # The name of the file to use for global style definition.
602 'style'))
604 # The name of the file to use for directory-local style definition.
605 LOCAL_STYLE = '.style.yapf'
607 # Alternative place for directory-local style definition. Style should be
611 # TODO(eliben): For now we're preserving the global presence of a style dict.
612 # Refactor this so that the style is passed around through yapf rather than