repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
pyros-dev/pyros-common | pyros_interfaces_common/regex_tools.py | find_first_regex_match | def find_first_regex_match(key, regex_candidates):
"""
find the first regex that match with the key
:param key: a key to try to match against multiple regex
:param match_candidates: a list of regexes to check if they match the key
:return: the first candidate found
"""
for cand in regex_cand... | python | def find_first_regex_match(key, regex_candidates):
"""
find the first regex that match with the key
:param key: a key to try to match against multiple regex
:param match_candidates: a list of regexes to check if they match the key
:return: the first candidate found
"""
for cand in regex_cand... | [
"def",
"find_first_regex_match",
"(",
"key",
",",
"regex_candidates",
")",
":",
"for",
"cand",
"in",
"regex_candidates",
":",
"try",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"cap_match_string",
"(",
"cand",
")",
")",
"if",
"pattern",
".",
"match",
"... | find the first regex that match with the key
:param key: a key to try to match against multiple regex
:param match_candidates: a list of regexes to check if they match the key
:return: the first candidate found | [
"find",
"the",
"first",
"regex",
"that",
"match",
"with",
"the",
"key",
":",
"param",
"key",
":",
"a",
"key",
"to",
"try",
"to",
"match",
"against",
"multiple",
"regex",
":",
"param",
"match_candidates",
":",
"a",
"list",
"of",
"regexes",
"to",
"check",
... | train | https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/regex_tools.py#L21-L36 |
pyros-dev/pyros-common | pyros_interfaces_common/regex_tools.py | regex_match_sublist | def regex_match_sublist(regex, match_candidates):
"""
Filter the match_candidates list to return only the candidate that match the regex
:param regex: a regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the candidates that ... | python | def regex_match_sublist(regex, match_candidates):
"""
Filter the match_candidates list to return only the candidate that match the regex
:param regex: a regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the candidates that ... | [
"def",
"regex_match_sublist",
"(",
"regex",
",",
"match_candidates",
")",
":",
"matches",
"=",
"[",
"]",
"try",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"cap_match_string",
"(",
"regex",
")",
")",
"matches",
"=",
"[",
"cand",
"for",
"cand",
"in",
... | Filter the match_candidates list to return only the candidate that match the regex
:param regex: a regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the candidates that match the regex | [
"Filter",
"the",
"match_candidates",
"list",
"to",
"return",
"only",
"the",
"candidate",
"that",
"match",
"the",
"regex",
":",
"param",
"regex",
":",
"a",
"regex",
"used",
"to",
"filter",
"the",
"list",
"of",
"candidates",
":",
"param",
"match_candidates",
"... | train | https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/regex_tools.py#L39-L52 |
pyros-dev/pyros-common | pyros_interfaces_common/regex_tools.py | regexes_match_sublist | def regexes_match_sublist(regexes, match_candidates):
"""
Filter the match_candidates list to return only the candidate that match the regex
:param regexes: a list of regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the ca... | python | def regexes_match_sublist(regexes, match_candidates):
"""
Filter the match_candidates list to return only the candidate that match the regex
:param regexes: a list of regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the ca... | [
"def",
"regexes_match_sublist",
"(",
"regexes",
",",
"match_candidates",
")",
":",
"return",
"[",
"match",
"for",
"sublist",
"in",
"[",
"regex_match_sublist",
"(",
"rgx",
",",
"match_candidates",
")",
"for",
"rgx",
"in",
"regexes",
"]",
"for",
"match",
"in",
... | Filter the match_candidates list to return only the candidate that match the regex
:param regexes: a list of regex used to filter the list of candidates
:param match_candidates: the list of candidates
:return: the filtered list of only the candidates that match the regex | [
"Filter",
"the",
"match_candidates",
"list",
"to",
"return",
"only",
"the",
"candidate",
"that",
"match",
"the",
"regex",
":",
"param",
"regexes",
":",
"a",
"list",
"of",
"regex",
"used",
"to",
"filter",
"the",
"list",
"of",
"candidates",
":",
"param",
"ma... | train | https://github.com/pyros-dev/pyros-common/blob/0709538b8777ec055ea31f59cdca5bebaaabb04e/pyros_interfaces_common/regex_tools.py#L55-L63 |
mattupstate/cubric | cubric/providers/amazon.py | create_server | def create_server():
"""Creates an EC2 Server"""
try:
import boto
except ImportError:
sys.exit("boto library required for creating servers with Amazon.")
print(green("Creating EC2 server"))
conn = boto.connect_ec2(
get_or_prompt('ec2_key', 'API Key'),
get_or_prompt... | python | def create_server():
"""Creates an EC2 Server"""
try:
import boto
except ImportError:
sys.exit("boto library required for creating servers with Amazon.")
print(green("Creating EC2 server"))
conn = boto.connect_ec2(
get_or_prompt('ec2_key', 'API Key'),
get_or_prompt... | [
"def",
"create_server",
"(",
")",
":",
"try",
":",
"import",
"boto",
"except",
"ImportError",
":",
"sys",
".",
"exit",
"(",
"\"boto library required for creating servers with Amazon.\"",
")",
"print",
"(",
"green",
"(",
"\"Creating EC2 server\"",
")",
")",
"conn",
... | Creates an EC2 Server | [
"Creates",
"an",
"EC2",
"Server"
] | train | https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/providers/amazon.py#L11-L55 |
jcalogovic/lightning | stormstats/downloader.py | return_time_elements | def return_time_elements(time_stamp):
"""Returns formatted strings of time stamps for HTML requests.
:parameters time_range: pandas.tslib.Timestamp
"""
yyyy = str(time_stamp.year)
mm = "%02d" % (time_stamp.month,)
dd = "%02d" % (time_stamp.day,)
hr = "%02d" % (time_stamp.hour,)
mins = "... | python | def return_time_elements(time_stamp):
"""Returns formatted strings of time stamps for HTML requests.
:parameters time_range: pandas.tslib.Timestamp
"""
yyyy = str(time_stamp.year)
mm = "%02d" % (time_stamp.month,)
dd = "%02d" % (time_stamp.day,)
hr = "%02d" % (time_stamp.hour,)
mins = "... | [
"def",
"return_time_elements",
"(",
"time_stamp",
")",
":",
"yyyy",
"=",
"str",
"(",
"time_stamp",
".",
"year",
")",
"mm",
"=",
"\"%02d\"",
"%",
"(",
"time_stamp",
".",
"month",
",",
")",
"dd",
"=",
"\"%02d\"",
"%",
"(",
"time_stamp",
".",
"day",
",",
... | Returns formatted strings of time stamps for HTML requests.
:parameters time_range: pandas.tslib.Timestamp | [
"Returns",
"formatted",
"strings",
"of",
"time",
"stamps",
"for",
"HTML",
"requests",
"."
] | train | https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/downloader.py#L10-L20 |
jcalogovic/lightning | stormstats/downloader.py | get_data | def get_data(start, end, username=None, password=None,
data_path=os.path.abspath(".")+'/tmp_data'):
"""**Download data (badly) from Blitzorg**
Using a specified time stamp for start and end, data is downloaded at a
default frequency (10 minute intervals). If a directory called data is not
... | python | def get_data(start, end, username=None, password=None,
data_path=os.path.abspath(".")+'/tmp_data'):
"""**Download data (badly) from Blitzorg**
Using a specified time stamp for start and end, data is downloaded at a
default frequency (10 minute intervals). If a directory called data is not
... | [
"def",
"get_data",
"(",
"start",
",",
"end",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"data_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"\".\"",
")",
"+",
"'/tmp_data'",
")",
":",
"dl_link",
"=",
"\"http://data.blitzortung... | **Download data (badly) from Blitzorg**
Using a specified time stamp for start and end, data is downloaded at a
default frequency (10 minute intervals). If a directory called data is not
present, it will be added to the cwd as the target for the downloads.
This is probably a bad idea however. It is muc... | [
"**",
"Download",
"data",
"(",
"badly",
")",
"from",
"Blitzorg",
"**"
] | train | https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/downloader.py#L23-L69 |
jcalogovic/lightning | stormstats/downloader.py | blitz_parser | def blitz_parser():
"""The start of a Blitzorg data parser. Read an unzipped file from Bzorg,
into a json object retrieved with .get_data().
"""
with gzip.open('tmp_data/bz-2015-02-01-06-30.json.gz', 'rb') as f:
file_content = f.read()
tx = file_content.strip()
k = tx.decode(encoding='ut... | python | def blitz_parser():
"""The start of a Blitzorg data parser. Read an unzipped file from Bzorg,
into a json object retrieved with .get_data().
"""
with gzip.open('tmp_data/bz-2015-02-01-06-30.json.gz', 'rb') as f:
file_content = f.read()
tx = file_content.strip()
k = tx.decode(encoding='ut... | [
"def",
"blitz_parser",
"(",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"'tmp_data/bz-2015-02-01-06-30.json.gz'",
",",
"'rb'",
")",
"as",
"f",
":",
"file_content",
"=",
"f",
".",
"read",
"(",
")",
"tx",
"=",
"file_content",
".",
"strip",
"(",
")",
"k",
... | The start of a Blitzorg data parser. Read an unzipped file from Bzorg,
into a json object retrieved with .get_data(). | [
"The",
"start",
"of",
"a",
"Blitzorg",
"data",
"parser",
".",
"Read",
"an",
"unzipped",
"file",
"from",
"Bzorg",
"into",
"a",
"json",
"object",
"retrieved",
"with",
".",
"get_data",
"()",
"."
] | train | https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/downloader.py#L72-L82 |
samfcmc/fenixedu-python-sdk | fenixedu/configuration.py | FenixEduConfiguration.fromConfigFile | def fromConfigFile(filename = DEFAULT_CONFIG_FILE):
""" Read settings from configuration file"""
parser = SafeConfigParser()
section = 'fenixedu'
parser.read(filename)
client_id = parser.get(section, 'client_id')
redirect_uri = parser.get(section, 'redirect_uri')
client_secret = parser.get(... | python | def fromConfigFile(filename = DEFAULT_CONFIG_FILE):
""" Read settings from configuration file"""
parser = SafeConfigParser()
section = 'fenixedu'
parser.read(filename)
client_id = parser.get(section, 'client_id')
redirect_uri = parser.get(section, 'redirect_uri')
client_secret = parser.get(... | [
"def",
"fromConfigFile",
"(",
"filename",
"=",
"DEFAULT_CONFIG_FILE",
")",
":",
"parser",
"=",
"SafeConfigParser",
"(",
")",
"section",
"=",
"'fenixedu'",
"parser",
".",
"read",
"(",
"filename",
")",
"client_id",
"=",
"parser",
".",
"get",
"(",
"section",
",... | Read settings from configuration file | [
"Read",
"settings",
"from",
"configuration",
"file"
] | train | https://github.com/samfcmc/fenixedu-python-sdk/blob/b9a1366853b2e7a6e208c46c3b99a589062677a9/fenixedu/configuration.py#L17-L36 |
mayfield/shellish | shellish/session.py | Session.map_subcommands | def map_subcommands(self, func):
""" Run `func` against all the subcommands attached to our root
command. """
def crawl(cmd):
for sc in cmd.subcommands.values():
yield from crawl(sc)
yield cmd
return map(func, crawl(self.root_command)) | python | def map_subcommands(self, func):
""" Run `func` against all the subcommands attached to our root
command. """
def crawl(cmd):
for sc in cmd.subcommands.values():
yield from crawl(sc)
yield cmd
return map(func, crawl(self.root_command)) | [
"def",
"map_subcommands",
"(",
"self",
",",
"func",
")",
":",
"def",
"crawl",
"(",
"cmd",
")",
":",
"for",
"sc",
"in",
"cmd",
".",
"subcommands",
".",
"values",
"(",
")",
":",
"yield",
"from",
"crawl",
"(",
"sc",
")",
"yield",
"cmd",
"return",
"map... | Run `func` against all the subcommands attached to our root
command. | [
"Run",
"func",
"against",
"all",
"the",
"subcommands",
"attached",
"to",
"our",
"root",
"command",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L89-L97 |
mayfield/shellish | shellish/session.py | Session.execute | def execute(self, command, args):
""" Event firing and exception conversion around command execution.
Common exceptions are run through our exception handler for
pretty-printing or debugging and then converted to SystemExit so the
interpretor will exit without further ado (or be caught i... | python | def execute(self, command, args):
""" Event firing and exception conversion around command execution.
Common exceptions are run through our exception handler for
pretty-printing or debugging and then converted to SystemExit so the
interpretor will exit without further ado (or be caught i... | [
"def",
"execute",
"(",
"self",
",",
"command",
",",
"args",
")",
":",
"self",
".",
"fire_event",
"(",
"'precmd'",
",",
"command",
",",
"args",
")",
"try",
":",
"try",
":",
"result",
"=",
"command",
".",
"run_wrap",
"(",
"args",
")",
"except",
"BaseEx... | Event firing and exception conversion around command execution.
Common exceptions are run through our exception handler for
pretty-printing or debugging and then converted to SystemExit so the
interpretor will exit without further ado (or be caught if
interactive). | [
"Event",
"firing",
"and",
"exception",
"conversion",
"around",
"command",
"execution",
".",
"Common",
"exceptions",
"are",
"run",
"through",
"our",
"exception",
"handler",
"for",
"pretty",
"-",
"printing",
"or",
"debugging",
"and",
"then",
"converted",
"to",
"Sy... | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L103-L132 |
mayfield/shellish | shellish/session.py | Session.handle_command_error | def handle_command_error(self, command, args, exc):
""" Depending on how the session is configured this will print
information about an unhandled command exception or possibly jump
to some other behavior like a debugger. """
verbosity = self.command_error_verbosity
if verbosity =... | python | def handle_command_error(self, command, args, exc):
""" Depending on how the session is configured this will print
information about an unhandled command exception or possibly jump
to some other behavior like a debugger. """
verbosity = self.command_error_verbosity
if verbosity =... | [
"def",
"handle_command_error",
"(",
"self",
",",
"command",
",",
"args",
",",
"exc",
")",
":",
"verbosity",
"=",
"self",
".",
"command_error_verbosity",
"if",
"verbosity",
"==",
"'traceback'",
":",
"self",
".",
"pretty_print_exc",
"(",
"command",
",",
"exc",
... | Depending on how the session is configured this will print
information about an unhandled command exception or possibly jump
to some other behavior like a debugger. | [
"Depending",
"on",
"how",
"the",
"session",
"is",
"configured",
"this",
"will",
"print",
"information",
"about",
"an",
"unhandled",
"command",
"exception",
"or",
"possibly",
"jump",
"to",
"some",
"other",
"behavior",
"like",
"a",
"debugger",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L134-L149 |
mayfield/shellish | shellish/session.py | Session.cmd_split | def cmd_split(self, line):
""" Get the command associated with this input line. """
cmd, *args = line.lstrip().split(' ', 1)
return self.root_command.subcommands[cmd], ' '.join(args) | python | def cmd_split(self, line):
""" Get the command associated with this input line. """
cmd, *args = line.lstrip().split(' ', 1)
return self.root_command.subcommands[cmd], ' '.join(args) | [
"def",
"cmd_split",
"(",
"self",
",",
"line",
")",
":",
"cmd",
",",
"",
"*",
"args",
"=",
"line",
".",
"lstrip",
"(",
")",
".",
"split",
"(",
"' '",
",",
"1",
")",
"return",
"self",
".",
"root_command",
".",
"subcommands",
"[",
"cmd",
"]",
",",
... | Get the command associated with this input line. | [
"Get",
"the",
"command",
"associated",
"with",
"this",
"input",
"line",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L174-L177 |
mayfield/shellish | shellish/session.py | Session.complete_wrap | def complete_wrap(self, func, *args, **kwargs):
""" Readline eats exceptions raised by completer functions. """
# Workaround readline's one-time-read of terminal width.
termcols = shutil.get_terminal_size()[0]
readline.parse_and_bind('set completion-display-width %d' % termcols)
... | python | def complete_wrap(self, func, *args, **kwargs):
""" Readline eats exceptions raised by completer functions. """
# Workaround readline's one-time-read of terminal width.
termcols = shutil.get_terminal_size()[0]
readline.parse_and_bind('set completion-display-width %d' % termcols)
... | [
"def",
"complete_wrap",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Workaround readline's one-time-read of terminal width.",
"termcols",
"=",
"shutil",
".",
"get_terminal_size",
"(",
")",
"[",
"0",
"]",
"readline",
".",
"p... | Readline eats exceptions raised by completer functions. | [
"Readline",
"eats",
"exceptions",
"raised",
"by",
"completer",
"functions",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L206-L215 |
mayfield/shellish | shellish/session.py | Session.setup_readline | def setup_readline(self):
""" Configure our tab completion settings for a context and then
restore them to previous settings on exit. """
readline.parse_and_bind('tab: complete')
completer_save = readline.get_completer()
delims_save = readline.get_completer_delims()
delim... | python | def setup_readline(self):
""" Configure our tab completion settings for a context and then
restore them to previous settings on exit. """
readline.parse_and_bind('tab: complete')
completer_save = readline.get_completer()
delims_save = readline.get_completer_delims()
delim... | [
"def",
"setup_readline",
"(",
"self",
")",
":",
"readline",
".",
"parse_and_bind",
"(",
"'tab: complete'",
")",
"completer_save",
"=",
"readline",
".",
"get_completer",
"(",
")",
"delims_save",
"=",
"readline",
".",
"get_completer_delims",
"(",
")",
"delims",
"=... | Configure our tab completion settings for a context and then
restore them to previous settings on exit. | [
"Configure",
"our",
"tab",
"completion",
"settings",
"for",
"a",
"context",
"and",
"then",
"restore",
"them",
"to",
"previous",
"settings",
"on",
"exit",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L222-L239 |
mayfield/shellish | shellish/session.py | Session.run_loop | def run_loop(self):
""" Main entry point for running in interactive mode. """
self.root_command.prog = ''
history_file = self.load_history()
rendering.vtmlprint(self.intro)
try:
self.loop()
finally:
readline.write_history_file(history_file) | python | def run_loop(self):
""" Main entry point for running in interactive mode. """
self.root_command.prog = ''
history_file = self.load_history()
rendering.vtmlprint(self.intro)
try:
self.loop()
finally:
readline.write_history_file(history_file) | [
"def",
"run_loop",
"(",
"self",
")",
":",
"self",
".",
"root_command",
".",
"prog",
"=",
"''",
"history_file",
"=",
"self",
".",
"load_history",
"(",
")",
"rendering",
".",
"vtmlprint",
"(",
"self",
".",
"intro",
")",
"try",
":",
"self",
".",
"loop",
... | Main entry point for running in interactive mode. | [
"Main",
"entry",
"point",
"for",
"running",
"in",
"interactive",
"mode",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L241-L249 |
mayfield/shellish | shellish/session.py | Session.loop | def loop(self):
""" Inner loop for interactive mode. Do not call directly. """
while True:
with self.setup_readline():
try:
line = input(self.prompt)
except EOFError:
_vprinterr('^D')
break
... | python | def loop(self):
""" Inner loop for interactive mode. Do not call directly. """
while True:
with self.setup_readline():
try:
line = input(self.prompt)
except EOFError:
_vprinterr('^D')
break
... | [
"def",
"loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"with",
"self",
".",
"setup_readline",
"(",
")",
":",
"try",
":",
"line",
"=",
"input",
"(",
"self",
".",
"prompt",
")",
"except",
"EOFError",
":",
"_vprinterr",
"(",
"'^D'",
")",
"break",
... | Inner loop for interactive mode. Do not call directly. | [
"Inner",
"loop",
"for",
"interactive",
"mode",
".",
"Do",
"not",
"call",
"directly",
"."
] | train | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/session.py#L251-L275 |
honzamach/pynspect | pynspect/rules.py | LogicalBinOpRule.traverse | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argu... | python | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argu... | [
"def",
"traverse",
"(",
"self",
",",
"traverser",
",",
"*",
"*",
"kwargs",
")",
":",
"lrt",
"=",
"self",
".",
"left",
".",
"traverse",
"(",
"traverser",
",",
"*",
"*",
"kwargs",
")",
"rrt",
"=",
"self",
".",
"right",
".",
"traverse",
"(",
"traverse... | Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argument, with the
result of traversing left subtree as s... | [
"Implementation",
"of",
"mandatory",
"interface",
"for",
"traversing",
"the",
"whole",
"rule",
"tree",
".",
"This",
"method",
"will",
"call",
"the",
"implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"rules",
".",
"RuleTreeTraverser",
".",
... | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/rules.py#L459-L474 |
honzamach/pynspect | pynspect/rules.py | UnaryOperationRule.traverse | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argu... | python | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argu... | [
"def",
"traverse",
"(",
"self",
",",
"traverser",
",",
"*",
"*",
"kwargs",
")",
":",
"rrt",
"=",
"self",
".",
"right",
".",
"traverse",
"(",
"traverser",
",",
"*",
"*",
"kwargs",
")",
"return",
"traverser",
".",
"unary_operation",
"(",
"self",
",",
"... | Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.binary_operation_logical`
method with reference to ``self`` instance as first argument and with the
result of traversing left subtree a... | [
"Implementation",
"of",
"mandatory",
"interface",
"for",
"traversing",
"the",
"whole",
"rule",
"tree",
".",
"This",
"method",
"will",
"call",
"the",
"implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"rules",
".",
"RuleTreeTraverser",
".",
... | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/rules.py#L547-L560 |
honzamach/pynspect | pynspect/rules.py | FunctionRule.traverse | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.function`
method with reference to ``self`` instance as first argument and with th... | python | def traverse(self, traverser, **kwargs):
"""
Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.function`
method with reference to ``self`` instance as first argument and with th... | [
"def",
"traverse",
"(",
"self",
",",
"traverser",
",",
"*",
"*",
"kwargs",
")",
":",
"atr",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"atr",
".",
"append",
"(",
"arg",
".",
"traverse",
"(",
"traverser",
",",
"*",
"*",
"kwargs",... | Implementation of mandatory interface for traversing the whole rule tree.
This method will call the implementation of :py:func:`pynspect.rules.RuleTreeTraverser.function`
method with reference to ``self`` instance as first argument and with the
result of traversing left subtree as second argumen... | [
"Implementation",
"of",
"mandatory",
"interface",
"for",
"traversing",
"the",
"whole",
"rule",
"tree",
".",
"This",
"method",
"will",
"call",
"the",
"implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"rules",
".",
"RuleTreeTraverser",
".",
... | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/rules.py#L583-L598 |
eugene-eeo/piggyback | piggyback/loader.py | import_module | def import_module(path):
"""
Import a module given a dotted *path* in the
form of ``.name(.name)*``, and returns the
last module (unlike ``__import__`` which just
returns the first module).
:param path: The dotted path to the module.
"""
mod = __import__(path, locals={}, globals={})
... | python | def import_module(path):
"""
Import a module given a dotted *path* in the
form of ``.name(.name)*``, and returns the
last module (unlike ``__import__`` which just
returns the first module).
:param path: The dotted path to the module.
"""
mod = __import__(path, locals={}, globals={})
... | [
"def",
"import_module",
"(",
"path",
")",
":",
"mod",
"=",
"__import__",
"(",
"path",
",",
"locals",
"=",
"{",
"}",
",",
"globals",
"=",
"{",
"}",
")",
"for",
"item",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
":",
"]",
":",
"try",
... | Import a module given a dotted *path* in the
form of ``.name(.name)*``, and returns the
last module (unlike ``__import__`` which just
returns the first module).
:param path: The dotted path to the module. | [
"Import",
"a",
"module",
"given",
"a",
"dotted",
"*",
"path",
"*",
"in",
"the",
"form",
"of",
".",
"name",
"(",
".",
"name",
")",
"*",
"and",
"returns",
"the",
"last",
"module",
"(",
"unlike",
"__import__",
"which",
"just",
"returns",
"the",
"first",
... | train | https://github.com/eugene-eeo/piggyback/blob/0e5efe40a37aa0373d860b8dabab1282bf074270/piggyback/loader.py#L34-L49 |
langloisjp/tstore | tstore/pgtablestorage.py | sqlselect | def sqlselect(table, fields=['*'], where=None, orderby=None, limit=None,
offset=None):
"""Generates SQL select ...
Returns (sql, params)
>>> sqlselect('t')
('select * from t', [])
>>> sqlselect('t', fields=['name', 'address'])
('select name, address from t', [])
>>> sqlselect(... | python | def sqlselect(table, fields=['*'], where=None, orderby=None, limit=None,
offset=None):
"""Generates SQL select ...
Returns (sql, params)
>>> sqlselect('t')
('select * from t', [])
>>> sqlselect('t', fields=['name', 'address'])
('select name, address from t', [])
>>> sqlselect(... | [
"def",
"sqlselect",
"(",
"table",
",",
"fields",
"=",
"[",
"'*'",
"]",
",",
"where",
"=",
"None",
",",
"orderby",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"validate_name",
"(",
"table",
")",
"if",
"fields",
"!="... | Generates SQL select ...
Returns (sql, params)
>>> sqlselect('t')
('select * from t', [])
>>> sqlselect('t', fields=['name', 'address'])
('select name, address from t', [])
>>> sqlselect('t', where={'name': 'Toto', 'country': 'US'})
('select * from t where country=%s and name=%s', ['US', 'T... | [
"Generates",
"SQL",
"select",
"...",
"Returns",
"(",
"sql",
"params",
")"
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L304-L357 |
langloisjp/tstore | tstore/pgtablestorage.py | sqlinsert | def sqlinsert(table, row):
"""Generates SQL insert into table ...
Returns (sql, parameters)
>>> sqlinsert('mytable', {'field1': 2, 'field2': 'toto'})
('insert into mytable (field1, field2) values (%s, %s)', [2, 'toto'])
>>> sqlinsert('t2', {'id': 1, 'name': 'Toto'})
('insert into t2 (id, name) ... | python | def sqlinsert(table, row):
"""Generates SQL insert into table ...
Returns (sql, parameters)
>>> sqlinsert('mytable', {'field1': 2, 'field2': 'toto'})
('insert into mytable (field1, field2) values (%s, %s)', [2, 'toto'])
>>> sqlinsert('t2', {'id': 1, 'name': 'Toto'})
('insert into t2 (id, name) ... | [
"def",
"sqlinsert",
"(",
"table",
",",
"row",
")",
":",
"validate_name",
"(",
"table",
")",
"fields",
"=",
"sorted",
"(",
"row",
".",
"keys",
"(",
")",
")",
"validate_names",
"(",
"fields",
")",
"values",
"=",
"[",
"row",
"[",
"field",
"]",
"for",
... | Generates SQL insert into table ...
Returns (sql, parameters)
>>> sqlinsert('mytable', {'field1': 2, 'field2': 'toto'})
('insert into mytable (field1, field2) values (%s, %s)', [2, 'toto'])
>>> sqlinsert('t2', {'id': 1, 'name': 'Toto'})
('insert into t2 (id, name) values (%s, %s)', [1, 'Toto']) | [
"Generates",
"SQL",
"insert",
"into",
"table",
"...",
"Returns",
"(",
"sql",
"parameters",
")"
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L360-L375 |
langloisjp/tstore | tstore/pgtablestorage.py | sqlupdate | def sqlupdate(table, rowupdate, where):
"""Generates SQL update table set ...
Returns (sql, parameters)
>>> sqlupdate('mytable', {'field1': 3, 'field2': 'hello'}, {'id': 5})
('update mytable set field1=%s, field2=%s where id=%s', [3, 'hello', 5])
"""
validate_name(table)
fields = sorted(row... | python | def sqlupdate(table, rowupdate, where):
"""Generates SQL update table set ...
Returns (sql, parameters)
>>> sqlupdate('mytable', {'field1': 3, 'field2': 'hello'}, {'id': 5})
('update mytable set field1=%s, field2=%s where id=%s', [3, 'hello', 5])
"""
validate_name(table)
fields = sorted(row... | [
"def",
"sqlupdate",
"(",
"table",
",",
"rowupdate",
",",
"where",
")",
":",
"validate_name",
"(",
"table",
")",
"fields",
"=",
"sorted",
"(",
"rowupdate",
".",
"keys",
"(",
")",
")",
"validate_names",
"(",
"fields",
")",
"values",
"=",
"[",
"rowupdate",
... | Generates SQL update table set ...
Returns (sql, parameters)
>>> sqlupdate('mytable', {'field1': 3, 'field2': 'hello'}, {'id': 5})
('update mytable set field1=%s, field2=%s where id=%s', [3, 'hello', 5]) | [
"Generates",
"SQL",
"update",
"table",
"set",
"...",
"Returns",
"(",
"sql",
"parameters",
")"
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L378-L395 |
langloisjp/tstore | tstore/pgtablestorage.py | sqldelete | def sqldelete(table, where):
"""Generates SQL delete from ... where ...
>>> sqldelete('t', {'id': 5})
('delete from t where id=%s', [5])
"""
validate_name(table)
(whereclause, wherevalues) = sqlwhere(where)
sql = "delete from {}".format(table)
if whereclause:
sql += " where " + ... | python | def sqldelete(table, where):
"""Generates SQL delete from ... where ...
>>> sqldelete('t', {'id': 5})
('delete from t where id=%s', [5])
"""
validate_name(table)
(whereclause, wherevalues) = sqlwhere(where)
sql = "delete from {}".format(table)
if whereclause:
sql += " where " + ... | [
"def",
"sqldelete",
"(",
"table",
",",
"where",
")",
":",
"validate_name",
"(",
"table",
")",
"(",
"whereclause",
",",
"wherevalues",
")",
"=",
"sqlwhere",
"(",
"where",
")",
"sql",
"=",
"\"delete from {}\"",
".",
"format",
"(",
"table",
")",
"if",
"wher... | Generates SQL delete from ... where ...
>>> sqldelete('t', {'id': 5})
('delete from t where id=%s', [5]) | [
"Generates",
"SQL",
"delete",
"from",
"...",
"where",
"..."
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L398-L409 |
langloisjp/tstore | tstore/pgtablestorage.py | sqlwhere | def sqlwhere(criteria=None):
"""Generates SQL where clause. Returns (sql, values).
Criteria is a dictionary of {field: value}.
>>> sqlwhere()
('', [])
>>> sqlwhere({'id': 5})
('id=%s', [5])
>>> sqlwhere({'id': 3, 'name': 'toto'})
('id=%s and name=%s', [3, 'toto'])
>>> sqlwhere({'id'... | python | def sqlwhere(criteria=None):
"""Generates SQL where clause. Returns (sql, values).
Criteria is a dictionary of {field: value}.
>>> sqlwhere()
('', [])
>>> sqlwhere({'id': 5})
('id=%s', [5])
>>> sqlwhere({'id': 3, 'name': 'toto'})
('id=%s and name=%s', [3, 'toto'])
>>> sqlwhere({'id'... | [
"def",
"sqlwhere",
"(",
"criteria",
"=",
"None",
")",
":",
"if",
"not",
"criteria",
":",
"return",
"(",
"''",
",",
"[",
"]",
")",
"fields",
"=",
"sorted",
"(",
"criteria",
".",
"keys",
"(",
")",
")",
"validate_names",
"(",
"fields",
")",
"values",
... | Generates SQL where clause. Returns (sql, values).
Criteria is a dictionary of {field: value}.
>>> sqlwhere()
('', [])
>>> sqlwhere({'id': 5})
('id=%s', [5])
>>> sqlwhere({'id': 3, 'name': 'toto'})
('id=%s and name=%s', [3, 'toto'])
>>> sqlwhere({'id': 3, 'name': 'toto', 'createdon': '2... | [
"Generates",
"SQL",
"where",
"clause",
".",
"Returns",
"(",
"sql",
"values",
")",
".",
"Criteria",
"is",
"a",
"dictionary",
"of",
"{",
"field",
":",
"value",
"}",
"."
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L412-L432 |
langloisjp/tstore | tstore/pgtablestorage.py | parse_dburl | def parse_dburl(dburl):
"""Parse DB URL. Return (scheme, user, password, host, dbname)
pg://user:pass@host/dbname
>>> parse_dburl("pg://user:pass@host/name")
('pg', 'user', 'pass', 'host', 'name')
>>> parse_dburl("dbm:///dbfile")
('dbm', '', '', '', 'dbfile')
>>> parse_dburl("pg://user:@/na... | python | def parse_dburl(dburl):
"""Parse DB URL. Return (scheme, user, password, host, dbname)
pg://user:pass@host/dbname
>>> parse_dburl("pg://user:pass@host/name")
('pg', 'user', 'pass', 'host', 'name')
>>> parse_dburl("dbm:///dbfile")
('dbm', '', '', '', 'dbfile')
>>> parse_dburl("pg://user:@/na... | [
"def",
"parse_dburl",
"(",
"dburl",
")",
":",
"res",
"=",
"urlparse",
".",
"urlparse",
"(",
"dburl",
")",
"if",
"'@'",
"in",
"res",
".",
"netloc",
":",
"(",
"creds",
",",
"host",
")",
"=",
"res",
".",
"netloc",
".",
"split",
"(",
"'@'",
")",
"els... | Parse DB URL. Return (scheme, user, password, host, dbname)
pg://user:pass@host/dbname
>>> parse_dburl("pg://user:pass@host/name")
('pg', 'user', 'pass', 'host', 'name')
>>> parse_dburl("dbm:///dbfile")
('dbm', '', '', '', 'dbfile')
>>> parse_dburl("pg://user:@/name")
('pg', 'user', '', '',... | [
"Parse",
"DB",
"URL",
".",
"Return",
"(",
"scheme",
"user",
"password",
"host",
"dbname",
")",
"pg",
":",
"//",
"user",
":",
"pass@host",
"/",
"dbname"
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L472-L492 |
langloisjp/tstore | tstore/pgtablestorage.py | DB.select | def select(self, table, fields=['*'], where=None, orderby=None,
limit=None, offset=None):
"""
Query and return list of records.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop tabl... | python | def select(self, table, fields=['*'], where=None, orderby=None,
limit=None, offset=None):
"""
Query and return list of records.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop tabl... | [
"def",
"select",
"(",
"self",
",",
"table",
",",
"fields",
"=",
"[",
"'*'",
"]",
",",
"where",
"=",
"None",
",",
"orderby",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"offset",
"=",
"None",
")",
":",
"(",
"sql",
",",
"values",
")",
"=",
"sqls... | Query and return list of records.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop table if exists t2')
>>> s.execute('create table t2 (id int, name text)')
>>> s.insert('t2', {'id': 1, 'name': 'T... | [
"Query",
"and",
"return",
"list",
"of",
"records",
"."
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L98-L118 |
langloisjp/tstore | tstore/pgtablestorage.py | DB.insert | def insert(self, table, row):
"""
Add new row. Row must be a dict or implement the mapping interface.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop table if exists t2')
>>> s.execute('c... | python | def insert(self, table, row):
"""
Add new row. Row must be a dict or implement the mapping interface.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop table if exists t2')
>>> s.execute('c... | [
"def",
"insert",
"(",
"self",
",",
"table",
",",
"row",
")",
":",
"(",
"sql",
",",
"values",
")",
"=",
"sqlinsert",
"(",
"table",
",",
"row",
")",
"self",
".",
"execute",
"(",
"sql",
",",
"values",
")"
] | Add new row. Row must be a dict or implement the mapping interface.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
>>> s.execute('drop table if exists t2')
>>> s.execute('create table t2 (id int, name text)')
>>> s... | [
"Add",
"new",
"row",
".",
"Row",
"must",
"be",
"a",
"dict",
"or",
"implement",
"the",
"mapping",
"interface",
"."
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L120-L138 |
langloisjp/tstore | tstore/pgtablestorage.py | DB.update | def update(self, table, rowupdate, where):
"""
Update matching records.
- rowupdate is a dict with updated fields, e.g. {'name': 'John'}.
- See `sqlwhere` for where clause.
Returns the number of rows updated.
>>> import getpass
>>> s = DB(dbname='test', user=get... | python | def update(self, table, rowupdate, where):
"""
Update matching records.
- rowupdate is a dict with updated fields, e.g. {'name': 'John'}.
- See `sqlwhere` for where clause.
Returns the number of rows updated.
>>> import getpass
>>> s = DB(dbname='test', user=get... | [
"def",
"update",
"(",
"self",
",",
"table",
",",
"rowupdate",
",",
"where",
")",
":",
"(",
"sql",
",",
"values",
")",
"=",
"sqlupdate",
"(",
"table",
",",
"rowupdate",
",",
"where",
")",
"return",
"self",
".",
"execute",
"(",
"sql",
",",
"values",
... | Update matching records.
- rowupdate is a dict with updated fields, e.g. {'name': 'John'}.
- See `sqlwhere` for where clause.
Returns the number of rows updated.
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(), host='localhost',
... password='')
... | [
"Update",
"matching",
"records",
".",
"-",
"rowupdate",
"is",
"a",
"dict",
"with",
"updated",
"fields",
"e",
".",
"g",
".",
"{",
"name",
":",
"John",
"}",
".",
"-",
"See",
"sqlwhere",
"for",
"where",
"clause",
"."
] | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L140-L162 |
langloisjp/tstore | tstore/pgtablestorage.py | DB.execute | def execute(self, sql, params=None):
"""
Execute given SQL.
Calls `rollback` if there's a DB error and re-raises the exception.
Calls `commit` if autocommit is True and there was no error.
Returns number of rows affected (for commands that affect rows).
>>> import getpas... | python | def execute(self, sql, params=None):
"""
Execute given SQL.
Calls `rollback` if there's a DB error and re-raises the exception.
Calls `commit` if autocommit is True and there was no error.
Returns number of rows affected (for commands that affect rows).
>>> import getpas... | [
"def",
"execute",
"(",
"self",
",",
"sql",
",",
"params",
"=",
"None",
")",
":",
"logging",
".",
"debug",
"(",
"sql",
")",
"try",
":",
"self",
".",
"_cursor",
".",
"execute",
"(",
"sql",
",",
"params",
")",
"if",
"self",
".",
"autocommit",
":",
"... | Execute given SQL.
Calls `rollback` if there's a DB error and re-raises the exception.
Calls `commit` if autocommit is True and there was no error.
Returns number of rows affected (for commands that affect rows).
>>> import getpass
>>> s = DB(dbname='test', user=getpass.getuser(... | [
"Execute",
"given",
"SQL",
".",
"Calls",
"rollback",
"if",
"there",
"s",
"a",
"DB",
"error",
"and",
"re",
"-",
"raises",
"the",
"exception",
".",
"Calls",
"commit",
"if",
"autocommit",
"is",
"True",
"and",
"there",
"was",
"no",
"error",
".",
"Returns",
... | train | https://github.com/langloisjp/tstore/blob/b438f8aaf09117bf6f922ba06ae5cf46b7b97a57/tstore/pgtablestorage.py#L189-L217 |
the01/python-paps | examples/measure/server.py | cmd_line | def cmd_line(line, ctrl):
server = ctrl.modules[0]
""" :type : StartServer """
if line == "statistic start":
server.stat_gather = True
elif line == "statistic stop":
server.stat_gather = False
elif line == "statistic reset":
server.statistic_reset()
elif line == "statisti... | python | def cmd_line(line, ctrl):
server = ctrl.modules[0]
""" :type : StartServer """
if line == "statistic start":
server.stat_gather = True
elif line == "statistic stop":
server.stat_gather = False
elif line == "statistic reset":
server.statistic_reset()
elif line == "statisti... | [
"def",
"cmd_line",
"(",
"line",
",",
"ctrl",
")",
":",
"server",
"=",
"ctrl",
".",
"modules",
"[",
"0",
"]",
"if",
"line",
"==",
"\"statistic start\"",
":",
"server",
".",
"stat_gather",
"=",
"True",
"elif",
"line",
"==",
"\"statistic stop\"",
":",
"serv... | :type : StartServer | [
":",
"type",
":",
"StartServer"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/measure/server.py#L122-L133 |
the01/python-paps | examples/measure/server.py | create | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | python | def create(host, port):
"""
Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None
"""
wrapper = WrapperServer({
'server': None
})
d = {
'listen_port': port,
'changer': wrapper
}
if host:
... | [
"def",
"create",
"(",
"host",
",",
"port",
")",
":",
"wrapper",
"=",
"WrapperServer",
"(",
"{",
"'server'",
":",
"None",
"}",
")",
"d",
"=",
"{",
"'listen_port'",
":",
"port",
",",
"'changer'",
":",
"wrapper",
"}",
"if",
"host",
":",
"d",
"[",
"'li... | Prepare server to execute
:return: Modules to execute, cmd line function
:rtype: list[WrapperServer], callable | None | [
"Prepare",
"server",
"to",
"execute"
] | train | https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/examples/measure/server.py#L136-L155 |
mgaitan/one | one.py | one | def one(iterable, cmp=None):
"""
Return the object in the given iterable that evaluates to True.
If the given iterable has more than one object that evaluates to True,
or if there is no object that fulfills such condition, return False.
If a callable ``cmp`` is given, it's used to evaluate each el... | python | def one(iterable, cmp=None):
"""
Return the object in the given iterable that evaluates to True.
If the given iterable has more than one object that evaluates to True,
or if there is no object that fulfills such condition, return False.
If a callable ``cmp`` is given, it's used to evaluate each el... | [
"def",
"one",
"(",
"iterable",
",",
"cmp",
"=",
"None",
")",
":",
"the_one",
"=",
"False",
"for",
"i",
"in",
"iterable",
":",
"if",
"cmp",
"(",
"i",
")",
"if",
"cmp",
"else",
"i",
":",
"if",
"the_one",
":",
"return",
"False",
"the_one",
"=",
"i",... | Return the object in the given iterable that evaluates to True.
If the given iterable has more than one object that evaluates to True,
or if there is no object that fulfills such condition, return False.
If a callable ``cmp`` is given, it's used to evaluate each element.
>>> one((True, False, Fa... | [
"Return",
"the",
"object",
"in",
"the",
"given",
"iterable",
"that",
"evaluates",
"to",
"True",
"."
] | train | https://github.com/mgaitan/one/blob/c6639cd7f31c0541df5f8512561a2bb0feea194c/one.py#L4-L35 |
honzamach/pynspect | pynspect/filters.py | grfcbk_strlen | def grfcbk_strlen(args):
"""
Grammar rule function callback: **strlen**. This function will measure the
string length of all subitems of the first item in argument list.
:param list args: List of function arguments.
:return: Length of all subitems of the first item in argument list.
:rtype: int... | python | def grfcbk_strlen(args):
"""
Grammar rule function callback: **strlen**. This function will measure the
string length of all subitems of the first item in argument list.
:param list args: List of function arguments.
:return: Length of all subitems of the first item in argument list.
:rtype: int... | [
"def",
"grfcbk_strlen",
"(",
"args",
")",
":",
"if",
"not",
"args",
"[",
"0",
"]",
":",
"return",
"None",
"if",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"list",
")",
":",
"return",
"[",
"len",
"(",
"x",
")",
"for",
"x",
"in",
"args",
"[",... | Grammar rule function callback: **strlen**. This function will measure the
string length of all subitems of the first item in argument list.
:param list args: List of function arguments.
:return: Length of all subitems of the first item in argument list.
:rtype: int or list | [
"Grammar",
"rule",
"function",
"callback",
":",
"**",
"strlen",
"**",
".",
"This",
"function",
"will",
"measure",
"the",
"string",
"length",
"of",
"all",
"subitems",
"of",
"the",
"first",
"item",
"in",
"argument",
"list",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L120-L133 |
honzamach/pynspect | pynspect/filters.py | DataObjectFilter.prepare | def prepare(self, rule):
"""
Parse and/or compile given rule into rule tree.
:param rule: Filtering grammar rule.
:return: Parsed and/or compiled rule.
"""
if self.parser:
rule = self.parser.parse(rule)
if self.compiler:
rule = self.compil... | python | def prepare(self, rule):
"""
Parse and/or compile given rule into rule tree.
:param rule: Filtering grammar rule.
:return: Parsed and/or compiled rule.
"""
if self.parser:
rule = self.parser.parse(rule)
if self.compiler:
rule = self.compil... | [
"def",
"prepare",
"(",
"self",
",",
"rule",
")",
":",
"if",
"self",
".",
"parser",
":",
"rule",
"=",
"self",
".",
"parser",
".",
"parse",
"(",
"rule",
")",
"if",
"self",
".",
"compiler",
":",
"rule",
"=",
"self",
".",
"compiler",
".",
"compile",
... | Parse and/or compile given rule into rule tree.
:param rule: Filtering grammar rule.
:return: Parsed and/or compiled rule. | [
"Parse",
"and",
"/",
"or",
"compile",
"given",
"rule",
"into",
"rule",
"tree",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L209-L220 |
honzamach/pynspect | pynspect/filters.py | DataObjectFilter.binary_operation_logical | def binary_operation_logical(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_logical` interface.
"""
return self.evaluate_binop_logical(rule.operation, left, right, **kwargs) | python | def binary_operation_logical(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_logical` interface.
"""
return self.evaluate_binop_logical(rule.operation, left, right, **kwargs) | [
"def",
"binary_operation_logical",
"(",
"self",
",",
"rule",
",",
"left",
",",
"right",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"evaluate_binop_logical",
"(",
"rule",
".",
"operation",
",",
"left",
",",
"right",
",",
"*",
"*",
"kwargs",... | Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_logical` interface. | [
"Implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"traversers",
".",
"RuleTreeTraverser",
".",
"binary_operation_logical",
"interface",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L289-L293 |
honzamach/pynspect | pynspect/filters.py | DataObjectFilter.binary_operation_comparison | def binary_operation_comparison(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_comparison` interface.
"""
return self.evaluate_binop_comparison(rule.operation, left, right, **kwargs) | python | def binary_operation_comparison(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_comparison` interface.
"""
return self.evaluate_binop_comparison(rule.operation, left, right, **kwargs) | [
"def",
"binary_operation_comparison",
"(",
"self",
",",
"rule",
",",
"left",
",",
"right",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"evaluate_binop_comparison",
"(",
"rule",
".",
"operation",
",",
"left",
",",
"right",
",",
"*",
"*",
"kw... | Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_comparison` interface. | [
"Implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"traversers",
".",
"RuleTreeTraverser",
".",
"binary_operation_comparison",
"interface",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L295-L299 |
honzamach/pynspect | pynspect/filters.py | DataObjectFilter.binary_operation_math | def binary_operation_math(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_math` interface.
"""
return self.evaluate_binop_math(rule.operation, left, right, **kwargs) | python | def binary_operation_math(self, rule, left, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_math` interface.
"""
return self.evaluate_binop_math(rule.operation, left, right, **kwargs) | [
"def",
"binary_operation_math",
"(",
"self",
",",
"rule",
",",
"left",
",",
"right",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"evaluate_binop_math",
"(",
"rule",
".",
"operation",
",",
"left",
",",
"right",
",",
"*",
"*",
"kwargs",
")"... | Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.binary_operation_math` interface. | [
"Implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"traversers",
".",
"RuleTreeTraverser",
".",
"binary_operation_math",
"interface",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L301-L305 |
honzamach/pynspect | pynspect/filters.py | DataObjectFilter.unary_operation | def unary_operation(self, rule, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.unary_operation` interface.
"""
return self.evaluate_unop(rule.operation, right, **kwargs) | python | def unary_operation(self, rule, right, **kwargs):
"""
Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.unary_operation` interface.
"""
return self.evaluate_unop(rule.operation, right, **kwargs) | [
"def",
"unary_operation",
"(",
"self",
",",
"rule",
",",
"right",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"evaluate_unop",
"(",
"rule",
".",
"operation",
",",
"right",
",",
"*",
"*",
"kwargs",
")"
] | Implementation of :py:func:`pynspect.traversers.RuleTreeTraverser.unary_operation` interface. | [
"Implementation",
"of",
":",
"py",
":",
"func",
":",
"pynspect",
".",
"traversers",
".",
"RuleTreeTraverser",
".",
"unary_operation",
"interface",
"."
] | train | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/filters.py#L307-L311 |
DasIch/argvard | argvard/__init__.py | ExecutableBase.from_main | def from_main(cls, signature=''):
"""
A decorator that creates an instance and registers the decorated
function as main function, see :meth:`main` for more information.
.. versionadded:: 0.2
"""
instance = cls()
def decorate(function):
instance.main(... | python | def from_main(cls, signature=''):
"""
A decorator that creates an instance and registers the decorated
function as main function, see :meth:`main` for more information.
.. versionadded:: 0.2
"""
instance = cls()
def decorate(function):
instance.main(... | [
"def",
"from_main",
"(",
"cls",
",",
"signature",
"=",
"''",
")",
":",
"instance",
"=",
"cls",
"(",
")",
"def",
"decorate",
"(",
"function",
")",
":",
"instance",
".",
"main",
"(",
"signature",
")",
"(",
"function",
")",
"return",
"instance",
"return",... | A decorator that creates an instance and registers the decorated
function as main function, see :meth:`main` for more information.
.. versionadded:: 0.2 | [
"A",
"decorator",
"that",
"creates",
"an",
"instance",
"and",
"registers",
"the",
"decorated",
"function",
"as",
"main",
"function",
"see",
":",
"meth",
":",
"main",
"for",
"more",
"information",
"."
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/__init__.py#L41-L53 |
DasIch/argvard | argvard/__init__.py | ExecutableBase.register_command | def register_command(self, name, command):
"""
Registers the `command` with the given `name`.
If the `name` has already been used to register a command a
:exc:`RuntimeError` will be raised.
"""
if name in self.commands:
raise RuntimeError('%s is already defin... | python | def register_command(self, name, command):
"""
Registers the `command` with the given `name`.
If the `name` has already been used to register a command a
:exc:`RuntimeError` will be raised.
"""
if name in self.commands:
raise RuntimeError('%s is already defin... | [
"def",
"register_command",
"(",
"self",
",",
"name",
",",
"command",
")",
":",
"if",
"name",
"in",
"self",
".",
"commands",
":",
"raise",
"RuntimeError",
"(",
"'%s is already defined'",
"%",
"name",
")",
"self",
".",
"commands",
"[",
"name",
"]",
"=",
"c... | Registers the `command` with the given `name`.
If the `name` has already been used to register a command a
:exc:`RuntimeError` will be raised. | [
"Registers",
"the",
"command",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/__init__.py#L108-L117 |
DasIch/argvard | argvard/__init__.py | ExecutableBase.option | def option(self, signature, overrideable=False):
"""
A decorator for registering an option with the given `signature`::
@app.option('--option')
def option(context):
# do something
pass
If the name in the signature has already been used to... | python | def option(self, signature, overrideable=False):
"""
A decorator for registering an option with the given `signature`::
@app.option('--option')
def option(context):
# do something
pass
If the name in the signature has already been used to... | [
"def",
"option",
"(",
"self",
",",
"signature",
",",
"overrideable",
"=",
"False",
")",
":",
"def",
"decorator",
"(",
"function",
")",
":",
"try",
":",
"function",
"=",
"annotations",
"(",
")",
"(",
"function",
")",
"except",
"RuntimeError",
":",
"pass",... | A decorator for registering an option with the given `signature`::
@app.option('--option')
def option(context):
# do something
pass
If the name in the signature has already been used to register an
option, a :exc:`RuntimeError` is raised unless t... | [
"A",
"decorator",
"for",
"registering",
"an",
"option",
"with",
"the",
"given",
"signature",
"::"
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/__init__.py#L119-L149 |
DasIch/argvard | argvard/__init__.py | ExecutableBase.main | def main(self, signature=''):
"""
A decorator that is used to register the main function with the given
`signature`::
@app.main()
def main(context):
# do something
pass
The main function is called, after any options and if no comm... | python | def main(self, signature=''):
"""
A decorator that is used to register the main function with the given
`signature`::
@app.main()
def main(context):
# do something
pass
The main function is called, after any options and if no comm... | [
"def",
"main",
"(",
"self",
",",
"signature",
"=",
"''",
")",
":",
"signature",
"=",
"Signature",
".",
"from_string",
"(",
"signature",
",",
"option",
"=",
"False",
")",
"def",
"decorator",
"(",
"function",
")",
":",
"if",
"self",
".",
"main_func",
"is... | A decorator that is used to register the main function with the given
`signature`::
@app.main()
def main(context):
# do something
pass
The main function is called, after any options and if no command has
been called. | [
"A",
"decorator",
"that",
"is",
"used",
"to",
"register",
"the",
"main",
"function",
"with",
"the",
"given",
"signature",
"::"
] | train | https://github.com/DasIch/argvard/blob/2603e323a995e0915ce41fcf49e2a82519556195/argvard/__init__.py#L151-L179 |
jonathansick/paperweight | paperweight/nlputils.py | wordify | def wordify(text):
"""Generate a list of words given text, removing punctuation.
Parameters
----------
text : unicode
A piece of english text.
Returns
-------
words : list
List of words.
"""
stopset = set(nltk.corpus.stopwords.words('english'))
tokens = nltk.Wor... | python | def wordify(text):
"""Generate a list of words given text, removing punctuation.
Parameters
----------
text : unicode
A piece of english text.
Returns
-------
words : list
List of words.
"""
stopset = set(nltk.corpus.stopwords.words('english'))
tokens = nltk.Wor... | [
"def",
"wordify",
"(",
"text",
")",
":",
"stopset",
"=",
"set",
"(",
"nltk",
".",
"corpus",
".",
"stopwords",
".",
"words",
"(",
"'english'",
")",
")",
"tokens",
"=",
"nltk",
".",
"WordPunctTokenizer",
"(",
")",
".",
"tokenize",
"(",
"text",
")",
"re... | Generate a list of words given text, removing punctuation.
Parameters
----------
text : unicode
A piece of english text.
Returns
-------
words : list
List of words. | [
"Generate",
"a",
"list",
"of",
"words",
"given",
"text",
"removing",
"punctuation",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/nlputils.py#L10-L25 |
mkurnikov/typed-env | typed_env/initialize.py | initialize_env | def initialize_env(env_file=None, fail_silently=True, load_globally=True):
"""
Returns an instance of _Environment after reading the system environment an
optionally provided file.
"""
data = {}
data.update(os.environ)
if env_file:
data.update(read_file_values(env_file, fail_silently... | python | def initialize_env(env_file=None, fail_silently=True, load_globally=True):
"""
Returns an instance of _Environment after reading the system environment an
optionally provided file.
"""
data = {}
data.update(os.environ)
if env_file:
data.update(read_file_values(env_file, fail_silently... | [
"def",
"initialize_env",
"(",
"env_file",
"=",
"None",
",",
"fail_silently",
"=",
"True",
",",
"load_globally",
"=",
"True",
")",
":",
"data",
"=",
"{",
"}",
"data",
".",
"update",
"(",
"os",
".",
"environ",
")",
"if",
"env_file",
":",
"data",
".",
"... | Returns an instance of _Environment after reading the system environment an
optionally provided file. | [
"Returns",
"an",
"instance",
"of",
"_Environment",
"after",
"reading",
"the",
"system",
"environment",
"an",
"optionally",
"provided",
"file",
"."
] | train | https://github.com/mkurnikov/typed-env/blob/d0f3e947f0d5561c9fd1679d6faa9830de24d870/typed_env/initialize.py#L10-L23 |
inveniosoftware-attic/invenio-knowledge | docs/_ext/flask_app.py | setup | def setup(sphinx):
"""Setup Sphinx object."""
from flask import has_app_context
from invenio_base.factory import create_app
PACKAGES = ['invenio_base', 'invenio.modules.accounts',
'invenio.modules.records', 'invenio_knowledge']
if not has_app_context():
app = create_app(PACK... | python | def setup(sphinx):
"""Setup Sphinx object."""
from flask import has_app_context
from invenio_base.factory import create_app
PACKAGES = ['invenio_base', 'invenio.modules.accounts',
'invenio.modules.records', 'invenio_knowledge']
if not has_app_context():
app = create_app(PACK... | [
"def",
"setup",
"(",
"sphinx",
")",
":",
"from",
"flask",
"import",
"has_app_context",
"from",
"invenio_base",
".",
"factory",
"import",
"create_app",
"PACKAGES",
"=",
"[",
"'invenio_base'",
",",
"'invenio.modules.accounts'",
",",
"'invenio.modules.records'",
",",
"... | Setup Sphinx object. | [
"Setup",
"Sphinx",
"object",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/docs/_ext/flask_app.py#L23-L33 |
oleg-golovanov/unilog | unilog/convert.py | pretty_spaces | def pretty_spaces(level):
"""
Return spaces and new line.
:type level: int or None
:param level: deep level
:rtype: unicode
:return: string with new line and spaces
"""
if level is None:
return u''
return (os.linesep if level >= 0 else u'') + (u' ' * (INDENT * level)) | python | def pretty_spaces(level):
"""
Return spaces and new line.
:type level: int or None
:param level: deep level
:rtype: unicode
:return: string with new line and spaces
"""
if level is None:
return u''
return (os.linesep if level >= 0 else u'') + (u' ' * (INDENT * level)) | [
"def",
"pretty_spaces",
"(",
"level",
")",
":",
"if",
"level",
"is",
"None",
":",
"return",
"u''",
"return",
"(",
"os",
".",
"linesep",
"if",
"level",
">=",
"0",
"else",
"u''",
")",
"+",
"(",
"u' '",
"*",
"(",
"INDENT",
"*",
"level",
")",
")"
] | Return spaces and new line.
:type level: int or None
:param level: deep level
:rtype: unicode
:return: string with new line and spaces | [
"Return",
"spaces",
"and",
"new",
"line",
"."
] | train | https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/convert.py#L20-L33 |
oleg-golovanov/unilog | unilog/convert.py | unimapping | def unimapping(arg, level):
"""
Mapping object to unicode string.
:type arg: collections.Mapping
:param arg: mapping object
:type level: int
:param level: deep level
:rtype: unicode
:return: mapping object as unicode string
"""
if not isinstance(arg, collections.Mapping):
... | python | def unimapping(arg, level):
"""
Mapping object to unicode string.
:type arg: collections.Mapping
:param arg: mapping object
:type level: int
:param level: deep level
:rtype: unicode
:return: mapping object as unicode string
"""
if not isinstance(arg, collections.Mapping):
... | [
"def",
"unimapping",
"(",
"arg",
",",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"collections",
".",
"Mapping",
")",
":",
"raise",
"TypeError",
"(",
"'expected collections.Mapping, {} received'",
".",
"format",
"(",
"type",
"(",
"arg",
")... | Mapping object to unicode string.
:type arg: collections.Mapping
:param arg: mapping object
:type level: int
:param level: deep level
:rtype: unicode
:return: mapping object as unicode string | [
"Mapping",
"object",
"to",
"unicode",
"string",
"."
] | train | https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/convert.py#L52-L80 |
oleg-golovanov/unilog | unilog/convert.py | uniiterable | def uniiterable(arg, level):
"""
Iterable object to unicode string.
:type arg: collections.Iterable
:param arg: iterable object
:type level: int
:param level: deep level
:rtype: unicode
:return: iterable object as unicode string
"""
if not isinstance(arg, collections.Iterable)... | python | def uniiterable(arg, level):
"""
Iterable object to unicode string.
:type arg: collections.Iterable
:param arg: iterable object
:type level: int
:param level: deep level
:rtype: unicode
:return: iterable object as unicode string
"""
if not isinstance(arg, collections.Iterable)... | [
"def",
"uniiterable",
"(",
"arg",
",",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"collections",
".",
"Iterable",
")",
":",
"raise",
"TypeError",
"(",
"'expected collections.Iterable, {} received'",
".",
"format",
"(",
"type",
"(",
"arg",
... | Iterable object to unicode string.
:type arg: collections.Iterable
:param arg: iterable object
:type level: int
:param level: deep level
:rtype: unicode
:return: iterable object as unicode string | [
"Iterable",
"object",
"to",
"unicode",
"string",
"."
] | train | https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/convert.py#L83-L114 |
oleg-golovanov/unilog | unilog/convert.py | convert | def convert(obj, encoding=LOCALE, level=None):
"""
Covert any object to unicode string.
:param obj: any object
:type encoding: str
:param encoding: codec for encoding unicode strings
(locale.getpreferredencoding() by default)
:type level: int
:param level: Deep level. I... | python | def convert(obj, encoding=LOCALE, level=None):
"""
Covert any object to unicode string.
:param obj: any object
:type encoding: str
:param encoding: codec for encoding unicode strings
(locale.getpreferredencoding() by default)
:type level: int
:param level: Deep level. I... | [
"def",
"convert",
"(",
"obj",
",",
"encoding",
"=",
"LOCALE",
",",
"level",
"=",
"None",
")",
":",
"callable_",
"=",
"CONVERTERS",
".",
"get",
"(",
"type",
"(",
"obj",
")",
")",
"if",
"callable_",
"is",
"not",
"None",
":",
"obj",
"=",
"callable_",
... | Covert any object to unicode string.
:param obj: any object
:type encoding: str
:param encoding: codec for encoding unicode strings
(locale.getpreferredencoding() by default)
:type level: int
:param level: Deep level. If None level is not considered.
:rtype: unicode
:r... | [
"Covert",
"any",
"object",
"to",
"unicode",
"string",
"."
] | train | https://github.com/oleg-golovanov/unilog/blob/4d59cd910032383a71796c4df7446fd5875938c3/unilog/convert.py#L117-L159 |
pyvec/pyvodb | pyvodb/cli/show.py | show | def show(ctx, city, date):
"""Show a particular meetup.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN (e.g. p1): show the N-th las... | python | def show(ctx, city, date):
"""Show a particular meetup.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN (e.g. p1): show the N-th las... | [
"def",
"show",
"(",
"ctx",
",",
"city",
",",
"date",
")",
":",
"db",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"today",
"=",
"ctx",
".",
"obj",
"[",
"'now'",
"]",
".",
"date",
"(",
")",
"term",
"=",
"ctx",
".",
"obj",
"[",
"'term'",
"]",
"e... | Show a particular meetup.
city: The meetup series.
\b
date: The date. May be:
- YYYY-MM-DD or YY-MM-DD (e.g. 2015-08-27)
- YYYY-MM or YY-MM (e.g. 2015-08)
- MM (e.g. 08): the given month in the current year
- pN (e.g. p1): show the N-th last meetup
- +N (e.g. +2): s... | [
"Show",
"a",
"particular",
"meetup",
"."
] | train | https://github.com/pyvec/pyvodb/blob/07183333df26eb12c5c2b98802cde3fb3a6c1339/pyvodb/cli/show.py#L14-L36 |
lexycore/django-rediser | django_rediser/storage.py | RedisJSON.srem | def srem(self, name, *values):
"""
send raw (source) values here. Right functioning with other values
not guaranteed (and even worse).
"""
return self.storage.srem(name, *self.dump(values, False)) | python | def srem(self, name, *values):
"""
send raw (source) values here. Right functioning with other values
not guaranteed (and even worse).
"""
return self.storage.srem(name, *self.dump(values, False)) | [
"def",
"srem",
"(",
"self",
",",
"name",
",",
"*",
"values",
")",
":",
"return",
"self",
".",
"storage",
".",
"srem",
"(",
"name",
",",
"*",
"self",
".",
"dump",
"(",
"values",
",",
"False",
")",
")"
] | send raw (source) values here. Right functioning with other values
not guaranteed (and even worse). | [
"send",
"raw",
"(",
"source",
")",
"values",
"here",
".",
"Right",
"functioning",
"with",
"other",
"values",
"not",
"guaranteed",
"(",
"and",
"even",
"worse",
")",
"."
] | train | https://github.com/lexycore/django-rediser/blob/95b7be5ce1bafd963b1a316c99ef19547f301112/django_rediser/storage.py#L142-L147 |
lexycore/django-rediser | django_rediser/storage.py | RedisJSON.sismember | def sismember(self, name, value):
"""
Return a boolean indicating if ``value`` is a member of set ``name``
send raw (source) values here. Right functioning with other values
not guaranteed (and even worse).
"""
return self.storage.sismember(name, self.dump(value)) | python | def sismember(self, name, value):
"""
Return a boolean indicating if ``value`` is a member of set ``name``
send raw (source) values here. Right functioning with other values
not guaranteed (and even worse).
"""
return self.storage.sismember(name, self.dump(value)) | [
"def",
"sismember",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"return",
"self",
".",
"storage",
".",
"sismember",
"(",
"name",
",",
"self",
".",
"dump",
"(",
"value",
")",
")"
] | Return a boolean indicating if ``value`` is a member of set ``name``
send raw (source) values here. Right functioning with other values
not guaranteed (and even worse). | [
"Return",
"a",
"boolean",
"indicating",
"if",
"value",
"is",
"a",
"member",
"of",
"set",
"name",
"send",
"raw",
"(",
"source",
")",
"values",
"here",
".",
"Right",
"functioning",
"with",
"other",
"values",
"not",
"guaranteed",
"(",
"and",
"even",
"worse",
... | train | https://github.com/lexycore/django-rediser/blob/95b7be5ce1bafd963b1a316c99ef19547f301112/django_rediser/storage.py#L152-L158 |
krukas/Trionyx | trionyx/config.py | ModelConfig.get_list_fields | def get_list_fields(self):
"""Get all list fields"""
from trionyx.renderer import renderer
model_fields = {f.name: f for f in self.model.get_fields(True, True)}
def create_list_fields(config_fields, list_fields=None):
list_fields = list_fields if list_fields else {}
... | python | def get_list_fields(self):
"""Get all list fields"""
from trionyx.renderer import renderer
model_fields = {f.name: f for f in self.model.get_fields(True, True)}
def create_list_fields(config_fields, list_fields=None):
list_fields = list_fields if list_fields else {}
... | [
"def",
"get_list_fields",
"(",
"self",
")",
":",
"from",
"trionyx",
".",
"renderer",
"import",
"renderer",
"model_fields",
"=",
"{",
"f",
".",
"name",
":",
"f",
"for",
"f",
"in",
"self",
".",
"model",
".",
"get_fields",
"(",
"True",
",",
"True",
")",
... | Get all list fields | [
"Get",
"all",
"list",
"fields"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/config.py#L162-L193 |
krukas/Trionyx | trionyx/config.py | ModelConfig._get_form | def _get_form(self, config_name, only_required=False):
"""Get form for given config else create form"""
if getattr(self, config_name, None):
return import_object_by_string(getattr(self, config_name))
def use_field(field):
if not only_required:
return True... | python | def _get_form(self, config_name, only_required=False):
"""Get form for given config else create form"""
if getattr(self, config_name, None):
return import_object_by_string(getattr(self, config_name))
def use_field(field):
if not only_required:
return True... | [
"def",
"_get_form",
"(",
"self",
",",
"config_name",
",",
"only_required",
"=",
"False",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"config_name",
",",
"None",
")",
":",
"return",
"import_object_by_string",
"(",
"getattr",
"(",
"self",
",",
"config_name",
... | Get form for given config else create form | [
"Get",
"form",
"for",
"given",
"config",
"else",
"create",
"form"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/config.py#L195-L205 |
krukas/Trionyx | trionyx/config.py | Models.auto_load_configs | def auto_load_configs(self):
"""Auto load all configs from app configs"""
for app in apps.get_app_configs():
for model in app.get_models():
config = ModelConfig(model, getattr(app, model.__name__, None))
self.configs[self.get_model_name(model)] = config | python | def auto_load_configs(self):
"""Auto load all configs from app configs"""
for app in apps.get_app_configs():
for model in app.get_models():
config = ModelConfig(model, getattr(app, model.__name__, None))
self.configs[self.get_model_name(model)] = config | [
"def",
"auto_load_configs",
"(",
"self",
")",
":",
"for",
"app",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"for",
"model",
"in",
"app",
".",
"get_models",
"(",
")",
":",
"config",
"=",
"ModelConfig",
"(",
"model",
",",
"getattr",
"(",
"app",... | Auto load all configs from app configs | [
"Auto",
"load",
"all",
"configs",
"from",
"app",
"configs"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/config.py#L215-L220 |
krukas/Trionyx | trionyx/config.py | Models.get_config | def get_config(self, model):
"""Get config for given model"""
if not inspect.isclass(model):
model = model.__class__
return self.configs.get(self.get_model_name(model)) | python | def get_config(self, model):
"""Get config for given model"""
if not inspect.isclass(model):
model = model.__class__
return self.configs.get(self.get_model_name(model)) | [
"def",
"get_config",
"(",
"self",
",",
"model",
")",
":",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"model",
")",
":",
"model",
"=",
"model",
".",
"__class__",
"return",
"self",
".",
"configs",
".",
"get",
"(",
"self",
".",
"get_model_name",
"(",
... | Get config for given model | [
"Get",
"config",
"for",
"given",
"model"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/config.py#L222-L226 |
krukas/Trionyx | trionyx/config.py | Models.get_all_configs | def get_all_configs(self, trionyx_models_only=True):
"""Get all model configs"""
from trionyx.models import BaseModel
for index, config in self.configs.items():
if not isinstance(config.model(), BaseModel):
continue
yield config | python | def get_all_configs(self, trionyx_models_only=True):
"""Get all model configs"""
from trionyx.models import BaseModel
for index, config in self.configs.items():
if not isinstance(config.model(), BaseModel):
continue
yield config | [
"def",
"get_all_configs",
"(",
"self",
",",
"trionyx_models_only",
"=",
"True",
")",
":",
"from",
"trionyx",
".",
"models",
"import",
"BaseModel",
"for",
"index",
",",
"config",
"in",
"self",
".",
"configs",
".",
"items",
"(",
")",
":",
"if",
"not",
"isi... | Get all model configs | [
"Get",
"all",
"model",
"configs"
] | train | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/config.py#L228-L236 |
CivicSpleen/ckcache | ckcache/multi.py | MultiCache.put | def put(self, source, rel_path, metadata=None):
"""Puts to only the first upstream. This is to be symmetric with put_stream."""
return self.upstreams[0].put(source, rel_path, metadata) | python | def put(self, source, rel_path, metadata=None):
"""Puts to only the first upstream. This is to be symmetric with put_stream."""
return self.upstreams[0].put(source, rel_path, metadata) | [
"def",
"put",
"(",
"self",
",",
"source",
",",
"rel_path",
",",
"metadata",
"=",
"None",
")",
":",
"return",
"self",
".",
"upstreams",
"[",
"0",
"]",
".",
"put",
"(",
"source",
",",
"rel_path",
",",
"metadata",
")"
] | Puts to only the first upstream. This is to be symmetric with put_stream. | [
"Puts",
"to",
"only",
"the",
"first",
"upstream",
".",
"This",
"is",
"to",
"be",
"symmetric",
"with",
"put_stream",
"."
] | train | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/multi.py#L52-L54 |
CivicSpleen/ckcache | ckcache/multi.py | AltReadCache.list | def list(self, path=None, with_metadata=False, include_partitions=False):
"""Combine a listing of all of the upstreams, and add a metadata item for the
repo_id"""
l = {}
for upstream in [self.alternate, self.upstream]:
for k, v in upstream.list(path, with_metadata, include_... | python | def list(self, path=None, with_metadata=False, include_partitions=False):
"""Combine a listing of all of the upstreams, and add a metadata item for the
repo_id"""
l = {}
for upstream in [self.alternate, self.upstream]:
for k, v in upstream.list(path, with_metadata, include_... | [
"def",
"list",
"(",
"self",
",",
"path",
"=",
"None",
",",
"with_metadata",
"=",
"False",
",",
"include_partitions",
"=",
"False",
")",
":",
"l",
"=",
"{",
"}",
"for",
"upstream",
"in",
"[",
"self",
".",
"alternate",
",",
"self",
".",
"upstream",
"]"... | Combine a listing of all of the upstreams, and add a metadata item for the
repo_id | [
"Combine",
"a",
"listing",
"of",
"all",
"of",
"the",
"upstreams",
"and",
"add",
"a",
"metadata",
"item",
"for",
"the",
"repo_id"
] | train | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/multi.py#L132-L146 |
CivicSpleen/ckcache | ckcache/multi.py | AltReadCache._copy_across | def _copy_across(self, rel_path, cb=None):
"""If the upstream doesn't have the file, get it from the alternate and store it in the upstream"""
from . import copy_file_or_flo
if not self.upstream.has(rel_path):
if not self.alternate.has(rel_path):
return None
... | python | def _copy_across(self, rel_path, cb=None):
"""If the upstream doesn't have the file, get it from the alternate and store it in the upstream"""
from . import copy_file_or_flo
if not self.upstream.has(rel_path):
if not self.alternate.has(rel_path):
return None
... | [
"def",
"_copy_across",
"(",
"self",
",",
"rel_path",
",",
"cb",
"=",
"None",
")",
":",
"from",
".",
"import",
"copy_file_or_flo",
"if",
"not",
"self",
".",
"upstream",
".",
"has",
"(",
"rel_path",
")",
":",
"if",
"not",
"self",
".",
"alternate",
".",
... | If the upstream doesn't have the file, get it from the alternate and store it in the upstream | [
"If",
"the",
"upstream",
"doesn",
"t",
"have",
"the",
"file",
"get",
"it",
"from",
"the",
"alternate",
"and",
"store",
"it",
"in",
"the",
"upstream"
] | train | https://github.com/CivicSpleen/ckcache/blob/0c699b6ba97ff164e9702504f0e1643dd4cd39e1/ckcache/multi.py#L148-L170 |
rjw57/throw | throw/terminalinterface.py | TerminalInterface.input_fields | def input_fields(self, preamble, *args):
"""Get a set of fields from the user. Optionally a preamble may be
shown to the user secribing the fields to return. The fields are
specified as the remaining arguments with each field being a a
list with the following entries:
- a pr... | python | def input_fields(self, preamble, *args):
"""Get a set of fields from the user. Optionally a preamble may be
shown to the user secribing the fields to return. The fields are
specified as the remaining arguments with each field being a a
list with the following entries:
- a pr... | [
"def",
"input_fields",
"(",
"self",
",",
"preamble",
",",
"*",
"args",
")",
":",
"self",
".",
"new_section",
"(",
")",
"if",
"preamble",
"is",
"not",
"None",
":",
"self",
".",
"message",
"(",
"preamble",
")",
"if",
"any",
"(",
"[",
"True",
"for",
"... | Get a set of fields from the user. Optionally a preamble may be
shown to the user secribing the fields to return. The fields are
specified as the remaining arguments with each field being a a
list with the following entries:
- a programmer-visible name for the field
- a ... | [
"Get",
"a",
"set",
"of",
"fields",
"from",
"the",
"user",
".",
"Optionally",
"a",
"preamble",
"may",
"be",
"shown",
"to",
"the",
"user",
"secribing",
"the",
"fields",
"to",
"return",
".",
"The",
"fields",
"are",
"specified",
"as",
"the",
"remaining",
"ar... | train | https://github.com/rjw57/throw/blob/74a7116362ba5b45635ab247472b25cfbdece4ee/throw/terminalinterface.py#L189-L238 |
CitrineInformatics/dftparse | dftparse/wien2k/sigmak_parser.py | _parse_sigmak | def _parse_sigmak(line, lines):
"""Parse Energy, Re sigma xx, Im sigma xx, Re sigma zz, Im sigma zz"""
split_line = line.split()
energy = float(split_line[0])
re_sigma_xx = float(split_line[1])
im_sigma_xx = float(split_line[2])
re_sigma_zz = float(split_line[3])
im_sigma_zz = float(split_... | python | def _parse_sigmak(line, lines):
"""Parse Energy, Re sigma xx, Im sigma xx, Re sigma zz, Im sigma zz"""
split_line = line.split()
energy = float(split_line[0])
re_sigma_xx = float(split_line[1])
im_sigma_xx = float(split_line[2])
re_sigma_zz = float(split_line[3])
im_sigma_zz = float(split_... | [
"def",
"_parse_sigmak",
"(",
"line",
",",
"lines",
")",
":",
"split_line",
"=",
"line",
".",
"split",
"(",
")",
"energy",
"=",
"float",
"(",
"split_line",
"[",
"0",
"]",
")",
"re_sigma_xx",
"=",
"float",
"(",
"split_line",
"[",
"1",
"]",
")",
"im_sig... | Parse Energy, Re sigma xx, Im sigma xx, Re sigma zz, Im sigma zz | [
"Parse",
"Energy",
"Re",
"sigma",
"xx",
"Im",
"sigma",
"xx",
"Re",
"sigma",
"zz",
"Im",
"sigma",
"zz"
] | train | https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/wien2k/sigmak_parser.py#L4-L16 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | require_self | def require_self(func, *args, **kwargs):
"""Decorator to require that this component be installed"""
try:
__import__(package['name'])
except ImportError:
sys.stderr.write(
"This component needs to be installed first. Run " +
"`invoke install`\n")
sys.exit(1)
... | python | def require_self(func, *args, **kwargs):
"""Decorator to require that this component be installed"""
try:
__import__(package['name'])
except ImportError:
sys.stderr.write(
"This component needs to be installed first. Run " +
"`invoke install`\n")
sys.exit(1)
... | [
"def",
"require_self",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"__import__",
"(",
"package",
"[",
"'name'",
"]",
")",
"except",
"ImportError",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"This component needs to ... | Decorator to require that this component be installed | [
"Decorator",
"to",
"require",
"that",
"this",
"component",
"be",
"installed"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L35-L45 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | require_pip_module | def require_pip_module(module):
"""Decorator to check for a module and helpfully exit if it's not found"""
def wrapper(func, *args, **kwargs):
try:
__import__(module)
except ImportError:
sys.stderr.write(
"`pip install %s` to enable this feature\n" % modu... | python | def require_pip_module(module):
"""Decorator to check for a module and helpfully exit if it's not found"""
def wrapper(func, *args, **kwargs):
try:
__import__(module)
except ImportError:
sys.stderr.write(
"`pip install %s` to enable this feature\n" % modu... | [
"def",
"require_pip_module",
"(",
"module",
")",
":",
"def",
"wrapper",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"__import__",
"(",
"module",
")",
"except",
"ImportError",
":",
"sys",
".",
"stderr",
".",
"write",
... | Decorator to check for a module and helpfully exit if it's not found | [
"Decorator",
"to",
"check",
"for",
"a",
"module",
"and",
"helpfully",
"exit",
"if",
"it",
"s",
"not",
"found"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L48-L60 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | replaced_by_django_migrations | def replaced_by_django_migrations(func, *args, **kwargs):
"""Decorator to preempt South requirement"""
DjangoSettings() # trigger helpful messages if Django is missing
import django
if django.VERSION >= (1, 7):
print("Django 1.7+ has its own migrations system.")
print("Use this instea... | python | def replaced_by_django_migrations(func, *args, **kwargs):
"""Decorator to preempt South requirement"""
DjangoSettings() # trigger helpful messages if Django is missing
import django
if django.VERSION >= (1, 7):
print("Django 1.7+ has its own migrations system.")
print("Use this instea... | [
"def",
"replaced_by_django_migrations",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"DjangoSettings",
"(",
")",
"# trigger helpful messages if Django is missing",
"import",
"django",
"if",
"django",
".",
"VERSION",
">=",
"(",
"1",
",",
"7",... | Decorator to preempt South requirement | [
"Decorator",
"to",
"preempt",
"South",
"requirement"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L64-L74 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | create_migration | def create_migration(initial=False):
"""Create a South migration for this project"""
settings = DjangoSettings()
if 'south' not in (name.lower() for name in settings.INSTALLED_APPS):
print("Temporarily adding 'south' into INSTALLED_APPS.")
settings.INSTALLED_APPS.append('south')
kwargs... | python | def create_migration(initial=False):
"""Create a South migration for this project"""
settings = DjangoSettings()
if 'south' not in (name.lower() for name in settings.INSTALLED_APPS):
print("Temporarily adding 'south' into INSTALLED_APPS.")
settings.INSTALLED_APPS.append('south')
kwargs... | [
"def",
"create_migration",
"(",
"initial",
"=",
"False",
")",
":",
"settings",
"=",
"DjangoSettings",
"(",
")",
"if",
"'south'",
"not",
"in",
"(",
"name",
".",
"lower",
"(",
")",
"for",
"name",
"in",
"settings",
".",
"INSTALLED_APPS",
")",
":",
"print",
... | Create a South migration for this project | [
"Create",
"a",
"South",
"migration",
"for",
"this",
"project"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L87-L96 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | coverage | def coverage(reportdir=None, extra=None):
"""Test this project with coverage reports"""
import coverage as coverage_api
cov = coverage_api.coverage()
opts = {'directory': reportdir} if reportdir else {}
cov.start()
test(extra)
cov.stop()
cov.html_report(**opts) | python | def coverage(reportdir=None, extra=None):
"""Test this project with coverage reports"""
import coverage as coverage_api
cov = coverage_api.coverage()
opts = {'directory': reportdir} if reportdir else {}
cov.start()
test(extra)
cov.stop()
cov.html_report(**opts) | [
"def",
"coverage",
"(",
"reportdir",
"=",
"None",
",",
"extra",
"=",
"None",
")",
":",
"import",
"coverage",
"as",
"coverage_api",
"cov",
"=",
"coverage_api",
".",
"coverage",
"(",
")",
"opts",
"=",
"{",
"'directory'",
":",
"reportdir",
"}",
"if",
"repor... | Test this project with coverage reports | [
"Test",
"this",
"project",
"with",
"coverage",
"reports"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L116-L126 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | managepy | def managepy(cmd, extra=None):
"""Run manage.py using this component's specific Django settings"""
extra = extra.split() if extra else []
run_django_cli(['invoke', cmd] + extra) | python | def managepy(cmd, extra=None):
"""Run manage.py using this component's specific Django settings"""
extra = extra.split() if extra else []
run_django_cli(['invoke', cmd] + extra) | [
"def",
"managepy",
"(",
"cmd",
",",
"extra",
"=",
"None",
")",
":",
"extra",
"=",
"extra",
".",
"split",
"(",
")",
"if",
"extra",
"else",
"[",
"]",
"run_django_cli",
"(",
"[",
"'invoke'",
",",
"cmd",
"]",
"+",
"extra",
")"
] | Run manage.py using this component's specific Django settings | [
"Run",
"manage",
".",
"py",
"using",
"this",
"component",
"s",
"specific",
"Django",
"settings"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L130-L134 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | install | def install(editable=True):
"""Install this component (or remove and reinstall)"""
try:
__import__(package['name'])
except ImportError:
pass
else:
run("pip uninstall --quiet -y %s" % package['name'], warn=True)
cmd = "pip install --quiet "
cmd += "-e ." if editable else... | python | def install(editable=True):
"""Install this component (or remove and reinstall)"""
try:
__import__(package['name'])
except ImportError:
pass
else:
run("pip uninstall --quiet -y %s" % package['name'], warn=True)
cmd = "pip install --quiet "
cmd += "-e ." if editable else... | [
"def",
"install",
"(",
"editable",
"=",
"True",
")",
":",
"try",
":",
"__import__",
"(",
"package",
"[",
"'name'",
"]",
")",
"except",
"ImportError",
":",
"pass",
"else",
":",
"run",
"(",
"\"pip uninstall --quiet -y %s\"",
"%",
"package",
"[",
"'name'",
"]... | Install this component (or remove and reinstall) | [
"Install",
"this",
"component",
"(",
"or",
"remove",
"and",
"reinstall",
")"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L138-L151 |
armstrong/armstrong.dev | armstrong/dev/tasks.py | remove_armstrong | def remove_armstrong():
"""Remove all Armstrong components (except for Dev) from this environment"""
from pip.util import get_installed_distributions
pkgs = get_installed_distributions(local_only=True, include_editables=True)
apps = [pkg for pkg in pkgs
if pkg.key.startswith('armstrong') an... | python | def remove_armstrong():
"""Remove all Armstrong components (except for Dev) from this environment"""
from pip.util import get_installed_distributions
pkgs = get_installed_distributions(local_only=True, include_editables=True)
apps = [pkg for pkg in pkgs
if pkg.key.startswith('armstrong') an... | [
"def",
"remove_armstrong",
"(",
")",
":",
"from",
"pip",
".",
"util",
"import",
"get_installed_distributions",
"pkgs",
"=",
"get_installed_distributions",
"(",
"local_only",
"=",
"True",
",",
"include_editables",
"=",
"True",
")",
"apps",
"=",
"[",
"pkg",
"for",... | Remove all Armstrong components (except for Dev) from this environment | [
"Remove",
"all",
"Armstrong",
"components",
"(",
"except",
"for",
"Dev",
")",
"from",
"this",
"environment"
] | train | https://github.com/armstrong/armstrong.dev/blob/6fd8b863038d9e5ebfd52dfe5ce6c85fb441c267/armstrong/dev/tasks.py#L155-L171 |
CitrineInformatics/dftparse | dftparse/vasp/outcar_parser.py | _parse_total_magnetization | def _parse_total_magnetization(line, lines):
"""Parse the total magnetization, which is somewhat hidden"""
toks = line.split()
res = {"number of electrons": float(toks[3])}
if len(toks) > 5:
res["total magnetization"] = float(toks[5])
return res | python | def _parse_total_magnetization(line, lines):
"""Parse the total magnetization, which is somewhat hidden"""
toks = line.split()
res = {"number of electrons": float(toks[3])}
if len(toks) > 5:
res["total magnetization"] = float(toks[5])
return res | [
"def",
"_parse_total_magnetization",
"(",
"line",
",",
"lines",
")",
":",
"toks",
"=",
"line",
".",
"split",
"(",
")",
"res",
"=",
"{",
"\"number of electrons\"",
":",
"float",
"(",
"toks",
"[",
"3",
"]",
")",
"}",
"if",
"len",
"(",
"toks",
")",
">",... | Parse the total magnetization, which is somewhat hidden | [
"Parse",
"the",
"total",
"magnetization",
"which",
"is",
"somewhat",
"hidden"
] | train | https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/vasp/outcar_parser.py#L4-L10 |
lsst-sqre/sqre-apikit | examples/example1.py | main | def main():
"""Primary entry point; we supply '/', but the class brings '/metadata'"""
app = apikit.APIFlask(name="Hello",
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
# pylint: disable=unu... | python | def main():
"""Primary entry point; we supply '/', but the class brings '/metadata'"""
app = apikit.APIFlask(name="Hello",
version="0.0.1",
repository="http://example.repo",
description="Hello World App")
# pylint: disable=unu... | [
"def",
"main",
"(",
")",
":",
"app",
"=",
"apikit",
".",
"APIFlask",
"(",
"name",
"=",
"\"Hello\"",
",",
"version",
"=",
"\"0.0.1\"",
",",
"repository",
"=",
"\"http://example.repo\"",
",",
"description",
"=",
"\"Hello World App\"",
")",
"# pylint: disable=unuse... | Primary entry point; we supply '/', but the class brings '/metadata | [
"Primary",
"entry",
"point",
";",
"we",
"supply",
"/",
"but",
"the",
"class",
"brings",
"/",
"metadata"
] | train | https://github.com/lsst-sqre/sqre-apikit/blob/ff505b63d2e29303ff7f05f2bd5eabd0f6d7026e/examples/example1.py#L9-L22 |
bitlabstudio/django-server-guardian-api | server_guardian_api/processors/django_mailer.py | deferred_emails | def deferred_emails():
"""Checks for deferred email, that otherwise fill up the queue."""
status = SERVER_STATUS['OK']
count = Message.objects.deferred().count()
if DEFERRED_WARNING_THRESHOLD <= count < DEFERRED_DANGER_THRESHOLD:
status = SERVER_STATUS['WARNING']
if count >= DEFERRED_DANGER... | python | def deferred_emails():
"""Checks for deferred email, that otherwise fill up the queue."""
status = SERVER_STATUS['OK']
count = Message.objects.deferred().count()
if DEFERRED_WARNING_THRESHOLD <= count < DEFERRED_DANGER_THRESHOLD:
status = SERVER_STATUS['WARNING']
if count >= DEFERRED_DANGER... | [
"def",
"deferred_emails",
"(",
")",
":",
"status",
"=",
"SERVER_STATUS",
"[",
"'OK'",
"]",
"count",
"=",
"Message",
".",
"objects",
".",
"deferred",
"(",
")",
".",
"count",
"(",
")",
"if",
"DEFERRED_WARNING_THRESHOLD",
"<=",
"count",
"<",
"DEFERRED_DANGER_TH... | Checks for deferred email, that otherwise fill up the queue. | [
"Checks",
"for",
"deferred",
"email",
"that",
"otherwise",
"fill",
"up",
"the",
"queue",
"."
] | train | https://github.com/bitlabstudio/django-server-guardian-api/blob/c996245b5a8e8f6f590251a8757adcca79d114e3/server_guardian_api/processors/django_mailer.py#L22-L36 |
bitlabstudio/django-server-guardian-api | server_guardian_api/processors/django_mailer.py | email_queue | def email_queue():
"""Checks for emails, that fill up the queue without getting sent."""
status = SERVER_STATUS['OK']
count = Message.objects.exclude(priority=PRIORITY_DEFERRED).filter(
when_added__lte=now() - timedelta(minutes=QUEUE_TIMEOUT)).count()
if QUEUE_WARNING_THRESHOLD <= count < QUEUE... | python | def email_queue():
"""Checks for emails, that fill up the queue without getting sent."""
status = SERVER_STATUS['OK']
count = Message.objects.exclude(priority=PRIORITY_DEFERRED).filter(
when_added__lte=now() - timedelta(minutes=QUEUE_TIMEOUT)).count()
if QUEUE_WARNING_THRESHOLD <= count < QUEUE... | [
"def",
"email_queue",
"(",
")",
":",
"status",
"=",
"SERVER_STATUS",
"[",
"'OK'",
"]",
"count",
"=",
"Message",
".",
"objects",
".",
"exclude",
"(",
"priority",
"=",
"PRIORITY_DEFERRED",
")",
".",
"filter",
"(",
"when_added__lte",
"=",
"now",
"(",
")",
"... | Checks for emails, that fill up the queue without getting sent. | [
"Checks",
"for",
"emails",
"that",
"fill",
"up",
"the",
"queue",
"without",
"getting",
"sent",
"."
] | train | https://github.com/bitlabstudio/django-server-guardian-api/blob/c996245b5a8e8f6f590251a8757adcca79d114e3/server_guardian_api/processors/django_mailer.py#L39-L55 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18n.yaml_force_unicode | def yaml_force_unicode():
"""
Force pyyaml to return unicode values.
"""
#/
## modified from |http://stackoverflow.com/a/2967461|
if sys.version_info[0] == 2:
def construct_func(self, node):
return self.construct_scalar(node)
yaml.L... | python | def yaml_force_unicode():
"""
Force pyyaml to return unicode values.
"""
#/
## modified from |http://stackoverflow.com/a/2967461|
if sys.version_info[0] == 2:
def construct_func(self, node):
return self.construct_scalar(node)
yaml.L... | [
"def",
"yaml_force_unicode",
"(",
")",
":",
"#/",
"## modified from |http://stackoverflow.com/a/2967461|",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"def",
"construct_func",
"(",
"self",
",",
"node",
")",
":",
"return",
"self",
".",
"con... | Force pyyaml to return unicode values. | [
"Force",
"pyyaml",
"to",
"return",
"unicode",
"values",
"."
] | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L78-L88 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18n.get_locale_hints | def get_locale_hints():
"""
Get a list of locale hints,
guessed according to Python's default locale info.
"""
#/
lang, encoding = locale.getdefaultlocale()
## can both be None
#/
if lang and '_' in lang:
lang3, _, lang2 = la... | python | def get_locale_hints():
"""
Get a list of locale hints,
guessed according to Python's default locale info.
"""
#/
lang, encoding = locale.getdefaultlocale()
## can both be None
#/
if lang and '_' in lang:
lang3, _, lang2 = la... | [
"def",
"get_locale_hints",
"(",
")",
":",
"#/",
"lang",
",",
"encoding",
"=",
"locale",
".",
"getdefaultlocale",
"(",
")",
"## can both be None",
"#/",
"if",
"lang",
"and",
"'_'",
"in",
"lang",
":",
"lang3",
",",
"_",
",",
"lang2",
"=",
"lang",
".",
"p... | Get a list of locale hints,
guessed according to Python's default locale info. | [
"Get",
"a",
"list",
"of",
"locale",
"hints",
"guessed",
"according",
"to",
"Python",
"s",
"default",
"locale",
"info",
"."
] | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L91-L123 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18n.get_locale_choices | def get_locale_choices(locale_dir):
"""
Get a list of locale file names in the given locale dir.
"""
#/
file_name_s = os.listdir(locale_dir)
#/
choice_s = []
for file_name in file_name_s:
if file_name.endswith(I18n.TT_FILE_EXT... | python | def get_locale_choices(locale_dir):
"""
Get a list of locale file names in the given locale dir.
"""
#/
file_name_s = os.listdir(locale_dir)
#/
choice_s = []
for file_name in file_name_s:
if file_name.endswith(I18n.TT_FILE_EXT... | [
"def",
"get_locale_choices",
"(",
"locale_dir",
")",
":",
"#/",
"file_name_s",
"=",
"os",
".",
"listdir",
"(",
"locale_dir",
")",
"#/",
"choice_s",
"=",
"[",
"]",
"for",
"file_name",
"in",
"file_name_s",
":",
"if",
"file_name",
".",
"endswith",
"(",
"I18n"... | Get a list of locale file names in the given locale dir. | [
"Get",
"a",
"list",
"of",
"locale",
"file",
"names",
"in",
"the",
"given",
"locale",
"dir",
"."
] | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L126-L146 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18nObj.load_tt_dict | def load_tt_dict(self, locale, tt_d):
"""
Load a tt dict into |self.tt_dd|.
|tt| means text transform.
locale: key into |self.tt_dd|.
tt_d: a tt dict.
"""
#/ get the old tt dict of the locale
tt_d_old = self.tt_dd.get(locale, None)
... | python | def load_tt_dict(self, locale, tt_d):
"""
Load a tt dict into |self.tt_dd|.
|tt| means text transform.
locale: key into |self.tt_dd|.
tt_d: a tt dict.
"""
#/ get the old tt dict of the locale
tt_d_old = self.tt_dd.get(locale, None)
... | [
"def",
"load_tt_dict",
"(",
"self",
",",
"locale",
",",
"tt_d",
")",
":",
"#/ get the old tt dict of the locale",
"tt_d_old",
"=",
"self",
".",
"tt_dd",
".",
"get",
"(",
"locale",
",",
"None",
")",
"#/ if has old tt dict",
"## N",
"if",
"tt_d_old",
"is",
"None... | Load a tt dict into |self.tt_dd|.
|tt| means text transform.
locale: key into |self.tt_dd|.
tt_d: a tt dict. | [
"Load",
"a",
"tt",
"dict",
"into",
"|self",
".",
"tt_dd|",
".",
"|tt|",
"means",
"text",
"transform",
".",
"locale",
":",
"key",
"into",
"|self",
".",
"tt_dd|",
".",
"tt_d",
":",
"a",
"tt",
"dict",
"."
] | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L201-L221 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18nObj.load_tt_file | def load_tt_file(self, locale, path_func=None, encoding=None):
"""
Load a tt file's tt dict into |self.tt_dd|.
|tt| means text transform.
locale: locale key into |self.tt_dd|.
path_func: tt file path func
encoding: tt file encoding
"""
#/... | python | def load_tt_file(self, locale, path_func=None, encoding=None):
"""
Load a tt file's tt dict into |self.tt_dd|.
|tt| means text transform.
locale: locale key into |self.tt_dd|.
path_func: tt file path func
encoding: tt file encoding
"""
#/... | [
"def",
"load_tt_file",
"(",
"self",
",",
"locale",
",",
"path_func",
"=",
"None",
",",
"encoding",
"=",
"None",
")",
":",
"#/",
"path_func",
"=",
"path_func",
"or",
"self",
".",
"path_func",
"encoding",
"=",
"encoding",
"or",
"self",
".",
"file_encoding",
... | Load a tt file's tt dict into |self.tt_dd|.
|tt| means text transform.
locale: locale key into |self.tt_dd|.
path_func: tt file path func
encoding: tt file encoding | [
"Load",
"a",
"tt",
"file",
"s",
"tt",
"dict",
"into",
"|self",
".",
"tt_dd|",
".",
"|tt|",
"means",
"text",
"transform",
".",
"locale",
":",
"locale",
"key",
"into",
"|self",
".",
"tt_dd|",
".",
"path_func",
":",
"tt",
"file",
"path",
"func",
"encoding... | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L223-L262 |
AoiKuiyuyou/AoikI18n | src/aoiki18n/aoiki18n_.py | I18nObj.tt | def tt(self, key, locale=None, locale2=None, default=I18n.DFT):
"""
|tt| means text transform.
key: tt key.
locale: main locale key into |self.tt_dd|. Default to |self.locale|
locale2: fallback locale key into |self.tt_dd|. Default to |self.locale2|
default: a de... | python | def tt(self, key, locale=None, locale2=None, default=I18n.DFT):
"""
|tt| means text transform.
key: tt key.
locale: main locale key into |self.tt_dd|. Default to |self.locale|
locale2: fallback locale key into |self.tt_dd|. Default to |self.locale2|
default: a de... | [
"def",
"tt",
"(",
"self",
",",
"key",
",",
"locale",
"=",
"None",
",",
"locale2",
"=",
"None",
",",
"default",
"=",
"I18n",
".",
"DFT",
")",
":",
"#/",
"locale",
"=",
"locale",
"or",
"self",
".",
"locale",
"locale2",
"=",
"locale2",
"or",
"self",
... | |tt| means text transform.
key: tt key.
locale: main locale key into |self.tt_dd|. Default to |self.locale|
locale2: fallback locale key into |self.tt_dd|. Default to |self.locale2|
default: a default value in case tt value is not found. Default to raise KeyError. | [
"|tt|",
"means",
"text",
"transform",
".",
"key",
":",
"tt",
"key",
".",
"locale",
":",
"main",
"locale",
"key",
"into",
"|self",
".",
"tt_dd|",
".",
"Default",
"to",
"|self",
".",
"locale|",
"locale2",
":",
"fallback",
"locale",
"key",
"into",
"|self",
... | train | https://github.com/AoiKuiyuyou/AoikI18n/blob/8d60ea6a2be24e533a9cf92b433a8cfdb67f813e/src/aoiki18n/aoiki18n_.py#L264-L305 |
Infinidat/infi.recipe.console_scripts | src/infi/recipe/console_scripts/egg.py | Eggs.working_set | def working_set(self, extra=()):
"""Separate method to just get the working set
This is intended for reuse by similar recipes.
"""
options = self.options
b_options = self.buildout['buildout']
# Backward compat. :(
options['executable'] = sys.executable
... | python | def working_set(self, extra=()):
"""Separate method to just get the working set
This is intended for reuse by similar recipes.
"""
options = self.options
b_options = self.buildout['buildout']
# Backward compat. :(
options['executable'] = sys.executable
... | [
"def",
"working_set",
"(",
"self",
",",
"extra",
"=",
"(",
")",
")",
":",
"options",
"=",
"self",
".",
"options",
"b_options",
"=",
"self",
".",
"buildout",
"[",
"'buildout'",
"]",
"# Backward compat. :(",
"options",
"[",
"'executable'",
"]",
"=",
"sys",
... | Separate method to just get the working set
This is intended for reuse by similar recipes. | [
"Separate",
"method",
"to",
"just",
"get",
"the",
"working",
"set"
] | train | https://github.com/Infinidat/infi.recipe.console_scripts/blob/7beab59537654ee475527dbbd59b0aa49348ebd3/src/infi/recipe/console_scripts/egg.py#L38-L70 |
storax/upme | src/upme/main.py | get_required | def get_required(dist):
"""Return a set with all distributions that are required of dist
This also includes subdependencies and the given distribution.
:param dist: the distribution to query. Can also be the name of the distribution
:type dist: :class:`pkg_resources.Distribution` | str
:returns: a... | python | def get_required(dist):
"""Return a set with all distributions that are required of dist
This also includes subdependencies and the given distribution.
:param dist: the distribution to query. Can also be the name of the distribution
:type dist: :class:`pkg_resources.Distribution` | str
:returns: a... | [
"def",
"get_required",
"(",
"dist",
")",
":",
"d",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"dist",
")",
"reqs",
"=",
"set",
"(",
"d",
".",
"requires",
"(",
")",
")",
"allds",
"=",
"set",
"(",
"[",
"d",
"]",
")",
"while",
"reqs",
":",
... | Return a set with all distributions that are required of dist
This also includes subdependencies and the given distribution.
:param dist: the distribution to query. Can also be the name of the distribution
:type dist: :class:`pkg_resources.Distribution` | str
:returns: a list of distributions that are... | [
"Return",
"a",
"set",
"with",
"all",
"distributions",
"that",
"are",
"required",
"of",
"dist"
] | train | https://github.com/storax/upme/blob/41c2d91f922691e31ff940f33b755d2cb64dfef8/src/upme/main.py#L8-L29 |
storax/upme | src/upme/main.py | is_outdated | def is_outdated(dist, dep=False):
"""Return a dict with outdated distributions
If the given distribution has dependencies, they are checked as well.
:param dist: a distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param dep: If True, also return all outdated dependencies... | python | def is_outdated(dist, dep=False):
"""Return a dict with outdated distributions
If the given distribution has dependencies, they are checked as well.
:param dist: a distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param dep: If True, also return all outdated dependencies... | [
"def",
"is_outdated",
"(",
"dist",
",",
"dep",
"=",
"False",
")",
":",
"if",
"dep",
":",
"required",
"=",
"get_required",
"(",
"dist",
")",
"else",
":",
"required",
"=",
"set",
"(",
"[",
"dist",
"]",
")",
"ListCommand",
"=",
"pip",
".",
"commands",
... | Return a dict with outdated distributions
If the given distribution has dependencies, they are checked as well.
:param dist: a distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param dep: If True, also return all outdated dependencies. If False, only check given dist.
:t... | [
"Return",
"a",
"dict",
"with",
"outdated",
"distributions"
] | train | https://github.com/storax/upme/blob/41c2d91f922691e31ff940f33b755d2cb64dfef8/src/upme/main.py#L32-L60 |
storax/upme | src/upme/main.py | update | def update(dist, args=None):
"""Update the given distribution and all of its dependencies
:param dist: the distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param args: extra arguments for the install command.
this is somewhat equivalent to: pip install -U <d... | python | def update(dist, args=None):
"""Update the given distribution and all of its dependencies
:param dist: the distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param args: extra arguments for the install command.
this is somewhat equivalent to: pip install -U <d... | [
"def",
"update",
"(",
"dist",
",",
"args",
"=",
"None",
")",
":",
"dist",
"=",
"pkg_resources",
".",
"get_distribution",
"(",
"dist",
")",
"InstallCommand",
"=",
"pip",
".",
"commands",
"[",
"'install'",
"]",
"ic",
"=",
"InstallCommand",
"(",
")",
"iargs... | Update the given distribution and all of its dependencies
:param dist: the distribution to check
:type dist: :class:`pkg_resources.Distribution` | str
:param args: extra arguments for the install command.
this is somewhat equivalent to: pip install -U <dist> args
:type args: list
:... | [
"Update",
"the",
"given",
"distribution",
"and",
"all",
"of",
"its",
"dependencies"
] | train | https://github.com/storax/upme/blob/41c2d91f922691e31ff940f33b755d2cb64dfef8/src/upme/main.py#L63-L81 |
storax/upme | src/upme/main.py | restart | def restart():
"""Restart the application the same way it was started
:returns: None
:rtype: None
:raises: SystemExit
"""
python = sys.executable
os.execl(python, python, * sys.argv) | python | def restart():
"""Restart the application the same way it was started
:returns: None
:rtype: None
:raises: SystemExit
"""
python = sys.executable
os.execl(python, python, * sys.argv) | [
"def",
"restart",
"(",
")",
":",
"python",
"=",
"sys",
".",
"executable",
"os",
".",
"execl",
"(",
"python",
",",
"python",
",",
"*",
"sys",
".",
"argv",
")"
] | Restart the application the same way it was started
:returns: None
:rtype: None
:raises: SystemExit | [
"Restart",
"the",
"application",
"the",
"same",
"way",
"it",
"was",
"started"
] | train | https://github.com/storax/upme/blob/41c2d91f922691e31ff940f33b755d2cb64dfef8/src/upme/main.py#L84-L92 |
fr33jc/bang | bang/providers/openstack/__init__.py | server_to_dict | def server_to_dict(server):
"""
Returns the :class:`dict` representation of a server object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects.
"""
def get_ips_for_server(server):
public_ips = []
private_ips = []
... | python | def server_to_dict(server):
"""
Returns the :class:`dict` representation of a server object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects.
"""
def get_ips_for_server(server):
public_ips = []
private_ips = []
... | [
"def",
"server_to_dict",
"(",
"server",
")",
":",
"def",
"get_ips_for_server",
"(",
"server",
")",
":",
"public_ips",
"=",
"[",
"]",
"private_ips",
"=",
"[",
"]",
"def",
"address_is_public",
"(",
"address",
")",
":",
"return",
"address",
"[",
"'OS-EXT-IPS:ty... | Returns the :class:`dict` representation of a server object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects. | [
"Returns",
"the",
":",
"class",
":",
"dict",
"representation",
"of",
"a",
"server",
"object",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L31-L67 |
fr33jc/bang | bang/providers/openstack/__init__.py | db_to_dict | def db_to_dict(db):
"""
Returns the :class:`dict` representation of a database object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects.
"""
return {
A.database.HOST: db.hostname,
A.database.PORT: db.port,
... | python | def db_to_dict(db):
"""
Returns the :class:`dict` representation of a database object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects.
"""
return {
A.database.HOST: db.hostname,
A.database.PORT: db.port,
... | [
"def",
"db_to_dict",
"(",
"db",
")",
":",
"return",
"{",
"A",
".",
"database",
".",
"HOST",
":",
"db",
".",
"hostname",
",",
"A",
".",
"database",
".",
"PORT",
":",
"db",
".",
"port",
",",
"}"
] | Returns the :class:`dict` representation of a database object.
The returned :class:`dict` is meant to be consumed by
:class:`~bang.deployers.cloud.ServerDeployer` objects. | [
"Returns",
"the",
":",
"class",
":",
"dict",
"representation",
"of",
"a",
"database",
"object",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L70-L81 |
fr33jc/bang | bang/providers/openstack/__init__.py | authenticated | def authenticated(f):
"""Decorator that authenticates to Keystone automatically."""
@wraps(f)
def new_f(self, *args, **kwargs):
if not self.nova_client.client.auth_token:
self.authenticate()
return f(self, *args, **kwargs)
return new_f | python | def authenticated(f):
"""Decorator that authenticates to Keystone automatically."""
@wraps(f)
def new_f(self, *args, **kwargs):
if not self.nova_client.client.auth_token:
self.authenticate()
return f(self, *args, **kwargs)
return new_f | [
"def",
"authenticated",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"new_f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"nova_client",
".",
"client",
".",
"auth_token",
":",
"self",
"."... | Decorator that authenticates to Keystone automatically. | [
"Decorator",
"that",
"authenticates",
"to",
"Keystone",
"automatically",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L438-L445 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.find_ssh_pub_key | def find_ssh_pub_key(self, name):
"""
Returns ``True`` if an SSH key named :attr:`name` is found.
Otherwise returns ``False``.
:rtype: :class:`bool`
"""
return bool(self.nova.keypairs.findall(name=name)) | python | def find_ssh_pub_key(self, name):
"""
Returns ``True`` if an SSH key named :attr:`name` is found.
Otherwise returns ``False``.
:rtype: :class:`bool`
"""
return bool(self.nova.keypairs.findall(name=name)) | [
"def",
"find_ssh_pub_key",
"(",
"self",
",",
"name",
")",
":",
"return",
"bool",
"(",
"self",
".",
"nova",
".",
"keypairs",
".",
"findall",
"(",
"name",
"=",
"name",
")",
")"
] | Returns ``True`` if an SSH key named :attr:`name` is found.
Otherwise returns ``False``.
:rtype: :class:`bool` | [
"Returns",
"True",
"if",
"an",
"SSH",
"key",
"named",
":",
"attr",
":",
"name",
"is",
"found",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L136-L145 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.create_ssh_pub_key | def create_ssh_pub_key(self, name, key):
"""
Installs the public SSH key under the name :attr:`name`.
Once installed, the key can be referenced when creating new server
instances.
"""
self.nova.keypairs.create(name, key) | python | def create_ssh_pub_key(self, name, key):
"""
Installs the public SSH key under the name :attr:`name`.
Once installed, the key can be referenced when creating new server
instances.
"""
self.nova.keypairs.create(name, key) | [
"def",
"create_ssh_pub_key",
"(",
"self",
",",
"name",
",",
"key",
")",
":",
"self",
".",
"nova",
".",
"keypairs",
".",
"create",
"(",
"name",
",",
"key",
")"
] | Installs the public SSH key under the name :attr:`name`.
Once installed, the key can be referenced when creating new server
instances. | [
"Installs",
"the",
"public",
"SSH",
"key",
"under",
"the",
"name",
":",
"attr",
":",
"name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L147-L155 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.find_servers | def find_servers(self, tags, running=True):
"""
Returns any servers in the region that have tags that match the
key-value pairs in :attr:`tags`.
:param Mapping tags: A mapping object in which the keys are the tag
names and the values are the tag values.
:param bool... | python | def find_servers(self, tags, running=True):
"""
Returns any servers in the region that have tags that match the
key-value pairs in :attr:`tags`.
:param Mapping tags: A mapping object in which the keys are the tag
names and the values are the tag values.
:param bool... | [
"def",
"find_servers",
"(",
"self",
",",
"tags",
",",
"running",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"\"Finding instances with tags: %s\"",
"%",
"tags",
")",
"search_opts",
"=",
"{",
"}",
"if",
"running",
":",
"search_opts",
"[",
"'status'",
"... | Returns any servers in the region that have tags that match the
key-value pairs in :attr:`tags`.
:param Mapping tags: A mapping object in which the keys are the tag
names and the values are the tag values.
:param bool running: A flag to limit server list to instances that are
... | [
"Returns",
"any",
"servers",
"in",
"the",
"region",
"that",
"have",
"tags",
"that",
"match",
"the",
"key",
"-",
"value",
"pairs",
"in",
":",
"attr",
":",
"tags",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L157-L184 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.create_server | def create_server(self, basename, disk_image_id, instance_type,
ssh_key_name, tags=None, availability_zone=None,
timeout_s=DEFAULT_TIMEOUT_S, floating_ip=True,
**kwargs):
"""
Creates a new server instance. This call blocks until the server is
created and avai... | python | def create_server(self, basename, disk_image_id, instance_type,
ssh_key_name, tags=None, availability_zone=None,
timeout_s=DEFAULT_TIMEOUT_S, floating_ip=True,
**kwargs):
"""
Creates a new server instance. This call blocks until the server is
created and avai... | [
"def",
"create_server",
"(",
"self",
",",
"basename",
",",
"disk_image_id",
",",
"instance_type",
",",
"ssh_key_name",
",",
"tags",
"=",
"None",
",",
"availability_zone",
"=",
"None",
",",
"timeout_s",
"=",
"DEFAULT_TIMEOUT_S",
",",
"floating_ip",
"=",
"True",
... | Creates a new server instance. This call blocks until the server is
created and available for normal use, or :attr:`timeout_s` has elapsed.
:param str basename: An identifier for the server. A random postfix
will be appended to this basename to work around OpenStack Nova
REST... | [
"Creates",
"a",
"new",
"server",
"instance",
".",
"This",
"call",
"blocks",
"until",
"the",
"server",
"is",
"created",
"and",
"available",
"for",
"normal",
"use",
"or",
":",
"attr",
":",
"timeout_s",
"has",
"elapsed",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L189-L262 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.find_secgroup | def find_secgroup(self, name):
"""
Find a security group by name.
Returns a :class:`NovaSecGroup` instance if found, otherwise returns
None.
"""
groups = self.nova.security_groups.findall(name=name)
if groups:
return NovaSecGroup(groups[0]) | python | def find_secgroup(self, name):
"""
Find a security group by name.
Returns a :class:`NovaSecGroup` instance if found, otherwise returns
None.
"""
groups = self.nova.security_groups.findall(name=name)
if groups:
return NovaSecGroup(groups[0]) | [
"def",
"find_secgroup",
"(",
"self",
",",
"name",
")",
":",
"groups",
"=",
"self",
".",
"nova",
".",
"security_groups",
".",
"findall",
"(",
"name",
"=",
"name",
")",
"if",
"groups",
":",
"return",
"NovaSecGroup",
"(",
"groups",
"[",
"0",
"]",
")"
] | Find a security group by name.
Returns a :class:`NovaSecGroup` instance if found, otherwise returns
None. | [
"Find",
"a",
"security",
"group",
"by",
"name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L264-L274 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.create_secgroup | def create_secgroup(self, name, desc):
"""
Creates a new server security group.
:param str name: The name of the security group to create.
:param str desc: A short description of the group.
"""
self.nova.security_groups.create(name, desc) | python | def create_secgroup(self, name, desc):
"""
Creates a new server security group.
:param str name: The name of the security group to create.
:param str desc: A short description of the group.
"""
self.nova.security_groups.create(name, desc) | [
"def",
"create_secgroup",
"(",
"self",
",",
"name",
",",
"desc",
")",
":",
"self",
".",
"nova",
".",
"security_groups",
".",
"create",
"(",
"name",
",",
"desc",
")"
] | Creates a new server security group.
:param str name: The name of the security group to create.
:param str desc: A short description of the group. | [
"Creates",
"a",
"new",
"server",
"security",
"group",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L276-L284 |
fr33jc/bang | bang/providers/openstack/__init__.py | Nova.create_secgroup_rule | def create_secgroup_rule(self, protocol, from_port, to_port,
source, target):
"""
Creates a new server security group rule.
:param str protocol: E.g. ``tcp``, ``icmp``, etc...
:param int from_port: E.g. ``1``
:param int to_port: E.g. ``65535``
:param str s... | python | def create_secgroup_rule(self, protocol, from_port, to_port,
source, target):
"""
Creates a new server security group rule.
:param str protocol: E.g. ``tcp``, ``icmp``, etc...
:param int from_port: E.g. ``1``
:param int to_port: E.g. ``65535``
:param str s... | [
"def",
"create_secgroup_rule",
"(",
"self",
",",
"protocol",
",",
"from_port",
",",
"to_port",
",",
"source",
",",
"target",
")",
":",
"nova",
"=",
"self",
".",
"nova",
"def",
"get_id",
"(",
"gname",
")",
":",
"sg",
"=",
"nova",
".",
"security_groups",
... | Creates a new server security group rule.
:param str protocol: E.g. ``tcp``, ``icmp``, etc...
:param int from_port: E.g. ``1``
:param int to_port: E.g. ``65535``
:param str source:
:param str target: | [
"Creates",
"a",
"new",
"server",
"security",
"group",
"rule",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L286-L319 |
fr33jc/bang | bang/providers/openstack/__init__.py | Swift.create_bucket | def create_bucket(self, name, headers=None):
"""
Creates a bucket named :attr:`name`.
:param dict headers: Any headers to use when performing the HTTP PUT.
"""
self.provider.swift_client.put_container(name, headers) | python | def create_bucket(self, name, headers=None):
"""
Creates a bucket named :attr:`name`.
:param dict headers: Any headers to use when performing the HTTP PUT.
"""
self.provider.swift_client.put_container(name, headers) | [
"def",
"create_bucket",
"(",
"self",
",",
"name",
",",
"headers",
"=",
"None",
")",
":",
"self",
".",
"provider",
".",
"swift_client",
".",
"put_container",
"(",
"name",
",",
"headers",
")"
] | Creates a bucket named :attr:`name`.
:param dict headers: Any headers to use when performing the HTTP PUT. | [
"Creates",
"a",
"bucket",
"named",
":",
"attr",
":",
"name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L332-L339 |
fr33jc/bang | bang/providers/openstack/__init__.py | RedDwarf.find_db_instance | def find_db_instance(self, name, running=True):
"""
Searches for a db instance named :attr:`name`.
:param str name: The name of the target db instance
:param bool running: A flag to only look for instances that are
actually *running*.
:rtype: :class:`dict`
... | python | def find_db_instance(self, name, running=True):
"""
Searches for a db instance named :attr:`name`.
:param str name: The name of the target db instance
:param bool running: A flag to only look for instances that are
actually *running*.
:rtype: :class:`dict`
... | [
"def",
"find_db_instance",
"(",
"self",
",",
"name",
",",
"running",
"=",
"True",
")",
":",
"found",
"=",
"None",
"for",
"i",
"in",
"self",
".",
"provider",
".",
"reddwarf_client",
".",
"instances",
".",
"list",
"(",
")",
":",
"if",
"i",
".",
"name",... | Searches for a db instance named :attr:`name`.
:param str name: The name of the target db instance
:param bool running: A flag to only look for instances that are
actually *running*.
:rtype: :class:`dict` | [
"Searches",
"for",
"a",
"db",
"instance",
"named",
":",
"attr",
":",
"name",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L343-L364 |
fr33jc/bang | bang/providers/openstack/__init__.py | RedDwarf.create_db | def create_db(self, instance_name, instance_type, admin_username,
admin_password, security_groups=None, db_name=None,
storage_size_gb=DEFAULT_STORAGE_SIZE_GB,
timeout_s=DEFAULT_TIMEOUT_S):
"""
Creates a database instance.
This method blocks until the db insta... | python | def create_db(self, instance_name, instance_type, admin_username,
admin_password, security_groups=None, db_name=None,
storage_size_gb=DEFAULT_STORAGE_SIZE_GB,
timeout_s=DEFAULT_TIMEOUT_S):
"""
Creates a database instance.
This method blocks until the db insta... | [
"def",
"create_db",
"(",
"self",
",",
"instance_name",
",",
"instance_type",
",",
"admin_username",
",",
"admin_password",
",",
"security_groups",
"=",
"None",
",",
"db_name",
"=",
"None",
",",
"storage_size_gb",
"=",
"DEFAULT_STORAGE_SIZE_GB",
",",
"timeout_s",
"... | Creates a database instance.
This method blocks until the db instance is active, or until
:attr:`timeout_s` has elapsed.
:param str instance_name: A name to assign to the db instance.
:param str instance_type: The server instance type (e.g. ``medium``).
:param str admin_use... | [
"Creates",
"a",
"database",
"instance",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L395-L435 |
fr33jc/bang | bang/providers/openstack/__init__.py | OpenStack.nova_client | def nova_client(self):
"""
Each of the OpenStack client libraries (i.e. the ``python-*client``
projects that live under https://github.com/openstack/) has its own way
of connecting to the identity service (keystone).
The object returned here is a :class:`novaclient.v1_1.client.C... | python | def nova_client(self):
"""
Each of the OpenStack client libraries (i.e. the ``python-*client``
projects that live under https://github.com/openstack/) has its own way
of connecting to the identity service (keystone).
The object returned here is a :class:`novaclient.v1_1.client.C... | [
"def",
"nova_client",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_client",
":",
"self",
".",
"_client",
"=",
"self",
".",
"_get_nova_client",
"(",
")",
"return",
"self",
".",
"_client"
] | Each of the OpenStack client libraries (i.e. the ``python-*client``
projects that live under https://github.com/openstack/) has its own way
of connecting to the identity service (keystone).
The object returned here is a :class:`novaclient.v1_1.client.Client`. | [
"Each",
"of",
"the",
"OpenStack",
"client",
"libraries",
"(",
"i",
".",
"e",
".",
"the",
"python",
"-",
"*",
"client",
"projects",
"that",
"live",
"under",
"https",
":",
"//",
"github",
".",
"com",
"/",
"openstack",
"/",
")",
"has",
"its",
"own",
"wa... | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/openstack/__init__.py#L491-L502 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.