repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
peterwittek/ncpol2sdpa
ncpol2sdpa/steering_hierarchy.py
SteeringHierarchy._process_monomial
def _process_monomial(self, monomial, n_vars): """Process a single monomial when building the moment matrix. """ coeff, monomial = monomial.as_coeff_Mul() k = 0 # Have we seen this monomial before? conjugate = False try: # If yes, then we improve spars...
python
def _process_monomial(self, monomial, n_vars): """Process a single monomial when building the moment matrix. """ coeff, monomial = monomial.as_coeff_Mul() k = 0 # Have we seen this monomial before? conjugate = False try: # If yes, then we improve spars...
[ "def", "_process_monomial", "(", "self", ",", "monomial", ",", "n_vars", ")", ":", "coeff", ",", "monomial", "=", "monomial", ".", "as_coeff_Mul", "(", ")", "k", "=", "0", "# Have we seen this monomial before?", "conjugate", "=", "False", "try", ":", "# If yes...
Process a single monomial when building the moment matrix.
[ "Process", "a", "single", "monomial", "when", "building", "the", "moment", "matrix", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/steering_hierarchy.py#L80-L108
train
Process a single monomial when building the moment matrix.
peterwittek/ncpol2sdpa
ncpol2sdpa/steering_hierarchy.py
SteeringHierarchy.__get_trace_facvar
def __get_trace_facvar(self, polynomial): """Return dense vector representation of a polynomial. This function is nearly identical to __push_facvar_sparse, but instead of pushing sparse entries to the constraint matrices, it returns a dense vector. """ facvar = [0] * (sel...
python
def __get_trace_facvar(self, polynomial): """Return dense vector representation of a polynomial. This function is nearly identical to __push_facvar_sparse, but instead of pushing sparse entries to the constraint matrices, it returns a dense vector. """ facvar = [0] * (sel...
[ "def", "__get_trace_facvar", "(", "self", ",", "polynomial", ")", ":", "facvar", "=", "[", "0", "]", "*", "(", "self", ".", "n_vars", "+", "1", ")", "F", "=", "{", "}", "for", "i", "in", "range", "(", "self", ".", "matrix_var_dim", ")", ":", "for...
Return dense vector representation of a polynomial. This function is nearly identical to __push_facvar_sparse, but instead of pushing sparse entries to the constraint matrices, it returns a dense vector.
[ "Return", "dense", "vector", "representation", "of", "a", "polynomial", ".", "This", "function", "is", "nearly", "identical", "to", "__push_facvar_sparse", "but", "instead", "of", "pushing", "sparse", "entries", "to", "the", "constraint", "matrices", "it", "return...
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/steering_hierarchy.py#L186-L219
train
This function returns a dense vector representation of a polynomial. This function is also intended to be used by the trace function of the polynomial. This function is also intended to be used by the pushing_facvar_sparse function.
peterwittek/ncpol2sdpa
ncpol2sdpa/steering_hierarchy.py
SteeringHierarchy.set_objective
def set_objective(self, objective, extraobjexpr=None): """Set or change the objective function of the polynomial optimization problem. :param objective: Describes the objective function. :type objective: :class:`sympy.core.expr.Expr` :param extraobjexpr: Optional parameter of a ...
python
def set_objective(self, objective, extraobjexpr=None): """Set or change the objective function of the polynomial optimization problem. :param objective: Describes the objective function. :type objective: :class:`sympy.core.expr.Expr` :param extraobjexpr: Optional parameter of a ...
[ "def", "set_objective", "(", "self", ",", "objective", ",", "extraobjexpr", "=", "None", ")", ":", "if", "objective", "is", "not", "None", "and", "self", ".", "matrix_var_dim", "is", "not", "None", ":", "facvar", "=", "self", ".", "__get_trace_facvar", "("...
Set or change the objective function of the polynomial optimization problem. :param objective: Describes the objective function. :type objective: :class:`sympy.core.expr.Expr` :param extraobjexpr: Optional parameter of a string expression of a linear combina...
[ "Set", "or", "change", "the", "objective", "function", "of", "the", "polynomial", "optimization", "problem", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/steering_hierarchy.py#L221-L242
train
Set or change the objective function of the polynomial optimization.
peterwittek/ncpol2sdpa
ncpol2sdpa/steering_hierarchy.py
SteeringHierarchy._calculate_block_structure
def _calculate_block_structure(self, inequalities, equalities, momentinequalities, momentequalities, extramomentmatrix, removeequalities, block_struct=None): """Calculates the block_struct array for the outp...
python
def _calculate_block_structure(self, inequalities, equalities, momentinequalities, momentequalities, extramomentmatrix, removeequalities, block_struct=None): """Calculates the block_struct array for the outp...
[ "def", "_calculate_block_structure", "(", "self", ",", "inequalities", ",", "equalities", ",", "momentinequalities", ",", "momentequalities", ",", "extramomentmatrix", ",", "removeequalities", ",", "block_struct", "=", "None", ")", ":", "super", "(", "SteeringHierarch...
Calculates the block_struct array for the output file.
[ "Calculates", "the", "block_struct", "array", "for", "the", "output", "file", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/steering_hierarchy.py#L244-L256
train
Calculates the block_struct array for the output file.
peterwittek/ncpol2sdpa
ncpol2sdpa/steering_hierarchy.py
SteeringHierarchy.write_to_file
def write_to_file(self, filename, filetype=None): """Write the relaxation to a file. :param filename: The name of the file to write to. The type can be autodetected from the extension: .dat-s for SDPA, .task for mosek, .csv for human readable format, or...
python
def write_to_file(self, filename, filetype=None): """Write the relaxation to a file. :param filename: The name of the file to write to. The type can be autodetected from the extension: .dat-s for SDPA, .task for mosek, .csv for human readable format, or...
[ "def", "write_to_file", "(", "self", ",", "filename", ",", "filetype", "=", "None", ")", ":", "if", "filetype", "==", "\"txt\"", "and", "not", "filename", ".", "endswith", "(", "\".txt\"", ")", ":", "raise", "Exception", "(", "\"TXT files must have .txt extens...
Write the relaxation to a file. :param filename: The name of the file to write to. The type can be autodetected from the extension: .dat-s for SDPA, .task for mosek, .csv for human readable format, or .txt for a symbolic export ...
[ "Write", "the", "relaxation", "to", "a", "file", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/steering_hierarchy.py#L268-L315
train
Writes the relaxation to a file.
laike9m/ezcf
ezcf/_base.py
BaseFinder.get_outerframe_skip_importlib_frame
def get_outerframe_skip_importlib_frame(level): """ There's a bug in Python3.4+, see http://bugs.python.org/issue23773, remove this and use sys._getframe(3) when bug is fixed """ if sys.version_info < (3, 4): return sys._getframe(level) else: curre...
python
def get_outerframe_skip_importlib_frame(level): """ There's a bug in Python3.4+, see http://bugs.python.org/issue23773, remove this and use sys._getframe(3) when bug is fixed """ if sys.version_info < (3, 4): return sys._getframe(level) else: curre...
[ "def", "get_outerframe_skip_importlib_frame", "(", "level", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "4", ")", ":", "return", "sys", ".", "_getframe", "(", "level", ")", "else", ":", "currentframe", "=", "inspect", ".", "currentframe...
There's a bug in Python3.4+, see http://bugs.python.org/issue23773, remove this and use sys._getframe(3) when bug is fixed
[ "There", "s", "a", "bug", "in", "Python3", ".", "4", "+", "see", "http", ":", "//", "bugs", ".", "python", ".", "org", "/", "issue23773", "remove", "this", "and", "use", "sys", ".", "_getframe", "(", "3", ")", "when", "bug", "is", "fixed" ]
30b0f7ecfd4062e9b9a2f8f13ae1f2fd9f21fa12
https://github.com/laike9m/ezcf/blob/30b0f7ecfd4062e9b9a2f8f13ae1f2fd9f21fa12/ezcf/_base.py#L46-L62
train
Returns the outerframe of the given level skipping importlib frames.
kmn/coincheck
coincheck/market.py
Market.public_api
def public_api(self,url): ''' template function of public api''' try : url in api_urls return ast.literal_eval(requests.get(base_url + api_urls.get(url)).text) except Exception as e: print(e)
python
def public_api(self,url): ''' template function of public api''' try : url in api_urls return ast.literal_eval(requests.get(base_url + api_urls.get(url)).text) except Exception as e: print(e)
[ "def", "public_api", "(", "self", ",", "url", ")", ":", "try", ":", "url", "in", "api_urls", "return", "ast", ".", "literal_eval", "(", "requests", ".", "get", "(", "base_url", "+", "api_urls", ".", "get", "(", "url", ")", ")", ".", "text", ")", "e...
template function of public api
[ "template", "function", "of", "public", "api" ]
4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc
https://github.com/kmn/coincheck/blob/4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc/coincheck/market.py#L19-L25
train
template function of public api
bpython/curtsies
curtsies/escseqparse.py
parse
def parse(s): r""" Returns a list of strings or format dictionaries to describe the strings. May raise a ValueError if it can't be parsed. >>> parse(">>> []") ['>>> []'] >>> #parse("\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\...
python
def parse(s): r""" Returns a list of strings or format dictionaries to describe the strings. May raise a ValueError if it can't be parsed. >>> parse(">>> []") ['>>> []'] >>> #parse("\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\...
[ "def", "parse", "(", "s", ")", ":", "stuff", "=", "[", "]", "rest", "=", "s", "while", "True", ":", "front", ",", "token", ",", "rest", "=", "peel_off_esc_code", "(", "rest", ")", "if", "front", ":", "stuff", ".", "append", "(", "front", ")", "if...
r""" Returns a list of strings or format dictionaries to describe the strings. May raise a ValueError if it can't be parsed. >>> parse(">>> []") ['>>> []'] >>> #parse("\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m\x1b[33m]\x1b[39m\x1b[33m[\x1b[39m")
[ "r", "Returns", "a", "list", "of", "strings", "or", "format", "dictionaries", "to", "describe", "the", "strings", "." ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/escseqparse.py#L23-L48
train
r Parses a string s and returns a list of strings or format dictionaries to describe the strings.
bpython/curtsies
curtsies/escseqparse.py
peel_off_esc_code
def peel_off_esc_code(s): r"""Returns processed text, the next token, and unprocessed text >>> front, d, rest = peel_off_esc_code('somestuff') >>> front, rest ('some', 'stuff') >>> d == {'numbers': [2], 'command': 'A', 'intermed': '', 'private': '', 'csi': '\x1b[', 'seq': '\x1b[2A'} True ...
python
def peel_off_esc_code(s): r"""Returns processed text, the next token, and unprocessed text >>> front, d, rest = peel_off_esc_code('somestuff') >>> front, rest ('some', 'stuff') >>> d == {'numbers': [2], 'command': 'A', 'intermed': '', 'private': '', 'csi': '\x1b[', 'seq': '\x1b[2A'} True ...
[ "def", "peel_off_esc_code", "(", "s", ")", ":", "p", "=", "r\"\"\"(?P<front>.*?)\n (?P<seq>\n (?P<csi>\n (?:[\u001b]\\[)\n |\n [\"\"\"", "+", "'\\x9b'", "+", "r\"\"\"])\n (?P<private>)\n ...
r"""Returns processed text, the next token, and unprocessed text >>> front, d, rest = peel_off_esc_code('somestuff') >>> front, rest ('some', 'stuff') >>> d == {'numbers': [2], 'command': 'A', 'intermed': '', 'private': '', 'csi': '\x1b[', 'seq': '\x1b[2A'} True
[ "r", "Returns", "processed", "text", "the", "next", "token", "and", "unprocessed", "text" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/escseqparse.py#L51-L92
train
Return the processed text the next token and unprocessed text.
bpython/curtsies
curtsies/events.py
get_key
def get_key(bytes_, encoding, keynames='curtsies', full=False): """Return key pressed from bytes_ or None Return a key name or None meaning it's an incomplete sequence of bytes (more bytes needed to determine the key pressed) encoding is how the bytes should be translated to unicode - it should ma...
python
def get_key(bytes_, encoding, keynames='curtsies', full=False): """Return key pressed from bytes_ or None Return a key name or None meaning it's an incomplete sequence of bytes (more bytes needed to determine the key pressed) encoding is how the bytes should be translated to unicode - it should ma...
[ "def", "get_key", "(", "bytes_", ",", "encoding", ",", "keynames", "=", "'curtsies'", ",", "full", "=", "False", ")", ":", "if", "not", "all", "(", "isinstance", "(", "c", ",", "type", "(", "b''", ")", ")", "for", "c", "in", "bytes_", ")", ":", "...
Return key pressed from bytes_ or None Return a key name or None meaning it's an incomplete sequence of bytes (more bytes needed to determine the key pressed) encoding is how the bytes should be translated to unicode - it should match the terminal encoding. keynames is a string describing how key...
[ "Return", "key", "pressed", "from", "bytes_", "or", "None" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/events.py#L142-L218
train
Return a key pressed from bytes_ or None meaning it s an incomplete sequence of bytes.
bpython/curtsies
curtsies/events.py
could_be_unfinished_char
def could_be_unfinished_char(seq, encoding): """Whether seq bytes might create a char in encoding if more bytes were added""" if decodable(seq, encoding): return False # any sensible encoding surely doesn't require lookahead (right?) # (if seq bytes encoding a character, adding another byte shou...
python
def could_be_unfinished_char(seq, encoding): """Whether seq bytes might create a char in encoding if more bytes were added""" if decodable(seq, encoding): return False # any sensible encoding surely doesn't require lookahead (right?) # (if seq bytes encoding a character, adding another byte shou...
[ "def", "could_be_unfinished_char", "(", "seq", ",", "encoding", ")", ":", "if", "decodable", "(", "seq", ",", "encoding", ")", ":", "return", "False", "# any sensible encoding surely doesn't require lookahead (right?)", "# (if seq bytes encoding a character, adding another byte...
Whether seq bytes might create a char in encoding if more bytes were added
[ "Whether", "seq", "bytes", "might", "create", "a", "char", "in", "encoding", "if", "more", "bytes", "were", "added" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/events.py#L220-L231
train
Whether seq bytes might create a char in encoding if more bytes were added
bpython/curtsies
curtsies/events.py
pp_event
def pp_event(seq): """Returns pretty representation of an Event or keypress""" if isinstance(seq, Event): return str(seq) # Get the original sequence back if seq is a pretty name already rev_curses = dict((v, k) for k, v in CURSES_NAMES.items()) rev_curtsies = dict((v, k) for k, v in CURTS...
python
def pp_event(seq): """Returns pretty representation of an Event or keypress""" if isinstance(seq, Event): return str(seq) # Get the original sequence back if seq is a pretty name already rev_curses = dict((v, k) for k, v in CURSES_NAMES.items()) rev_curtsies = dict((v, k) for k, v in CURTS...
[ "def", "pp_event", "(", "seq", ")", ":", "if", "isinstance", "(", "seq", ",", "Event", ")", ":", "return", "str", "(", "seq", ")", "# Get the original sequence back if seq is a pretty name already", "rev_curses", "=", "dict", "(", "(", "v", ",", "k", ")", "f...
Returns pretty representation of an Event or keypress
[ "Returns", "pretty", "representation", "of", "an", "Event", "or", "keypress" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/events.py#L243-L260
train
Returns a pretty representation of an Event or keypress
chris1610/barnum-proj
barnum/gen_data.py
create_nouns
def create_nouns(max=2): """ Return a string of random nouns up to max number """ nouns = [] for noun in range(0, max): nouns.append(random.choice(noun_list)) return " ".join(nouns)
python
def create_nouns(max=2): """ Return a string of random nouns up to max number """ nouns = [] for noun in range(0, max): nouns.append(random.choice(noun_list)) return " ".join(nouns)
[ "def", "create_nouns", "(", "max", "=", "2", ")", ":", "nouns", "=", "[", "]", "for", "noun", "in", "range", "(", "0", ",", "max", ")", ":", "nouns", ".", "append", "(", "random", ".", "choice", "(", "noun_list", ")", ")", "return", "\" \"", ".",...
Return a string of random nouns up to max number
[ "Return", "a", "string", "of", "random", "nouns", "up", "to", "max", "number" ]
0a38f24bde66373553d02fbf67b733c1d55ada33
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L112-L119
train
Return a string of random nouns up to max number
chris1610/barnum-proj
barnum/gen_data.py
create_date
def create_date(past=False, max_years_future=10, max_years_past=10): """ Create a random valid date If past, then dates can be in the past If into the future, then no more than max_years into the future If it's not, then it can't be any older than max_years_past """ if past: start = ...
python
def create_date(past=False, max_years_future=10, max_years_past=10): """ Create a random valid date If past, then dates can be in the past If into the future, then no more than max_years into the future If it's not, then it can't be any older than max_years_past """ if past: start = ...
[ "def", "create_date", "(", "past", "=", "False", ",", "max_years_future", "=", "10", ",", "max_years_past", "=", "10", ")", ":", "if", "past", ":", "start", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "-", "datetime", ".", "timedelta", "(...
Create a random valid date If past, then dates can be in the past If into the future, then no more than max_years into the future If it's not, then it can't be any older than max_years_past
[ "Create", "a", "random", "valid", "date", "If", "past", "then", "dates", "can", "be", "in", "the", "past", "If", "into", "the", "future", "then", "no", "more", "than", "max_years", "into", "the", "future", "If", "it", "s", "not", "then", "it", "can", ...
0a38f24bde66373553d02fbf67b733c1d55ada33
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L122-L139
train
Create a random valid date based on the given parameters
chris1610/barnum-proj
barnum/gen_data.py
create_birthday
def create_birthday(min_age=18, max_age=80): """ Create a random birthday fomr someone between the ages of min_age and max_age """ age = random.randint(min_age, max_age) start = datetime.date.today() - datetime.timedelta(days=random.randint(0, 365)) return start - datetime.timedelta(days=age * 3...
python
def create_birthday(min_age=18, max_age=80): """ Create a random birthday fomr someone between the ages of min_age and max_age """ age = random.randint(min_age, max_age) start = datetime.date.today() - datetime.timedelta(days=random.randint(0, 365)) return start - datetime.timedelta(days=age * 3...
[ "def", "create_birthday", "(", "min_age", "=", "18", ",", "max_age", "=", "80", ")", ":", "age", "=", "random", ".", "randint", "(", "min_age", ",", "max_age", ")", "start", "=", "datetime", ".", "date", ".", "today", "(", ")", "-", "datetime", ".", ...
Create a random birthday fomr someone between the ages of min_age and max_age
[ "Create", "a", "random", "birthday", "fomr", "someone", "between", "the", "ages", "of", "min_age", "and", "max_age" ]
0a38f24bde66373553d02fbf67b733c1d55ada33
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L142-L148
train
Create a random birthday fomr someone between the ages of min_age and max_age
chris1610/barnum-proj
barnum/gen_data.py
create_pw
def create_pw(length=8, digits=2, upper=2, lower=2): """Create a random password From Stackoverflow: http://stackoverflow.com/questions/7479442/high-quality-simple-random-password-generator Create a random password with the specified length and no. of digit, upper and lower case letters. :para...
python
def create_pw(length=8, digits=2, upper=2, lower=2): """Create a random password From Stackoverflow: http://stackoverflow.com/questions/7479442/high-quality-simple-random-password-generator Create a random password with the specified length and no. of digit, upper and lower case letters. :para...
[ "def", "create_pw", "(", "length", "=", "8", ",", "digits", "=", "2", ",", "upper", "=", "2", ",", "lower", "=", "2", ")", ":", "seed", "(", "time", "(", ")", ")", "lowercase", "=", "string", ".", "ascii_lowercase", "uppercase", "=", "string", ".",...
Create a random password From Stackoverflow: http://stackoverflow.com/questions/7479442/high-quality-simple-random-password-generator Create a random password with the specified length and no. of digit, upper and lower case letters. :param length: Maximum no. of characters in the password :typ...
[ "Create", "a", "random", "password", "From", "Stackoverflow", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "7479442", "/", "high", "-", "quality", "-", "simple", "-", "random", "-", "password", "-", "generator" ]
0a38f24bde66373553d02fbf67b733c1d55ada33
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L189-L227
train
Create a random password in a random language
chris1610/barnum-proj
barnum/gen_data.py
show_examples
def show_examples(): """ Run through some simple examples """ first, last = create_name() add = create_street() zip, city, state = create_city_state_zip() phone = create_phone(zip) print(first, last) print(add) print("{0:s} {1:s} {2:s}".format(city, state, zip)) print(phone) ...
python
def show_examples(): """ Run through some simple examples """ first, last = create_name() add = create_street() zip, city, state = create_city_state_zip() phone = create_phone(zip) print(first, last) print(add) print("{0:s} {1:s} {2:s}".format(city, state, zip)) print(phone) ...
[ "def", "show_examples", "(", ")", ":", "first", ",", "last", "=", "create_name", "(", ")", "add", "=", "create_street", "(", ")", "zip", ",", "city", ",", "state", "=", "create_city_state_zip", "(", ")", "phone", "=", "create_phone", "(", "zip", ")", "...
Run through some simple examples
[ "Run", "through", "some", "simple", "examples" ]
0a38f24bde66373553d02fbf67b733c1d55ada33
https://github.com/chris1610/barnum-proj/blob/0a38f24bde66373553d02fbf67b733c1d55ada33/barnum/gen_data.py#L229-L249
train
Run through some simple examples
peterwittek/ncpol2sdpa
ncpol2sdpa/mosek_utils.py
convert_to_mosek_index
def convert_to_mosek_index(block_struct, row_offsets, block_offsets, row): """MOSEK requires a specific sparse format to define the lower-triangular part of a symmetric matrix. This function does the conversion from the sparse upper triangular matrix format of Ncpol2SDPA. """ block_index, i, j = con...
python
def convert_to_mosek_index(block_struct, row_offsets, block_offsets, row): """MOSEK requires a specific sparse format to define the lower-triangular part of a symmetric matrix. This function does the conversion from the sparse upper triangular matrix format of Ncpol2SDPA. """ block_index, i, j = con...
[ "def", "convert_to_mosek_index", "(", "block_struct", ",", "row_offsets", ",", "block_offsets", ",", "row", ")", ":", "block_index", ",", "i", ",", "j", "=", "convert_row_to_sdpa_index", "(", "block_struct", ",", "row_offsets", ",", "row", ")", "offset", "=", ...
MOSEK requires a specific sparse format to define the lower-triangular part of a symmetric matrix. This function does the conversion from the sparse upper triangular matrix format of Ncpol2SDPA.
[ "MOSEK", "requires", "a", "specific", "sparse", "format", "to", "define", "the", "lower", "-", "triangular", "part", "of", "a", "symmetric", "matrix", ".", "This", "function", "does", "the", "conversion", "from", "the", "sparse", "upper", "triangular", "matrix...
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/mosek_utils.py#L102-L113
train
This function converts a row of a Mosek matrix into the lower - triangular index of the C and C j.
peterwittek/ncpol2sdpa
ncpol2sdpa/mosek_utils.py
convert_to_mosek_matrix
def convert_to_mosek_matrix(sdp): """Converts the entire sparse representation of the Fi constraint matrices to sparse MOSEK matrices. """ barci = [] barcj = [] barcval = [] barai = [] baraj = [] baraval = [] for k in range(sdp.n_vars): barai.append([]) baraj.appe...
python
def convert_to_mosek_matrix(sdp): """Converts the entire sparse representation of the Fi constraint matrices to sparse MOSEK matrices. """ barci = [] barcj = [] barcval = [] barai = [] baraj = [] baraval = [] for k in range(sdp.n_vars): barai.append([]) baraj.appe...
[ "def", "convert_to_mosek_matrix", "(", "sdp", ")", ":", "barci", "=", "[", "]", "barcj", "=", "[", "]", "barcval", "=", "[", "]", "barai", "=", "[", "]", "baraj", "=", "[", "]", "baraval", "=", "[", "]", "for", "k", "in", "range", "(", "sdp", "...
Converts the entire sparse representation of the Fi constraint matrices to sparse MOSEK matrices.
[ "Converts", "the", "entire", "sparse", "representation", "of", "the", "Fi", "constraint", "matrices", "to", "sparse", "MOSEK", "matrices", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/mosek_utils.py#L116-L155
train
Converts the entire sparse representation of the Fi constraint matrices to sparse MOSEK matrices.
peterwittek/ncpol2sdpa
ncpol2sdpa/mosek_utils.py
convert_to_mosek
def convert_to_mosek(sdp): """Convert an SDP relaxation to a MOSEK task. :param sdp: The SDP relaxation to convert. :type sdp: :class:`ncpol2sdpa.sdp`. :returns: :class:`mosek.Task`. """ import mosek # Cheat when variables are complex and convert with PICOS if sdp.complex_matrix: ...
python
def convert_to_mosek(sdp): """Convert an SDP relaxation to a MOSEK task. :param sdp: The SDP relaxation to convert. :type sdp: :class:`ncpol2sdpa.sdp`. :returns: :class:`mosek.Task`. """ import mosek # Cheat when variables are complex and convert with PICOS if sdp.complex_matrix: ...
[ "def", "convert_to_mosek", "(", "sdp", ")", ":", "import", "mosek", "# Cheat when variables are complex and convert with PICOS", "if", "sdp", ".", "complex_matrix", ":", "from", ".", "picos_utils", "import", "convert_to_picos", "Problem", "=", "convert_to_picos", "(", "...
Convert an SDP relaxation to a MOSEK task. :param sdp: The SDP relaxation to convert. :type sdp: :class:`ncpol2sdpa.sdp`. :returns: :class:`mosek.Task`.
[ "Convert", "an", "SDP", "relaxation", "to", "a", "MOSEK", "task", "." ]
bce75d524d0b9d0093f32e3a0a5611f8589351a7
https://github.com/peterwittek/ncpol2sdpa/blob/bce75d524d0b9d0093f32e3a0a5611f8589351a7/ncpol2sdpa/mosek_utils.py#L158-L208
train
Convert an SDP relaxation to a MOSEK task.
bpython/curtsies
docs/ansi.py
ANSIColorParser._add_text
def _add_text(self, text): """ If ``text`` is not empty, append a new Text node to the most recent pending node, if there is any, or to the new nodes, if there are no pending nodes. """ if text: if self.pending_nodes: self.pending_nodes[-1].app...
python
def _add_text(self, text): """ If ``text`` is not empty, append a new Text node to the most recent pending node, if there is any, or to the new nodes, if there are no pending nodes. """ if text: if self.pending_nodes: self.pending_nodes[-1].app...
[ "def", "_add_text", "(", "self", ",", "text", ")", ":", "if", "text", ":", "if", "self", ".", "pending_nodes", ":", "self", ".", "pending_nodes", "[", "-", "1", "]", ".", "append", "(", "nodes", ".", "Text", "(", "text", ")", ")", "else", ":", "s...
If ``text`` is not empty, append a new Text node to the most recent pending node, if there is any, or to the new nodes, if there are no pending nodes.
[ "If", "text", "is", "not", "empty", "append", "a", "new", "Text", "node", "to", "the", "most", "recent", "pending", "node", "if", "there", "is", "any", "or", "to", "the", "new", "nodes", "if", "there", "are", "no", "pending", "nodes", "." ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/docs/ansi.py#L96-L106
train
Add a new Text node to the most recent NoCOOKIE.
bpython/curtsies
setup.py
version
def version(): """Return version string.""" with open(os.path.join('curtsies', '__init__.py')) as input_file: for line in input_file: if line.startswith('__version__'): return ast.parse(line).body[0].value.s
python
def version(): """Return version string.""" with open(os.path.join('curtsies', '__init__.py')) as input_file: for line in input_file: if line.startswith('__version__'): return ast.parse(line).body[0].value.s
[ "def", "version", "(", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "'curtsies'", ",", "'__init__.py'", ")", ")", "as", "input_file", ":", "for", "line", "in", "input_file", ":", "if", "line", ".", "startswith", "(", "'__version_...
Return version string.
[ "Return", "version", "string", "." ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/setup.py#L6-L11
train
Return version string.
bpython/curtsies
curtsies/formatstringarray.py
fsarray
def fsarray(strings, *args, **kwargs): """fsarray(list_of_FmtStrs_or_strings, width=None) -> FSArray Returns a new FSArray of width of the maximum size of the provided strings, or width provided, and height of the number of strings provided. If a width is provided, raises a ValueError if any of the str...
python
def fsarray(strings, *args, **kwargs): """fsarray(list_of_FmtStrs_or_strings, width=None) -> FSArray Returns a new FSArray of width of the maximum size of the provided strings, or width provided, and height of the number of strings provided. If a width is provided, raises a ValueError if any of the str...
[ "def", "fsarray", "(", "strings", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "strings", "=", "list", "(", "strings", ")", "if", "'width'", "in", "kwargs", ":", "width", "=", "kwargs", "[", "'width'", "]", "del", "kwargs", "[", "'width'", ...
fsarray(list_of_FmtStrs_or_strings, width=None) -> FSArray Returns a new FSArray of width of the maximum size of the provided strings, or width provided, and height of the number of strings provided. If a width is provided, raises a ValueError if any of the strings are of length greater than this width
[ "fsarray", "(", "list_of_FmtStrs_or_strings", "width", "=", "None", ")", "-", ">", "FSArray" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/formatstringarray.py#L40-L60
train
Returns an FSArray of the maximum size of the provided FmtStrs_or_strings or width and height of the number of strings provided.
bpython/curtsies
curtsies/formatstringarray.py
FSArray.diff
def diff(cls, a, b, ignore_formatting=False): """Returns two FSArrays with differences underlined""" def underline(x): return u'\x1b[4m%s\x1b[0m' % (x,) def blink(x): return u'\x1b[5m%s\x1b[0m' % (x,) a_rows = [] b_rows = [] max_width = max([len(row) for row in a] + [len(...
python
def diff(cls, a, b, ignore_formatting=False): """Returns two FSArrays with differences underlined""" def underline(x): return u'\x1b[4m%s\x1b[0m' % (x,) def blink(x): return u'\x1b[5m%s\x1b[0m' % (x,) a_rows = [] b_rows = [] max_width = max([len(row) for row in a] + [len(...
[ "def", "diff", "(", "cls", ",", "a", ",", "b", ",", "ignore_formatting", "=", "False", ")", ":", "def", "underline", "(", "x", ")", ":", "return", "u'\\x1b[4m%s\\x1b[0m'", "%", "(", "x", ",", ")", "def", "blink", "(", "x", ")", ":", "return", "u'\\...
Returns two FSArrays with differences underlined
[ "Returns", "two", "FSArrays", "with", "differences", "underlined" ]
223e42b97fbf6c86b479ed4f0963a067333c5a63
https://github.com/bpython/curtsies/blob/223e42b97fbf6c86b479ed4f0963a067333c5a63/curtsies/formatstringarray.py#L139-L171
train
Returns two FSArrays with differences underlined
kmn/coincheck
coincheck/order.py
Order.create
def create(self,rate, amount, order_type, pair): ''' create new order function :param rate: float :param amount: float :param order_type: str; set 'buy' or 'sell' :param pair: str; set 'btc_jpy' ''' nonce = nounce() payload = { 'rate': rate, ...
python
def create(self,rate, amount, order_type, pair): ''' create new order function :param rate: float :param amount: float :param order_type: str; set 'buy' or 'sell' :param pair: str; set 'btc_jpy' ''' nonce = nounce() payload = { 'rate': rate, ...
[ "def", "create", "(", "self", ",", "rate", ",", "amount", ",", "order_type", ",", "pair", ")", ":", "nonce", "=", "nounce", "(", ")", "payload", "=", "{", "'rate'", ":", "rate", ",", "'amount'", ":", "amount", ",", "'order_type'", ":", "order_type", ...
create new order function :param rate: float :param amount: float :param order_type: str; set 'buy' or 'sell' :param pair: str; set 'btc_jpy'
[ "create", "new", "order", "function", ":", "param", "rate", ":", "float", ":", "param", "amount", ":", "float", ":", "param", "order_type", ":", "str", ";", "set", "buy", "or", "sell", ":", "param", "pair", ":", "str", ";", "set", "btc_jpy" ]
4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc
https://github.com/kmn/coincheck/blob/4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc/coincheck/order.py#L20-L43
train
create new order function
kmn/coincheck
coincheck/order.py
Order.cancel
def cancel(self,order_id): ''' cancel the specified order :param order_id: order_id to be canceled ''' url= 'https://coincheck.com/api/exchange/orders/' + order_id headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.delete(url,hea...
python
def cancel(self,order_id): ''' cancel the specified order :param order_id: order_id to be canceled ''' url= 'https://coincheck.com/api/exchange/orders/' + order_id headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.delete(url,hea...
[ "def", "cancel", "(", "self", ",", "order_id", ")", ":", "url", "=", "'https://coincheck.com/api/exchange/orders/'", "+", "order_id", "headers", "=", "make_header", "(", "url", ",", "access_key", "=", "self", ".", "access_key", ",", "secret_key", "=", "self", ...
cancel the specified order :param order_id: order_id to be canceled
[ "cancel", "the", "specified", "order", ":", "param", "order_id", ":", "order_id", "to", "be", "canceled" ]
4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc
https://github.com/kmn/coincheck/blob/4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc/coincheck/order.py#L59-L66
train
cancel the order with the specified order_id
kmn/coincheck
coincheck/order.py
Order.history
def history(self): ''' show payment history ''' url= 'https://coincheck.com/api/exchange/orders/transactions' headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.get(url,headers=headers) return json.loads(r.text)
python
def history(self): ''' show payment history ''' url= 'https://coincheck.com/api/exchange/orders/transactions' headers = make_header(url,access_key=self.access_key,secret_key=self.secret_key) r = requests.get(url,headers=headers) return json.loads(r.text)
[ "def", "history", "(", "self", ")", ":", "url", "=", "'https://coincheck.com/api/exchange/orders/transactions'", "headers", "=", "make_header", "(", "url", ",", "access_key", "=", "self", ".", "access_key", ",", "secret_key", "=", "self", ".", "secret_key", ")", ...
show payment history
[ "show", "payment", "history" ]
4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc
https://github.com/kmn/coincheck/blob/4e1062f1e564cddceec2f6fb4d70fe3a3ab645bc/coincheck/order.py#L68-L74
train
show payment history
mottosso/be
be/vendor/click/_termui_impl.py
_length_hint
def _length_hint(obj): """Returns the length hint of an object.""" try: return len(obj) except TypeError: try: get_hint = type(obj).__length_hint__ except AttributeError: return None try: hint = get_hint(obj) except TypeError: ...
python
def _length_hint(obj): """Returns the length hint of an object.""" try: return len(obj) except TypeError: try: get_hint = type(obj).__length_hint__ except AttributeError: return None try: hint = get_hint(obj) except TypeError: ...
[ "def", "_length_hint", "(", "obj", ")", ":", "try", ":", "return", "len", "(", "obj", ")", "except", "TypeError", ":", "try", ":", "get_hint", "=", "type", "(", "obj", ")", ".", "__length_hint__", "except", "AttributeError", ":", "return", "None", "try",...
Returns the length hint of an object.
[ "Returns", "the", "length", "hint", "of", "an", "object", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/_termui_impl.py#L30-L47
train
Returns the length hint of an object.
mottosso/be
be/vendor/click/_termui_impl.py
pager
def pager(text, color=None): """Decide what method to use for paging through text.""" stdout = _default_text_stdout() if not isatty(sys.stdin) or not isatty(stdout): return _nullpager(stdout, text, color) if 'PAGER' in os.environ: if WIN: return _tempfilepager(text, os.enviro...
python
def pager(text, color=None): """Decide what method to use for paging through text.""" stdout = _default_text_stdout() if not isatty(sys.stdin) or not isatty(stdout): return _nullpager(stdout, text, color) if 'PAGER' in os.environ: if WIN: return _tempfilepager(text, os.enviro...
[ "def", "pager", "(", "text", ",", "color", "=", "None", ")", ":", "stdout", "=", "_default_text_stdout", "(", ")", "if", "not", "isatty", "(", "sys", ".", "stdin", ")", "or", "not", "isatty", "(", "stdout", ")", ":", "return", "_nullpager", "(", "std...
Decide what method to use for paging through text.
[ "Decide", "what", "method", "to", "use", "for", "paging", "through", "text", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/_termui_impl.py#L255-L279
train
Decide what method to use for paging through text.
mottosso/be
be/vendor/requests/packages/urllib3/util/retry.py
Retry.from_int
def from_int(cls, retries, redirect=True, default=None): """ Backwards-compatibility for the old retries format.""" if retries is None: retries = default if default is not None else cls.DEFAULT if isinstance(retries, Retry): return retries redirect = bool(redire...
python
def from_int(cls, retries, redirect=True, default=None): """ Backwards-compatibility for the old retries format.""" if retries is None: retries = default if default is not None else cls.DEFAULT if isinstance(retries, Retry): return retries redirect = bool(redire...
[ "def", "from_int", "(", "cls", ",", "retries", ",", "redirect", "=", "True", ",", "default", "=", "None", ")", ":", "if", "retries", "is", "None", ":", "retries", "=", "default", "if", "default", "is", "not", "None", "else", "cls", ".", "DEFAULT", "i...
Backwards-compatibility for the old retries format.
[ "Backwards", "-", "compatibility", "for", "the", "old", "retries", "format", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L145-L156
train
Converts a retries value to a Retry object.
mottosso/be
be/vendor/requests/packages/urllib3/util/retry.py
Retry.get_backoff_time
def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ if self._observed_errors <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (self._observed_errors - 1)) return min(self.BACKOFF_MAX, backoff_value)
python
def get_backoff_time(self): """ Formula for computing the current backoff :rtype: float """ if self._observed_errors <= 1: return 0 backoff_value = self.backoff_factor * (2 ** (self._observed_errors - 1)) return min(self.BACKOFF_MAX, backoff_value)
[ "def", "get_backoff_time", "(", "self", ")", ":", "if", "self", ".", "_observed_errors", "<=", "1", ":", "return", "0", "backoff_value", "=", "self", ".", "backoff_factor", "*", "(", "2", "**", "(", "self", ".", "_observed_errors", "-", "1", ")", ")", ...
Formula for computing the current backoff :rtype: float
[ "Formula", "for", "computing", "the", "current", "backoff" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L158-L167
train
Returns the current backoff time.
mottosso/be
be/vendor/requests/packages/urllib3/util/retry.py
Retry.is_forced_retry
def is_forced_retry(self, method, status_code): """ Is this method/status code retryable? (Based on method/codes whitelists) """ if self.method_whitelist and method.upper() not in self.method_whitelist: return False return self.status_forcelist and status_code in self.status...
python
def is_forced_retry(self, method, status_code): """ Is this method/status code retryable? (Based on method/codes whitelists) """ if self.method_whitelist and method.upper() not in self.method_whitelist: return False return self.status_forcelist and status_code in self.status...
[ "def", "is_forced_retry", "(", "self", ",", "method", ",", "status_code", ")", ":", "if", "self", ".", "method_whitelist", "and", "method", ".", "upper", "(", ")", "not", "in", "self", ".", "method_whitelist", ":", "return", "False", "return", "self", ".",...
Is this method/status code retryable? (Based on method/codes whitelists)
[ "Is", "this", "method", "/", "status", "code", "retryable?", "(", "Based", "on", "method", "/", "codes", "whitelists", ")" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/util/retry.py#L192-L198
train
Is this method retryable?
mottosso/be
be/vendor/click/types.py
convert_type
def convert_type(ty, default=None): """Converts a callable or python ty into the most appropriate param ty. """ if isinstance(ty, tuple): return Tuple(ty) if isinstance(ty, ParamType): return ty guessed_type = False if ty is None and default is not None: ty = type(def...
python
def convert_type(ty, default=None): """Converts a callable or python ty into the most appropriate param ty. """ if isinstance(ty, tuple): return Tuple(ty) if isinstance(ty, ParamType): return ty guessed_type = False if ty is None and default is not None: ty = type(def...
[ "def", "convert_type", "(", "ty", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "ty", ",", "tuple", ")", ":", "return", "Tuple", "(", "ty", ")", "if", "isinstance", "(", "ty", ",", "ParamType", ")", ":", "return", "ty", "guessed_typ...
Converts a callable or python ty into the most appropriate param ty.
[ "Converts", "a", "callable", "or", "python", "ty", "into", "the", "most", "appropriate", "param", "ty", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/types.py#L445-L480
train
Converts a callable or python ty into the most appropriate param ty.
mottosso/be
be/vendor/click/formatting.py
wrap_text
def wrap_text(text, width=78, initial_indent='', subsequent_indent='', preserve_paragraphs=False): """A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intellige...
python
def wrap_text(text, width=78, initial_indent='', subsequent_indent='', preserve_paragraphs=False): """A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intellige...
[ "def", "wrap_text", "(", "text", ",", "width", "=", "78", ",", "initial_indent", "=", "''", ",", "subsequent_indent", "=", "''", ",", "preserve_paragraphs", "=", "False", ")", ":", "from", ".", "_textwrap", "import", "TextWrapper", "text", "=", "text", "."...
A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intelligently handle paragraphs (defined by two empty lines). If paragraphs are handled, a paragraph can be prefixed wit...
[ "A", "helper", "function", "that", "intelligently", "wraps", "text", ".", "By", "default", "it", "assumes", "that", "it", "operates", "on", "a", "single", "paragraph", "of", "text", "but", "if", "the", "preserve_paragraphs", "parameter", "is", "provided", "it"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/formatting.py#L27-L92
train
A helper function that intelligently wraps text.
mottosso/be
be/vendor/click/formatting.py
HelpFormatter.write_usage
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ prefix = '%*s%s' % (self.current_indent, ...
python
def write_usage(self, prog, args='', prefix='Usage: '): """Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line. """ prefix = '%*s%s' % (self.current_indent, ...
[ "def", "write_usage", "(", "self", ",", "prog", ",", "args", "=", "''", ",", "prefix", "=", "'Usage: '", ")", ":", "prefix", "=", "'%*s%s'", "%", "(", "self", ".", "current_indent", ",", "prefix", ",", "prog", ")", "self", ".", "write", "(", "prefix"...
Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line.
[ "Writes", "a", "usage", "line", "into", "the", "buffer", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/formatting.py#L129-L145
train
Writes a usage line into the buffer.
mottosso/be
be/cli.py
in_
def in_(ctx, topics, yes, as_, enter): """Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolut...
python
def in_(ctx, topics, yes, as_, enter): """Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolut...
[ "def", "in_", "(", "ctx", ",", "topics", ",", "yes", ",", "as_", ",", "enter", ")", ":", "topics", "=", "map", "(", "str", ",", "topics", ")", "# They enter as unicode", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERRO...
Set the current topics to `topics` Environment: BE_PROJECT: First topic BE_CWD: Current `be` working directory BE_TOPICS: Arguments to `in` BE_DEVELOPMENTDIR: Absolute path to current development directory BE_PROJECTROOT: Absolute path to current project BE_PROJECTSR...
[ "Set", "the", "current", "topics", "to", "topics" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L77-L274
train
Set the current topics to topics
mottosso/be
be/cli.py
new
def new(preset, name, silent, update): """Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created """ if self.isactive(): lib.echo("Please exit current preset before starting a new") ...
python
def new(preset, name, silent, update): """Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created """ if self.isactive(): lib.echo("Please exit current preset before starting a new") ...
[ "def", "new", "(", "preset", ",", "name", ",", "silent", ",", "update", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"Please exit current preset before starting a new\"", ")", "sys", ".", "exit", "(", "lib", ".", "US...
Create new default preset \b Usage: $ be new ad "blue_unicorn" created $ be new film --name spiderman "spiderman" created
[ "Create", "new", "default", "preset" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L284-L374
train
Create a new empty file in the current project
mottosso/be
be/cli.py
update
def update(preset, clean): """Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad".. """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ER...
python
def update(preset, clean): """Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad".. """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ER...
[ "def", "update", "(", "preset", ",", "clean", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "presets", "=", "_extern"...
Update a local preset This command will cause `be` to pull a preset already available locally. \b Usage: $ be update ad Updating "ad"..
[ "Update", "a", "local", "preset" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L380-L427
train
Update a local preset
mottosso/be
be/cli.py
tab
def tab(topics, complete): """Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete. """ # Discard `be tab` ...
python
def tab(topics, complete): """Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete. """ # Discard `be tab` ...
[ "def", "tab", "(", "topics", ",", "complete", ")", ":", "# Discard `be tab`", "topics", "=", "list", "(", "topics", ")", "[", "2", ":", "]", "# When given an incomplete argument,", "# the argument is *sometimes* returned twice (?)", "# .. note:: Seen in Git Bash on Windows"...
Utility sub-command for tabcompletion This command is meant to be called by a tab completion function and is given a the currently entered topics, along with a boolean indicating whether or not the last entered argument is complete.
[ "Utility", "sub", "-", "command", "for", "tabcompletion" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L433-L512
train
Utility sub - command for tab completion
mottosso/be
be/cli.py
activate
def activate(): """Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. h...
python
def activate(): """Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. h...
[ "def", "activate", "(", ")", ":", "parent", "=", "lib", ".", "parent", "(", ")", "try", ":", "cmd", "=", "lib", ".", "cmd", "(", "parent", ")", "except", "SystemError", "as", "exc", ":", "lib", ".", "echo", "(", "exc", ")", "sys", ".", "exit", ...
Enter into an environment with support for tab-completion This command drops you into a subshell, similar to the one generated via `be in ...`, except no topic is present and instead it enables tab-completion for supported shells. See documentation for further information. https://github.com/motto...
[ "Enter", "into", "an", "environment", "with", "support", "for", "tab", "-", "completion" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L516-L546
train
Enter into an environment with support for tab - completion
mottosso/be
be/cli.py
ls
def ls(topics): """List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insuffici...
python
def ls(topics): """List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insuffici...
[ "def", "ls", "(", "topics", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "# List projects", "if", "len", "(", "topic...
List contents of current context \b Usage: $ be ls - spiderman - hulk $ be ls spiderman - peter - mjay $ be ls spiderman seq01 - 1000 - 2000 - 2500 Return codes: 0 Normal 2 When insufficient arguments are suppl...
[ "List", "contents", "of", "current", "context" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L551-L608
train
List contents of current context.
mottosso/be
be/cli.py
mkdir
def mkdir(dir, enter): """Create directory with template for topic of the current environment """ if not os.path.exists(dir): os.makedirs(dir)
python
def mkdir(dir, enter): """Create directory with template for topic of the current environment """ if not os.path.exists(dir): os.makedirs(dir)
[ "def", "mkdir", "(", "dir", ",", "enter", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "dir", ")", ":", "os", ".", "makedirs", "(", "dir", ")" ]
Create directory with template for topic of the current environment
[ "Create", "directory", "with", "template", "for", "topic", "of", "the", "current", "environment" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L614-L620
train
Create a directory with the template for the current environment
mottosso/be
be/cli.py
preset_ls
def preset_ls(remote): """List presets \b Usage: $ be preset ls - ad - game - film """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) if remote: presets = _extern.github_presets() else: ...
python
def preset_ls(remote): """List presets \b Usage: $ be preset ls - ad - game - film """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) if remote: presets = _extern.github_presets() else: ...
[ "def", "preset_ls", "(", "remote", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "if", "remote", ":", "presets", "=",...
List presets \b Usage: $ be preset ls - ad - game - film
[ "List", "presets" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L630-L656
train
List presets available on the current project
mottosso/be
be/cli.py
preset_find
def preset_find(query): """Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) found = _extern.github_presets().get(query) if found: lib.echo(...
python
def preset_find(query): """Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git """ if self.isactive(): lib.echo("ERROR: Exit current project first") sys.exit(lib.USER_ERROR) found = _extern.github_presets().get(query) if found: lib.echo(...
[ "def", "preset_find", "(", "query", ")", ":", "if", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Exit current project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "found", "=", "_extern", ".", "gith...
Find preset from hub \b $ be find ad https://github.com/mottosso/be-ad.git
[ "Find", "preset", "from", "hub" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L661-L678
train
Find preset from hub
mottosso/be
be/cli.py
dump
def dump(): """Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ... """ if not self.isactive(): lib.echo("ERROR: Enter a project first") sys.exit(lib.U...
python
def dump(): """Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ... """ if not self.isactive(): lib.echo("ERROR: Enter a project first") sys.exit(lib.U...
[ "def", "dump", "(", ")", ":", "if", "not", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"ERROR: Enter a project first\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "# Print custom environment variables first", "custom",...
Print current environment Environment is outputted in a YAML-friendly format \b Usage: $ be dump Prefixed: - BE_TOPICS=hulk bruce animation - ...
[ "Print", "current", "environment" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L682-L727
train
Print current environment and redirected environment variables
mottosso/be
be/cli.py
what
def what(): """Print current topics""" if not self.isactive(): lib.echo("No topic") sys.exit(lib.USER_ERROR) lib.echo(os.environ.get("BE_TOPICS", "This is a bug"))
python
def what(): """Print current topics""" if not self.isactive(): lib.echo("No topic") sys.exit(lib.USER_ERROR) lib.echo(os.environ.get("BE_TOPICS", "This is a bug"))
[ "def", "what", "(", ")", ":", "if", "not", "self", ".", "isactive", "(", ")", ":", "lib", ".", "echo", "(", "\"No topic\"", ")", "sys", ".", "exit", "(", "lib", ".", "USER_ERROR", ")", "lib", ".", "echo", "(", "os", ".", "environ", ".", "get", ...
Print current topics
[ "Print", "current", "topics" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L731-L738
train
Print current topics
mottosso/be
be/vendor/requests/utils.py
get_netrc_auth
def get_netrc_auth(url): """Returns the Requests tuple auth for a given url from netrc.""" try: from netrc import netrc, NetrcParseError netrc_path = None for f in NETRC_FILES: try: loc = os.path.expanduser('~/{0}'.format(f)) except KeyError: ...
python
def get_netrc_auth(url): """Returns the Requests tuple auth for a given url from netrc.""" try: from netrc import netrc, NetrcParseError netrc_path = None for f in NETRC_FILES: try: loc = os.path.expanduser('~/{0}'.format(f)) except KeyError: ...
[ "def", "get_netrc_auth", "(", "url", ")", ":", "try", ":", "from", "netrc", "import", "netrc", ",", "NetrcParseError", "netrc_path", "=", "None", "for", "f", "in", "NETRC_FILES", ":", "try", ":", "loc", "=", "os", ".", "path", ".", "expanduser", "(", "...
Returns the Requests tuple auth for a given url from netrc.
[ "Returns", "the", "Requests", "tuple", "auth", "for", "a", "given", "url", "from", "netrc", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L70-L113
train
Returns the Requests tuple auth for a given url from netrc.
mottosso/be
be/vendor/requests/utils.py
add_dict_to_cookiejar
def add_dict_to_cookiejar(cj, cookie_dict): """Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. """ cj2 = cookiejar_from_dict(cookie_dict) cj.update(cj2) return cj
python
def add_dict_to_cookiejar(cj, cookie_dict): """Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar. """ cj2 = cookiejar_from_dict(cookie_dict) cj.update(cj2) return cj
[ "def", "add_dict_to_cookiejar", "(", "cj", ",", "cookie_dict", ")", ":", "cj2", "=", "cookiejar_from_dict", "(", "cookie_dict", ")", "cj", ".", "update", "(", "cj2", ")", "return", "cj" ]
Returns a CookieJar from a key/value dictionary. :param cj: CookieJar to insert cookies into. :param cookie_dict: Dict of key/values to insert into CookieJar.
[ "Returns", "a", "CookieJar", "from", "a", "key", "/", "value", "dictionary", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L276-L285
train
Returns a CookieJar from a key - value dictionary.
mottosso/be
be/vendor/requests/utils.py
should_bypass_proxies
def should_bypass_proxies(url): """ Returns whether we should bypass proxies or not. """ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL # we're getting isn't in the no_proxy list. no_proxy = get_pr...
python
def should_bypass_proxies(url): """ Returns whether we should bypass proxies or not. """ get_proxy = lambda k: os.environ.get(k) or os.environ.get(k.upper()) # First check whether no_proxy is defined. If it is, check that the URL # we're getting isn't in the no_proxy list. no_proxy = get_pr...
[ "def", "should_bypass_proxies", "(", "url", ")", ":", "get_proxy", "=", "lambda", "k", ":", "os", ".", "environ", ".", "get", "(", "k", ")", "or", "os", ".", "environ", ".", "get", "(", "k", ".", "upper", "(", ")", ")", "# First check whether no_proxy ...
Returns whether we should bypass proxies or not.
[ "Returns", "whether", "we", "should", "bypass", "proxies", "or", "not", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L487-L530
train
Returns whether we should bypass proxies on this URL.
mottosso/be
be/vendor/requests/utils.py
default_user_agent
def default_user_agent(name="python-requests"): """Return a string representing the default user agent.""" _implementation = platform.python_implementation() if _implementation == 'CPython': _implementation_version = platform.python_version() elif _implementation == 'PyPy': _implementat...
python
def default_user_agent(name="python-requests"): """Return a string representing the default user agent.""" _implementation = platform.python_implementation() if _implementation == 'CPython': _implementation_version = platform.python_version() elif _implementation == 'PyPy': _implementat...
[ "def", "default_user_agent", "(", "name", "=", "\"python-requests\"", ")", ":", "_implementation", "=", "platform", ".", "python_implementation", "(", ")", "if", "_implementation", "==", "'CPython'", ":", "_implementation_version", "=", "platform", ".", "python_versio...
Return a string representing the default user agent.
[ "Return", "a", "string", "representing", "the", "default", "user", "agent", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L540-L568
train
Return a string representing the default user agent.
mottosso/be
be/vendor/requests/utils.py
to_native_string
def to_native_string(string, encoding='ascii'): """ Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise. """ out = None if isinstance(string, builtin_str...
python
def to_native_string(string, encoding='ascii'): """ Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise. """ out = None if isinstance(string, builtin_str...
[ "def", "to_native_string", "(", "string", ",", "encoding", "=", "'ascii'", ")", ":", "out", "=", "None", "if", "isinstance", "(", "string", ",", "builtin_str", ")", ":", "out", "=", "string", "else", ":", "if", "is_py2", ":", "out", "=", "string", ".",...
Given a string object, regardless of type, returns a representation of that string in the native string type, encoding and decoding where necessary. This assumes ASCII unless told otherwise.
[ "Given", "a", "string", "object", "regardless", "of", "type", "returns", "a", "representation", "of", "that", "string", "in", "the", "native", "string", "type", "encoding", "and", "decoding", "where", "necessary", ".", "This", "assumes", "ASCII", "unless", "to...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/utils.py#L676-L692
train
Given a string object regardless of type returns a representation of that string in the native string type encoding and decoding where necessary.
mottosso/be
be/vendor/click/core.py
_bashcomplete
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
python
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
[ "def", "_bashcomplete", "(", "cmd", ",", "prog_name", ",", "complete_var", "=", "None", ")", ":", "if", "complete_var", "is", "None", ":", "complete_var", "=", "'_%s_COMPLETE'", "%", "(", "prog_name", ".", "replace", "(", "'-'", ",", "'_'", ")", ")", "."...
Internal handler for the bash completion support.
[ "Internal", "handler", "for", "the", "bash", "completion", "support", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L25-L35
train
Internal handler for the bash completion support.
mottosso/be
be/vendor/click/core.py
Context.invoke
def invoke(*args, **kwargs): """Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first a...
python
def invoke(*args, **kwargs): """Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first a...
[ "def", "invoke", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ",", "callback", "=", "args", "[", ":", "2", "]", "ctx", "=", "self", "# This is just to improve the error message in cases where old", "# code incorrectly invoked this method. This will ev...
Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first argument is a click command object. In t...
[ "Invokes", "a", "command", "callback", "in", "exactly", "the", "way", "it", "expects", ".", "There", "are", "two", "ways", "to", "invoke", "this", "method", ":" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L418-L475
train
Invoke a command callback in exactly the way it expects.
mottosso/be
be/vendor/click/core.py
BaseCommand.make_context
def make_context(self, info_name, args, parent=None, **extra): """This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation....
python
def make_context(self, info_name, args, parent=None, **extra): """This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation....
[ "def", "make_context", "(", "self", ",", "info_name", ",", "args", ",", "parent", "=", "None", ",", "*", "*", "extra", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "context_settings", ")", ":", "if", "key", "not", "in", ...
This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation. Generally this is the most descriptive name fo...
[ "This", "function", "when", "given", "an", "info", "name", "and", "arguments", "will", "kick", "off", "the", "parsing", "and", "create", "a", "new", ":", "class", ":", "Context", ".", "It", "does", "not", "invoke", "the", "actual", "command", "callback", ...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L541-L561
train
This function is called by the command line parser when a new context is created.
mottosso/be
be/vendor/click/core.py
BaseCommand.main
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): """This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``Syste...
python
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): """This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``Syste...
[ "def", "main", "(", "self", ",", "args", "=", "None", ",", "prog_name", "=", "None", ",", "complete_var", "=", "None", ",", "standalone_mode", "=", "True", ",", "*", "*", "extra", ")", ":", "# If we are in Python 3, we will verify that the environment is", "# sa...
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``SystemExit`` needs to be caught. This method is also available by directly calling the instance of ...
[ "This", "is", "the", "way", "to", "invoke", "a", "script", "with", "all", "the", "bells", "and", "whistles", "as", "a", "command", "line", "application", ".", "This", "will", "always", "terminate", "the", "application", "after", "a", "call", ".", "If", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L577-L660
train
This is the main method of the command line application.
mottosso/be
be/vendor/click/core.py
Command.make_parser
def make_parser(self, ctx): """Creates the underlying option parser for this command.""" parser = OptionParser(ctx) parser.allow_interspersed_args = ctx.allow_interspersed_args parser.ignore_unknown_options = ctx.ignore_unknown_options for param in self.get_params(ctx): ...
python
def make_parser(self, ctx): """Creates the underlying option parser for this command.""" parser = OptionParser(ctx) parser.allow_interspersed_args = ctx.allow_interspersed_args parser.ignore_unknown_options = ctx.ignore_unknown_options for param in self.get_params(ctx): ...
[ "def", "make_parser", "(", "self", ",", "ctx", ")", ":", "parser", "=", "OptionParser", "(", "ctx", ")", "parser", ".", "allow_interspersed_args", "=", "ctx", ".", "allow_interspersed_args", "parser", ".", "ignore_unknown_options", "=", "ctx", ".", "ignore_unkno...
Creates the underlying option parser for this command.
[ "Creates", "the", "underlying", "option", "parser", "for", "this", "command", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L758-L765
train
Creates the underlying option parser for this command.
mottosso/be
be/vendor/click/core.py
Command.format_help_text
def format_help_text(self, ctx, formatter): """Writes the help text to the formatter if it exists.""" if self.help: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(self.help)
python
def format_help_text(self, ctx, formatter): """Writes the help text to the formatter if it exists.""" if self.help: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(self.help)
[ "def", "format_help_text", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "if", "self", ".", "help", ":", "formatter", ".", "write_paragraph", "(", ")", "with", "formatter", ".", "indentation", "(", ")", ":", "formatter", ".", "write_text", "(", "s...
Writes the help text to the formatter if it exists.
[ "Writes", "the", "help", "text", "to", "the", "formatter", "if", "it", "exists", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L790-L795
train
Writes the help text to the formatter if it exists.
mottosso/be
be/vendor/click/core.py
Group.add_command
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') self.commands[name...
python
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') self.commands[name...
[ "def", "add_command", "(", "self", ",", "cmd", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "cmd", ".", "name", "if", "name", "is", "None", ":", "raise", "TypeError", "(", "'Command has no name.'", ")", "self", ".", "commands", "[", ...
Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used.
[ "Registers", "another", ":", "class", ":", "Command", "with", "this", "group", ".", "If", "the", "name", "is", "not", "provided", "the", "name", "of", "the", "command", "is", "used", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/core.py#L1071-L1078
train
Registers another command with this group.
mottosso/be
be/vendor/click/decorators.py
pass_obj
def pass_obj(f): """Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system. """ @pass_context def new_func(*args, **kwargs): ctx = args[0] return ctx.invoke(f, ...
python
def pass_obj(f): """Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system. """ @pass_context def new_func(*args, **kwargs): ctx = args[0] return ctx.invoke(f, ...
[ "def", "pass_obj", "(", "f", ")", ":", "@", "pass_context", "def", "new_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ctx", "=", "args", "[", "0", "]", "return", "ctx", ".", "invoke", "(", "f", ",", "ctx", ".", "obj", ",", "*", ...
Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system.
[ "Similar", "to", ":", "func", ":", "pass_context", "but", "only", "pass", "the", "object", "on", "the", "context", "onwards", "(", ":", "attr", ":", "Context", ".", "obj", ")", ".", "This", "is", "useful", "if", "that", "object", "represents", "the", "...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L18-L27
train
Decorator to pass the object on the object on the object context.
mottosso/be
be/vendor/click/decorators.py
option
def option(*param_decls, **attrs): """Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attachin...
python
def option(*param_decls, **attrs): """Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attachin...
[ "def", "option", "(", "*", "param_decls", ",", "*", "*", "attrs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "'help'", "in", "attrs", ":", "attrs", "[", "'help'", "]", "=", "inspect", ".", "cleandoc", "(", "attrs", "[", "'help'", "]", ...
Attaches an option to the command. All positional arguments are passed as parameter declarations to :class:`Option`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Option` instance manually and attaching it to the :attr:`Command.params` list. ...
[ "Attaches", "an", "option", "to", "the", "command", ".", "All", "positional", "arguments", "are", "passed", "as", "parameter", "declarations", "to", ":", "class", ":", "Option", ";", "all", "keyword", "arguments", "are", "forwarded", "unchanged", "(", "except"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L153-L169
train
Decorator to add an option to the command.
mottosso/be
be/vendor/click/decorators.py
version_option
def version_option(version=None, *param_decls, **attrs): """Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. ...
python
def version_option(version=None, *param_decls, **attrs): """Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. ...
[ "def", "version_option", "(", "version", "=", "None", ",", "*", "param_decls", ",", "*", "*", "attrs", ")", ":", "if", "version", "is", "None", ":", "module", "=", "sys", ".", "_getframe", "(", "1", ")", ".", "f_globals", ".", "get", "(", "'__name__'...
Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. If not provided Click attempts an auto disc...
[ "Adds", "a", "--", "version", "option", "which", "immediately", "ends", "the", "program", "printing", "out", "the", "version", "number", ".", "This", "is", "implemented", "as", "an", "eager", "option", "that", "prints", "the", "version", "and", "exits", "the...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/decorators.py#L222-L273
train
Adds a option to be applied to a single command line command line.
mottosso/be
be/vendor/requests/auth.py
_basic_auth_str
def _basic_auth_str(username, password): """Returns a Basic Auth string.""" authstr = 'Basic ' + to_native_string( b64encode(('%s:%s' % (username, password)).encode('latin1')).strip() ) return authstr
python
def _basic_auth_str(username, password): """Returns a Basic Auth string.""" authstr = 'Basic ' + to_native_string( b64encode(('%s:%s' % (username, password)).encode('latin1')).strip() ) return authstr
[ "def", "_basic_auth_str", "(", "username", ",", "password", ")", ":", "authstr", "=", "'Basic '", "+", "to_native_string", "(", "b64encode", "(", "(", "'%s:%s'", "%", "(", "username", ",", "password", ")", ")", ".", "encode", "(", "'latin1'", ")", ")", "...
Returns a Basic Auth string.
[ "Returns", "a", "Basic", "Auth", "string", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/auth.py#L26-L33
train
Returns a Basic Auth string.
mottosso/be
be/util.py
ls
def ls(*topic, **kwargs): """List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call w...
python
def ls(*topic, **kwargs): """List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call w...
[ "def", "ls", "(", "*", "topic", ",", "*", "*", "kwargs", ")", ":", "context", "=", "dump", "(", ")", "root", "=", "kwargs", ".", "get", "(", "\"root\"", ")", "or", "context", ".", "get", "(", "\"cwd\"", ")", "or", "os", ".", "getcwd", "(", ")",...
List topic from external datastore Arguments: topic (str): One or more topics, e.g. ("project", "item", "task") root (str, optional): Absolute path to where projects reside, defaults to os.getcwd() backend (callable, optional): Function to call with absolute path as ...
[ "List", "topic", "from", "external", "datastore" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/util.py#L7-L82
train
List all the items in the external datastore.
mottosso/be
be/util.py
dump
def dump(context=os.environ): """Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment. """ output = {} for key, value in context.iteritems(): if not key.startswith("BE_"): continu...
python
def dump(context=os.environ): """Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment. """ output = {} for key, value in context.iteritems(): if not key.startswith("BE_"): continu...
[ "def", "dump", "(", "context", "=", "os", ".", "environ", ")", ":", "output", "=", "{", "}", "for", "key", ",", "value", "in", "context", ".", "iteritems", "(", ")", ":", "if", "not", "key", ".", "startswith", "(", "\"BE_\"", ")", ":", "continue", ...
Dump current environment as a dictionary Arguments: context (dict, optional): Current context, defaults to the current environment.
[ "Dump", "current", "environment", "as", "a", "dictionary" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/util.py#L100-L115
train
Dump current environment as a dictionary
mottosso/be
be/_extern.py
cwd
def cwd(): """Return the be current working directory""" cwd = os.environ.get("BE_CWD") if cwd and not os.path.isdir(cwd): sys.stderr.write("ERROR: %s is not a directory" % cwd) sys.exit(lib.USER_ERROR) return cwd or os.getcwd().replace("\\", "/")
python
def cwd(): """Return the be current working directory""" cwd = os.environ.get("BE_CWD") if cwd and not os.path.isdir(cwd): sys.stderr.write("ERROR: %s is not a directory" % cwd) sys.exit(lib.USER_ERROR) return cwd or os.getcwd().replace("\\", "/")
[ "def", "cwd", "(", ")", ":", "cwd", "=", "os", ".", "environ", ".", "get", "(", "\"BE_CWD\"", ")", "if", "cwd", "and", "not", "os", ".", "path", ".", "isdir", "(", "cwd", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"ERROR: %s is not a dire...
Return the be current working directory
[ "Return", "the", "be", "current", "working", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L52-L58
train
Return the be current working directory
mottosso/be
be/_extern.py
write_script
def write_script(script, tempdir): """Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script """ name = "script" + self.suffix path = os.path.join(tempdir, name) with open(path, "w") as f: ...
python
def write_script(script, tempdir): """Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script """ name = "script" + self.suffix path = os.path.join(tempdir, name) with open(path, "w") as f: ...
[ "def", "write_script", "(", "script", ",", "tempdir", ")", ":", "name", "=", "\"script\"", "+", "self", ".", "suffix", "path", "=", "os", ".", "path", ".", "join", "(", "tempdir", ",", "name", ")", "with", "open", "(", "path", ",", "\"w\"", ")", "a...
Write script to a temporary directory Arguments: script (list): Commands which to put into a file Returns: Absolute path to script
[ "Write", "script", "to", "a", "temporary", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L105-L122
train
Writes a list of commands to a temporary directory and returns the absolute path to the script
mottosso/be
be/_extern.py
write_aliases
def write_aliases(aliases, tempdir): """Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored """ platform = lib.platform() if platform == "unix": home_alias = "cd $BE_DEVE...
python
def write_aliases(aliases, tempdir): """Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored """ platform = lib.platform() if platform == "unix": home_alias = "cd $BE_DEVE...
[ "def", "write_aliases", "(", "aliases", ",", "tempdir", ")", ":", "platform", "=", "lib", ".", "platform", "(", ")", "if", "platform", "==", "\"unix\"", ":", "home_alias", "=", "\"cd $BE_DEVELOPMENTDIR\"", "else", ":", "home_alias", "=", "\"cd %BE_DEVELOPMENTDIR...
Write aliases to temporary directory Arguments: aliases (dict): {name: value} dict of aliases tempdir (str): Absolute path to where aliases will be stored
[ "Write", "aliases", "to", "temporary", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L125-L160
train
Write aliases to temporary directory
mottosso/be
be/_extern.py
presets_dir
def presets_dir(): """Return presets directory""" default_presets_dir = os.path.join( os.path.expanduser("~"), ".be", "presets") presets_dir = os.environ.get(BE_PRESETSDIR) or default_presets_dir if not os.path.exists(presets_dir): os.makedirs(presets_dir) return presets_dir
python
def presets_dir(): """Return presets directory""" default_presets_dir = os.path.join( os.path.expanduser("~"), ".be", "presets") presets_dir = os.environ.get(BE_PRESETSDIR) or default_presets_dir if not os.path.exists(presets_dir): os.makedirs(presets_dir) return presets_dir
[ "def", "presets_dir", "(", ")", ":", "default_presets_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", ",", "\".be\"", ",", "\"presets\"", ")", "presets_dir", "=", "os", ".", "environ", ".", "get"...
Return presets directory
[ "Return", "presets", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L168-L175
train
Return presets directory
mottosso/be
be/_extern.py
remove_preset
def remove_preset(preset): """Physically delete local preset Arguments: preset (str): Name of preset """ preset_dir = os.path.join(presets_dir(), preset) try: shutil.rmtree(preset_dir) except IOError: lib.echo("\"%s\" did not exist" % preset)
python
def remove_preset(preset): """Physically delete local preset Arguments: preset (str): Name of preset """ preset_dir = os.path.join(presets_dir(), preset) try: shutil.rmtree(preset_dir) except IOError: lib.echo("\"%s\" did not exist" % preset)
[ "def", "remove_preset", "(", "preset", ")", ":", "preset_dir", "=", "os", ".", "path", ".", "join", "(", "presets_dir", "(", ")", ",", "preset", ")", "try", ":", "shutil", ".", "rmtree", "(", "preset_dir", ")", "except", "IOError", ":", "lib", ".", "...
Physically delete local preset Arguments: preset (str): Name of preset
[ "Physically", "delete", "local", "preset" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L178-L191
train
Physically delete local preset
mottosso/be
be/_extern.py
get
def get(path, **kwargs): """requests.get wrapper""" token = os.environ.get(BE_GITHUB_API_TOKEN) if token: kwargs["headers"] = { "Authorization": "token %s" % token } try: response = requests.get(path, verify=False, **kwargs) if response.status_code == 403: ...
python
def get(path, **kwargs): """requests.get wrapper""" token = os.environ.get(BE_GITHUB_API_TOKEN) if token: kwargs["headers"] = { "Authorization": "token %s" % token } try: response = requests.get(path, verify=False, **kwargs) if response.status_code == 403: ...
[ "def", "get", "(", "path", ",", "*", "*", "kwargs", ")", ":", "token", "=", "os", ".", "environ", ".", "get", "(", "BE_GITHUB_API_TOKEN", ")", "if", "token", ":", "kwargs", "[", "\"headers\"", "]", "=", "{", "\"Authorization\"", ":", "\"token %s\"", "%...
requests.get wrapper
[ "requests", ".", "get", "wrapper" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L194-L216
train
Wrapper for requests. get
mottosso/be
be/_extern.py
_gist_is_preset
def _gist_is_preset(repo): """Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde """ _, gistid = repo.split("/") gist_template = "https://api.github.com/gists/{}" gist_path = gist_template.format(gistid) response = ge...
python
def _gist_is_preset(repo): """Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde """ _, gistid = repo.split("/") gist_template = "https://api.github.com/gists/{}" gist_path = gist_template.format(gistid) response = ge...
[ "def", "_gist_is_preset", "(", "repo", ")", ":", "_", ",", "gistid", "=", "repo", ".", "split", "(", "\"/\"", ")", "gist_template", "=", "\"https://api.github.com/gists/{}\"", "gist_path", "=", "gist_template", ".", "format", "(", "gistid", ")", "response", "=...
Evaluate whether gist is a be package Arguments: gist (str): username/id pair e.g. mottosso/2bb4651a05af85711cde
[ "Evaluate", "whether", "gist", "is", "a", "be", "package" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L239-L272
train
Evaluate whether gist is a be package
mottosso/be
be/_extern.py
_repo_is_preset
def _repo_is_preset(repo): """Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad """ package_template = "https://raw.githubusercontent.com" package_template += "/{repo}/master/package.json" package_path = package_template.for...
python
def _repo_is_preset(repo): """Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad """ package_template = "https://raw.githubusercontent.com" package_template += "/{repo}/master/package.json" package_path = package_template.for...
[ "def", "_repo_is_preset", "(", "repo", ")", ":", "package_template", "=", "\"https://raw.githubusercontent.com\"", "package_template", "+=", "\"/{repo}/master/package.json\"", "package_path", "=", "package_template", ".", "format", "(", "repo", "=", "repo", ")", "response...
Evaluate whether GitHub repository is a be package Arguments: gist (str): username/id pair e.g. mottosso/be-ad
[ "Evaluate", "whether", "GitHub", "repository", "is", "a", "be", "package" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L275-L299
train
Evaluate whether GitHub repository is a be package
mottosso/be
be/_extern.py
github_presets
def github_presets(): """Return remote presets hosted on GitHub""" addr = ("https://raw.githubusercontent.com" "/mottosso/be-presets/master/presets.json") response = get(addr) if response.status_code == 404: lib.echo("Could not connect with preset database") sys.exit(lib.PRO...
python
def github_presets(): """Return remote presets hosted on GitHub""" addr = ("https://raw.githubusercontent.com" "/mottosso/be-presets/master/presets.json") response = get(addr) if response.status_code == 404: lib.echo("Could not connect with preset database") sys.exit(lib.PRO...
[ "def", "github_presets", "(", ")", ":", "addr", "=", "(", "\"https://raw.githubusercontent.com\"", "\"/mottosso/be-presets/master/presets.json\"", ")", "response", "=", "get", "(", "addr", ")", "if", "response", ".", "status_code", "==", "404", ":", "lib", ".", "e...
Return remote presets hosted on GitHub
[ "Return", "remote", "presets", "hosted", "on", "GitHub" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L383-L394
train
Return remote presets hosted on GitHub
mottosso/be
be/_extern.py
copy_preset
def copy_preset(preset_dir, project_dir): """Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project ...
python
def copy_preset(preset_dir, project_dir): """Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project ...
[ "def", "copy_preset", "(", "preset_dir", ",", "project_dir", ")", ":", "os", ".", "makedirs", "(", "project_dir", ")", "package_file", "=", "os", ".", "path", ".", "join", "(", "preset_dir", ",", "\"package.json\"", ")", "with", "open", "(", "package_file", ...
Copy contents of preset into new project If package.json contains the key "contents", limit the files copied to those present in this list. Arguments: preset_dir (str): Absolute path to preset project_dir (str): Absolute path to new project
[ "Copy", "contents", "of", "preset", "into", "new", "project" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L397-L427
train
Copy contents of preset into new project_dir
mottosso/be
be/_extern.py
_resolve_references
def _resolve_references(templates): """Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replace...
python
def _resolve_references(templates): """Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replace...
[ "def", "_resolve_references", "(", "templates", ")", ":", "def", "repl", "(", "match", ")", ":", "lib", ".", "echo", "(", "\"Deprecation warning: The {@ref} syntax is being removed\"", ")", "key", "=", "pattern", "[", "match", ".", "start", "(", ")", ":", "mat...
Resolve {@} occurences by expansion Given a dictionary {"a": "{@b}/x", "b": "{key}/y"} Return {"a", "{key}/y/x", "b": "{key}/y"} { key: {@reference}/{variable} # pattern } In plain english, it looks within `pattern` for references and replaces them with the value of the matching k...
[ "Resolve", "{", "@", "}", "occurences", "by", "expansion" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/_extern.py#L430-L474
train
Resolve occurences by expansion
mottosso/be
be/vendor/requests/packages/urllib3/_collections.py
HTTPHeaderDict.add
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = key...
python
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = key...
[ "def", "add", "(", "self", ",", "key", ",", "val", ")", ":", "key_lower", "=", "key", ".", "lower", "(", ")", "new_vals", "=", "key", ",", "val", "# Keep the common case aka no item present as fast as possible", "vals", "=", "_dict_setdefault", "(", "self", ",...
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
[ "Adds", "a", "(", "name", "value", ")", "pair", "doesn", "t", "overwrite", "the", "value", "if", "it", "already", "exists", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L207-L228
train
Adds a ( name value ) pair to the dictionary. Doesn t overwrite the value if it already exists.
mottosso/be
be/vendor/requests/packages/urllib3/_collections.py
HTTPHeaderDict.getlist
def getlist(self, key): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = _dict_getitem(self, key.lower()) except KeyError: return [] else: if isinstance(vals, tuple): ...
python
def getlist(self, key): """Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.""" try: vals = _dict_getitem(self, key.lower()) except KeyError: return [] else: if isinstance(vals, tuple): ...
[ "def", "getlist", "(", "self", ",", "key", ")", ":", "try", ":", "vals", "=", "_dict_getitem", "(", "self", ",", "key", ".", "lower", "(", ")", ")", "except", "KeyError", ":", "return", "[", "]", "else", ":", "if", "isinstance", "(", "vals", ",", ...
Returns a list of all the values for the named field. Returns an empty list if the key doesn't exist.
[ "Returns", "a", "list", "of", "all", "the", "values", "for", "the", "named", "field", ".", "Returns", "an", "empty", "list", "if", "the", "key", "doesn", "t", "exist", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L256-L267
train
Returns a list of all the values for the named field. Returns an empty list if the key doesn t exist. Returns an empty list if the key doesn t exist. Returns an empty list if the key doesn t exist. Returns an empty list if the key doesn t exist. Returns an empty list if the key doesn t exist. Returns an empty list if t...
mottosso/be
be/vendor/requests/packages/urllib3/_collections.py
HTTPHeaderDict.iteritems
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = _dict_getitem(self, key) for val in vals[1:]: yield vals[0], val
python
def iteritems(self): """Iterate over all header lines, including duplicate ones.""" for key in self: vals = _dict_getitem(self, key) for val in vals[1:]: yield vals[0], val
[ "def", "iteritems", "(", "self", ")", ":", "for", "key", "in", "self", ":", "vals", "=", "_dict_getitem", "(", "self", ",", "key", ")", "for", "val", "in", "vals", "[", "1", ":", "]", ":", "yield", "vals", "[", "0", "]", ",", "val" ]
Iterate over all header lines, including duplicate ones.
[ "Iterate", "over", "all", "header", "lines", "including", "duplicate", "ones", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L290-L295
train
Iterate over all header lines including duplicate ones.
mottosso/be
be/vendor/requests/packages/urllib3/_collections.py
HTTPHeaderDict.itermerged
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = _dict_getitem(self, key) yield val[0], ', '.join(val[1:])
python
def itermerged(self): """Iterate over all headers, merging duplicate ones together.""" for key in self: val = _dict_getitem(self, key) yield val[0], ', '.join(val[1:])
[ "def", "itermerged", "(", "self", ")", ":", "for", "key", "in", "self", ":", "val", "=", "_dict_getitem", "(", "self", ",", "key", ")", "yield", "val", "[", "0", "]", ",", "', '", ".", "join", "(", "val", "[", "1", ":", "]", ")" ]
Iterate over all headers, merging duplicate ones together.
[ "Iterate", "over", "all", "headers", "merging", "duplicate", "ones", "together", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L297-L301
train
Iterate over all headers merging duplicate ones together.
mottosso/be
be/vendor/requests/packages/urllib3/_collections.py
HTTPHeaderDict.from_httplib
def from_httplib(cls, message, duplicates=('set-cookie',)): # Python 2 """Read headers from a Python 2 httplib message object.""" ret = cls(message.items()) # ret now contains only the last header line for each duplicate. # Importing with all duplicates would be nice, but this would ...
python
def from_httplib(cls, message, duplicates=('set-cookie',)): # Python 2 """Read headers from a Python 2 httplib message object.""" ret = cls(message.items()) # ret now contains only the last header line for each duplicate. # Importing with all duplicates would be nice, but this would ...
[ "def", "from_httplib", "(", "cls", ",", "message", ",", "duplicates", "=", "(", "'set-cookie'", ",", ")", ")", ":", "# Python 2", "ret", "=", "cls", "(", "message", ".", "items", "(", ")", ")", "# ret now contains only the last header line for each duplicate.", ...
Read headers from a Python 2 httplib message object.
[ "Read", "headers", "from", "a", "Python", "2", "httplib", "message", "object", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/_collections.py#L307-L320
train
Read headers from a Python 2 httplib message object.
mottosso/be
be/vendor/requests/packages/urllib3/request.py
RequestMethods.request_encode_url
def request_encode_url(self, method, url, fields=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if fields: url += '?' + urlencode(fields) ...
python
def request_encode_url(self, method, url, fields=None, **urlopen_kw): """ Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. """ if fields: url += '?' + urlencode(fields) ...
[ "def", "request_encode_url", "(", "self", ",", "method", ",", "url", ",", "fields", "=", "None", ",", "*", "*", "urlopen_kw", ")", ":", "if", "fields", ":", "url", "+=", "'?'", "+", "urlencode", "(", "fields", ")", "return", "self", ".", "urlopen", "...
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc.
[ "Make", "a", "request", "using", ":", "meth", ":", "urlopen", "with", "the", "fields", "encoded", "in", "the", "url", ".", "This", "is", "useful", "for", "request", "methods", "like", "GET", "HEAD", "DELETE", "etc", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/requests/packages/urllib3/request.py#L74-L81
train
Make a request using the method url and fields encoded in
mottosso/be
be/vendor/click/utils.py
make_str
def make_str(value): """Converts a value into a valid string.""" if isinstance(value, bytes): try: return value.decode(sys.getfilesystemencoding()) except UnicodeError: return value.decode('utf-8', 'replace') return text_type(value)
python
def make_str(value): """Converts a value into a valid string.""" if isinstance(value, bytes): try: return value.decode(sys.getfilesystemencoding()) except UnicodeError: return value.decode('utf-8', 'replace') return text_type(value)
[ "def", "make_str", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "try", ":", "return", "value", ".", "decode", "(", "sys", ".", "getfilesystemencoding", "(", ")", ")", "except", "UnicodeError", ":", "return", "value", ...
Converts a value into a valid string.
[ "Converts", "a", "value", "into", "a", "valid", "string", "." ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L89-L96
train
Converts a value into a valid string.
mottosso/be
be/vendor/click/utils.py
echo
def echo(message=None, file=None, nl=True, err=False, color=None): """Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the s...
python
def echo(message=None, file=None, nl=True, err=False, color=None): """Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the s...
[ "def", "echo", "(", "message", "=", "None", ",", "file", "=", "None", ",", "nl", "=", "True", ",", "err", "=", "False", ",", "color", "=", "None", ")", ":", "if", "file", "is", "None", ":", "if", "err", ":", "file", "=", "_default_text_stderr", "...
Prints a message plus a newline to the given file or stdout. On first sight, this looks like the print function, but it has improved support for handling Unicode and binary data that does not fail no matter how badly configured the system is. Primarily it means that you can print binary data as well a...
[ "Prints", "a", "message", "plus", "a", "newline", "to", "the", "given", "file", "or", "stdout", ".", "On", "first", "sight", "this", "looks", "like", "the", "print", "function", "but", "it", "has", "improved", "support", "for", "handling", "Unicode", "and"...
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/vendor/click/utils.py#L213-L296
train
Prints a message to the given file or stdout.
mottosso/be
be/lib.py
parent
def parent(): """Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.e...
python
def parent(): """Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.e...
[ "def", "parent", "(", ")", ":", "if", "self", ".", "_parent", ":", "return", "self", ".", "_parent", "if", "\"BE_SHELL\"", "in", "os", ".", "environ", ":", "self", ".", "_parent", "=", "os", ".", "environ", "[", "\"BE_SHELL\"", "]", "else", ":", "# I...
Determine subshell matching the currently running shell The shell is determined by either a pre-defined BE_SHELL environment variable, or, if none is found, via psutil which looks at the parent process directly through system-level calls. For example, is `be` is run from cmd.exe, then the full ...
[ "Determine", "subshell", "matching", "the", "currently", "running", "shell" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L23-L67
train
Determine the parent shell for the currently running shell.
mottosso/be
be/lib.py
platform
def platform(): """Return platform for the current shell, e.g. windows or unix""" executable = parent() basename = os.path.basename(executable) basename, _ = os.path.splitext(basename) if basename in ("bash", "sh"): return "unix" if basename in ("cmd", "powershell"): return "win...
python
def platform(): """Return platform for the current shell, e.g. windows or unix""" executable = parent() basename = os.path.basename(executable) basename, _ = os.path.splitext(basename) if basename in ("bash", "sh"): return "unix" if basename in ("cmd", "powershell"): return "win...
[ "def", "platform", "(", ")", ":", "executable", "=", "parent", "(", ")", "basename", "=", "os", ".", "path", ".", "basename", "(", "executable", ")", "basename", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "basename", ")", "if", "basename...
Return platform for the current shell, e.g. windows or unix
[ "Return", "platform", "for", "the", "current", "shell", "e", ".", "g", ".", "windows", "or", "unix" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L70-L81
train
Return the platform for the current shell e. g. windows unix or unix
mottosso/be
be/lib.py
cmd
def cmd(parent): """Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable """ shell_name = os.path.basename(parent).rsplit(".", 1)[0] dirname = os.path.dirname(__file__) # Support for Bash if shell_name in ("bash", "sh")...
python
def cmd(parent): """Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable """ shell_name = os.path.basename(parent).rsplit(".", 1)[0] dirname = os.path.dirname(__file__) # Support for Bash if shell_name in ("bash", "sh")...
[ "def", "cmd", "(", "parent", ")", ":", "shell_name", "=", "os", ".", "path", ".", "basename", "(", "parent", ")", ".", "rsplit", "(", "\".\"", ",", "1", ")", "[", "0", "]", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ...
Determine subshell command for subprocess.call Arguments: parent (str): Absolute path to parent shell executable
[ "Determine", "subshell", "command", "for", "subprocess", ".", "call" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L84-L114
train
Determine subshell command for subprocess. call Arguments : parent (str ) : Absolute path to parent shell executable
mottosso/be
be/lib.py
context
def context(root, project=""): """Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below. """ environment = os.environ.copy() environment.update({ "BE_PROJECT":...
python
def context(root, project=""): """Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below. """ environment = os.environ.copy() environment.update({ "BE_PROJECT":...
[ "def", "context", "(", "root", ",", "project", "=", "\"\"", ")", ":", "environment", "=", "os", ".", "environ", ".", "copy", "(", ")", "environment", ".", "update", "(", "{", "\"BE_PROJECT\"", ":", "project", ",", "\"BE_PROJECTROOT\"", ":", "(", "os", ...
Produce the be environment The environment is an exact replica of the active environment of the current process, with a few additional variables, all of which are listed below.
[ "Produce", "the", "be", "environment" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L117-L152
train
Produce the active be environment with additional variables and values listed below.
mottosso/be
be/lib.py
random_name
def random_name(): """Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus """ adj = _data.adjectives[random.randint(0, len(_data.adjectives) - 1)] noun = _data.nouns[random.randint(0, len(_data.nouns) - 1)] return "%s_%s" ...
python
def random_name(): """Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus """ adj = _data.adjectives[random.randint(0, len(_data.adjectives) - 1)] noun = _data.nouns[random.randint(0, len(_data.nouns) - 1)] return "%s_%s" ...
[ "def", "random_name", "(", ")", ":", "adj", "=", "_data", ".", "adjectives", "[", "random", ".", "randint", "(", "0", ",", "len", "(", "_data", ".", "adjectives", ")", "-", "1", ")", "]", "noun", "=", "_data", ".", "nouns", "[", "random", ".", "r...
Return a random name Example: >> random_name() dizzy_badge >> random_name() evasive_cactus
[ "Return", "a", "random", "name" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L155-L168
train
Return a random name of the available adjective and nouns.
mottosso/be
be/lib.py
isproject
def isproject(path): """Return whether or not `path` is a project Arguments: path (str): Absolute path """ try: if os.path.basename(path)[0] in (".", "_"): return False if not os.path.isdir(path): return False if not any(fname in os.listdir(path...
python
def isproject(path): """Return whether or not `path` is a project Arguments: path (str): Absolute path """ try: if os.path.basename(path)[0] in (".", "_"): return False if not os.path.isdir(path): return False if not any(fname in os.listdir(path...
[ "def", "isproject", "(", "path", ")", ":", "try", ":", "if", "os", ".", "path", ".", "basename", "(", "path", ")", "[", "0", "]", "in", "(", "\".\"", ",", "\"_\"", ")", ":", "return", "False", "if", "not", "os", ".", "path", ".", "isdir", "(", ...
Return whether or not `path` is a project Arguments: path (str): Absolute path
[ "Return", "whether", "or", "not", "path", "is", "a", "project" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L171-L191
train
Return whether or not path is a project
mottosso/be
be/lib.py
echo
def echo(text, silent=False, newline=True): """Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline. """ if silent: return ...
python
def echo(text, silent=False, newline=True): """Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline. """ if silent: return ...
[ "def", "echo", "(", "text", ",", "silent", "=", "False", ",", "newline", "=", "True", ")", ":", "if", "silent", ":", "return", "print", "(", "text", ")", "if", "newline", "else", "sys", ".", "stdout", ".", "write", "(", "text", ")" ]
Print to the console Arguments: text (str): Text to print to the console silen (bool, optional): Whether or not to produce any output newline (bool, optional): Whether or not to append a newline.
[ "Print", "to", "the", "console" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L194-L206
train
Print to the console
mottosso/be
be/lib.py
list_projects
def list_projects(root, backend=os.listdir): """List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. """ projects = list() for project in sorted(backend(root)): abspath = os.path.join(root, pro...
python
def list_projects(root, backend=os.listdir): """List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. """ projects = list() for project in sorted(backend(root)): abspath = os.path.join(root, pro...
[ "def", "list_projects", "(", "root", ",", "backend", "=", "os", ".", "listdir", ")", ":", "projects", "=", "list", "(", ")", "for", "project", "in", "sorted", "(", "backend", "(", "root", ")", ")", ":", "abspath", "=", "os", ".", "path", ".", "join...
List projects at `root` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory.
[ "List", "projects", "at", "root" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L209-L223
train
List all projects at root
mottosso/be
be/lib.py
list_inventory
def list_inventory(inventory): """List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml """ inv...
python
def list_inventory(inventory): """List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml """ inv...
[ "def", "list_inventory", "(", "inventory", ")", ":", "inverted", "=", "invert_inventory", "(", "inventory", ")", "items", "=", "list", "(", ")", "for", "item", "in", "sorted", "(", "inverted", ",", "key", "=", "lambda", "a", ":", "(", "inverted", "[", ...
List a projects inventory Given a project, simply list the contents of `inventory.yaml` Arguments: root (str): Absolute path to the `be` root directory, typically the current working directory. inventory (dict): inventory.yaml
[ "List", "a", "projects", "inventory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L226-L242
train
List a projects inventory Given a project simply list the contents of the inventory. yaml
mottosso/be
be/lib.py
list_template
def list_template(root, topics, templates, inventory, be, absolute=False): """List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list...
python
def list_template(root, topics, templates, inventory, be, absolute=False): """List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list...
[ "def", "list_template", "(", "root", ",", "topics", ",", "templates", ",", "inventory", ",", "be", ",", "absolute", "=", "False", ")", ":", "project", "=", "topics", "[", "0", "]", "# Get item", "try", ":", "key", "=", "be", ".", "get", "(", "\"templ...
List contents for resolved template Resolve a template as far as possible via the given `topics`. For example, if a template supports 5 arguments, but only 3 are given, resolve the template until its 4th argument and list the contents thereafter. In some cases, an additional path is present follow...
[ "List", "contents", "for", "resolved", "template" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L245-L324
train
List contents for resolved template
mottosso/be
be/lib.py
invert_inventory
def invert_inventory(inventory): """Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory """ inverted = dict() for binding, items in inventory.iteritems(): for...
python
def invert_inventory(inventory): """Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory """ inverted = dict() for binding, items in inventory.iteritems(): for...
[ "def", "invert_inventory", "(", "inventory", ")", ":", "inverted", "=", "dict", "(", ")", "for", "binding", ",", "items", "in", "inventory", ".", "iteritems", "(", ")", ":", "for", "item", "in", "items", ":", "if", "isinstance", "(", "item", ",", "dict...
Return {item: binding} from {binding: item} Protect against items with additional metadata and items whose type is a number Returns: Dictionary of inverted inventory
[ "Return", "{", "item", ":", "binding", "}", "from", "{", "binding", ":", "item", "}" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L327-L351
train
Invert the inventory by removing items with additional metadata and items whose type is a number
mottosso/be
be/lib.py
pos_development_directory
def pos_development_directory(templates, inventory, context, topics, user, item): """Return absolute path to development directory Arguments: templates (...
python
def pos_development_directory(templates, inventory, context, topics, user, item): """Return absolute path to development directory Arguments: templates (...
[ "def", "pos_development_directory", "(", "templates", ",", "inventory", ",", "context", ",", "topics", ",", "user", ",", "item", ")", ":", "replacement_fields", "=", "replacement_fields_from_context", "(", "context", ")", "binding", "=", "binding_from_item", "(", ...
Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` user (str): Current `be` user item (str): Item from template-bin...
[ "Return", "absolute", "path", "to", "development", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L358-L395
train
Return absolute path to development directory
mottosso/be
be/lib.py
fixed_development_directory
def fixed_development_directory(templates, inventory, topics, user): """Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` ...
python
def fixed_development_directory(templates, inventory, topics, user): """Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` ...
[ "def", "fixed_development_directory", "(", "templates", ",", "inventory", ",", "topics", ",", "user", ")", ":", "echo", "(", "\"Fixed syntax has been deprecated, see positional syntax\"", ")", "project", ",", "item", ",", "task", "=", "topics", "[", "0", "]", ".",...
Return absolute path to development directory Arguments: templates (dict): templates.yaml inventory (dict): inventory.yaml context (dict): The be context, from context() topics (list): Arguments to `in` user (str): Current `be` user
[ "Return", "absolute", "path", "to", "development", "directory" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L398-L439
train
Return absolute path to development directory
mottosso/be
be/lib.py
replacement_fields_from_context
def replacement_fields_from_context(context): """Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context """ return dict((k[3:].lower(), context[k]) for k in context if k.startswith("BE_"))
python
def replacement_fields_from_context(context): """Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context """ return dict((k[3:].lower(), context[k]) for k in context if k.startswith("BE_"))
[ "def", "replacement_fields_from_context", "(", "context", ")", ":", "return", "dict", "(", "(", "k", "[", "3", ":", "]", ".", "lower", "(", ")", ",", "context", "[", "k", "]", ")", "for", "k", "in", "context", "if", "k", ".", "startswith", "(", "\"...
Convert context replacement fields Example: BE_KEY=value -> {"key": "value} Arguments: context (dict): The current context
[ "Convert", "context", "replacement", "fields" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L442-L454
train
Convert context replacement fields from BE_KEY to key = value
mottosso/be
be/lib.py
item_from_topics
def item_from_topics(key, topics): """Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for t...
python
def item_from_topics(key, topics): """Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for t...
[ "def", "item_from_topics", "(", "key", ",", "topics", ")", ":", "if", "re", ".", "match", "(", "\"{\\d+}\"", ",", "key", ")", ":", "pos", "=", "int", "(", "key", ".", "strip", "(", "\"{}\"", ")", ")", "try", ":", "binding", "=", "topics", "[", "p...
Get binding from `topics` via `key` Example: {0} == hello --> be in hello world {1} == world --> be in hello world Returns: Single topic matching the key Raises: IndexError (int): With number of required arguments for the key
[ "Get", "binding", "from", "topics", "via", "key" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L457-L484
train
Get binding from topics via key
mottosso/be
be/lib.py
pattern_from_template
def pattern_from_template(templates, name): """Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name """ if name not in templates: echo("No template named \"%s\"" % name) sys.exit(1) return templates[name]
python
def pattern_from_template(templates, name): """Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name """ if name not in templates: echo("No template named \"%s\"" % name) sys.exit(1) return templates[name]
[ "def", "pattern_from_template", "(", "templates", ",", "name", ")", ":", "if", "name", "not", "in", "templates", ":", "echo", "(", "\"No template named \\\"%s\\\"\"", "%", "name", ")", "sys", ".", "exit", "(", "1", ")", "return", "templates", "[", "name", ...
Return pattern for name Arguments: templates (dict): Current templates name (str): Name of name
[ "Return", "pattern", "for", "name" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L510-L523
train
Return pattern for name
mottosso/be
be/lib.py
binding_from_item
def binding_from_item(inventory, item): """Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item """ if item in self.bindings: return self.bindings[item] bindin...
python
def binding_from_item(inventory, item): """Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item """ if item in self.bindings: return self.bindings[item] bindin...
[ "def", "binding_from_item", "(", "inventory", ",", "item", ")", ":", "if", "item", "in", "self", ".", "bindings", ":", "return", "self", ".", "bindings", "[", "item", "]", "bindings", "=", "invert_inventory", "(", "inventory", ")", "try", ":", "self", "....
Return binding for `item` Example: asset: - myasset The binding is "asset" Arguments: project: Name of project item (str): Name of item
[ "Return", "binding", "for", "item" ]
0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71
https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/lib.py#L526-L552
train
Return the binding for item