text
stringlengths 0
828
|
|---|
return [""# {}"".format(s)]
|
elif format.startswith(""rest""):
|
return format_underline(s, _CHAR, 0)"
|
4562,"def format_h2(s, format=""text"", indents=0):
|
""""""
|
Encloses string in format text
|
Args, Returns: see format_h1()
|
>>> print(""\\n"".join(format_h2(""Header 2"", indents=2)))
|
Header 2
|
--------
|
>>> print(""\\n"".join(format_h2(""Header 2"", ""markdown"", 2)))
|
## Header 2
|
""""""
|
_CHAR = ""-""
|
if format.startswith(""text""):
|
return format_underline(s, _CHAR, indents)
|
elif format.startswith(""markdown""):
|
return [""## {}"".format(s)]
|
elif format.startswith(""rest""):
|
return format_underline(s, _CHAR, 0)"
|
4563,"def format_h3(s, format=""text"", indents=0):
|
""""""
|
Encloses string in format text
|
Args, Returns: see format_h1()
|
""""""
|
_CHAR = ""~""
|
if format.startswith(""text""):
|
return format_underline(s, _CHAR, indents)
|
elif format.startswith(""markdown""):
|
return [""### {}"".format(s)]
|
elif format.startswith(""rest""):
|
return format_underline(s, _CHAR, 0)"
|
4564,"def format_h4(s, format=""text"", indents=0):
|
""""""
|
Encloses string in format text
|
Args, Returns: see format_h1()
|
""""""
|
_CHAR = ""^""
|
if format.startswith(""text""):
|
return format_underline(s, _CHAR, indents)
|
elif format.startswith(""markdown""):
|
return [""#### {}"".format(s)]
|
elif format.startswith(""rest""):
|
return format_underline(s, _CHAR, 0)"
|
4565,"def question(question, options, default=None):
|
""""""Ask a question with case-insensitive options of answers
|
Args:
|
question: string **without** the question mark and without the options.
|
Example: 'Commit changes'
|
options_: string or sequence of strings. If string, options will be single-lettered.
|
Examples: 'YNC', ['yes', 'no', 'cancel']. options are case-insensitive
|
default: default option. If passed, default option will be shown in uppercase.
|
Answers are case-insensitive, but options will be shown in lowercase, except for the default
|
option.
|
Returns:
|
str: chosen option. Although the answer is case-insensitive, the result will be as informed
|
in the 'options' argument.
|
""""""
|
# Make sure options is a list
|
options_ = [x for x in options]
|
if default is not None and default not in options_:
|
raise ValueError(""Default option '{}' is not in options {}."".format(default, options))
|
oto = ""/"".join([x.upper() if x == default else x.lower() for x in options_]) # to show
|
ocomp = [x.lower() for x in options_] # to be used in comparison
|
while True:
|
ans = input(""{} ({})? "".format(question, oto)).lower()
|
if ans == """" and default is not None:
|
ret = default
|
break
|
elif ans in ocomp:
|
ret = options_[ocomp.index(ans)]
|
break
|
return ret"
|
4566,"def yesno(question, default=None):
|
""""""Asks a yes/no question
|
Args:
|
question: string **without** the question mark and without the options.
|
Example: 'Create links'
|
default: default option. Accepted values are 'Y', 'YES', 'N', 'NO' or lowercase versions of
|
these valus (this argument is case-insensitive)
|
Returns:
|
bool: True if user answered Yes, False otherwise
|
""""""
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.