repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
minrk/findspark
findspark.py
_add_to_submit_args
def _add_to_submit_args(s): """Adds string s to the PYSPARK_SUBMIT_ARGS env var""" new_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "") + (" %s" % s) os.environ["PYSPARK_SUBMIT_ARGS"] = new_args return new_args
python
def _add_to_submit_args(s): """Adds string s to the PYSPARK_SUBMIT_ARGS env var""" new_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "") + (" %s" % s) os.environ["PYSPARK_SUBMIT_ARGS"] = new_args return new_args
[ "def", "_add_to_submit_args", "(", "s", ")", ":", "new_args", "=", "os", ".", "environ", ".", "get", "(", "\"PYSPARK_SUBMIT_ARGS\"", ",", "\"\"", ")", "+", "(", "\" %s\"", "%", "s", ")", "os", ".", "environ", "[", "\"PYSPARK_SUBMIT_ARGS\"", "]", "=", "ne...
Adds string s to the PYSPARK_SUBMIT_ARGS env var
[ "Adds", "string", "s", "to", "the", "PYSPARK_SUBMIT_ARGS", "env", "var" ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L149-L153
train
minrk/findspark
findspark.py
add_packages
def add_packages(packages): """Add external packages to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- packages: list of package names in string format """ #if the parameter is a string, convert to a single element list if isinstance(packages,str)...
python
def add_packages(packages): """Add external packages to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- packages: list of package names in string format """ #if the parameter is a string, convert to a single element list if isinstance(packages,str)...
[ "def", "add_packages", "(", "packages", ")", ":", "if", "isinstance", "(", "packages", ",", "str", ")", ":", "packages", "=", "[", "packages", "]", "_add_to_submit_args", "(", "\"--packages \"", "+", "\",\"", ".", "join", "(", "packages", ")", "+", "\" pys...
Add external packages to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- packages: list of package names in string format
[ "Add", "external", "packages", "to", "the", "pyspark", "interpreter", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L155-L169
train
minrk/findspark
findspark.py
add_jars
def add_jars(jars): """Add external jars to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- jars: list of path to jars in string format """ #if the parameter is a string, convert to a single element list if isinstance(jars,str): jars = [jar...
python
def add_jars(jars): """Add external jars to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- jars: list of path to jars in string format """ #if the parameter is a string, convert to a single element list if isinstance(jars,str): jars = [jar...
[ "def", "add_jars", "(", "jars", ")", ":", "if", "isinstance", "(", "jars", ",", "str", ")", ":", "jars", "=", "[", "jars", "]", "_add_to_submit_args", "(", "\"--jars \"", "+", "\",\"", ".", "join", "(", "jars", ")", "+", "\" pyspark-shell\"", ")" ]
Add external jars to the pyspark interpreter. Set the PYSPARK_SUBMIT_ARGS properly. Parameters ---------- jars: list of path to jars in string format
[ "Add", "external", "jars", "to", "the", "pyspark", "interpreter", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L171-L185
train
sdispater/cleo
cleo/parser.py
Parser.parse
def parse(cls, expression): """ Parse the given console command definition into a dict. :param expression: The expression to parse :type expression: str :rtype: dict """ parsed = {"name": None, "arguments": [], "options": []} if not expression.strip(): ...
python
def parse(cls, expression): """ Parse the given console command definition into a dict. :param expression: The expression to parse :type expression: str :rtype: dict """ parsed = {"name": None, "arguments": [], "options": []} if not expression.strip(): ...
[ "def", "parse", "(", "cls", ",", "expression", ")", ":", "parsed", "=", "{", "\"name\"", ":", "None", ",", "\"arguments\"", ":", "[", "]", ",", "\"options\"", ":", "[", "]", "}", "if", "not", "expression", ".", "strip", "(", ")", ":", "raise", "Val...
Parse the given console command definition into a dict. :param expression: The expression to parse :type expression: str :rtype: dict
[ "Parse", "the", "given", "console", "command", "definition", "into", "a", "dict", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L16-L45
train
sdispater/cleo
cleo/parser.py
Parser._parameters
def _parameters(cls, tokens): """ Extract all of the parameters from the tokens. :param tokens: The tokens to extract the parameters from :type tokens: list :rtype: dict """ arguments = [] options = [] for token in tokens: if not tok...
python
def _parameters(cls, tokens): """ Extract all of the parameters from the tokens. :param tokens: The tokens to extract the parameters from :type tokens: list :rtype: dict """ arguments = [] options = [] for token in tokens: if not tok...
[ "def", "_parameters", "(", "cls", ",", "tokens", ")", ":", "arguments", "=", "[", "]", "options", "=", "[", "]", "for", "token", "in", "tokens", ":", "if", "not", "token", ".", "startswith", "(", "\"--\"", ")", ":", "arguments", ".", "append", "(", ...
Extract all of the parameters from the tokens. :param tokens: The tokens to extract the parameters from :type tokens: list :rtype: dict
[ "Extract", "all", "of", "the", "parameters", "from", "the", "tokens", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L48-L66
train
sdispater/cleo
cleo/parser.py
Parser._parse_argument
def _parse_argument(cls, token): """ Parse an argument expression. :param token: The argument expression :type token: str :rtype: InputArgument """ description = "" validator = None if " : " in token: token, description = tuple(token...
python
def _parse_argument(cls, token): """ Parse an argument expression. :param token: The argument expression :type token: str :rtype: InputArgument """ description = "" validator = None if " : " in token: token, description = tuple(token...
[ "def", "_parse_argument", "(", "cls", ",", "token", ")", ":", "description", "=", "\"\"", "validator", "=", "None", "if", "\" : \"", "in", "token", ":", "token", ",", "description", "=", "tuple", "(", "token", ".", "split", "(", "\" : \"", ",", "2", ")...
Parse an argument expression. :param token: The argument expression :type token: str :rtype: InputArgument
[ "Parse", "an", "argument", "expression", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L69-L117
train
sdispater/cleo
cleo/parser.py
Parser._parse_option
def _parse_option(cls, token): """ Parse an option expression. :param token: The option expression :type token: str :rtype: InputOption """ description = "" validator = None if " : " in token: token, description = tuple(token.split("...
python
def _parse_option(cls, token): """ Parse an option expression. :param token: The option expression :type token: str :rtype: InputOption """ description = "" validator = None if " : " in token: token, description = tuple(token.split("...
[ "def", "_parse_option", "(", "cls", ",", "token", ")", ":", "description", "=", "\"\"", "validator", "=", "None", "if", "\" : \"", "in", "token", ":", "token", ",", "description", "=", "tuple", "(", "token", ".", "split", "(", "\" : \"", ",", "2", ")",...
Parse an option expression. :param token: The option expression :type token: str :rtype: InputOption
[ "Parse", "an", "option", "expression", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/parser.py#L120-L186
train
sdispater/cleo
cleo/application.py
Application.add
def add(self, command): # type: (BaseCommand) -> Application """ Adds a command object. """ self.add_command(command.config) command.set_application(self) return self
python
def add(self, command): # type: (BaseCommand) -> Application """ Adds a command object. """ self.add_command(command.config) command.set_application(self) return self
[ "def", "add", "(", "self", ",", "command", ")", ":", "self", ".", "add_command", "(", "command", ".", "config", ")", "command", ".", "set_application", "(", "self", ")", "return", "self" ]
Adds a command object.
[ "Adds", "a", "command", "object", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/application.py#L38-L45
train
sdispater/cleo
cleo/commands/command.py
Command._configure_using_fluent_definition
def _configure_using_fluent_definition(self): """ Configure the console command using a fluent definition. """ definition = Parser.parse(self.signature) self._config.set_name(definition["name"]) for name, flags, description, default in definition["arguments"]: ...
python
def _configure_using_fluent_definition(self): """ Configure the console command using a fluent definition. """ definition = Parser.parse(self.signature) self._config.set_name(definition["name"]) for name, flags, description, default in definition["arguments"]: ...
[ "def", "_configure_using_fluent_definition", "(", "self", ")", ":", "definition", "=", "Parser", ".", "parse", "(", "self", ".", "signature", ")", "self", ".", "_config", ".", "set_name", "(", "definition", "[", "\"name\"", "]", ")", "for", "name", ",", "f...
Configure the console command using a fluent definition.
[ "Configure", "the", "console", "command", "using", "a", "fluent", "definition", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L71-L83
train
sdispater/cleo
cleo/commands/command.py
Command.argument
def argument(self, key=None): """ Get the value of a command argument. """ if key is None: return self._args.arguments() return self._args.argument(key)
python
def argument(self, key=None): """ Get the value of a command argument. """ if key is None: return self._args.arguments() return self._args.argument(key)
[ "def", "argument", "(", "self", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "return", "self", ".", "_args", ".", "arguments", "(", ")", "return", "self", ".", "_args", ".", "argument", "(", "key", ")" ]
Get the value of a command argument.
[ "Get", "the", "value", "of", "a", "command", "argument", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L124-L131
train
sdispater/cleo
cleo/commands/command.py
Command.option
def option(self, key=None): """ Get the value of a command option. """ if key is None: return self._args.options() return self._args.option(key)
python
def option(self, key=None): """ Get the value of a command option. """ if key is None: return self._args.options() return self._args.option(key)
[ "def", "option", "(", "self", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "return", "self", ".", "_args", ".", "options", "(", ")", "return", "self", ".", "_args", ".", "option", "(", "key", ")" ]
Get the value of a command option.
[ "Get", "the", "value", "of", "a", "command", "option", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L133-L140
train
sdispater/cleo
cleo/commands/command.py
Command.confirm
def confirm(self, question, default=False, true_answer_regex="(?i)^y"): """ Confirm a question with the user. """ return self._io.confirm(question, default, true_answer_regex)
python
def confirm(self, question, default=False, true_answer_regex="(?i)^y"): """ Confirm a question with the user. """ return self._io.confirm(question, default, true_answer_regex)
[ "def", "confirm", "(", "self", ",", "question", ",", "default", "=", "False", ",", "true_answer_regex", "=", "\"(?i)^y\"", ")", ":", "return", "self", ".", "_io", ".", "confirm", "(", "question", ",", "default", ",", "true_answer_regex", ")" ]
Confirm a question with the user.
[ "Confirm", "a", "question", "with", "the", "user", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L142-L146
train
sdispater/cleo
cleo/commands/command.py
Command.ask
def ask(self, question, default=None): """ Prompt the user for input. """ if isinstance(question, Question): return self._io.ask_question(question) return self._io.ask(question, default)
python
def ask(self, question, default=None): """ Prompt the user for input. """ if isinstance(question, Question): return self._io.ask_question(question) return self._io.ask(question, default)
[ "def", "ask", "(", "self", ",", "question", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "question", ",", "Question", ")", ":", "return", "self", ".", "_io", ".", "ask_question", "(", "question", ")", "return", "self", ".", "_io", ...
Prompt the user for input.
[ "Prompt", "the", "user", "for", "input", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L148-L155
train
sdispater/cleo
cleo/commands/command.py
Command.choice
def choice(self, question, choices, default=None, attempts=None, multiple=False): """ Give the user a single choice from an list of answers. """ question = ChoiceQuestion(question, choices, default) question.set_max_attempts(attempts) question.set_multi_select(multiple) ...
python
def choice(self, question, choices, default=None, attempts=None, multiple=False): """ Give the user a single choice from an list of answers. """ question = ChoiceQuestion(question, choices, default) question.set_max_attempts(attempts) question.set_multi_select(multiple) ...
[ "def", "choice", "(", "self", ",", "question", ",", "choices", ",", "default", "=", "None", ",", "attempts", "=", "None", ",", "multiple", "=", "False", ")", ":", "question", "=", "ChoiceQuestion", "(", "question", ",", "choices", ",", "default", ")", ...
Give the user a single choice from an list of answers.
[ "Give", "the", "user", "a", "single", "choice", "from", "an", "list", "of", "answers", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L163-L172
train
sdispater/cleo
cleo/commands/command.py
Command.create_question
def create_question(self, question, type=None, **kwargs): """ Returns a Question of specified type. """ if not type: return Question(question, **kwargs) if type == "choice": return ChoiceQuestion(question, **kwargs) if type == "confirmation": ...
python
def create_question(self, question, type=None, **kwargs): """ Returns a Question of specified type. """ if not type: return Question(question, **kwargs) if type == "choice": return ChoiceQuestion(question, **kwargs) if type == "confirmation": ...
[ "def", "create_question", "(", "self", ",", "question", ",", "type", "=", "None", ",", "**", "kwargs", ")", ":", "if", "not", "type", ":", "return", "Question", "(", "question", ",", "**", "kwargs", ")", "if", "type", "==", "\"choice\"", ":", "return",...
Returns a Question of specified type.
[ "Returns", "a", "Question", "of", "specified", "type", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L174-L185
train
sdispater/cleo
cleo/commands/command.py
Command.table
def table(self, header=None, rows=None, style=None): """ Return a Table instance. """ if style is not None: style = self.TABLE_STYLES[style] table = Table(style) if header: table.set_header_row(header) if rows: table.set_rows...
python
def table(self, header=None, rows=None, style=None): """ Return a Table instance. """ if style is not None: style = self.TABLE_STYLES[style] table = Table(style) if header: table.set_header_row(header) if rows: table.set_rows...
[ "def", "table", "(", "self", ",", "header", "=", "None", ",", "rows", "=", "None", ",", "style", "=", "None", ")", ":", "if", "style", "is", "not", "None", ":", "style", "=", "self", ".", "TABLE_STYLES", "[", "style", "]", "table", "=", "Table", ...
Return a Table instance.
[ "Return", "a", "Table", "instance", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L187-L202
train
sdispater/cleo
cleo/commands/command.py
Command.render_table
def render_table(self, headers, rows, style=None): """ Format input to textual table. """ table = self.table(headers, rows, style) table.render(self._io)
python
def render_table(self, headers, rows, style=None): """ Format input to textual table. """ table = self.table(headers, rows, style) table.render(self._io)
[ "def", "render_table", "(", "self", ",", "headers", ",", "rows", ",", "style", "=", "None", ")", ":", "table", "=", "self", ".", "table", "(", "headers", ",", "rows", ",", "style", ")", "table", ".", "render", "(", "self", ".", "_io", ")" ]
Format input to textual table.
[ "Format", "input", "to", "textual", "table", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L204-L210
train
sdispater/cleo
cleo/commands/command.py
Command.line
def line(self, text, style=None, verbosity=None): """ Write a string as information output. """ if style: styled = "<%s>%s</>" % (style, text) else: styled = text self._io.write_line(styled, verbosity)
python
def line(self, text, style=None, verbosity=None): """ Write a string as information output. """ if style: styled = "<%s>%s</>" % (style, text) else: styled = text self._io.write_line(styled, verbosity)
[ "def", "line", "(", "self", ",", "text", ",", "style", "=", "None", ",", "verbosity", "=", "None", ")", ":", "if", "style", ":", "styled", "=", "\"<%s>%s</>\"", "%", "(", "style", ",", "text", ")", "else", ":", "styled", "=", "text", "self", ".", ...
Write a string as information output.
[ "Write", "a", "string", "as", "information", "output", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L224-L233
train
sdispater/cleo
cleo/commands/command.py
Command.line_error
def line_error(self, text, style=None, verbosity=None): """ Write a string as information output to stderr. """ if style: styled = "<%s>%s</>" % (style, text) else: styled = text self._io.error_line(styled, verbosity)
python
def line_error(self, text, style=None, verbosity=None): """ Write a string as information output to stderr. """ if style: styled = "<%s>%s</>" % (style, text) else: styled = text self._io.error_line(styled, verbosity)
[ "def", "line_error", "(", "self", ",", "text", ",", "style", "=", "None", ",", "verbosity", "=", "None", ")", ":", "if", "style", ":", "styled", "=", "\"<%s>%s</>\"", "%", "(", "style", ",", "text", ")", "else", ":", "styled", "=", "text", "self", ...
Write a string as information output to stderr.
[ "Write", "a", "string", "as", "information", "output", "to", "stderr", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L235-L244
train
sdispater/cleo
cleo/commands/command.py
Command.progress_indicator
def progress_indicator(self, fmt=None, interval=100, values=None): """ Creates a new progress indicator. """ return ProgressIndicator(self.io, fmt, interval, values)
python
def progress_indicator(self, fmt=None, interval=100, values=None): """ Creates a new progress indicator. """ return ProgressIndicator(self.io, fmt, interval, values)
[ "def", "progress_indicator", "(", "self", ",", "fmt", "=", "None", ",", "interval", "=", "100", ",", "values", "=", "None", ")", ":", "return", "ProgressIndicator", "(", "self", ".", "io", ",", "fmt", ",", "interval", ",", "values", ")" ]
Creates a new progress indicator.
[ "Creates", "a", "new", "progress", "indicator", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L284-L288
train
sdispater/cleo
cleo/commands/command.py
Command.spin
def spin(self, start_message, end_message, fmt=None, interval=100, values=None): """ Automatically spin a progress indicator. """ spinner = ProgressIndicator(self.io, fmt, interval, values) return spinner.auto(start_message, end_message)
python
def spin(self, start_message, end_message, fmt=None, interval=100, values=None): """ Automatically spin a progress indicator. """ spinner = ProgressIndicator(self.io, fmt, interval, values) return spinner.auto(start_message, end_message)
[ "def", "spin", "(", "self", ",", "start_message", ",", "end_message", ",", "fmt", "=", "None", ",", "interval", "=", "100", ",", "values", "=", "None", ")", ":", "spinner", "=", "ProgressIndicator", "(", "self", ".", "io", ",", "fmt", ",", "interval", ...
Automatically spin a progress indicator.
[ "Automatically", "spin", "a", "progress", "indicator", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L290-L296
train
sdispater/cleo
cleo/commands/command.py
Command.add_style
def add_style(self, name, fg=None, bg=None, options=None): """ Adds a new style """ style = Style(name) if fg is not None: style.fg(fg) if bg is not None: style.bg(bg) if options is not None: if "bold" in options: ...
python
def add_style(self, name, fg=None, bg=None, options=None): """ Adds a new style """ style = Style(name) if fg is not None: style.fg(fg) if bg is not None: style.bg(bg) if options is not None: if "bold" in options: ...
[ "def", "add_style", "(", "self", ",", "name", ",", "fg", "=", "None", ",", "bg", "=", "None", ",", "options", "=", "None", ")", ":", "style", "=", "Style", "(", "name", ")", "if", "fg", "is", "not", "None", ":", "style", ".", "fg", "(", "fg", ...
Adds a new style
[ "Adds", "a", "new", "style" ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L298-L317
train
sdispater/cleo
cleo/commands/command.py
Command.overwrite
def overwrite(self, text, size=None): """ Overwrites the current line. It will not add a new line so use line('') if necessary. """ self._io.overwrite(text, size=size)
python
def overwrite(self, text, size=None): """ Overwrites the current line. It will not add a new line so use line('') if necessary. """ self._io.overwrite(text, size=size)
[ "def", "overwrite", "(", "self", ",", "text", ",", "size", "=", "None", ")", ":", "self", ".", "_io", ".", "overwrite", "(", "text", ",", "size", "=", "size", ")" ]
Overwrites the current line. It will not add a new line so use line('') if necessary.
[ "Overwrites", "the", "current", "line", "." ]
cf44ac2eba2d6435516501e47e5521ee2da9115a
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L319-L326
train
Mergifyio/git-pull-request
git_pull_request/__init__.py
get_github_hostname_user_repo_from_url
def get_github_hostname_user_repo_from_url(url): """Return hostname, user and repository to fork from. :param url: The URL to parse :return: hostname, user, repository """ parsed = parse.urlparse(url) if parsed.netloc == '': # Probably ssh host, sep, path = parsed.path.partition...
python
def get_github_hostname_user_repo_from_url(url): """Return hostname, user and repository to fork from. :param url: The URL to parse :return: hostname, user, repository """ parsed = parse.urlparse(url) if parsed.netloc == '': # Probably ssh host, sep, path = parsed.path.partition...
[ "def", "get_github_hostname_user_repo_from_url", "(", "url", ")", ":", "parsed", "=", "parse", ".", "urlparse", "(", "url", ")", "if", "parsed", ".", "netloc", "==", "''", ":", "host", ",", "sep", ",", "path", "=", "parsed", ".", "path", ".", "partition"...
Return hostname, user and repository to fork from. :param url: The URL to parse :return: hostname, user, repository
[ "Return", "hostname", "user", "and", "repository", "to", "fork", "from", "." ]
58dbe3325b3dfada02482a32223fb36ebb193248
https://github.com/Mergifyio/git-pull-request/blob/58dbe3325b3dfada02482a32223fb36ebb193248/git_pull_request/__init__.py#L114-L130
train
Mergifyio/git-pull-request
git_pull_request/__init__.py
git_get_title_and_message
def git_get_title_and_message(begin, end): """Get title and message summary for patches between 2 commits. :param begin: first commit to look at :param end: last commit to look at :return: number of commits, title, message """ titles = git_get_log_titles(begin, end) title = "Pull request fo...
python
def git_get_title_and_message(begin, end): """Get title and message summary for patches between 2 commits. :param begin: first commit to look at :param end: last commit to look at :return: number of commits, title, message """ titles = git_get_log_titles(begin, end) title = "Pull request fo...
[ "def", "git_get_title_and_message", "(", "begin", ",", "end", ")", ":", "titles", "=", "git_get_log_titles", "(", "begin", ",", "end", ")", "title", "=", "\"Pull request for \"", "+", "end", "if", "len", "(", "titles", ")", "==", "1", ":", "title", "=", ...
Get title and message summary for patches between 2 commits. :param begin: first commit to look at :param end: last commit to look at :return: number of commits, title, message
[ "Get", "title", "and", "message", "summary", "for", "patches", "between", "2", "commits", "." ]
58dbe3325b3dfada02482a32223fb36ebb193248
https://github.com/Mergifyio/git-pull-request/blob/58dbe3325b3dfada02482a32223fb36ebb193248/git_pull_request/__init__.py#L160-L180
train
zhebrak/raftos
raftos/state.py
validate_commit_index
def validate_commit_index(func): """Apply to State Machine everything up to commit index""" @functools.wraps(func) def wrapped(self, *args, **kwargs): for not_applied in range(self.log.last_applied + 1, self.log.commit_index + 1): self.state_machine.apply(self.log[not_applied]['command'...
python
def validate_commit_index(func): """Apply to State Machine everything up to commit index""" @functools.wraps(func) def wrapped(self, *args, **kwargs): for not_applied in range(self.log.last_applied + 1, self.log.commit_index + 1): self.state_machine.apply(self.log[not_applied]['command'...
[ "def", "validate_commit_index", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "not_applied", "in", "range", "(", "self", ".", "log", "."...
Apply to State Machine everything up to commit index
[ "Apply", "to", "State", "Machine", "everything", "up", "to", "commit", "index" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L42-L57
train
zhebrak/raftos
raftos/state.py
Leader.execute_command
async def execute_command(self, command): """Write to log & send AppendEntries RPC""" self.apply_future = asyncio.Future(loop=self.loop) entry = self.log.write(self.storage.term, command) asyncio.ensure_future(self.append_entries(), loop=self.loop) await self.apply_future
python
async def execute_command(self, command): """Write to log & send AppendEntries RPC""" self.apply_future = asyncio.Future(loop=self.loop) entry = self.log.write(self.storage.term, command) asyncio.ensure_future(self.append_entries(), loop=self.loop) await self.apply_future
[ "async", "def", "execute_command", "(", "self", ",", "command", ")", ":", "self", ".", "apply_future", "=", "asyncio", ".", "Future", "(", "loop", "=", "self", ".", "loop", ")", "entry", "=", "self", ".", "log", ".", "write", "(", "self", ".", "stora...
Write to log & send AppendEntries RPC
[ "Write", "to", "log", "&", "send", "AppendEntries", "RPC" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L260-L267
train
zhebrak/raftos
raftos/state.py
Candidate.start
def start(self): """Increment current term, vote for herself & send vote requests""" self.storage.update({ 'term': self.storage.term + 1, 'voted_for': self.id }) self.vote_count = 1 self.request_vote() self.election_timer.start()
python
def start(self): """Increment current term, vote for herself & send vote requests""" self.storage.update({ 'term': self.storage.term + 1, 'voted_for': self.id }) self.vote_count = 1 self.request_vote() self.election_timer.start()
[ "def", "start", "(", "self", ")", ":", "self", ".", "storage", ".", "update", "(", "{", "'term'", ":", "self", ".", "storage", ".", "term", "+", "1", ",", "'voted_for'", ":", "self", ".", "id", "}", ")", "self", ".", "vote_count", "=", "1", "self...
Increment current term, vote for herself & send vote requests
[ "Increment", "current", "term", "vote", "for", "herself", "&", "send", "vote", "requests" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L293-L302
train
zhebrak/raftos
raftos/state.py
Candidate.on_receive_request_vote_response
def on_receive_request_vote_response(self, data): """Receives response for vote request. If the vote was granted then check if we got majority and may become Leader """ if data.get('vote_granted'): self.vote_count += 1 if self.state.is_majority(self.vote_count):...
python
def on_receive_request_vote_response(self, data): """Receives response for vote request. If the vote was granted then check if we got majority and may become Leader """ if data.get('vote_granted'): self.vote_count += 1 if self.state.is_majority(self.vote_count):...
[ "def", "on_receive_request_vote_response", "(", "self", ",", "data", ")", ":", "if", "data", ".", "get", "(", "'vote_granted'", ")", ":", "self", ".", "vote_count", "+=", "1", "if", "self", ".", "state", ".", "is_majority", "(", "self", ".", "vote_count", ...
Receives response for vote request. If the vote was granted then check if we got majority and may become Leader
[ "Receives", "response", "for", "vote", "request", ".", "If", "the", "vote", "was", "granted", "then", "check", "if", "we", "got", "majority", "and", "may", "become", "Leader" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L326-L335
train
zhebrak/raftos
raftos/state.py
Follower.init_storage
def init_storage(self): """Set current term to zero upon initialization & voted_for to None""" if not self.storage.exists('term'): self.storage.update({ 'term': 0, }) self.storage.update({ 'voted_for': None })
python
def init_storage(self): """Set current term to zero upon initialization & voted_for to None""" if not self.storage.exists('term'): self.storage.update({ 'term': 0, }) self.storage.update({ 'voted_for': None })
[ "def", "init_storage", "(", "self", ")", ":", "if", "not", "self", ".", "storage", ".", "exists", "(", "'term'", ")", ":", "self", ".", "storage", ".", "update", "(", "{", "'term'", ":", "0", ",", "}", ")", "self", ".", "storage", ".", "update", ...
Set current term to zero upon initialization & voted_for to None
[ "Set", "current", "term", "to", "zero", "upon", "initialization", "&", "voted_for", "to", "None" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L368-L377
train
zhebrak/raftos
raftos/state.py
State.wait_for_election_success
async def wait_for_election_success(cls): """Await this function if your cluster must have a leader""" if cls.leader is None: cls.leader_future = asyncio.Future(loop=cls.loop) await cls.leader_future
python
async def wait_for_election_success(cls): """Await this function if your cluster must have a leader""" if cls.leader is None: cls.leader_future = asyncio.Future(loop=cls.loop) await cls.leader_future
[ "async", "def", "wait_for_election_success", "(", "cls", ")", ":", "if", "cls", ".", "leader", "is", "None", ":", "cls", ".", "leader_future", "=", "asyncio", ".", "Future", "(", "loop", "=", "cls", ".", "loop", ")", "await", "cls", ".", "leader_future" ...
Await this function if your cluster must have a leader
[ "Await", "this", "function", "if", "your", "cluster", "must", "have", "a", "leader" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L597-L601
train
zhebrak/raftos
raftos/state.py
State.wait_until_leader
async def wait_until_leader(cls, node_id): """Await this function if you want to do nothing until node_id becomes a leader""" if node_id is None: raise ValueError('Node id can not be None!') if cls.get_leader() != node_id: cls.wait_until_leader_id = node_id c...
python
async def wait_until_leader(cls, node_id): """Await this function if you want to do nothing until node_id becomes a leader""" if node_id is None: raise ValueError('Node id can not be None!') if cls.get_leader() != node_id: cls.wait_until_leader_id = node_id c...
[ "async", "def", "wait_until_leader", "(", "cls", ",", "node_id", ")", ":", "if", "node_id", "is", "None", ":", "raise", "ValueError", "(", "'Node id can not be None!'", ")", "if", "cls", ".", "get_leader", "(", ")", "!=", "node_id", ":", "cls", ".", "wait_...
Await this function if you want to do nothing until node_id becomes a leader
[ "Await", "this", "function", "if", "you", "want", "to", "do", "nothing", "until", "node_id", "becomes", "a", "leader" ]
0d6f9e049b526279b1035f597291a96cf50c9b40
https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L604-L615
train
datajoint/datajoint-python
datajoint/declare.py
declare
def declare(full_table_name, definition, context): """ Parse declaration and create new SQL table accordingly. :param full_table_name: full name of the table :param definition: DataJoint table definition :param context: dictionary of objects that might be referred to in the table. """ tabl...
python
def declare(full_table_name, definition, context): """ Parse declaration and create new SQL table accordingly. :param full_table_name: full name of the table :param definition: DataJoint table definition :param context: dictionary of objects that might be referred to in the table. """ tabl...
[ "def", "declare", "(", "full_table_name", ",", "definition", ",", "context", ")", ":", "table_name", "=", "full_table_name", ".", "strip", "(", "'`'", ")", ".", "split", "(", "'.'", ")", "[", "1", "]", "if", "len", "(", "table_name", ")", ">", "MAX_TAB...
Parse declaration and create new SQL table accordingly. :param full_table_name: full name of the table :param definition: DataJoint table definition :param context: dictionary of objects that might be referred to in the table.
[ "Parse", "declaration", "and", "create", "new", "SQL", "table", "accordingly", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/declare.py#L192-L245
train
datajoint/datajoint-python
datajoint/schema.py
create_virtual_module
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None): """ Creates a python module with the given name from the name of a schema on the server and automatically adds classes to it corresponding to the tables in the schema. :param module_name: dis...
python
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None): """ Creates a python module with the given name from the name of a schema on the server and automatically adds classes to it corresponding to the tables in the schema. :param module_name: dis...
[ "def", "create_virtual_module", "(", "module_name", ",", "schema_name", ",", "create_schema", "=", "False", ",", "create_tables", "=", "False", ",", "connection", "=", "None", ")", ":", "module", "=", "types", ".", "ModuleType", "(", "module_name", ")", "_sche...
Creates a python module with the given name from the name of a schema on the server and automatically adds classes to it corresponding to the tables in the schema. :param module_name: displayed module name :param schema_name: name of the database in mysql :param create_schema: if True, create the schem...
[ "Creates", "a", "python", "module", "with", "the", "given", "name", "from", "the", "name", "of", "a", "schema", "on", "the", "server", "and", "automatically", "adds", "classes", "to", "it", "corresponding", "to", "the", "tables", "in", "the", "schema", "."...
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L241-L256
train
datajoint/datajoint-python
datajoint/schema.py
Schema.drop
def drop(self, force=False): """ Drop the associated schema if it exists """ if not self.exists: logger.info("Schema named `{database}` does not exist. Doing nothing.".format(database=self.database)) elif (not config['safemode'] or force or ...
python
def drop(self, force=False): """ Drop the associated schema if it exists """ if not self.exists: logger.info("Schema named `{database}` does not exist. Doing nothing.".format(database=self.database)) elif (not config['safemode'] or force or ...
[ "def", "drop", "(", "self", ",", "force", "=", "False", ")", ":", "if", "not", "self", ".", "exists", ":", "logger", ".", "info", "(", "\"Schema named `{database}` does not exist. Doing nothing.\"", ".", "format", "(", "database", "=", "self", ".", "database",...
Drop the associated schema if it exists
[ "Drop", "the", "associated", "schema", "if", "it", "exists" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L146-L161
train
datajoint/datajoint-python
datajoint/schema.py
Schema.process_relation_class
def process_relation_class(self, relation_class, context, assert_declared=False): """ assign schema properties to the relation class and declare the table """ relation_class.database = self.database relation_class._connection = self.connection relation_class._heading = He...
python
def process_relation_class(self, relation_class, context, assert_declared=False): """ assign schema properties to the relation class and declare the table """ relation_class.database = self.database relation_class._connection = self.connection relation_class._heading = He...
[ "def", "process_relation_class", "(", "self", ",", "relation_class", ",", "context", ",", "assert_declared", "=", "False", ")", ":", "relation_class", ".", "database", "=", "self", ".", "database", "relation_class", ".", "_connection", "=", "self", ".", "connect...
assign schema properties to the relation class and declare the table
[ "assign", "schema", "properties", "to", "the", "relation", "class", "and", "declare", "the", "table" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/schema.py#L171-L197
train
datajoint/datajoint-python
datajoint/table.py
Table.declare
def declare(self, context=None): """ Use self.definition to declare the table in the schema. """ try: sql, uses_external = declare(self.full_table_name, self.definition, context) if uses_external: sql = sql.format(external_table=self.external_table...
python
def declare(self, context=None): """ Use self.definition to declare the table in the schema. """ try: sql, uses_external = declare(self.full_table_name, self.definition, context) if uses_external: sql = sql.format(external_table=self.external_table...
[ "def", "declare", "(", "self", ",", "context", "=", "None", ")", ":", "try", ":", "sql", ",", "uses_external", "=", "declare", "(", "self", ".", "full_table_name", ",", "self", ".", "definition", ",", "context", ")", "if", "uses_external", ":", "sql", ...
Use self.definition to declare the table in the schema.
[ "Use", "self", ".", "definition", "to", "declare", "the", "table", "in", "the", "schema", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L58-L74
train
datajoint/datajoint-python
datajoint/table.py
Table.delete_quick
def delete_quick(self, get_count=False): """ Deletes the table without cascading and without user prompt. If this table has populated dependent tables, this will fail. """ query = 'DELETE FROM ' + self.full_table_name + self.where_clause self.connection.query(query) ...
python
def delete_quick(self, get_count=False): """ Deletes the table without cascading and without user prompt. If this table has populated dependent tables, this will fail. """ query = 'DELETE FROM ' + self.full_table_name + self.where_clause self.connection.query(query) ...
[ "def", "delete_quick", "(", "self", ",", "get_count", "=", "False", ")", ":", "query", "=", "'DELETE FROM '", "+", "self", ".", "full_table_name", "+", "self", ".", "where_clause", "self", ".", "connection", ".", "query", "(", "query", ")", "count", "=", ...
Deletes the table without cascading and without user prompt. If this table has populated dependent tables, this will fail.
[ "Deletes", "the", "table", "without", "cascading", "and", "without", "user", "prompt", ".", "If", "this", "table", "has", "populated", "dependent", "tables", "this", "will", "fail", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L313-L322
train
datajoint/datajoint-python
datajoint/table.py
Table._update
def _update(self, attrname, value=None): """ Updates a field in an existing tuple. This is not a datajoyous operation and should not be used routinely. Relational database maintain referential integrity on the level of a tuple. Therefore, the UPDATE operator can violate refer...
python
def _update(self, attrname, value=None): """ Updates a field in an existing tuple. This is not a datajoyous operation and should not be used routinely. Relational database maintain referential integrity on the level of a tuple. Therefore, the UPDATE operator can violate refer...
[ "def", "_update", "(", "self", ",", "attrname", ",", "value", "=", "None", ")", ":", "if", "len", "(", "self", ")", "!=", "1", ":", "raise", "DataJointError", "(", "'Update is only allowed on one tuple at a time'", ")", "if", "attrname", "not", "in", "self",...
Updates a field in an existing tuple. This is not a datajoyous operation and should not be used routinely. Relational database maintain referential integrity on the level of a tuple. Therefore, the UPDATE operator can violate referential integrity. The datajoyous way to update information is ...
[ "Updates", "a", "field", "in", "an", "existing", "tuple", ".", "This", "is", "not", "a", "datajoyous", "operation", "and", "should", "not", "be", "used", "routinely", ".", "Relational", "database", "maintain", "referential", "integrity", "on", "the", "level", ...
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/table.py#L525-L568
train
datajoint/datajoint-python
datajoint/expression.py
QueryExpression.where_clause
def where_clause(self): """ convert self.restriction to the SQL WHERE clause """ cond = self._make_condition(self.restriction) return '' if cond is True else ' WHERE %s' % cond
python
def where_clause(self): """ convert self.restriction to the SQL WHERE clause """ cond = self._make_condition(self.restriction) return '' if cond is True else ' WHERE %s' % cond
[ "def", "where_clause", "(", "self", ")", ":", "cond", "=", "self", ".", "_make_condition", "(", "self", ".", "restriction", ")", "return", "''", "if", "cond", "is", "True", "else", "' WHERE %s'", "%", "cond" ]
convert self.restriction to the SQL WHERE clause
[ "convert", "self", ".", "restriction", "to", "the", "SQL", "WHERE", "clause" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L196-L201
train
datajoint/datajoint-python
datajoint/expression.py
QueryExpression.preview
def preview(self, limit=None, width=None): """ returns a preview of the contents of the query. """ heading = self.heading rel = self.proj(*heading.non_blobs) if limit is None: limit = config['display.limit'] if width is None: width = config...
python
def preview(self, limit=None, width=None): """ returns a preview of the contents of the query. """ heading = self.heading rel = self.proj(*heading.non_blobs) if limit is None: limit = config['display.limit'] if width is None: width = config...
[ "def", "preview", "(", "self", ",", "limit", "=", "None", ",", "width", "=", "None", ")", ":", "heading", "=", "self", ".", "heading", "rel", "=", "self", ".", "proj", "(", "*", "heading", ".", "non_blobs", ")", "if", "limit", "is", "None", ":", ...
returns a preview of the contents of the query.
[ "returns", "a", "preview", "of", "the", "contents", "of", "the", "query", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L382-L405
train
datajoint/datajoint-python
datajoint/expression.py
Join.make_argument_subquery
def make_argument_subquery(arg): """ Decide when a Join argument needs to be wrapped in a subquery """ return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg
python
def make_argument_subquery(arg): """ Decide when a Join argument needs to be wrapped in a subquery """ return Subquery.create(arg) if isinstance(arg, (GroupBy, Projection)) or arg.restriction else arg
[ "def", "make_argument_subquery", "(", "arg", ")", ":", "return", "Subquery", ".", "create", "(", "arg", ")", "if", "isinstance", "(", "arg", ",", "(", "GroupBy", ",", "Projection", ")", ")", "or", "arg", ".", "restriction", "else", "arg" ]
Decide when a Join argument needs to be wrapped in a subquery
[ "Decide", "when", "a", "Join", "argument", "needs", "to", "be", "wrapped", "in", "a", "subquery" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L606-L610
train
datajoint/datajoint-python
datajoint/expression.py
Projection._need_subquery
def _need_subquery(arg, attributes, named_attributes): """ Decide whether the projection argument needs to be wrapped in a subquery """ if arg.heading.expressions or arg.distinct: # argument has any renamed (computed) attributes return True restricting_attributes = a...
python
def _need_subquery(arg, attributes, named_attributes): """ Decide whether the projection argument needs to be wrapped in a subquery """ if arg.heading.expressions or arg.distinct: # argument has any renamed (computed) attributes return True restricting_attributes = a...
[ "def", "_need_subquery", "(", "arg", ",", "attributes", ",", "named_attributes", ")", ":", "if", "arg", ".", "heading", ".", "expressions", "or", "arg", ".", "distinct", ":", "return", "True", "restricting_attributes", "=", "arg", ".", "attributes_in_restriction...
Decide whether the projection argument needs to be wrapped in a subquery
[ "Decide", "whether", "the", "projection", "argument", "needs", "to", "be", "wrapped", "in", "a", "subquery" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L717-L725
train
datajoint/datajoint-python
datajoint/expression.py
Subquery.create
def create(cls, arg): """ construct a subquery from arg """ obj = cls() obj._connection = arg.connection obj._heading = arg.heading.make_subquery_heading() obj._arg = arg return obj
python
def create(cls, arg): """ construct a subquery from arg """ obj = cls() obj._connection = arg.connection obj._heading = arg.heading.make_subquery_heading() obj._arg = arg return obj
[ "def", "create", "(", "cls", ",", "arg", ")", ":", "obj", "=", "cls", "(", ")", "obj", ".", "_connection", "=", "arg", ".", "connection", "obj", ".", "_heading", "=", "arg", ".", "heading", ".", "make_subquery_heading", "(", ")", "obj", ".", "_arg", ...
construct a subquery from arg
[ "construct", "a", "subquery", "from", "arg" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/expression.py#L800-L808
train
datajoint/datajoint-python
datajoint/utils.py
user_choice
def user_choice(prompt, choices=("yes", "no"), default=None): """ Prompts the user for confirmation. The default value, if any, is capitalized. :param prompt: Information to display to the user. :param choices: an iterable of possible choices. :param default: default choice :return: the user's...
python
def user_choice(prompt, choices=("yes", "no"), default=None): """ Prompts the user for confirmation. The default value, if any, is capitalized. :param prompt: Information to display to the user. :param choices: an iterable of possible choices. :param default: default choice :return: the user's...
[ "def", "user_choice", "(", "prompt", ",", "choices", "=", "(", "\"yes\"", ",", "\"no\"", ")", ",", "default", "=", "None", ")", ":", "assert", "default", "is", "None", "or", "default", "in", "choices", "choice_list", "=", "', '", ".", "join", "(", "(",...
Prompts the user for confirmation. The default value, if any, is capitalized. :param prompt: Information to display to the user. :param choices: an iterable of possible choices. :param default: default choice :return: the user's choice
[ "Prompts", "the", "user", "for", "confirmation", ".", "The", "default", "value", "if", "any", "is", "capitalized", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/utils.py#L16-L31
train
datajoint/datajoint-python
datajoint/fetch.py
to_dicts
def to_dicts(recarray): """convert record array to a dictionaries""" for rec in recarray: yield dict(zip(recarray.dtype.names, rec.tolist()))
python
def to_dicts(recarray): """convert record array to a dictionaries""" for rec in recarray: yield dict(zip(recarray.dtype.names, rec.tolist()))
[ "def", "to_dicts", "(", "recarray", ")", ":", "for", "rec", "in", "recarray", ":", "yield", "dict", "(", "zip", "(", "recarray", ".", "dtype", ".", "names", ",", "rec", ".", "tolist", "(", ")", ")", ")" ]
convert record array to a dictionaries
[ "convert", "record", "array", "to", "a", "dictionaries" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/fetch.py#L24-L27
train
datajoint/datajoint-python
datajoint/fetch.py
Fetch.keys
def keys(self, **kwargs): """ DEPRECATED Iterator that returns primary keys as a sequence of dicts. """ warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. ' 'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stackleve...
python
def keys(self, **kwargs): """ DEPRECATED Iterator that returns primary keys as a sequence of dicts. """ warnings.warn('Use of `rel.fetch.keys()` notation is deprecated. ' 'Please use `rel.fetch("KEY")` or `rel.fetch(dj.key)` for equivalent result', stackleve...
[ "def", "keys", "(", "self", ",", "**", "kwargs", ")", ":", "warnings", ".", "warn", "(", "'Use of `rel.fetch.keys()` notation is deprecated. '", "'Please use `rel.fetch(\"KEY\")` or `rel.fetch(dj.key)` for equivalent result'", ",", "stacklevel", "=", "2", ")", "yield", "fro...
DEPRECATED Iterator that returns primary keys as a sequence of dicts.
[ "DEPRECATED", "Iterator", "that", "returns", "primary", "keys", "as", "a", "sequence", "of", "dicts", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/fetch.py#L131-L138
train
datajoint/datajoint-python
datajoint/hash.py
key_hash
def key_hash(key): """ 32-byte hash used for lookup of primary keys of jobs """ hashed = hashlib.md5() for k, v in sorted(key.items()): hashed.update(str(v).encode()) return hashed.hexdigest()
python
def key_hash(key): """ 32-byte hash used for lookup of primary keys of jobs """ hashed = hashlib.md5() for k, v in sorted(key.items()): hashed.update(str(v).encode()) return hashed.hexdigest()
[ "def", "key_hash", "(", "key", ")", ":", "hashed", "=", "hashlib", ".", "md5", "(", ")", "for", "k", ",", "v", "in", "sorted", "(", "key", ".", "items", "(", ")", ")", ":", "hashed", ".", "update", "(", "str", "(", "v", ")", ".", "encode", "(...
32-byte hash used for lookup of primary keys of jobs
[ "32", "-", "byte", "hash", "used", "for", "lookup", "of", "primary", "keys", "of", "jobs" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/hash.py#L5-L12
train
datajoint/datajoint-python
datajoint/connection.py
conn
def conn(host=None, user=None, password=None, init_fun=None, reset=False): """ Returns a persistent connection object to be shared by multiple modules. If the connection is not yet established or reset=True, a new connection is set up. If connection information is not provided, it is taken from config w...
python
def conn(host=None, user=None, password=None, init_fun=None, reset=False): """ Returns a persistent connection object to be shared by multiple modules. If the connection is not yet established or reset=True, a new connection is set up. If connection information is not provided, it is taken from config w...
[ "def", "conn", "(", "host", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "init_fun", "=", "None", ",", "reset", "=", "False", ")", ":", "if", "not", "hasattr", "(", "conn", ",", "'connection'", ")", "or", "reset", ":", ...
Returns a persistent connection object to be shared by multiple modules. If the connection is not yet established or reset=True, a new connection is set up. If connection information is not provided, it is taken from config which takes the information from dj_local_conf.json. If the password is not specifie...
[ "Returns", "a", "persistent", "connection", "object", "to", "be", "shared", "by", "multiple", "modules", ".", "If", "the", "connection", "is", "not", "yet", "established", "or", "reset", "=", "True", "a", "new", "connection", "is", "set", "up", ".", "If", ...
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L20-L44
train
datajoint/datajoint-python
datajoint/connection.py
Connection.connect
def connect(self): """ Connects to the database server. """ with warnings.catch_warnings(): warnings.filterwarnings('ignore', '.*deprecated.*') self._conn = client.connect( init_command=self.init_fun, sql_mode="NO_ZERO_DATE,NO_ZERO_...
python
def connect(self): """ Connects to the database server. """ with warnings.catch_warnings(): warnings.filterwarnings('ignore', '.*deprecated.*') self._conn = client.connect( init_command=self.init_fun, sql_mode="NO_ZERO_DATE,NO_ZERO_...
[ "def", "connect", "(", "self", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "filterwarnings", "(", "'ignore'", ",", "'.*deprecated.*'", ")", "self", ".", "_conn", "=", "client", ".", "connect", "(", "init_command", "...
Connects to the database server.
[ "Connects", "to", "the", "database", "server", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L88-L100
train
datajoint/datajoint-python
datajoint/connection.py
Connection.start_transaction
def start_transaction(self): """ Starts a transaction error. :raise DataJointError: if there is an ongoing transaction. """ if self.in_transaction: raise DataJointError("Nested connections are not supported.") self.query('START TRANSACTION WITH CONSISTENT SNA...
python
def start_transaction(self): """ Starts a transaction error. :raise DataJointError: if there is an ongoing transaction. """ if self.in_transaction: raise DataJointError("Nested connections are not supported.") self.query('START TRANSACTION WITH CONSISTENT SNA...
[ "def", "start_transaction", "(", "self", ")", ":", "if", "self", ".", "in_transaction", ":", "raise", "DataJointError", "(", "\"Nested connections are not supported.\"", ")", "self", ".", "query", "(", "'START TRANSACTION WITH CONSISTENT SNAPSHOT'", ")", "self", ".", ...
Starts a transaction error. :raise DataJointError: if there is an ongoing transaction.
[ "Starts", "a", "transaction", "error", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/connection.py#L185-L195
train
datajoint/datajoint-python
datajoint/settings.py
Config.save_global
def save_global(self, verbose=False): """ saves the settings in the global config file """ self.save(os.path.expanduser(os.path.join('~', GLOBALCONFIG)), verbose)
python
def save_global(self, verbose=False): """ saves the settings in the global config file """ self.save(os.path.expanduser(os.path.join('~', GLOBALCONFIG)), verbose)
[ "def", "save_global", "(", "self", ",", "verbose", "=", "False", ")", ":", "self", ".", "save", "(", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "join", "(", "'~'", ",", "GLOBALCONFIG", ")", ")", ",", "verbose", ")" ]
saves the settings in the global config file
[ "saves", "the", "settings", "in", "the", "global", "config", "file" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/settings.py#L121-L125
train
datajoint/datajoint-python
datajoint/heading.py
Attribute.todict
def todict(self): """Convert namedtuple to dict.""" return OrderedDict((name, self[i]) for i, name in enumerate(self._fields))
python
def todict(self): """Convert namedtuple to dict.""" return OrderedDict((name, self[i]) for i, name in enumerate(self._fields))
[ "def", "todict", "(", "self", ")", ":", "return", "OrderedDict", "(", "(", "name", ",", "self", "[", "i", "]", ")", "for", "i", ",", "name", "in", "enumerate", "(", "self", ".", "_fields", ")", ")" ]
Convert namedtuple to dict.
[ "Convert", "namedtuple", "to", "dict", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L20-L22
train
datajoint/datajoint-python
datajoint/heading.py
Heading.as_dtype
def as_dtype(self): """ represent the heading as a numpy dtype """ return np.dtype(dict( names=self.names, formats=[v.dtype for v in self.attributes.values()]))
python
def as_dtype(self): """ represent the heading as a numpy dtype """ return np.dtype(dict( names=self.names, formats=[v.dtype for v in self.attributes.values()]))
[ "def", "as_dtype", "(", "self", ")", ":", "return", "np", ".", "dtype", "(", "dict", "(", "names", "=", "self", ".", "names", ",", "formats", "=", "[", "v", ".", "dtype", "for", "v", "in", "self", ".", "attributes", ".", "values", "(", ")", "]", ...
represent the heading as a numpy dtype
[ "represent", "the", "heading", "as", "a", "numpy", "dtype" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L112-L118
train
datajoint/datajoint-python
datajoint/heading.py
Heading.as_sql
def as_sql(self): """ represent heading as SQL field list """ return ','.join('`%s`' % name if self.attributes[name].sql_expression is None else '%s as `%s`' % (self.attributes[name].sql_expression, name) for name in self.names)
python
def as_sql(self): """ represent heading as SQL field list """ return ','.join('`%s`' % name if self.attributes[name].sql_expression is None else '%s as `%s`' % (self.attributes[name].sql_expression, name) for name in self.names)
[ "def", "as_sql", "(", "self", ")", ":", "return", "','", ".", "join", "(", "'`%s`'", "%", "name", "if", "self", ".", "attributes", "[", "name", "]", ".", "sql_expression", "is", "None", "else", "'%s as `%s`'", "%", "(", "self", ".", "attributes", "[", ...
represent heading as SQL field list
[ "represent", "heading", "as", "SQL", "field", "list" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L121-L127
train
datajoint/datajoint-python
datajoint/heading.py
Heading.join
def join(self, other): """ Join two headings into a new one. It assumes that self and other are headings that share no common dependent attributes. """ return Heading( [self.attributes[name].todict() for name in self.primary_key] + [other.attributes[name]....
python
def join(self, other): """ Join two headings into a new one. It assumes that self and other are headings that share no common dependent attributes. """ return Heading( [self.attributes[name].todict() for name in self.primary_key] + [other.attributes[name]....
[ "def", "join", "(", "self", ",", "other", ")", ":", "return", "Heading", "(", "[", "self", ".", "attributes", "[", "name", "]", ".", "todict", "(", ")", "for", "name", "in", "self", ".", "primary_key", "]", "+", "[", "other", ".", "attributes", "["...
Join two headings into a new one. It assumes that self and other are headings that share no common dependent attributes.
[ "Join", "two", "headings", "into", "a", "new", "one", ".", "It", "assumes", "that", "self", "and", "other", "are", "headings", "that", "share", "no", "common", "dependent", "attributes", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L271-L280
train
datajoint/datajoint-python
datajoint/heading.py
Heading.make_subquery_heading
def make_subquery_heading(self): """ Create a new heading with removed attribute sql_expressions. Used by subqueries, which resolve the sql_expressions. """ return Heading(dict(v.todict(), sql_expression=None) for v in self.attributes.values())
python
def make_subquery_heading(self): """ Create a new heading with removed attribute sql_expressions. Used by subqueries, which resolve the sql_expressions. """ return Heading(dict(v.todict(), sql_expression=None) for v in self.attributes.values())
[ "def", "make_subquery_heading", "(", "self", ")", ":", "return", "Heading", "(", "dict", "(", "v", ".", "todict", "(", ")", ",", "sql_expression", "=", "None", ")", "for", "v", "in", "self", ".", "attributes", ".", "values", "(", ")", ")" ]
Create a new heading with removed attribute sql_expressions. Used by subqueries, which resolve the sql_expressions.
[ "Create", "a", "new", "heading", "with", "removed", "attribute", "sql_expressions", ".", "Used", "by", "subqueries", "which", "resolve", "the", "sql_expressions", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/heading.py#L282-L287
train
datajoint/datajoint-python
datajoint/blob.py
BlobReader.squeeze
def squeeze(self, array): """ Simplify the given array as much as possible - squeeze out all singleton dimensions and also convert a zero dimensional array into array scalar """ if not self._squeeze: return array array = array.copy() array = array.sque...
python
def squeeze(self, array): """ Simplify the given array as much as possible - squeeze out all singleton dimensions and also convert a zero dimensional array into array scalar """ if not self._squeeze: return array array = array.copy() array = array.sque...
[ "def", "squeeze", "(", "self", ",", "array", ")", ":", "if", "not", "self", ".", "_squeeze", ":", "return", "array", "array", "=", "array", ".", "copy", "(", ")", "array", "=", "array", ".", "squeeze", "(", ")", "if", "array", ".", "ndim", "==", ...
Simplify the given array as much as possible - squeeze out all singleton dimensions and also convert a zero dimensional array into array scalar
[ "Simplify", "the", "given", "array", "as", "much", "as", "possible", "-", "squeeze", "out", "all", "singleton", "dimensions", "and", "also", "convert", "a", "zero", "dimensional", "array", "into", "array", "scalar" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/blob.py#L152-L163
train
datajoint/datajoint-python
datajoint/blob.py
BlobReader.read_string
def read_string(self, advance=True): """ Read a string terminated by null byte '\0'. The returned string object is ASCII decoded, and will not include the terminating null byte. """ target = self._blob.find(b'\0', self.pos) assert target >= self._pos data = self._...
python
def read_string(self, advance=True): """ Read a string terminated by null byte '\0'. The returned string object is ASCII decoded, and will not include the terminating null byte. """ target = self._blob.find(b'\0', self.pos) assert target >= self._pos data = self._...
[ "def", "read_string", "(", "self", ",", "advance", "=", "True", ")", ":", "target", "=", "self", ".", "_blob", ".", "find", "(", "b'\\0'", ",", "self", ".", "pos", ")", "assert", "target", ">=", "self", ".", "_pos", "data", "=", "self", ".", "_blob...
Read a string terminated by null byte '\0'. The returned string object is ASCII decoded, and will not include the terminating null byte.
[ "Read", "a", "string", "terminated", "by", "null", "byte", "\\", "0", ".", "The", "returned", "string", "object", "is", "ASCII", "decoded", "and", "will", "not", "include", "the", "terminating", "null", "byte", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/blob.py#L180-L190
train
datajoint/datajoint-python
datajoint/blob.py
BlobReader.read_value
def read_value(self, dtype='uint64', count=1, advance=True): """ Read one or more scalars of the indicated dtype. Count specifies the number of scalars to be read in. """ data = np.frombuffer(self._blob, dtype=dtype, count=count, offset=self.pos) if advance: #...
python
def read_value(self, dtype='uint64', count=1, advance=True): """ Read one or more scalars of the indicated dtype. Count specifies the number of scalars to be read in. """ data = np.frombuffer(self._blob, dtype=dtype, count=count, offset=self.pos) if advance: #...
[ "def", "read_value", "(", "self", ",", "dtype", "=", "'uint64'", ",", "count", "=", "1", ",", "advance", "=", "True", ")", ":", "data", "=", "np", ".", "frombuffer", "(", "self", ".", "_blob", ",", "dtype", "=", "dtype", ",", "count", "=", "count",...
Read one or more scalars of the indicated dtype. Count specifies the number of scalars to be read in.
[ "Read", "one", "or", "more", "scalars", "of", "the", "indicated", "dtype", ".", "Count", "specifies", "the", "number", "of", "scalars", "to", "be", "read", "in", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/blob.py#L192-L203
train
datajoint/datajoint-python
datajoint/external.py
ExternalTable.put
def put(self, store, obj): """ put an object in external store """ spec = self._get_store_spec(store) blob = pack(obj) blob_hash = long_hash(blob) + store[len('external-'):] if spec['protocol'] == 'file': folder = os.path.join(spec['location'], self.da...
python
def put(self, store, obj): """ put an object in external store """ spec = self._get_store_spec(store) blob = pack(obj) blob_hash = long_hash(blob) + store[len('external-'):] if spec['protocol'] == 'file': folder = os.path.join(spec['location'], self.da...
[ "def", "put", "(", "self", ",", "store", ",", "obj", ")", ":", "spec", "=", "self", ".", "_get_store_spec", "(", "store", ")", "blob", "=", "pack", "(", "obj", ")", "blob_hash", "=", "long_hash", "(", "blob", ")", "+", "store", "[", "len", "(", "...
put an object in external store
[ "put", "an", "object", "in", "external", "store" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/external.py#L45-L74
train
datajoint/datajoint-python
datajoint/external.py
ExternalTable.get
def get(self, blob_hash): """ get an object from external store. Does not need to check whether it's in the table. """ if blob_hash is None: return None store = blob_hash[STORE_HASH_LENGTH:] store = 'external' + ('-' if store else '') + store ...
python
def get(self, blob_hash): """ get an object from external store. Does not need to check whether it's in the table. """ if blob_hash is None: return None store = blob_hash[STORE_HASH_LENGTH:] store = 'external' + ('-' if store else '') + store ...
[ "def", "get", "(", "self", ",", "blob_hash", ")", ":", "if", "blob_hash", "is", "None", ":", "return", "None", "store", "=", "blob_hash", "[", "STORE_HASH_LENGTH", ":", "]", "store", "=", "'external'", "+", "(", "'-'", "if", "store", "else", "''", ")",...
get an object from external store. Does not need to check whether it's in the table.
[ "get", "an", "object", "from", "external", "store", ".", "Does", "not", "need", "to", "check", "whether", "it", "s", "in", "the", "table", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/external.py#L76-L118
train
datajoint/datajoint-python
datajoint/external.py
ExternalTable.delete_garbage
def delete_garbage(self): """ Delete items that are no longer referenced. This operation is safe to perform at any time. """ self.connection.query( "DELETE FROM `{db}`.`{tab}` WHERE ".format(tab=self.table_name, db=self.database) + " AND ".join( ...
python
def delete_garbage(self): """ Delete items that are no longer referenced. This operation is safe to perform at any time. """ self.connection.query( "DELETE FROM `{db}`.`{tab}` WHERE ".format(tab=self.table_name, db=self.database) + " AND ".join( ...
[ "def", "delete_garbage", "(", "self", ")", ":", "self", ".", "connection", ".", "query", "(", "\"DELETE FROM `{db}`.`{tab}` WHERE \"", ".", "format", "(", "tab", "=", "self", ".", "table_name", ",", "db", "=", "self", ".", "database", ")", "+", "\" AND \"", ...
Delete items that are no longer referenced. This operation is safe to perform at any time.
[ "Delete", "items", "that", "are", "no", "longer", "referenced", ".", "This", "operation", "is", "safe", "to", "perform", "at", "any", "time", "." ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/external.py#L147-L157
train
datajoint/datajoint-python
datajoint/external.py
ExternalTable.clean_store
def clean_store(self, store, display_progress=True): """ Clean unused data in an external storage repository from unused blobs. This must be performed after delete_garbage during low-usage periods to reduce risks of data loss. """ spec = self._get_store_spec(store) progre...
python
def clean_store(self, store, display_progress=True): """ Clean unused data in an external storage repository from unused blobs. This must be performed after delete_garbage during low-usage periods to reduce risks of data loss. """ spec = self._get_store_spec(store) progre...
[ "def", "clean_store", "(", "self", ",", "store", ",", "display_progress", "=", "True", ")", ":", "spec", "=", "self", ".", "_get_store_spec", "(", "store", ")", "progress", "=", "tqdm", "if", "display_progress", "else", "lambda", "x", ":", "x", "if", "sp...
Clean unused data in an external storage repository from unused blobs. This must be performed after delete_garbage during low-usage periods to reduce risks of data loss.
[ "Clean", "unused", "data", "in", "an", "external", "storage", "repository", "from", "unused", "blobs", ".", "This", "must", "be", "performed", "after", "delete_garbage", "during", "low", "-", "usage", "periods", "to", "reduce", "risks", "of", "data", "loss", ...
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/external.py#L159-L176
train
datajoint/datajoint-python
datajoint/errors.py
is_connection_error
def is_connection_error(e): """ Checks if error e pertains to a connection issue """ return (isinstance(e, err.InterfaceError) and e.args[0] == "(0, '')") or\ (isinstance(e, err.OperationalError) and e.args[0] in operation_error_codes.values())
python
def is_connection_error(e): """ Checks if error e pertains to a connection issue """ return (isinstance(e, err.InterfaceError) and e.args[0] == "(0, '')") or\ (isinstance(e, err.OperationalError) and e.args[0] in operation_error_codes.values())
[ "def", "is_connection_error", "(", "e", ")", ":", "return", "(", "isinstance", "(", "e", ",", "err", ".", "InterfaceError", ")", "and", "e", ".", "args", "[", "0", "]", "==", "\"(0, '')\"", ")", "or", "(", "isinstance", "(", "e", ",", "err", ".", "...
Checks if error e pertains to a connection issue
[ "Checks", "if", "error", "e", "pertains", "to", "a", "connection", "issue" ]
4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c
https://github.com/datajoint/datajoint-python/blob/4f29bb154a7ed2b8b64b4d3a9c8be4c16b39621c/datajoint/errors.py#L18-L23
train
python-hyper/brotlipy
src/brotli/brotli.py
decompress
def decompress(data): """ Decompress a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data. """ d = Decompressor() data = d.decompress(data) d.finish() return data
python
def decompress(data): """ Decompress a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data. """ d = Decompressor() data = d.decompress(data) d.finish() return data
[ "def", "decompress", "(", "data", ")", ":", "d", "=", "Decompressor", "(", ")", "data", "=", "d", ".", "decompress", "(", "data", ")", "d", ".", "finish", "(", ")", "return", "data" ]
Decompress a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data.
[ "Decompress", "a", "complete", "Brotli", "-", "compressed", "string", "." ]
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L82-L91
train
python-hyper/brotlipy
src/brotli/brotli.py
compress
def compress(data, mode=DEFAULT_MODE, quality=lib.BROTLI_DEFAULT_QUALITY, lgwin=lib.BROTLI_DEFAULT_WINDOW, lgblock=0, dictionary=b''): """ Compress a string using Brotli. .. versionchanged:: 0.5.0 Added ``mode``, ``quality``, `lgwin``,...
python
def compress(data, mode=DEFAULT_MODE, quality=lib.BROTLI_DEFAULT_QUALITY, lgwin=lib.BROTLI_DEFAULT_WINDOW, lgblock=0, dictionary=b''): """ Compress a string using Brotli. .. versionchanged:: 0.5.0 Added ``mode``, ``quality``, `lgwin``,...
[ "def", "compress", "(", "data", ",", "mode", "=", "DEFAULT_MODE", ",", "quality", "=", "lib", ".", "BROTLI_DEFAULT_QUALITY", ",", "lgwin", "=", "lib", ".", "BROTLI_DEFAULT_WINDOW", ",", "lgblock", "=", "0", ",", "dictionary", "=", "b''", ")", ":", "compres...
Compress a string using Brotli. .. versionchanged:: 0.5.0 Added ``mode``, ``quality``, `lgwin``, ``lgblock``, and ``dictionary`` parameters. :param data: A bytestring containing the data to compress. :type data: ``bytes`` :param mode: The encoder mode. :type mode: :class:`BrotliEnco...
[ "Compress", "a", "string", "using", "Brotli", "." ]
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L94-L152
train
python-hyper/brotlipy
src/brotli/brotli.py
Compressor._compress
def _compress(self, data, operation): """ This private method compresses some data in a given mode. This is used because almost all of the code uses the exact same setup. It wouldn't have to, but it doesn't hurt at all. """ # The 'algorithm' for working out how big to mak...
python
def _compress(self, data, operation): """ This private method compresses some data in a given mode. This is used because almost all of the code uses the exact same setup. It wouldn't have to, but it doesn't hurt at all. """ # The 'algorithm' for working out how big to mak...
[ "def", "_compress", "(", "self", ",", "data", ",", "operation", ")", ":", "original_output_size", "=", "int", "(", "math", ".", "ceil", "(", "len", "(", "data", ")", "+", "(", "len", "(", "data", ")", ">>", "2", ")", "+", "10240", ")", ")", "avai...
This private method compresses some data in a given mode. This is used because almost all of the code uses the exact same setup. It wouldn't have to, but it doesn't hurt at all.
[ "This", "private", "method", "compresses", "some", "data", "in", "a", "given", "mode", ".", "This", "is", "used", "because", "almost", "all", "of", "the", "code", "uses", "the", "exact", "same", "setup", ".", "It", "wouldn", "t", "have", "to", "but", "...
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L283-L317
train
python-hyper/brotlipy
src/brotli/brotli.py
Compressor.flush
def flush(self): """ Flush the compressor. This will emit the remaining output data, but will not destroy the compressor. It can be used, for example, to ensure that given chunks of content will decompress immediately. """ chunks = [] chunks.append(self._compress(...
python
def flush(self): """ Flush the compressor. This will emit the remaining output data, but will not destroy the compressor. It can be used, for example, to ensure that given chunks of content will decompress immediately. """ chunks = [] chunks.append(self._compress(...
[ "def", "flush", "(", "self", ")", ":", "chunks", "=", "[", "]", "chunks", ".", "append", "(", "self", ".", "_compress", "(", "b''", ",", "lib", ".", "BROTLI_OPERATION_FLUSH", ")", ")", "while", "lib", ".", "BrotliEncoderHasMoreOutput", "(", "self", ".", ...
Flush the compressor. This will emit the remaining output data, but will not destroy the compressor. It can be used, for example, to ensure that given chunks of content will decompress immediately.
[ "Flush", "the", "compressor", ".", "This", "will", "emit", "the", "remaining", "output", "data", "but", "will", "not", "destroy", "the", "compressor", ".", "It", "can", "be", "used", "for", "example", "to", "ensure", "that", "given", "chunks", "of", "conte...
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L330-L342
train
python-hyper/brotlipy
src/brotli/brotli.py
Compressor.finish
def finish(self): """ Finish the compressor. This will emit the remaining output data and transition the compressor to a completed state. The compressor cannot be used again after this point, and must be replaced. """ chunks = [] while lib.BrotliEncoderIsFinished(...
python
def finish(self): """ Finish the compressor. This will emit the remaining output data and transition the compressor to a completed state. The compressor cannot be used again after this point, and must be replaced. """ chunks = [] while lib.BrotliEncoderIsFinished(...
[ "def", "finish", "(", "self", ")", ":", "chunks", "=", "[", "]", "while", "lib", ".", "BrotliEncoderIsFinished", "(", "self", ".", "_encoder", ")", "==", "lib", ".", "BROTLI_FALSE", ":", "chunks", ".", "append", "(", "self", ".", "_compress", "(", "b''...
Finish the compressor. This will emit the remaining output data and transition the compressor to a completed state. The compressor cannot be used again after this point, and must be replaced.
[ "Finish", "the", "compressor", ".", "This", "will", "emit", "the", "remaining", "output", "data", "and", "transition", "the", "compressor", "to", "a", "completed", "state", ".", "The", "compressor", "cannot", "be", "used", "again", "after", "this", "point", ...
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L344-L354
train
python-hyper/brotlipy
src/brotli/brotli.py
Decompressor.decompress
def decompress(self, data): """ Decompress part of a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data. :returns: A bytestring containing the decompressed data. """ chunks = [] available_in = ffi.new("size_t *", len(d...
python
def decompress(self, data): """ Decompress part of a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data. :returns: A bytestring containing the decompressed data. """ chunks = [] available_in = ffi.new("size_t *", len(d...
[ "def", "decompress", "(", "self", ",", "data", ")", ":", "chunks", "=", "[", "]", "available_in", "=", "ffi", ".", "new", "(", "\"size_t *\"", ",", "len", "(", "data", ")", ")", "in_buffer", "=", "ffi", ".", "new", "(", "\"uint8_t[]\"", ",", "data", ...
Decompress part of a complete Brotli-compressed string. :param data: A bytestring containing Brotli-compressed data. :returns: A bytestring containing the decompressed data.
[ "Decompress", "part", "of", "a", "complete", "Brotli", "-", "compressed", "string", "." ]
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L386-L435
train
python-hyper/brotlipy
src/brotli/brotli.py
Decompressor.finish
def finish(self): """ Finish the decompressor. As the decompressor decompresses eagerly, this will never actually emit any data. However, it will potentially throw errors if a truncated or damaged data stream has been used. Note that, once this method is called, the decompressor...
python
def finish(self): """ Finish the decompressor. As the decompressor decompresses eagerly, this will never actually emit any data. However, it will potentially throw errors if a truncated or damaged data stream has been used. Note that, once this method is called, the decompressor...
[ "def", "finish", "(", "self", ")", ":", "assert", "(", "lib", ".", "BrotliDecoderHasMoreOutput", "(", "self", ".", "_decoder", ")", "==", "lib", ".", "BROTLI_FALSE", ")", "if", "lib", ".", "BrotliDecoderIsFinished", "(", "self", ".", "_decoder", ")", "==",...
Finish the decompressor. As the decompressor decompresses eagerly, this will never actually emit any data. However, it will potentially throw errors if a truncated or damaged data stream has been used. Note that, once this method is called, the decompressor is no longer safe for further...
[ "Finish", "the", "decompressor", ".", "As", "the", "decompressor", "decompresses", "eagerly", "this", "will", "never", "actually", "emit", "any", "data", ".", "However", "it", "will", "potentially", "throw", "errors", "if", "a", "truncated", "or", "damaged", "...
ffddf2ea5adc584c8c353d246bb1077b7e781b63
https://github.com/python-hyper/brotlipy/blob/ffddf2ea5adc584c8c353d246bb1077b7e781b63/src/brotli/brotli.py#L451-L466
train
adafruit/Adafruit_Python_CharLCD
examples/char_lcd_rgb_pwm.py
hsv_to_rgb
def hsv_to_rgb(hsv): """Converts a tuple of hue, saturation, value to a tuple of red, green blue. Hue should be an angle from 0.0 to 359.0. Saturation and value should be a value from 0.0 to 1.0, where saturation controls the intensity of the hue and value controls the brightness. """ # Algorit...
python
def hsv_to_rgb(hsv): """Converts a tuple of hue, saturation, value to a tuple of red, green blue. Hue should be an angle from 0.0 to 359.0. Saturation and value should be a value from 0.0 to 1.0, where saturation controls the intensity of the hue and value controls the brightness. """ # Algorit...
[ "def", "hsv_to_rgb", "(", "hsv", ")", ":", "h", ",", "s", ",", "v", "=", "hsv", "if", "s", "==", "0", ":", "return", "(", "v", ",", "v", ",", "v", ")", "h", "/=", "60.0", "i", "=", "math", ".", "floor", "(", "h", ")", "f", "=", "h", "-"...
Converts a tuple of hue, saturation, value to a tuple of red, green blue. Hue should be an angle from 0.0 to 359.0. Saturation and value should be a value from 0.0 to 1.0, where saturation controls the intensity of the hue and value controls the brightness.
[ "Converts", "a", "tuple", "of", "hue", "saturation", "value", "to", "a", "tuple", "of", "red", "green", "blue", ".", "Hue", "should", "be", "an", "angle", "from", "0", ".", "0", "to", "359", ".", "0", ".", "Saturation", "and", "value", "should", "be"...
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/examples/char_lcd_rgb_pwm.py#L9-L36
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.set_cursor
def set_cursor(self, col, row): """Move the cursor to an explicit column and row position.""" # Clamp row to the last row of the display. if row > self._lines: row = self._lines - 1 # Set location. self.write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
python
def set_cursor(self, col, row): """Move the cursor to an explicit column and row position.""" # Clamp row to the last row of the display. if row > self._lines: row = self._lines - 1 # Set location. self.write8(LCD_SETDDRAMADDR | (col + LCD_ROW_OFFSETS[row]))
[ "def", "set_cursor", "(", "self", ",", "col", ",", "row", ")", ":", "if", "row", ">", "self", ".", "_lines", ":", "row", "=", "self", ".", "_lines", "-", "1", "self", ".", "write8", "(", "LCD_SETDDRAMADDR", "|", "(", "col", "+", "LCD_ROW_OFFSETS", ...
Move the cursor to an explicit column and row position.
[ "Move", "the", "cursor", "to", "an", "explicit", "column", "and", "row", "position", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L183-L189
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.enable_display
def enable_display(self, enable): """Enable or disable the display. Set enable to True to enable.""" if enable: self.displaycontrol |= LCD_DISPLAYON else: self.displaycontrol &= ~LCD_DISPLAYON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
python
def enable_display(self, enable): """Enable or disable the display. Set enable to True to enable.""" if enable: self.displaycontrol |= LCD_DISPLAYON else: self.displaycontrol &= ~LCD_DISPLAYON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
[ "def", "enable_display", "(", "self", ",", "enable", ")", ":", "if", "enable", ":", "self", ".", "displaycontrol", "|=", "LCD_DISPLAYON", "else", ":", "self", ".", "displaycontrol", "&=", "~", "LCD_DISPLAYON", "self", ".", "write8", "(", "LCD_DISPLAYCONTROL", ...
Enable or disable the display. Set enable to True to enable.
[ "Enable", "or", "disable", "the", "display", ".", "Set", "enable", "to", "True", "to", "enable", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L191-L197
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.show_cursor
def show_cursor(self, show): """Show or hide the cursor. Cursor is shown if show is True.""" if show: self.displaycontrol |= LCD_CURSORON else: self.displaycontrol &= ~LCD_CURSORON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
python
def show_cursor(self, show): """Show or hide the cursor. Cursor is shown if show is True.""" if show: self.displaycontrol |= LCD_CURSORON else: self.displaycontrol &= ~LCD_CURSORON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
[ "def", "show_cursor", "(", "self", ",", "show", ")", ":", "if", "show", ":", "self", ".", "displaycontrol", "|=", "LCD_CURSORON", "else", ":", "self", ".", "displaycontrol", "&=", "~", "LCD_CURSORON", "self", ".", "write8", "(", "LCD_DISPLAYCONTROL", "|", ...
Show or hide the cursor. Cursor is shown if show is True.
[ "Show", "or", "hide", "the", "cursor", ".", "Cursor", "is", "shown", "if", "show", "is", "True", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L199-L205
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.blink
def blink(self, blink): """Turn on or off cursor blinking. Set blink to True to enable blinking.""" if blink: self.displaycontrol |= LCD_BLINKON else: self.displaycontrol &= ~LCD_BLINKON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
python
def blink(self, blink): """Turn on or off cursor blinking. Set blink to True to enable blinking.""" if blink: self.displaycontrol |= LCD_BLINKON else: self.displaycontrol &= ~LCD_BLINKON self.write8(LCD_DISPLAYCONTROL | self.displaycontrol)
[ "def", "blink", "(", "self", ",", "blink", ")", ":", "if", "blink", ":", "self", ".", "displaycontrol", "|=", "LCD_BLINKON", "else", ":", "self", ".", "displaycontrol", "&=", "~", "LCD_BLINKON", "self", ".", "write8", "(", "LCD_DISPLAYCONTROL", "|", "self"...
Turn on or off cursor blinking. Set blink to True to enable blinking.
[ "Turn", "on", "or", "off", "cursor", "blinking", ".", "Set", "blink", "to", "True", "to", "enable", "blinking", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L207-L213
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.set_left_to_right
def set_left_to_right(self): """Set text direction left to right.""" self.displaymode |= LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode)
python
def set_left_to_right(self): """Set text direction left to right.""" self.displaymode |= LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode)
[ "def", "set_left_to_right", "(", "self", ")", ":", "self", ".", "displaymode", "|=", "LCD_ENTRYLEFT", "self", ".", "write8", "(", "LCD_ENTRYMODESET", "|", "self", ".", "displaymode", ")" ]
Set text direction left to right.
[ "Set", "text", "direction", "left", "to", "right", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L223-L226
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.set_right_to_left
def set_right_to_left(self): """Set text direction right to left.""" self.displaymode &= ~LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode)
python
def set_right_to_left(self): """Set text direction right to left.""" self.displaymode &= ~LCD_ENTRYLEFT self.write8(LCD_ENTRYMODESET | self.displaymode)
[ "def", "set_right_to_left", "(", "self", ")", ":", "self", ".", "displaymode", "&=", "~", "LCD_ENTRYLEFT", "self", ".", "write8", "(", "LCD_ENTRYMODESET", "|", "self", ".", "displaymode", ")" ]
Set text direction right to left.
[ "Set", "text", "direction", "right", "to", "left", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L228-L231
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.autoscroll
def autoscroll(self, autoscroll): """Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text. """ if autoscroll: self.displaymode |= LCD_ENTRYSHIFTINCREMENT else: self.displaymode &= ~LCD_ENTRYSHIFTINCREM...
python
def autoscroll(self, autoscroll): """Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text. """ if autoscroll: self.displaymode |= LCD_ENTRYSHIFTINCREMENT else: self.displaymode &= ~LCD_ENTRYSHIFTINCREM...
[ "def", "autoscroll", "(", "self", ",", "autoscroll", ")", ":", "if", "autoscroll", ":", "self", ".", "displaymode", "|=", "LCD_ENTRYSHIFTINCREMENT", "else", ":", "self", ".", "displaymode", "&=", "~", "LCD_ENTRYSHIFTINCREMENT", "self", ".", "write8", "(", "LCD...
Autoscroll will 'right justify' text from the cursor if set True, otherwise it will 'left justify' the text.
[ "Autoscroll", "will", "right", "justify", "text", "from", "the", "cursor", "if", "set", "True", "otherwise", "it", "will", "left", "justify", "the", "text", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L233-L241
train
adafruit/Adafruit_Python_CharLCD
Adafruit_CharLCD/Adafruit_CharLCD.py
Adafruit_CharLCD.message
def message(self, text): """Write text to display. Note that text can include newlines.""" line = 0 # Iterate through each character. for char in text: # Advance to next line if character is a new line. if char == '\n': line += 1 #...
python
def message(self, text): """Write text to display. Note that text can include newlines.""" line = 0 # Iterate through each character. for char in text: # Advance to next line if character is a new line. if char == '\n': line += 1 #...
[ "def", "message", "(", "self", ",", "text", ")", ":", "line", "=", "0", "for", "char", "in", "text", ":", "if", "char", "==", "'\\n'", ":", "line", "+=", "1", "col", "=", "0", "if", "self", ".", "displaymode", "&", "LCD_ENTRYLEFT", ">", "0", "els...
Write text to display. Note that text can include newlines.
[ "Write", "text", "to", "display", ".", "Note", "that", "text", "can", "include", "newlines", "." ]
c126e6b673074c12a03f4bd36afb2fe40272341e
https://github.com/adafruit/Adafruit_Python_CharLCD/blob/c126e6b673074c12a03f4bd36afb2fe40272341e/Adafruit_CharLCD/Adafruit_CharLCD.py#L243-L256
train
i3visio/osrframework
osrframework/utils/regexp.py
RegexpObject.findExp
def findExp(self, data): ''' Method to look for the current regular expression in the provided string. :param data: string containing the text where the expressions will be looked for. :return: a list of verified regular expressions. ''' temp = [] ...
python
def findExp(self, data): ''' Method to look for the current regular expression in the provided string. :param data: string containing the text where the expressions will be looked for. :return: a list of verified regular expressions. ''' temp = [] ...
[ "def", "findExp", "(", "self", ",", "data", ")", ":", "temp", "=", "[", "]", "for", "r", "in", "self", ".", "reg_exp", ":", "try", ":", "temp", "+=", "re", ".", "findall", "(", "r", ",", "data", ")", "except", ":", "print", "self", ".", "name",...
Method to look for the current regular expression in the provided string. :param data: string containing the text where the expressions will be looked for. :return: a list of verified regular expressions.
[ "Method", "to", "look", "for", "the", "current", "regular", "expression", "in", "the", "provided", "string", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/regexp.py#L125-L150
train
i3visio/osrframework
osrframework/utils/general.py
exportUsufy
def exportUsufy(data, ext, fileH): """ Method that exports the different structures onto different formats. Args: ----- data: Data to export. ext: One of the following: csv, excel, json, ods. fileH: Fileheader for the output files. Returns: -------- Performs the...
python
def exportUsufy(data, ext, fileH): """ Method that exports the different structures onto different formats. Args: ----- data: Data to export. ext: One of the following: csv, excel, json, ods. fileH: Fileheader for the output files. Returns: -------- Performs the...
[ "def", "exportUsufy", "(", "data", ",", "ext", ",", "fileH", ")", ":", "if", "ext", "==", "\"csv\"", ":", "usufyToCsvExport", "(", "data", ",", "fileH", "+", "\".\"", "+", "ext", ")", "elif", "ext", "==", "\"gml\"", ":", "usufyToGmlExport", "(", "data"...
Method that exports the different structures onto different formats. Args: ----- data: Data to export. ext: One of the following: csv, excel, json, ods. fileH: Fileheader for the output files. Returns: -------- Performs the export as requested by parameter.
[ "Method", "that", "exports", "the", "different", "structures", "onto", "different", "formats", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L40-L69
train
i3visio/osrframework
osrframework/utils/general.py
_generateTabularData
def _generateTabularData(res, oldTabularData = {}, isTerminal=False, canUnicode=True): """ Method that recovers the values and columns from the current structure This method is used by: - usufyToCsvExport - usufyToOdsExport - usufyToXlsExport - usufyToXlsxExport Args: ...
python
def _generateTabularData(res, oldTabularData = {}, isTerminal=False, canUnicode=True): """ Method that recovers the values and columns from the current structure This method is used by: - usufyToCsvExport - usufyToOdsExport - usufyToXlsExport - usufyToXlsxExport Args: ...
[ "def", "_generateTabularData", "(", "res", ",", "oldTabularData", "=", "{", "}", ",", "isTerminal", "=", "False", ",", "canUnicode", "=", "True", ")", ":", "def", "_grabbingNewHeader", "(", "h", ")", ":", "if", "h", "[", "0", "]", "==", "\"@\"", ":", ...
Method that recovers the values and columns from the current structure This method is used by: - usufyToCsvExport - usufyToOdsExport - usufyToXlsExport - usufyToXlsxExport Args: ----- res: New data to export. oldTabularData: The previous data stored. ...
[ "Method", "that", "recovers", "the", "values", "and", "columns", "from", "the", "current", "structure" ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L72-L266
train
i3visio/osrframework
osrframework/utils/general.py
usufyToJsonExport
def usufyToJsonExport(d, fPath): """ Workaround to export to a json file. Args: ----- d: Data to export. fPath: File path for the output file. """ oldData = [] try: with open (fPath) as iF: oldText = iF.read() if oldText != "": ...
python
def usufyToJsonExport(d, fPath): """ Workaround to export to a json file. Args: ----- d: Data to export. fPath: File path for the output file. """ oldData = [] try: with open (fPath) as iF: oldText = iF.read() if oldText != "": ...
[ "def", "usufyToJsonExport", "(", "d", ",", "fPath", ")", ":", "oldData", "=", "[", "]", "try", ":", "with", "open", "(", "fPath", ")", "as", "iF", ":", "oldText", "=", "iF", ".", "read", "(", ")", "if", "oldText", "!=", "\"\"", ":", "oldData", "=...
Workaround to export to a json file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", "json", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L269-L291
train
i3visio/osrframework
osrframework/utils/general.py
usufyToTextExport
def usufyToTextExport(d, fPath=None): """ Workaround to export to a .txt file or to show the information. Args: ----- d: Data to export. fPath: File path for the output file. If None was provided, it will assume that it has to print it. Returns: -------- uni...
python
def usufyToTextExport(d, fPath=None): """ Workaround to export to a .txt file or to show the information. Args: ----- d: Data to export. fPath: File path for the output file. If None was provided, it will assume that it has to print it. Returns: -------- uni...
[ "def", "usufyToTextExport", "(", "d", ",", "fPath", "=", "None", ")", ":", "if", "d", "==", "[", "]", ":", "return", "\"+------------------+\\n| No data found... |\\n+------------------+\"", "import", "pyexcel", "as", "pe", "import", "pyexcel", ".", "ext", ".", ...
Workaround to export to a .txt file or to show the information. Args: ----- d: Data to export. fPath: File path for the output file. If None was provided, it will assume that it has to print it. Returns: -------- unicode: It sometimes returns a unicode representatio...
[ "Workaround", "to", "export", "to", "a", ".", "txt", "file", "or", "to", "show", "the", "information", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L294-L342
train
i3visio/osrframework
osrframework/utils/general.py
usufyToCsvExport
def usufyToCsvExport(d, fPath): """ Workaround to export to a CSV file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_io import get_data try: oldData = {"OSRFramework": get_data(fPath) } except: # No information ha...
python
def usufyToCsvExport(d, fPath): """ Workaround to export to a CSV file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_io import get_data try: oldData = {"OSRFramework": get_data(fPath) } except: # No information ha...
[ "def", "usufyToCsvExport", "(", "d", ",", "fPath", ")", ":", "from", "pyexcel_io", "import", "get_data", "try", ":", "oldData", "=", "{", "\"OSRFramework\"", ":", "get_data", "(", "fPath", ")", "}", "except", ":", "oldData", "=", "{", "\"OSRFramework\"", "...
Workaround to export to a CSV file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", "CSV", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L345-L368
train
i3visio/osrframework
osrframework/utils/general.py
usufyToOdsExport
def usufyToOdsExport(d, fPath): """ Workaround to export to a .ods file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_ods import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an array ...
python
def usufyToOdsExport(d, fPath): """ Workaround to export to a .ods file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_ods import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an array ...
[ "def", "usufyToOdsExport", "(", "d", ",", "fPath", ")", ":", "from", "pyexcel_ods", "import", "get_data", "try", ":", "oldData", "=", "{", "\"OSRFramework\"", ":", "get_data", "(", "fPath", ")", "}", "except", ":", "oldData", "=", "{", "\"OSRFramework\"", ...
Workaround to export to a .ods file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", ".", "ods", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L371-L394
train
i3visio/osrframework
osrframework/utils/general.py
usufyToXlsExport
def usufyToXlsExport(d, fPath): """ Workaround to export to a .xls file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_xls import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an array ...
python
def usufyToXlsExport(d, fPath): """ Workaround to export to a .xls file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_xls import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an array ...
[ "def", "usufyToXlsExport", "(", "d", ",", "fPath", ")", ":", "from", "pyexcel_xls", "import", "get_data", "try", ":", "oldData", "=", "{", "\"OSRFramework\"", ":", "get_data", "(", "fPath", ")", "}", "except", ":", "oldData", "=", "{", "\"OSRFramework\"", ...
Workaround to export to a .xls file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", ".", "xls", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L397-L419
train
i3visio/osrframework
osrframework/utils/general.py
usufyToXlsxExport
def usufyToXlsxExport(d, fPath): """ Workaround to export to a .xlsx file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_xlsx import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an arr...
python
def usufyToXlsxExport(d, fPath): """ Workaround to export to a .xlsx file. Args: ----- d: Data to export. fPath: File path for the output file. """ from pyexcel_xlsx import get_data try: #oldData = get_data(fPath) # A change in the API now returns only an arr...
[ "def", "usufyToXlsxExport", "(", "d", ",", "fPath", ")", ":", "from", "pyexcel_xlsx", "import", "get_data", "try", ":", "oldData", "=", "{", "\"OSRFramework\"", ":", "get_data", "(", "fPath", ")", "}", "except", ":", "oldData", "=", "{", "\"OSRFramework\"", ...
Workaround to export to a .xlsx file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", ".", "xlsx", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L422-L445
train
i3visio/osrframework
osrframework/utils/general.py
_generateGraphData
def _generateGraphData(data, oldData=nx.Graph()): """ Processing the data from i3visio structures to generate nodes and edges This function uses the networkx graph library. It will create a new node for each and i3visio.<something> entities while it will add properties for all the attribute startin...
python
def _generateGraphData(data, oldData=nx.Graph()): """ Processing the data from i3visio structures to generate nodes and edges This function uses the networkx graph library. It will create a new node for each and i3visio.<something> entities while it will add properties for all the attribute startin...
[ "def", "_generateGraphData", "(", "data", ",", "oldData", "=", "nx", ".", "Graph", "(", ")", ")", ":", "def", "_addNewNode", "(", "ent", ",", "g", ")", ":", "try", ":", "label", "=", "unicode", "(", "ent", "[", "\"value\"", "]", ")", "except", "Uni...
Processing the data from i3visio structures to generate nodes and edges This function uses the networkx graph library. It will create a new node for each and i3visio.<something> entities while it will add properties for all the attribute starting with "@". Args: ----- d: The i3visio struct...
[ "Processing", "the", "data", "from", "i3visio", "structures", "to", "generate", "nodes", "and", "edges" ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L448-L594
train
i3visio/osrframework
osrframework/utils/general.py
usufyToGmlExport
def usufyToGmlExport(d, fPath): """ Workaround to export data to a .gml file. Args: ----- d: Data to export. fPath: File path for the output file. """ # Reading the previous gml file try: oldData=nx.read_gml(fPath) except UnicodeDecodeError as e: print("U...
python
def usufyToGmlExport(d, fPath): """ Workaround to export data to a .gml file. Args: ----- d: Data to export. fPath: File path for the output file. """ # Reading the previous gml file try: oldData=nx.read_gml(fPath) except UnicodeDecodeError as e: print("U...
[ "def", "usufyToGmlExport", "(", "d", ",", "fPath", ")", ":", "try", ":", "oldData", "=", "nx", ".", "read_gml", "(", "fPath", ")", "except", "UnicodeDecodeError", "as", "e", ":", "print", "(", "\"UnicodeDecodeError:\\t\"", "+", "str", "(", "e", ")", ")",...
Workaround to export data to a .gml file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "data", "to", "a", ".", "gml", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L597-L625
train
i3visio/osrframework
osrframework/utils/general.py
usufyToPngExport
def usufyToPngExport(d, fPath): """ Workaround to export to a png file. Args: ----- d: Data to export. fPath: File path for the output file. """ newGraph = _generateGraphData(d) import matplotlib.pyplot as plt # Writing the png file nx.draw(newGraph) plt.savefig...
python
def usufyToPngExport(d, fPath): """ Workaround to export to a png file. Args: ----- d: Data to export. fPath: File path for the output file. """ newGraph = _generateGraphData(d) import matplotlib.pyplot as plt # Writing the png file nx.draw(newGraph) plt.savefig...
[ "def", "usufyToPngExport", "(", "d", ",", "fPath", ")", ":", "newGraph", "=", "_generateGraphData", "(", "d", ")", "import", "matplotlib", ".", "pyplot", "as", "plt", "nx", ".", "draw", "(", "newGraph", ")", "plt", ".", "savefig", "(", "fPath", ")" ]
Workaround to export to a png file. Args: ----- d: Data to export. fPath: File path for the output file.
[ "Workaround", "to", "export", "to", "a", "png", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L628-L642
train
i3visio/osrframework
osrframework/utils/general.py
fileToMD5
def fileToMD5(filename, block_size=256*128, binary=False): """ A function that calculates the MD5 hash of a file. Args: ----- filename: Path to the file. block_size: Chunks of suitable size. Block size directly depends on the block size of your filesystem to avoid performanc...
python
def fileToMD5(filename, block_size=256*128, binary=False): """ A function that calculates the MD5 hash of a file. Args: ----- filename: Path to the file. block_size: Chunks of suitable size. Block size directly depends on the block size of your filesystem to avoid performanc...
[ "def", "fileToMD5", "(", "filename", ",", "block_size", "=", "256", "*", "128", ",", "binary", "=", "False", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "for", "chunk", ...
A function that calculates the MD5 hash of a file. Args: ----- filename: Path to the file. block_size: Chunks of suitable size. Block size directly depends on the block size of your filesystem to avoid performances issues. Blocks of 4096 octets (Default NTFS). bi...
[ "A", "function", "that", "calculates", "the", "MD5", "hash", "of", "a", "file", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L645-L668
train
i3visio/osrframework
osrframework/utils/general.py
getCurrentStrDatetime
def getCurrentStrDatetime(): """ Generating the current Datetime with a given format Returns: -------- string: The string of a date. """ # Generating current time i = datetime.datetime.now() strTime = "%s-%s-%s_%sh%sm" % (i.year, i.month, i.day, i.hour, i.minute) return strT...
python
def getCurrentStrDatetime(): """ Generating the current Datetime with a given format Returns: -------- string: The string of a date. """ # Generating current time i = datetime.datetime.now() strTime = "%s-%s-%s_%sh%sm" % (i.year, i.month, i.day, i.hour, i.minute) return strT...
[ "def", "getCurrentStrDatetime", "(", ")", ":", "i", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "strTime", "=", "\"%s-%s-%s_%sh%sm\"", "%", "(", "i", ".", "year", ",", "i", ".", "month", ",", "i", ".", "day", ",", "i", ".", "hour", ",",...
Generating the current Datetime with a given format Returns: -------- string: The string of a date.
[ "Generating", "the", "current", "Datetime", "with", "a", "given", "format" ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L671-L682
train
i3visio/osrframework
osrframework/utils/general.py
getFilesFromAFolder
def getFilesFromAFolder(path): """ Getting all the files in a folder. Args: ----- path: The path in which looking for the files Returns: -------- list: The list of filenames found. """ from os import listdir from os.path import isfile, join #onlyfiles = [ f for ...
python
def getFilesFromAFolder(path): """ Getting all the files in a folder. Args: ----- path: The path in which looking for the files Returns: -------- list: The list of filenames found. """ from os import listdir from os.path import isfile, join #onlyfiles = [ f for ...
[ "def", "getFilesFromAFolder", "(", "path", ")", ":", "from", "os", "import", "listdir", "from", "os", ".", "path", "import", "isfile", ",", "join", "onlyFiles", "=", "[", "]", "for", "f", "in", "listdir", "(", "path", ")", ":", "if", "isfile", "(", "...
Getting all the files in a folder. Args: ----- path: The path in which looking for the files Returns: -------- list: The list of filenames found.
[ "Getting", "all", "the", "files", "in", "a", "folder", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L685-L704
train
i3visio/osrframework
osrframework/utils/general.py
urisToBrowser
def urisToBrowser(uris=[], autoraise=True): """ Method that launches the URI in the default browser of the system This function temporally deactivates the standard ouptut and errors to prevent the system to show unwanted messages. This method is based on this question from Stackoverflow. https:...
python
def urisToBrowser(uris=[], autoraise=True): """ Method that launches the URI in the default browser of the system This function temporally deactivates the standard ouptut and errors to prevent the system to show unwanted messages. This method is based on this question from Stackoverflow. https:...
[ "def", "urisToBrowser", "(", "uris", "=", "[", "]", ",", "autoraise", "=", "True", ")", ":", "savout1", "=", "os", ".", "dup", "(", "1", ")", "savout2", "=", "os", ".", "dup", "(", "2", ")", "os", ".", "close", "(", "1", ")", "os", ".", "clos...
Method that launches the URI in the default browser of the system This function temporally deactivates the standard ouptut and errors to prevent the system to show unwanted messages. This method is based on this question from Stackoverflow. https://stackoverflow.com/questions/2323080/how-can-i-disable-...
[ "Method", "that", "launches", "the", "URI", "in", "the", "default", "browser", "of", "the", "system" ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L707-L740
train
i3visio/osrframework
osrframework/utils/general.py
openResultsInBrowser
def openResultsInBrowser(res): """ Method that collects the URI from a list of entities and opens them Args: ----- res: A list containing several i3visio entities. """ print(emphasis("\n\tOpening URIs in the default web browser...")) urisToBrowser(["https://github.com/i3visio/osrfr...
python
def openResultsInBrowser(res): """ Method that collects the URI from a list of entities and opens them Args: ----- res: A list containing several i3visio entities. """ print(emphasis("\n\tOpening URIs in the default web browser...")) urisToBrowser(["https://github.com/i3visio/osrfr...
[ "def", "openResultsInBrowser", "(", "res", ")", ":", "print", "(", "emphasis", "(", "\"\\n\\tOpening URIs in the default web browser...\"", ")", ")", "urisToBrowser", "(", "[", "\"https://github.com/i3visio/osrframework\"", "]", ",", "autoraise", "=", "False", ")", "tim...
Method that collects the URI from a list of entities and opens them Args: ----- res: A list containing several i3visio entities.
[ "Method", "that", "collects", "the", "URI", "from", "a", "list", "of", "entities", "and", "opens", "them" ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L743-L763
train
i3visio/osrframework
osrframework/utils/general.py
colorize
def colorize(text, messageType=None): """ Function that colorizes a message. Args: ----- text: The string to be colorized. messageType: Possible options include "ERROR", "WARNING", "SUCCESS", "INFO" or "BOLD". Returns: -------- string: Colorized if the optio...
python
def colorize(text, messageType=None): """ Function that colorizes a message. Args: ----- text: The string to be colorized. messageType: Possible options include "ERROR", "WARNING", "SUCCESS", "INFO" or "BOLD". Returns: -------- string: Colorized if the optio...
[ "def", "colorize", "(", "text", ",", "messageType", "=", "None", ")", ":", "formattedText", "=", "str", "(", "text", ")", "if", "\"ERROR\"", "in", "messageType", ":", "formattedText", "=", "colorama", ".", "Fore", ".", "RED", "+", "formattedText", "elif", ...
Function that colorizes a message. Args: ----- text: The string to be colorized. messageType: Possible options include "ERROR", "WARNING", "SUCCESS", "INFO" or "BOLD". Returns: -------- string: Colorized if the option is correct, including a tag at the end ...
[ "Function", "that", "colorizes", "a", "message", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L766-L796
train
i3visio/osrframework
osrframework/utils/general.py
showLicense
def showLicense(): """ Method that prints the license if requested. It tries to find the license online and manually download it. This method only prints its contents in plain text. """ print("Trying to recover the contents of the license...\n") try: # Grab the license online and pr...
python
def showLicense(): """ Method that prints the license if requested. It tries to find the license online and manually download it. This method only prints its contents in plain text. """ print("Trying to recover the contents of the license...\n") try: # Grab the license online and pr...
[ "def", "showLicense", "(", ")", ":", "print", "(", "\"Trying to recover the contents of the license...\\n\"", ")", "try", ":", "text", "=", "urllib", ".", "urlopen", "(", "LICENSE_URL", ")", ".", "read", "(", ")", "print", "(", "\"License retrieved from \"", "+", ...
Method that prints the license if requested. It tries to find the license online and manually download it. This method only prints its contents in plain text.
[ "Method", "that", "prints", "the", "license", "if", "requested", "." ]
83437f4c14c9c08cb80a896bd9834c77f6567871
https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/utils/general.py#L823-L838
train