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 |
|---|---|---|---|---|---|---|---|---|---|---|
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/parser_csv.py | _remove_quotes | def _remove_quotes(word):
"""
Remove quotes from `word` if the word starts and ands with quotes (" or ').
"""
if not word or len(word) <= 2:
return word
if word[0] == word[-1] and word[0] in ["'", '"']:
return word[1:-1]
return word | python | def _remove_quotes(word):
"""
Remove quotes from `word` if the word starts and ands with quotes (" or ').
"""
if not word or len(word) <= 2:
return word
if word[0] == word[-1] and word[0] in ["'", '"']:
return word[1:-1]
return word | [
"def",
"_remove_quotes",
"(",
"word",
")",
":",
"if",
"not",
"word",
"or",
"len",
"(",
"word",
")",
"<=",
"2",
":",
"return",
"word",
"if",
"word",
"[",
"0",
"]",
"==",
"word",
"[",
"-",
"1",
"]",
"and",
"word",
"[",
"0",
"]",
"in",
"[",
"\"'... | Remove quotes from `word` if the word starts and ands with quotes (" or '). | [
"Remove",
"quotes",
"from",
"word",
"if",
"the",
"word",
"starts",
"and",
"ands",
"with",
"quotes",
"(",
"or",
")",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/parser_csv.py#L32-L42 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/parser_csv.py | decode | def decode(data):
"""
Handles decoding of the CSV `data`.
Args:
data (str): Data which will be decoded.
Returns:
dict: Dictionary with decoded data.
"""
# try to guess dialect of the csv file
dialect = None
try:
dialect = csv.Sniffer().sniff(data)
except Exc... | python | def decode(data):
"""
Handles decoding of the CSV `data`.
Args:
data (str): Data which will be decoded.
Returns:
dict: Dictionary with decoded data.
"""
# try to guess dialect of the csv file
dialect = None
try:
dialect = csv.Sniffer().sniff(data)
except Exc... | [
"def",
"decode",
"(",
"data",
")",
":",
"# try to guess dialect of the csv file",
"dialect",
"=",
"None",
"try",
":",
"dialect",
"=",
"csv",
".",
"Sniffer",
"(",
")",
".",
"sniff",
"(",
"data",
")",
"except",
"Exception",
":",
"pass",
"# parse data with csv pa... | Handles decoding of the CSV `data`.
Args:
data (str): Data which will be decoded.
Returns:
dict: Dictionary with decoded data. | [
"Handles",
"decoding",
"of",
"the",
"CSV",
"data",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/parser_csv.py#L45-L94 |
laco/python-scotty | scotty/__init__.py | cli | def cli(ctx, config, quiet):
"""AWS ECS Docker Deployment Tool"""
ctx.obj = {}
ctx.obj['config'] = load_config(config.read()) # yaml.load(config.read())
ctx.obj['quiet'] = quiet
log(ctx, ' * ' + rnd_scotty_quote() + ' * ') | python | def cli(ctx, config, quiet):
"""AWS ECS Docker Deployment Tool"""
ctx.obj = {}
ctx.obj['config'] = load_config(config.read()) # yaml.load(config.read())
ctx.obj['quiet'] = quiet
log(ctx, ' * ' + rnd_scotty_quote() + ' * ') | [
"def",
"cli",
"(",
"ctx",
",",
"config",
",",
"quiet",
")",
":",
"ctx",
".",
"obj",
"=",
"{",
"}",
"ctx",
".",
"obj",
"[",
"'config'",
"]",
"=",
"load_config",
"(",
"config",
".",
"read",
"(",
")",
")",
"# yaml.load(config.read())",
"ctx",
".",
"ob... | AWS ECS Docker Deployment Tool | [
"AWS",
"ECS",
"Docker",
"Deployment",
"Tool"
] | train | https://github.com/laco/python-scotty/blob/b8d1925db881adaf06ce3c532ab3a61835dce6a8/scotty/__init__.py#L12-L17 |
brentpayne/phrase | phrase/noun_phrase_dictionary.py | NounPhraseDictionary.merge_pos_tokens | def merge_pos_tokens(self, pos_tokens):
"""
takes an array of Part of Speech labeled tokens and returns a set of tokens where word tokens have been merged into Noun phrases.
:param pos_tokens: an array of (token, POS)
:returns: returns an array of word and phrase tokens
"""
... | python | def merge_pos_tokens(self, pos_tokens):
"""
takes an array of Part of Speech labeled tokens and returns a set of tokens where word tokens have been merged into Noun phrases.
:param pos_tokens: an array of (token, POS)
:returns: returns an array of word and phrase tokens
"""
... | [
"def",
"merge_pos_tokens",
"(",
"self",
",",
"pos_tokens",
")",
":",
"if",
"pos_tokens",
"is",
"None",
"or",
"len",
"(",
"pos_tokens",
")",
"<",
"0",
":",
"return",
"\"\"",
"tokens",
",",
"pos",
"=",
"zip",
"(",
"*",
"pos_tokens",
")",
"pos_phrase_ids",
... | takes an array of Part of Speech labeled tokens and returns a set of tokens where word tokens have been merged into Noun phrases.
:param pos_tokens: an array of (token, POS)
:returns: returns an array of word and phrase tokens | [
"takes",
"an",
"array",
"of",
"Part",
"of",
"Speech",
"labeled",
"tokens",
"and",
"returns",
"a",
"set",
"of",
"tokens",
"where",
"word",
"tokens",
"have",
"been",
"merged",
"into",
"Noun",
"phrases",
".",
":",
"param",
"pos_tokens",
":",
"an",
"array",
... | train | https://github.com/brentpayne/phrase/blob/2c25e202eff0f284cb724a36cec1b22a1169e7a2/phrase/noun_phrase_dictionary.py#L16-L28 |
brentpayne/phrase | phrase/noun_phrase_dictionary.py | NounPhraseDictionary.convert_noun_phrases | def convert_noun_phrases(self, id_run, pos_run):
"""
Converts any identified phrases in the run into phrase_ids. The dictionary provides all acceptable phrases
:param id_run: a run of token ids
:param dictionary: a dictionary of acceptable phrases described as there component token ids
... | python | def convert_noun_phrases(self, id_run, pos_run):
"""
Converts any identified phrases in the run into phrase_ids. The dictionary provides all acceptable phrases
:param id_run: a run of token ids
:param dictionary: a dictionary of acceptable phrases described as there component token ids
... | [
"def",
"convert_noun_phrases",
"(",
"self",
",",
"id_run",
",",
"pos_run",
")",
":",
"i",
"=",
"0",
"rv",
"=",
"[",
"]",
"while",
"i",
"<",
"len",
"(",
"id_run",
")",
":",
"phrase_id",
",",
"offset",
"=",
"PhraseDictionary",
".",
"return_max_phrase",
"... | Converts any identified phrases in the run into phrase_ids. The dictionary provides all acceptable phrases
:param id_run: a run of token ids
:param dictionary: a dictionary of acceptable phrases described as there component token ids
:return: a run of token and phrase ids. | [
"Converts",
"any",
"identified",
"phrases",
"in",
"the",
"run",
"into",
"phrase_ids",
".",
"The",
"dictionary",
"provides",
"all",
"acceptable",
"phrases",
":",
"param",
"id_run",
":",
"a",
"run",
"of",
"token",
"ids",
":",
"param",
"dictionary",
":",
"a",
... | train | https://github.com/brentpayne/phrase/blob/2c25e202eff0f284cb724a36cec1b22a1169e7a2/phrase/noun_phrase_dictionary.py#L31-L54 |
brentpayne/phrase | phrase/noun_phrase_dictionary.py | NounPhraseDictionary.add | def add(self, phrase, id=None):
"""
Adds a new phrase to the dictionary
:param phrase: the new phrase as a list of tokens
:param phrase_id: optionally the phrase_id can be set on addition. Beware, if you set one id you should set
them all as the auto-generated ids do not tak... | python | def add(self, phrase, id=None):
"""
Adds a new phrase to the dictionary
:param phrase: the new phrase as a list of tokens
:param phrase_id: optionally the phrase_id can be set on addition. Beware, if you set one id you should set
them all as the auto-generated ids do not tak... | [
"def",
"add",
"(",
"self",
",",
"phrase",
",",
"id",
"=",
"None",
")",
":",
"if",
"len",
"(",
"phrase",
")",
">",
"0",
"and",
"type",
"(",
"phrase",
"[",
"0",
"]",
")",
"in",
"(",
"tuple",
",",
"list",
")",
":",
"phrase",
"=",
"[",
"token",
... | Adds a new phrase to the dictionary
:param phrase: the new phrase as a list of tokens
:param phrase_id: optionally the phrase_id can be set on addition. Beware, if you set one id you should set
them all as the auto-generated ids do not take into account phrase_ids set this way.
:ret... | [
"Adds",
"a",
"new",
"phrase",
"to",
"the",
"dictionary",
":",
"param",
"phrase",
":",
"the",
"new",
"phrase",
"as",
"a",
"list",
"of",
"tokens",
":",
"param",
"phrase_id",
":",
"optionally",
"the",
"phrase_id",
"can",
"be",
"set",
"on",
"addition",
".",
... | train | https://github.com/brentpayne/phrase/blob/2c25e202eff0f284cb724a36cec1b22a1169e7a2/phrase/noun_phrase_dictionary.py#L56-L66 |
yunojuno-archive/python-errordite | errordite/handlers.py | ErrorditeHandler.emit | def emit(self, record):
"""
Sends exception info to Errordite.
This handler will ignore the log level, and look for an exception
within the record (as recored.exc_info) or current stack frame
(sys.exc_info()). If it finds neither, it will simply return without
doing anyt... | python | def emit(self, record):
"""
Sends exception info to Errordite.
This handler will ignore the log level, and look for an exception
within the record (as recored.exc_info) or current stack frame
(sys.exc_info()). If it finds neither, it will simply return without
doing anyt... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"if",
"not",
"self",
".",
"token",
":",
"raise",
"Exception",
"(",
"\"Missing Errordite service token.\"",
")",
"if",
"record",
".",
"levelname",
"==",
"'EXCEPTION'",
":",
"exc_info",
"=",
"record",
".",
... | Sends exception info to Errordite.
This handler will ignore the log level, and look for an exception
within the record (as recored.exc_info) or current stack frame
(sys.exc_info()). If it finds neither, it will simply return without
doing anything. | [
"Sends",
"exception",
"info",
"to",
"Errordite",
"."
] | train | https://github.com/yunojuno-archive/python-errordite/blob/320585f6e29043b3fea11304e0f1dde3ea3a19da/errordite/handlers.py#L49-L104 |
callowayproject/Transmogrify | transmogrify/contrib/django/templatetags/transmogrifiers.py | resolve | def resolve(var, context):
"""
Resolve the variable, or return the value passed to it in the first place
"""
try:
return var.resolve(context)
except template.VariableDoesNotExist:
return var.var | python | def resolve(var, context):
"""
Resolve the variable, or return the value passed to it in the first place
"""
try:
return var.resolve(context)
except template.VariableDoesNotExist:
return var.var | [
"def",
"resolve",
"(",
"var",
",",
"context",
")",
":",
"try",
":",
"return",
"var",
".",
"resolve",
"(",
"context",
")",
"except",
"template",
".",
"VariableDoesNotExist",
":",
"return",
"var",
".",
"var"
] | Resolve the variable, or return the value passed to it in the first place | [
"Resolve",
"the",
"variable",
"or",
"return",
"the",
"value",
"passed",
"to",
"it",
"in",
"the",
"first",
"place"
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/contrib/django/templatetags/transmogrifiers.py#L22-L29 |
callowayproject/Transmogrify | transmogrify/contrib/django/templatetags/transmogrifiers.py | no_param_shortcut | def no_param_shortcut(parser, token):
"""
Shortcut to transmogrify thumbnail
"""
bits = smart_split(token.contents)
tagname = bits.next()
try:
imageurl = bits.next()
except StopIteration:
raise template.TemplateSyntaxError("%r tag requires at least the image url" % tagname)
... | python | def no_param_shortcut(parser, token):
"""
Shortcut to transmogrify thumbnail
"""
bits = smart_split(token.contents)
tagname = bits.next()
try:
imageurl = bits.next()
except StopIteration:
raise template.TemplateSyntaxError("%r tag requires at least the image url" % tagname)
... | [
"def",
"no_param_shortcut",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"smart_split",
"(",
"token",
".",
"contents",
")",
"tagname",
"=",
"bits",
".",
"next",
"(",
")",
"try",
":",
"imageurl",
"=",
"bits",
".",
"next",
"(",
")",
"except",
"S... | Shortcut to transmogrify thumbnail | [
"Shortcut",
"to",
"transmogrify",
"thumbnail"
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/contrib/django/templatetags/transmogrifiers.py#L63-L74 |
callowayproject/Transmogrify | transmogrify/contrib/django/templatetags/transmogrifiers.py | two_param_shortcut | def two_param_shortcut(parser, token):
"""
Shortcut to transmogrify thumbnail
"""
bits = smart_split(token.contents)
tagname = bits.next()
try:
imageurl = bits.next()
param1 = bits.next()
param2 = bits.next()
param2 = param2.lstrip("#")
except StopIteration:
... | python | def two_param_shortcut(parser, token):
"""
Shortcut to transmogrify thumbnail
"""
bits = smart_split(token.contents)
tagname = bits.next()
try:
imageurl = bits.next()
param1 = bits.next()
param2 = bits.next()
param2 = param2.lstrip("#")
except StopIteration:
... | [
"def",
"two_param_shortcut",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"smart_split",
"(",
"token",
".",
"contents",
")",
"tagname",
"=",
"bits",
".",
"next",
"(",
")",
"try",
":",
"imageurl",
"=",
"bits",
".",
"next",
"(",
")",
"param1",
"... | Shortcut to transmogrify thumbnail | [
"Shortcut",
"to",
"transmogrify",
"thumbnail"
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/contrib/django/templatetags/transmogrifiers.py#L92-L106 |
etcher-be/emiz | emiz/avwx/__init__.py | Metar.update | def update(self, report: str = None) -> bool:
"""Updates raw, data, and translations by fetching and parsing the METAR report
Returns True is a new report is available, else False
"""
if report is not None:
self.raw = report
else:
raw = self.service.fetch... | python | def update(self, report: str = None) -> bool:
"""Updates raw, data, and translations by fetching and parsing the METAR report
Returns True is a new report is available, else False
"""
if report is not None:
self.raw = report
else:
raw = self.service.fetch... | [
"def",
"update",
"(",
"self",
",",
"report",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"report",
"is",
"not",
"None",
":",
"self",
".",
"raw",
"=",
"report",
"else",
":",
"raw",
"=",
"self",
".",
"service",
".",
"fetch",
"(",
"self",... | Updates raw, data, and translations by fetching and parsing the METAR report
Returns True is a new report is available, else False | [
"Updates",
"raw",
"data",
"and",
"translations",
"by",
"fetching",
"and",
"parsing",
"the",
"METAR",
"report"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/__init__.py#L88-L103 |
etcher-be/emiz | emiz/avwx/__init__.py | Metar.summary | def summary(self) -> str:
"""
Condensed report summary created from translations
"""
if not self.translations:
self.update()
return summary.metar(self.translations) | python | def summary(self) -> str:
"""
Condensed report summary created from translations
"""
if not self.translations:
self.update()
return summary.metar(self.translations) | [
"def",
"summary",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"translations",
":",
"self",
".",
"update",
"(",
")",
"return",
"summary",
".",
"metar",
"(",
"self",
".",
"translations",
")"
] | Condensed report summary created from translations | [
"Condensed",
"report",
"summary",
"created",
"from",
"translations"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/__init__.py#L106-L112 |
etcher-be/emiz | emiz/avwx/__init__.py | Metar.speech | def speech(self) -> str:
"""
Report summary designed to be read by a text-to-speech program
"""
if not self.data:
self.update()
return speech.metar(self.data, self.units) | python | def speech(self) -> str:
"""
Report summary designed to be read by a text-to-speech program
"""
if not self.data:
self.update()
return speech.metar(self.data, self.units) | [
"def",
"speech",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"data",
":",
"self",
".",
"update",
"(",
")",
"return",
"speech",
".",
"metar",
"(",
"self",
".",
"data",
",",
"self",
".",
"units",
")"
] | Report summary designed to be read by a text-to-speech program | [
"Report",
"summary",
"designed",
"to",
"be",
"read",
"by",
"a",
"text",
"-",
"to",
"-",
"speech",
"program"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/__init__.py#L115-L121 |
etcher-be/emiz | emiz/avwx/__init__.py | Taf.summary | def summary(self): # type: ignore
"""
Condensed summary for each forecast created from translations
"""
if not self.translations:
self.update()
return [summary.taf(trans) for trans in self.translations.forecast] | python | def summary(self): # type: ignore
"""
Condensed summary for each forecast created from translations
"""
if not self.translations:
self.update()
return [summary.taf(trans) for trans in self.translations.forecast] | [
"def",
"summary",
"(",
"self",
")",
":",
"# type: ignore",
"if",
"not",
"self",
".",
"translations",
":",
"self",
".",
"update",
"(",
")",
"return",
"[",
"summary",
".",
"taf",
"(",
"trans",
")",
"for",
"trans",
"in",
"self",
".",
"translations",
".",
... | Condensed summary for each forecast created from translations | [
"Condensed",
"summary",
"for",
"each",
"forecast",
"created",
"from",
"translations"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/__init__.py#L148-L154 |
etcher-be/emiz | emiz/avwx/__init__.py | Taf.speech | def speech(self) -> str:
"""
Report summary designed to be read by a text-to-speech program
"""
if not self.data:
self.update()
return speech.taf(self.data, self.units) | python | def speech(self) -> str:
"""
Report summary designed to be read by a text-to-speech program
"""
if not self.data:
self.update()
return speech.taf(self.data, self.units) | [
"def",
"speech",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"data",
":",
"self",
".",
"update",
"(",
")",
"return",
"speech",
".",
"taf",
"(",
"self",
".",
"data",
",",
"self",
".",
"units",
")"
] | Report summary designed to be read by a text-to-speech program | [
"Report",
"summary",
"designed",
"to",
"be",
"read",
"by",
"a",
"text",
"-",
"to",
"-",
"speech",
"program"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/__init__.py#L157-L163 |
limpyd/redis-limpyd-jobs | limpyd_jobs/scripts/worker.py | LaxOptionParser.parse_python_paths | def parse_python_paths(self, args):
"""
optparse doesn't manage stuff like this:
--pythonpath /my/modules/*
but it can manages
--pythonpath=/my/modules/*/
(but without handling globing)
This method handles correctly the one without "=" and manages globing
... | python | def parse_python_paths(self, args):
"""
optparse doesn't manage stuff like this:
--pythonpath /my/modules/*
but it can manages
--pythonpath=/my/modules/*/
(but without handling globing)
This method handles correctly the one without "=" and manages globing
... | [
"def",
"parse_python_paths",
"(",
"self",
",",
"args",
")",
":",
"paths",
"=",
"[",
"]",
"do_paths",
"=",
"False",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"==",
"'--pythonpath'",
":",
"# space separated",
"do_paths",
"=",
"True",
"continue",
"elif",
... | optparse doesn't manage stuff like this:
--pythonpath /my/modules/*
but it can manages
--pythonpath=/my/modules/*/
(but without handling globing)
This method handles correctly the one without "=" and manages globing | [
"optparse",
"doesn",
"t",
"manage",
"stuff",
"like",
"this",
":",
"--",
"pythonpath",
"/",
"my",
"/",
"modules",
"/",
"*",
"but",
"it",
"can",
"manages",
"--",
"pythonpath",
"=",
"/",
"my",
"/",
"modules",
"/",
"*",
"/",
"(",
"but",
"without",
"handl... | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/scripts/worker.py#L71-L105 |
jmoiron/gaspar | gaspar/consumers.py | Consumer.start | def start(self):
"""Start the consumer. This starts a listen loop on a zmq.PULL socket,
calling ``self.handle`` on each incoming request and pushing the response
on a zmq.PUSH socket back to the producer."""
if not self.initialized:
raise Exception("Consumer not initialized ... | python | def start(self):
"""Start the consumer. This starts a listen loop on a zmq.PULL socket,
calling ``self.handle`` on each incoming request and pushing the response
on a zmq.PUSH socket back to the producer."""
if not self.initialized:
raise Exception("Consumer not initialized ... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"initialized",
":",
"raise",
"Exception",
"(",
"\"Consumer not initialized (no Producer).\"",
")",
"producer",
"=",
"self",
".",
"producer",
"context",
"=",
"zmq",
".",
"_Context",
"(",
")",
"s... | Start the consumer. This starts a listen loop on a zmq.PULL socket,
calling ``self.handle`` on each incoming request and pushing the response
on a zmq.PUSH socket back to the producer. | [
"Start",
"the",
"consumer",
".",
"This",
"starts",
"a",
"listen",
"loop",
"on",
"a",
"zmq",
".",
"PULL",
"socket",
"calling",
"self",
".",
"handle",
"on",
"each",
"incoming",
"request",
"and",
"pushing",
"the",
"response",
"on",
"a",
"zmq",
".",
"PUSH",
... | train | https://github.com/jmoiron/gaspar/blob/cc9d7403a4d86382b10a7e96c6d0a020cc5e1b12/gaspar/consumers.py#L29-L42 |
jmoiron/gaspar | gaspar/consumers.py | Consumer.listen | def listen(self):
"""Listen forever on the zmq.PULL socket."""
while True:
message = self.pull.recv()
logger.debug("received message of length %d" % len(message))
uuid, message = message[:32], message[32:]
response = uuid + self.handle(message)
... | python | def listen(self):
"""Listen forever on the zmq.PULL socket."""
while True:
message = self.pull.recv()
logger.debug("received message of length %d" % len(message))
uuid, message = message[:32], message[32:]
response = uuid + self.handle(message)
... | [
"def",
"listen",
"(",
"self",
")",
":",
"while",
"True",
":",
"message",
"=",
"self",
".",
"pull",
".",
"recv",
"(",
")",
"logger",
".",
"debug",
"(",
"\"received message of length %d\"",
"%",
"len",
"(",
"message",
")",
")",
"uuid",
",",
"message",
"=... | Listen forever on the zmq.PULL socket. | [
"Listen",
"forever",
"on",
"the",
"zmq",
".",
"PULL",
"socket",
"."
] | train | https://github.com/jmoiron/gaspar/blob/cc9d7403a4d86382b10a7e96c6d0a020cc5e1b12/gaspar/consumers.py#L44-L51 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | get_strategy_types | def get_strategy_types():
"""Get a list of all :class:`Strategy` subclasses."""
def get_subtypes(type_):
subtypes = type_.__subclasses__()
for subtype in subtypes:
subtypes.extend(get_subtypes(subtype))
return subtypes
return get_subtypes(Strategy) | python | def get_strategy_types():
"""Get a list of all :class:`Strategy` subclasses."""
def get_subtypes(type_):
subtypes = type_.__subclasses__()
for subtype in subtypes:
subtypes.extend(get_subtypes(subtype))
return subtypes
return get_subtypes(Strategy) | [
"def",
"get_strategy_types",
"(",
")",
":",
"def",
"get_subtypes",
"(",
"type_",
")",
":",
"subtypes",
"=",
"type_",
".",
"__subclasses__",
"(",
")",
"for",
"subtype",
"in",
"subtypes",
":",
"subtypes",
".",
"extend",
"(",
"get_subtypes",
"(",
"subtype",
"... | Get a list of all :class:`Strategy` subclasses. | [
"Get",
"a",
"list",
"of",
"all",
":",
"class",
":",
"Strategy",
"subclasses",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L209-L216 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | get_file_type_map | def get_file_type_map():
"""Map file types (extensions) to strategy types."""
file_type_map = {}
for strategy_type in get_strategy_types():
for ext in strategy_type.file_types:
if ext in file_type_map:
raise KeyError(
'File type {ext} already registere... | python | def get_file_type_map():
"""Map file types (extensions) to strategy types."""
file_type_map = {}
for strategy_type in get_strategy_types():
for ext in strategy_type.file_types:
if ext in file_type_map:
raise KeyError(
'File type {ext} already registere... | [
"def",
"get_file_type_map",
"(",
")",
":",
"file_type_map",
"=",
"{",
"}",
"for",
"strategy_type",
"in",
"get_strategy_types",
"(",
")",
":",
"for",
"ext",
"in",
"strategy_type",
".",
"file_types",
":",
"if",
"ext",
"in",
"file_type_map",
":",
"raise",
"KeyE... | Map file types (extensions) to strategy types. | [
"Map",
"file",
"types",
"(",
"extensions",
")",
"to",
"strategy",
"types",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L219-L229 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | guess_strategy_type | def guess_strategy_type(file_name_or_ext):
"""Guess strategy type to use for file by extension.
Args:
file_name_or_ext: Either a file name with an extension or just
an extension
Returns:
Strategy: Type corresponding to extension or None if there's no
corresponding s... | python | def guess_strategy_type(file_name_or_ext):
"""Guess strategy type to use for file by extension.
Args:
file_name_or_ext: Either a file name with an extension or just
an extension
Returns:
Strategy: Type corresponding to extension or None if there's no
corresponding s... | [
"def",
"guess_strategy_type",
"(",
"file_name_or_ext",
")",
":",
"if",
"'.'",
"not",
"in",
"file_name_or_ext",
":",
"ext",
"=",
"file_name_or_ext",
"else",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name_or_ext",
")",
"ext",... | Guess strategy type to use for file by extension.
Args:
file_name_or_ext: Either a file name with an extension or just
an extension
Returns:
Strategy: Type corresponding to extension or None if there's no
corresponding strategy type | [
"Guess",
"strategy",
"type",
"to",
"use",
"for",
"file",
"by",
"extension",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L232-L250 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | Strategy.parse_file_name_and_section | def parse_file_name_and_section(self, file_name, section=None, extender=None,
extender_section=None):
"""Parse file name and (maybe) section.
File names can be absolute paths, relative paths, or asset
specs::
/home/user/project/local.cfg
... | python | def parse_file_name_and_section(self, file_name, section=None, extender=None,
extender_section=None):
"""Parse file name and (maybe) section.
File names can be absolute paths, relative paths, or asset
specs::
/home/user/project/local.cfg
... | [
"def",
"parse_file_name_and_section",
"(",
"self",
",",
"file_name",
",",
"section",
"=",
"None",
",",
"extender",
"=",
"None",
",",
"extender_section",
"=",
"None",
")",
":",
"if",
"'#'",
"in",
"file_name",
":",
"file_name",
",",
"parsed_section",
"=",
"fil... | Parse file name and (maybe) section.
File names can be absolute paths, relative paths, or asset
specs::
/home/user/project/local.cfg
local.cfg
some.package:local.cfg
File names can also include a section::
some.package:local.cfg#dev
If... | [
"Parse",
"file",
"name",
"and",
"(",
"maybe",
")",
"section",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L37-L82 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | INIStrategy.read_file | def read_file(self, file_name, section=None):
"""Read settings from specified ``section`` of config file."""
file_name, section = self.parse_file_name_and_section(file_name, section)
if not os.path.isfile(file_name):
raise SettingsFileNotFoundError(file_name)
parser = self.ma... | python | def read_file(self, file_name, section=None):
"""Read settings from specified ``section`` of config file."""
file_name, section = self.parse_file_name_and_section(file_name, section)
if not os.path.isfile(file_name):
raise SettingsFileNotFoundError(file_name)
parser = self.ma... | [
"def",
"read_file",
"(",
"self",
",",
"file_name",
",",
"section",
"=",
"None",
")",
":",
"file_name",
",",
"section",
"=",
"self",
".",
"parse_file_name_and_section",
"(",
"file_name",
",",
"section",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
... | Read settings from specified ``section`` of config file. | [
"Read",
"settings",
"from",
"specified",
"section",
"of",
"config",
"file",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L122-L152 |
PSU-OIT-ARC/django-local-settings | local_settings/strategy.py | INIStrategy.get_default_section | def get_default_section(self, file_name):
"""Returns first non-DEFAULT section; falls back to DEFAULT."""
if not os.path.isfile(file_name):
return 'DEFAULT'
parser = self.make_parser()
with open(file_name) as fp:
parser.read_file(fp)
sections = parser.sect... | python | def get_default_section(self, file_name):
"""Returns first non-DEFAULT section; falls back to DEFAULT."""
if not os.path.isfile(file_name):
return 'DEFAULT'
parser = self.make_parser()
with open(file_name) as fp:
parser.read_file(fp)
sections = parser.sect... | [
"def",
"get_default_section",
"(",
"self",
",",
"file_name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"return",
"'DEFAULT'",
"parser",
"=",
"self",
".",
"make_parser",
"(",
")",
"with",
"open",
"(",
"file_name"... | Returns first non-DEFAULT section; falls back to DEFAULT. | [
"Returns",
"first",
"non",
"-",
"DEFAULT",
"section",
";",
"falls",
"back",
"to",
"DEFAULT",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/strategy.py#L176-L185 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient._validate_install | def _validate_install(self):
''' a method to validate heroku is installed '''
self.printer('Checking heroku installation ... ', flush=True)
# import dependencies
from os import devnull
from subprocess import call, check_output
# validate cli installation... | python | def _validate_install(self):
''' a method to validate heroku is installed '''
self.printer('Checking heroku installation ... ', flush=True)
# import dependencies
from os import devnull
from subprocess import call, check_output
# validate cli installation... | [
"def",
"_validate_install",
"(",
"self",
")",
":",
"self",
".",
"printer",
"(",
"'Checking heroku installation ... '",
",",
"flush",
"=",
"True",
")",
"# import dependencies\r",
"from",
"os",
"import",
"devnull",
"from",
"subprocess",
"import",
"call",
",",
"check... | a method to validate heroku is installed | [
"a",
"method",
"to",
"validate",
"heroku",
"is",
"installed"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L65-L86 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient._update_netrc | def _update_netrc(self, netrc_path, auth_token, account_email):
''' a method to replace heroku login details in netrc file '''
# define patterns
import re
record_end = '(\n\n|\n\w|$)'
heroku_regex = re.compile('(machine\sapi\.heroku\.com.*?\nmachine\sgit\.heroku\... | python | def _update_netrc(self, netrc_path, auth_token, account_email):
''' a method to replace heroku login details in netrc file '''
# define patterns
import re
record_end = '(\n\n|\n\w|$)'
heroku_regex = re.compile('(machine\sapi\.heroku\.com.*?\nmachine\sgit\.heroku\... | [
"def",
"_update_netrc",
"(",
"self",
",",
"netrc_path",
",",
"auth_token",
",",
"account_email",
")",
":",
"# define patterns\r",
"import",
"re",
"record_end",
"=",
"'(\\n\\n|\\n\\w|$)'",
"heroku_regex",
"=",
"re",
".",
"compile",
"(",
"'(machine\\sapi\\.heroku\\.com.... | a method to replace heroku login details in netrc file | [
"a",
"method",
"to",
"replace",
"heroku",
"login",
"details",
"in",
"netrc",
"file"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L88-L117 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient._validate_login | def _validate_login(self):
''' a method to validate user can access heroku account '''
title = '%s.validate_login' % self.__class__.__name__
# verbosity
windows_insert = ' On windows, run in cmd.exe'
self.printer('Checking heroku credentials ...... | python | def _validate_login(self):
''' a method to validate user can access heroku account '''
title = '%s.validate_login' % self.__class__.__name__
# verbosity
windows_insert = ' On windows, run in cmd.exe'
self.printer('Checking heroku credentials ...... | [
"def",
"_validate_login",
"(",
"self",
")",
":",
"title",
"=",
"'%s.validate_login'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# verbosity\r",
"windows_insert",
"=",
"' On windows, run in cmd.exe'",
"self",
".",
"printer",
"(",
"'Checking heroku credentials ... ... | a method to validate user can access heroku account | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"heroku",
"account"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L119-L185 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient.access | def access(self, app_subdomain):
''' a method to validate user can access app '''
title = '%s.access' % self.__class__.__name__
# validate input
input_fields = {
'app_subdomain': app_subdomain
}
for key, value in input_fields.items():
... | python | def access(self, app_subdomain):
''' a method to validate user can access app '''
title = '%s.access' % self.__class__.__name__
# validate input
input_fields = {
'app_subdomain': app_subdomain
}
for key, value in input_fields.items():
... | [
"def",
"access",
"(",
"self",
",",
"app_subdomain",
")",
":",
"title",
"=",
"'%s.access'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate input\r",
"input_fields",
"=",
"{",
"'app_subdomain'",
":",
"app_subdomain",
"}",
"for",
"key",
",",
"value",... | a method to validate user can access app | [
"a",
"method",
"to",
"validate",
"user",
"can",
"access",
"app"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L187-L237 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient.deploy_docker | def deploy_docker(self, dockerfile_path, virtualbox_name='default'):
''' a method to deploy app to heroku using docker '''
title = '%s.deploy_docker' % self.__class__.__name__
# validate inputs
input_fields = {
'dockerfile_path': dockerfile_path,
'virtualb... | python | def deploy_docker(self, dockerfile_path, virtualbox_name='default'):
''' a method to deploy app to heroku using docker '''
title = '%s.deploy_docker' % self.__class__.__name__
# validate inputs
input_fields = {
'dockerfile_path': dockerfile_path,
'virtualb... | [
"def",
"deploy_docker",
"(",
"self",
",",
"dockerfile_path",
",",
"virtualbox_name",
"=",
"'default'",
")",
":",
"title",
"=",
"'%s.deploy_docker'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'dockerfile_path'",... | a method to deploy app to heroku using docker | [
"a",
"method",
"to",
"deploy",
"app",
"to",
"heroku",
"using",
"docker"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L239-L319 |
collectiveacuity/labPack | labpack/platforms/heroku.py | herokuClient.deploy_app | def deploy_app(self, site_folder, runtime_type=''):
''' a method to deploy a static html page to heroku using php '''
title = '%s.deploy_php' % self.__class__.__name__
# validate inputs
input_fields = {
'site_folder': site_folder,
'runtime_type': runtime_t... | python | def deploy_app(self, site_folder, runtime_type=''):
''' a method to deploy a static html page to heroku using php '''
title = '%s.deploy_php' % self.__class__.__name__
# validate inputs
input_fields = {
'site_folder': site_folder,
'runtime_type': runtime_t... | [
"def",
"deploy_app",
"(",
"self",
",",
"site_folder",
",",
"runtime_type",
"=",
"''",
")",
":",
"title",
"=",
"'%s.deploy_php'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'site_folder'",
":",
"site_folder",... | a method to deploy a static html page to heroku using php | [
"a",
"method",
"to",
"deploy",
"a",
"static",
"html",
"page",
"to",
"heroku",
"using",
"php"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/heroku.py#L321-L440 |
quasipedia/swaggery | swaggery/appinit.py | init | def init():
'''Initialise a WSGI application to be loaded by uWSGI.'''
# Load values from config file
config_file = os.path.realpath(os.path.join(os.getcwd(), 'swaggery.ini'))
config = configparser.RawConfigParser(allow_no_value=True)
config.read(config_file)
log_level = config.get('application'... | python | def init():
'''Initialise a WSGI application to be loaded by uWSGI.'''
# Load values from config file
config_file = os.path.realpath(os.path.join(os.getcwd(), 'swaggery.ini'))
config = configparser.RawConfigParser(allow_no_value=True)
config.read(config_file)
log_level = config.get('application'... | [
"def",
"init",
"(",
")",
":",
"# Load values from config file",
"config_file",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'swaggery.ini'",
")",
")",
"config",
"=",
"configparser... | Initialise a WSGI application to be loaded by uWSGI. | [
"Initialise",
"a",
"WSGI",
"application",
"to",
"be",
"loaded",
"by",
"uWSGI",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/appinit.py#L10-L26 |
ravenac95/lxc4u | lxc4u/service.py | LXCService.list_names | def list_names(cls):
"""Lists all known LXC names"""
response = subwrap.run(['lxc-ls'])
output = response.std_out
return map(str.strip, output.splitlines()) | python | def list_names(cls):
"""Lists all known LXC names"""
response = subwrap.run(['lxc-ls'])
output = response.std_out
return map(str.strip, output.splitlines()) | [
"def",
"list_names",
"(",
"cls",
")",
":",
"response",
"=",
"subwrap",
".",
"run",
"(",
"[",
"'lxc-ls'",
"]",
")",
"output",
"=",
"response",
".",
"std_out",
"return",
"map",
"(",
"str",
".",
"strip",
",",
"output",
".",
"splitlines",
"(",
")",
")"
] | Lists all known LXC names | [
"Lists",
"all",
"known",
"LXC",
"names"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L18-L22 |
ravenac95/lxc4u | lxc4u/service.py | LXCService.lxc_path | def lxc_path(cls, *join_paths):
"""Returns the LXC path (default on ubuntu is /var/lib/lxc)"""
response = subwrap.run(['lxc-ls', '-d'])
output = response.std_out
lxc_path = output.splitlines()[0]
lxc_path = lxc_path.strip()
return os.path.join(lxc_path, *join_paths) | python | def lxc_path(cls, *join_paths):
"""Returns the LXC path (default on ubuntu is /var/lib/lxc)"""
response = subwrap.run(['lxc-ls', '-d'])
output = response.std_out
lxc_path = output.splitlines()[0]
lxc_path = lxc_path.strip()
return os.path.join(lxc_path, *join_paths) | [
"def",
"lxc_path",
"(",
"cls",
",",
"*",
"join_paths",
")",
":",
"response",
"=",
"subwrap",
".",
"run",
"(",
"[",
"'lxc-ls'",
",",
"'-d'",
"]",
")",
"output",
"=",
"response",
".",
"std_out",
"lxc_path",
"=",
"output",
".",
"splitlines",
"(",
")",
"... | Returns the LXC path (default on ubuntu is /var/lib/lxc) | [
"Returns",
"the",
"LXC",
"path",
"(",
"default",
"on",
"ubuntu",
"is",
"/",
"var",
"/",
"lib",
"/",
"lxc",
")"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L25-L31 |
ravenac95/lxc4u | lxc4u/service.py | LXCService.create | def create(cls, name, template=None):
"""Creates an LXC"""
command = ['lxc-create', '-n', name]
if template:
command.extend(['-t', template])
subwrap.run(command) | python | def create(cls, name, template=None):
"""Creates an LXC"""
command = ['lxc-create', '-n', name]
if template:
command.extend(['-t', template])
subwrap.run(command) | [
"def",
"create",
"(",
"cls",
",",
"name",
",",
"template",
"=",
"None",
")",
":",
"command",
"=",
"[",
"'lxc-create'",
",",
"'-n'",
",",
"name",
"]",
"if",
"template",
":",
"command",
".",
"extend",
"(",
"[",
"'-t'",
",",
"template",
"]",
")",
"sub... | Creates an LXC | [
"Creates",
"an",
"LXC"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L34-L39 |
ravenac95/lxc4u | lxc4u/service.py | LXCService.info | def info(cls, name, get_state=True, get_pid=True):
"""Retrieves and parses info about an LXC"""
# Run lxc-info quietly
command = ['lxc-info', '-n', name]
response = subwrap.run(command)
lines = map(split_info_line, response.std_out.splitlines())
return dict(lines) | python | def info(cls, name, get_state=True, get_pid=True):
"""Retrieves and parses info about an LXC"""
# Run lxc-info quietly
command = ['lxc-info', '-n', name]
response = subwrap.run(command)
lines = map(split_info_line, response.std_out.splitlines())
return dict(lines) | [
"def",
"info",
"(",
"cls",
",",
"name",
",",
"get_state",
"=",
"True",
",",
"get_pid",
"=",
"True",
")",
":",
"# Run lxc-info quietly",
"command",
"=",
"[",
"'lxc-info'",
",",
"'-n'",
",",
"name",
"]",
"response",
"=",
"subwrap",
".",
"run",
"(",
"comm... | Retrieves and parses info about an LXC | [
"Retrieves",
"and",
"parses",
"info",
"about",
"an",
"LXC"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/service.py#L62-L68 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | WriteServiceModule.getClientModuleName | def getClientModuleName(self):
"""client module name.
"""
name = GetModuleBaseNameFromWSDL(self._wsdl)
if not name:
raise WsdlGeneratorError, 'could not determine a service name'
if self.client_module_suffix is None:
return name
return '%... | python | def getClientModuleName(self):
"""client module name.
"""
name = GetModuleBaseNameFromWSDL(self._wsdl)
if not name:
raise WsdlGeneratorError, 'could not determine a service name'
if self.client_module_suffix is None:
return name
return '%... | [
"def",
"getClientModuleName",
"(",
"self",
")",
":",
"name",
"=",
"GetModuleBaseNameFromWSDL",
"(",
"self",
".",
"_wsdl",
")",
"if",
"not",
"name",
":",
"raise",
"WsdlGeneratorError",
",",
"'could not determine a service name'",
"if",
"self",
".",
"client_module_suf... | client module name. | [
"client",
"module",
"name",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L74-L84 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | WriteServiceModule.getTypesModuleName | def getTypesModuleName(self):
"""types module name.
"""
if self.types_module_name is not None:
return self.types_module_name
name = GetModuleBaseNameFromWSDL(self._wsdl)
if not name:
raise WsdlGeneratorError, 'could not determine a service name'
... | python | def getTypesModuleName(self):
"""types module name.
"""
if self.types_module_name is not None:
return self.types_module_name
name = GetModuleBaseNameFromWSDL(self._wsdl)
if not name:
raise WsdlGeneratorError, 'could not determine a service name'
... | [
"def",
"getTypesModuleName",
"(",
"self",
")",
":",
"if",
"self",
".",
"types_module_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"types_module_name",
"name",
"=",
"GetModuleBaseNameFromWSDL",
"(",
"self",
".",
"_wsdl",
")",
"if",
"not",
"name",
"... | types module name. | [
"types",
"module",
"name",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L102-L115 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | WriteServiceModule.gatherNamespaces | def gatherNamespaces(self):
'''This method must execute once.. Grab all schemas
representing each targetNamespace.
'''
if self.usedNamespaces is not None:
return
self.logger.debug('gatherNamespaces')
self.usedNamespaces = {}
# Add all sc... | python | def gatherNamespaces(self):
'''This method must execute once.. Grab all schemas
representing each targetNamespace.
'''
if self.usedNamespaces is not None:
return
self.logger.debug('gatherNamespaces')
self.usedNamespaces = {}
# Add all sc... | [
"def",
"gatherNamespaces",
"(",
"self",
")",
":",
"if",
"self",
".",
"usedNamespaces",
"is",
"not",
"None",
":",
"return",
"self",
".",
"logger",
".",
"debug",
"(",
"'gatherNamespaces'",
")",
"self",
".",
"usedNamespaces",
"=",
"{",
"}",
"# Add all schemas d... | This method must execute once.. Grab all schemas
representing each targetNamespace. | [
"This",
"method",
"must",
"execute",
"once",
"..",
"Grab",
"all",
"schemas",
"representing",
"each",
"targetNamespace",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L146-L175 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | WriteServiceModule.writeClient | def writeClient(self, fd, sdClass=None, **kw):
"""write out client module to file descriptor.
Parameters and Keywords arguments:
fd -- file descriptor
sdClass -- service description class name
imports -- list of imports
readerclass -- class name of ParsedS... | python | def writeClient(self, fd, sdClass=None, **kw):
"""write out client module to file descriptor.
Parameters and Keywords arguments:
fd -- file descriptor
sdClass -- service description class name
imports -- list of imports
readerclass -- class name of ParsedS... | [
"def",
"writeClient",
"(",
"self",
",",
"fd",
",",
"sdClass",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"sdClass",
"=",
"sdClass",
"or",
"ServiceDescription",
"assert",
"issubclass",
"(",
"sdClass",
",",
"ServiceDescription",
")",
",",
"'parameter sdClass ... | write out client module to file descriptor.
Parameters and Keywords arguments:
fd -- file descriptor
sdClass -- service description class name
imports -- list of imports
readerclass -- class name of ParsedSoap reader
writerclass -- class name of SoapWr... | [
"write",
"out",
"client",
"module",
"to",
"file",
"descriptor",
".",
"Parameters",
"and",
"Keywords",
"arguments",
":",
"fd",
"--",
"file",
"descriptor",
"sdClass",
"--",
"service",
"description",
"class",
"name",
"imports",
"--",
"list",
"of",
"imports",
"rea... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L177-L213 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | WriteServiceModule.writeTypes | def writeTypes(self, fd):
"""write out types module to file descriptor.
"""
print >>fd, '#'*50
print >>fd, '# file: %s.py' %self.getTypesModuleName()
print >>fd, '#'
print >>fd, '# schema types generated by "%s"' %self.__class__
print >>fd, '# %s' %' '.join(sys... | python | def writeTypes(self, fd):
"""write out types module to file descriptor.
"""
print >>fd, '#'*50
print >>fd, '# file: %s.py' %self.getTypesModuleName()
print >>fd, '#'
print >>fd, '# schema types generated by "%s"' %self.__class__
print >>fd, '# %s' %' '.join(sys... | [
"def",
"writeTypes",
"(",
"self",
",",
"fd",
")",
":",
"print",
">>",
"fd",
",",
"'#'",
"*",
"50",
"print",
">>",
"fd",
",",
"'# file: %s.py'",
"%",
"self",
".",
"getTypesModuleName",
"(",
")",
"print",
">>",
"fd",
",",
"'#'",
"print",
">>",
"fd",
... | write out types module to file descriptor. | [
"write",
"out",
"types",
"module",
"to",
"file",
"descriptor",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L215-L233 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | ServiceDescription.setTypesModuleName | def setTypesModuleName(self, name, modulePath=None):
"""The types module to be imported.
Parameters
name -- name of types module
modulePath -- optional path where module is located.
"""
self.typesModuleName = '%s' %name
if modulePath is not None:
self.... | python | def setTypesModuleName(self, name, modulePath=None):
"""The types module to be imported.
Parameters
name -- name of types module
modulePath -- optional path where module is located.
"""
self.typesModuleName = '%s' %name
if modulePath is not None:
self.... | [
"def",
"setTypesModuleName",
"(",
"self",
",",
"name",
",",
"modulePath",
"=",
"None",
")",
":",
"self",
".",
"typesModuleName",
"=",
"'%s'",
"%",
"name",
"if",
"modulePath",
"is",
"not",
"None",
":",
"self",
".",
"typesModuleName",
"=",
"'%s.%s'",
"%",
... | The types module to be imported.
Parameters
name -- name of types module
modulePath -- optional path where module is located. | [
"The",
"types",
"module",
"to",
"be",
"imported",
".",
"Parameters",
"name",
"--",
"name",
"of",
"types",
"module",
"modulePath",
"--",
"optional",
"path",
"where",
"module",
"is",
"located",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L253-L261 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | ServiceDescription.write | def write(self, fd, msg_fd=None):
"""write out module to file descriptor.
fd -- file descriptor to write out service description.
msg_fd -- optional file descriptor for messages module.
"""
# if msg_fd != None:
# print >>fd, self.messagesImports
# print >>msg... | python | def write(self, fd, msg_fd=None):
"""write out module to file descriptor.
fd -- file descriptor to write out service description.
msg_fd -- optional file descriptor for messages module.
"""
# if msg_fd != None:
# print >>fd, self.messagesImports
# print >>msg... | [
"def",
"write",
"(",
"self",
",",
"fd",
",",
"msg_fd",
"=",
"None",
")",
":",
"# if msg_fd != None:",
"# print >>fd, self.messagesImports",
"# print >>msg_fd, self.imports",
"# else:",
"print",
">>",
"fd",
",",
"self",
".",
"imports",
... | write out module to file descriptor.
fd -- file descriptor to write out service description.
msg_fd -- optional file descriptor for messages module. | [
"write",
"out",
"module",
"to",
"file",
"descriptor",
".",
"fd",
"--",
"file",
"descriptor",
"to",
"write",
"out",
"service",
"description",
".",
"msg_fd",
"--",
"optional",
"file",
"descriptor",
"for",
"messages",
"module",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L320-L340 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | SchemaDescription.fromSchema | def fromSchema(self, schema):
''' Can be called multiple times, but will not redefine a
previously defined type definition or element declaration.
'''
ns = schema.getTargetNamespace()
assert self.targetNamespace is None or self.targetNamespace == ns,\
'SchemaDescrip... | python | def fromSchema(self, schema):
''' Can be called multiple times, but will not redefine a
previously defined type definition or element declaration.
'''
ns = schema.getTargetNamespace()
assert self.targetNamespace is None or self.targetNamespace == ns,\
'SchemaDescrip... | [
"def",
"fromSchema",
"(",
"self",
",",
"schema",
")",
":",
"ns",
"=",
"schema",
".",
"getTargetNamespace",
"(",
")",
"assert",
"self",
".",
"targetNamespace",
"is",
"None",
"or",
"self",
".",
"targetNamespace",
"==",
"ns",
",",
"'SchemaDescription instance rep... | Can be called multiple times, but will not redefine a
previously defined type definition or element declaration. | [
"Can",
"be",
"called",
"multiple",
"times",
"but",
"will",
"not",
"redefine",
"a",
"previously",
"defined",
"type",
"definition",
"or",
"element",
"declaration",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L401-L422 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | SchemaDescription.write | def write(self, fd):
"""write out to file descriptor.
"""
print >>fd, self.classHead
for t in self.items:
print >>fd, t
print >>fd, self.classFoot | python | def write(self, fd):
"""write out to file descriptor.
"""
print >>fd, self.classHead
for t in self.items:
print >>fd, t
print >>fd, self.classFoot | [
"def",
"write",
"(",
"self",
",",
"fd",
")",
":",
"print",
">>",
"fd",
",",
"self",
".",
"classHead",
"for",
"t",
"in",
"self",
".",
"items",
":",
"print",
">>",
"fd",
",",
"t",
"print",
">>",
"fd",
",",
"self",
".",
"classFoot"
] | write out to file descriptor. | [
"write",
"out",
"to",
"file",
"descriptor",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L430-L436 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/wsdl2python.py | ElementWriter.fromSchemaItem | def fromSchemaItem(self, item):
"""set up global elements.
"""
if item.isElement() is False or item.isLocal() is True:
raise TypeError, 'expecting global element declaration: %s' %item.getItemTrace()
local = False
qName = item.getAttribute('type')
if not qNam... | python | def fromSchemaItem(self, item):
"""set up global elements.
"""
if item.isElement() is False or item.isLocal() is True:
raise TypeError, 'expecting global element declaration: %s' %item.getItemTrace()
local = False
qName = item.getAttribute('type')
if not qNam... | [
"def",
"fromSchemaItem",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
".",
"isElement",
"(",
")",
"is",
"False",
"or",
"item",
".",
"isLocal",
"(",
")",
"is",
"True",
":",
"raise",
"TypeError",
",",
"'expecting global element declaration: %s'",
"%",
"... | set up global elements. | [
"set",
"up",
"global",
"elements",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/wsdl2python.py#L462-L493 |
yougov/yg.lockfile | yg/lockfile/__init__.py | LockBase.acquire | def acquire(self):
"""
Attempt to acquire the lock every `delay` seconds until the
lock is acquired or until `timeout` has expired.
Raises FileLockTimeout if the timeout is exceeded.
Errors opening the lock file (other than if it exists) are
passed through.
"""
... | python | def acquire(self):
"""
Attempt to acquire the lock every `delay` seconds until the
lock is acquired or until `timeout` has expired.
Raises FileLockTimeout if the timeout is exceeded.
Errors opening the lock file (other than if it exists) are
passed through.
"""
... | [
"def",
"acquire",
"(",
"self",
")",
":",
"self",
".",
"lock",
"=",
"retry_call",
"(",
"self",
".",
"_attempt",
",",
"retries",
"=",
"float",
"(",
"'inf'",
")",
",",
"trap",
"=",
"zc",
".",
"lockfile",
".",
"LockError",
",",
"cleanup",
"=",
"functools... | Attempt to acquire the lock every `delay` seconds until the
lock is acquired or until `timeout` has expired.
Raises FileLockTimeout if the timeout is exceeded.
Errors opening the lock file (other than if it exists) are
passed through. | [
"Attempt",
"to",
"acquire",
"the",
"lock",
"every",
"delay",
"seconds",
"until",
"the",
"lock",
"is",
"acquired",
"or",
"until",
"timeout",
"has",
"expired",
"."
] | train | https://github.com/yougov/yg.lockfile/blob/e6bf1e5e6a9aedc657b1fcf5601693da50744cfe/yg/lockfile/__init__.py#L67-L82 |
yougov/yg.lockfile | yg/lockfile/__init__.py | LockBase.release | def release(self):
"""
Release the lock and cleanup
"""
lock = vars(self).pop('lock', missing)
lock is not missing and self._release(lock) | python | def release(self):
"""
Release the lock and cleanup
"""
lock = vars(self).pop('lock', missing)
lock is not missing and self._release(lock) | [
"def",
"release",
"(",
"self",
")",
":",
"lock",
"=",
"vars",
"(",
"self",
")",
".",
"pop",
"(",
"'lock'",
",",
"missing",
")",
"lock",
"is",
"not",
"missing",
"and",
"self",
".",
"_release",
"(",
"lock",
")"
] | Release the lock and cleanup | [
"Release",
"the",
"lock",
"and",
"cleanup"
] | train | https://github.com/yougov/yg.lockfile/blob/e6bf1e5e6a9aedc657b1fcf5601693da50744cfe/yg/lockfile/__init__.py#L84-L89 |
praekelt/panya | panya/generic/views.py | GenericBase._resolve_view_params | def _resolve_view_params(self, request, defaults, *args, **kwargs):
"""
Resolves view params with least ammount of resistance.
Firstly check for params on urls passed args, then on class init args or members,
and lastly on class get methods .
"""
params = copy.copy(defau... | python | def _resolve_view_params(self, request, defaults, *args, **kwargs):
"""
Resolves view params with least ammount of resistance.
Firstly check for params on urls passed args, then on class init args or members,
and lastly on class get methods .
"""
params = copy.copy(defau... | [
"def",
"_resolve_view_params",
"(",
"self",
",",
"request",
",",
"defaults",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"copy",
".",
"copy",
"(",
"defaults",
")",
"params",
".",
"update",
"(",
"self",
".",
"params",
")",
"par... | Resolves view params with least ammount of resistance.
Firstly check for params on urls passed args, then on class init args or members,
and lastly on class get methods . | [
"Resolves",
"view",
"params",
"with",
"least",
"ammount",
"of",
"resistance",
".",
"Firstly",
"check",
"for",
"params",
"on",
"urls",
"passed",
"args",
"then",
"on",
"class",
"init",
"args",
"or",
"members",
"and",
"lastly",
"on",
"class",
"get",
"methods",
... | train | https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/generic/views.py#L50-L85 |
praekelt/panya | panya/generic/views.py | GenericForm.handle_valid | def handle_valid(self, form=None, *args, **kwargs):
"""
Called after the form has validated.
"""
# Take a chance and try save a subclass of a ModelForm.
if hasattr(form, 'save'):
form.save()
# Also try and call handle_valid method of the form itself.
i... | python | def handle_valid(self, form=None, *args, **kwargs):
"""
Called after the form has validated.
"""
# Take a chance and try save a subclass of a ModelForm.
if hasattr(form, 'save'):
form.save()
# Also try and call handle_valid method of the form itself.
i... | [
"def",
"handle_valid",
"(",
"self",
",",
"form",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Take a chance and try save a subclass of a ModelForm.",
"if",
"hasattr",
"(",
"form",
",",
"'save'",
")",
":",
"form",
".",
"save",
"(",
"... | Called after the form has validated. | [
"Called",
"after",
"the",
"form",
"has",
"validated",
"."
] | train | https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/generic/views.py#L172-L181 |
lwcook/horsetail-matching | horsetailmatching/weightedsum.py | WeightedSum.evalMetric | def evalMetric(self, x, w1=None, w2=None):
'''Evaluates the weighted sum metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param float w1: value to weight the mean by... | python | def evalMetric(self, x, w1=None, w2=None):
'''Evaluates the weighted sum metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param float w1: value to weight the mean by... | [
"def",
"evalMetric",
"(",
"self",
",",
"x",
",",
"w1",
"=",
"None",
",",
"w2",
"=",
"None",
")",
":",
"if",
"w1",
"is",
"None",
":",
"w1",
"=",
"self",
".",
"w1",
"if",
"w2",
"is",
"None",
":",
"w2",
"=",
"self",
".",
"w2",
"if",
"self",
".... | Evaluates the weighted sum metric at given values of the
design variables.
:param iterable x: values of the design variables, this is passed as
the first argument to the function fqoi
:param float w1: value to weight the mean by
:param float w2: value to weight the std by
... | [
"Evaluates",
"the",
"weighted",
"sum",
"metric",
"at",
"given",
"values",
"of",
"the",
"design",
"variables",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/weightedsum.py#L96-L143 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_indicator | def add_indicator(self,
value,
itype,
source='',
reference='',
method='',
campaign=None,
confidence=None,
bucket_list=[],
... | python | def add_indicator(self,
value,
itype,
source='',
reference='',
method='',
campaign=None,
confidence=None,
bucket_list=[],
... | [
"def",
"add_indicator",
"(",
"self",
",",
"value",
",",
"itype",
",",
"source",
"=",
"''",
",",
"reference",
"=",
"''",
",",
"method",
"=",
"''",
",",
"campaign",
"=",
"None",
",",
"confidence",
"=",
"None",
",",
"bucket_list",
"=",
"[",
"]",
",",
... | Add an indicator to CRITs
Args:
value: The indicator itself
itype: The overall indicator type. See your CRITs vocabulary
source: Source of the information
reference: A reference where more information can be found
method: The method for adding this in... | [
"Add",
"an",
"indicator",
"to",
"CRITs"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L43-L115 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_event | def add_event(self,
source,
reference,
event_title,
event_type,
method='',
description='',
bucket_list=[],
campaign='',
confidence='',
date=... | python | def add_event(self,
source,
reference,
event_title,
event_type,
method='',
description='',
bucket_list=[],
campaign='',
confidence='',
date=... | [
"def",
"add_event",
"(",
"self",
",",
"source",
",",
"reference",
",",
"event_title",
",",
"event_type",
",",
"method",
"=",
"''",
",",
"description",
"=",
"''",
",",
"bucket_list",
"=",
"[",
"]",
",",
"campaign",
"=",
"''",
",",
"confidence",
"=",
"''... | Adds an event. If the event name already exists, it will return that
event instead.
Args:
source: Source of the information
reference: A reference where more information can be found
event_title: The title of the event
event_type: The type of event. See y... | [
"Adds",
"an",
"event",
".",
"If",
"the",
"event",
"name",
"already",
"exists",
"it",
"will",
"return",
"that",
"event",
"instead",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L117-L183 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_sample_file | def add_sample_file(self,
sample_path,
source,
reference,
method='',
file_format='raw',
file_password='',
sample_name='',
campai... | python | def add_sample_file(self,
sample_path,
source,
reference,
method='',
file_format='raw',
file_password='',
sample_name='',
campai... | [
"def",
"add_sample_file",
"(",
"self",
",",
"sample_path",
",",
"source",
",",
"reference",
",",
"method",
"=",
"''",
",",
"file_format",
"=",
"'raw'",
",",
"file_password",
"=",
"''",
",",
"sample_name",
"=",
"''",
",",
"campaign",
"=",
"''",
",",
"conf... | Adds a file sample. For meta data only use add_sample_meta.
Args:
sample_path: The path on disk of the sample to upload
source: Source of the information
reference: A reference where more information can be found
method: The method for obtaining the sample.
... | [
"Adds",
"a",
"file",
"sample",
".",
"For",
"meta",
"data",
"only",
"use",
"add_sample_meta",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L185-L246 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_sample_meta | def add_sample_meta(self,
source,
reference,
method='',
filename='',
md5='',
sha1='',
sha256='',
size='',
... | python | def add_sample_meta(self,
source,
reference,
method='',
filename='',
md5='',
sha1='',
sha256='',
size='',
... | [
"def",
"add_sample_meta",
"(",
"self",
",",
"source",
",",
"reference",
",",
"method",
"=",
"''",
",",
"filename",
"=",
"''",
",",
"md5",
"=",
"''",
",",
"sha1",
"=",
"''",
",",
"sha256",
"=",
"''",
",",
"size",
"=",
"''",
",",
"mimetype",
"=",
"... | Adds a metadata sample. To add an actual file, use add_sample_file.
Args:
source: Source of the information
reference: A reference where more information can be found
method: The method for obtaining the sample.
filename: The name of the file.
md5: An... | [
"Adds",
"a",
"metadata",
"sample",
".",
"To",
"add",
"an",
"actual",
"file",
"use",
"add_sample_file",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L248-L309 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_email | def add_email(self,
email_path,
source,
reference,
method='',
upload_type='raw',
campaign='',
confidence='',
description='',
bucket_list=[],
... | python | def add_email(self,
email_path,
source,
reference,
method='',
upload_type='raw',
campaign='',
confidence='',
description='',
bucket_list=[],
... | [
"def",
"add_email",
"(",
"self",
",",
"email_path",
",",
"source",
",",
"reference",
",",
"method",
"=",
"''",
",",
"upload_type",
"=",
"'raw'",
",",
"campaign",
"=",
"''",
",",
"confidence",
"=",
"''",
",",
"description",
"=",
"''",
",",
"bucket_list",
... | Add an email object to CRITs. Only RAW, MSG, and EML are supported
currently.
Args:
email_path: The path on disk of the email.
source: Source of the information
reference: A reference where more information can be found
method: The method for obtaining th... | [
"Add",
"an",
"email",
"object",
"to",
"CRITs",
".",
"Only",
"RAW",
"MSG",
"and",
"EML",
"are",
"supported",
"currently",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L311-L369 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_backdoor | def add_backdoor(self,
backdoor_name,
source,
reference,
method='',
aliases=[],
version='',
campaign='',
confidence='',
description... | python | def add_backdoor(self,
backdoor_name,
source,
reference,
method='',
aliases=[],
version='',
campaign='',
confidence='',
description... | [
"def",
"add_backdoor",
"(",
"self",
",",
"backdoor_name",
",",
"source",
",",
"reference",
",",
"method",
"=",
"''",
",",
"aliases",
"=",
"[",
"]",
",",
"version",
"=",
"''",
",",
"campaign",
"=",
"''",
",",
"confidence",
"=",
"''",
",",
"description",... | Add a backdoor object to CRITs.
Args:
backdoor_name: The primary name of the backdoor
source: Source of the information
reference: A reference where more information can be found
method: The method for obtaining the backdoor information.
aliases: List... | [
"Add",
"a",
"backdoor",
"object",
"to",
"CRITs",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L371-L421 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.add_profile_point | def add_profile_point(self,
value,
source='',
reference='',
method='',
ticket='',
campaign=None,
confidence=None,
... | python | def add_profile_point(self,
value,
source='',
reference='',
method='',
ticket='',
campaign=None,
confidence=None,
... | [
"def",
"add_profile_point",
"(",
"self",
",",
"value",
",",
"source",
"=",
"''",
",",
"reference",
"=",
"''",
",",
"method",
"=",
"''",
",",
"ticket",
"=",
"''",
",",
"campaign",
"=",
"None",
",",
"confidence",
"=",
"None",
",",
"bucket_list",
"=",
"... | Add an indicator to CRITs
Args:
value: The profile point itself
source: Source of the information
reference: A reference where more information can be found
method: The method for adding this indicator
campaign: If the indicator has a campaign, add it... | [
"Add",
"an",
"indicator",
"to",
"CRITs"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L423-L469 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.get_events | def get_events(self, event_title, regex=False):
"""
Search for events with the provided title
Args:
event_title: The title of the event
Returns:
An event JSON object returned from the server with the following:
{
"meta":{
... | python | def get_events(self, event_title, regex=False):
"""
Search for events with the provided title
Args:
event_title: The title of the event
Returns:
An event JSON object returned from the server with the following:
{
"meta":{
... | [
"def",
"get_events",
"(",
"self",
",",
"event_title",
",",
"regex",
"=",
"False",
")",
":",
"regex_val",
"=",
"0",
"if",
"regex",
":",
"regex_val",
"=",
"1",
"r",
"=",
"requests",
".",
"get",
"(",
"'{0}/events/?api_key={1}&username={2}&c-title='",
"'{3}®ex=... | Search for events with the provided title
Args:
event_title: The title of the event
Returns:
An event JSON object returned from the server with the following:
{
"meta":{
"limit": 20, "next": null, "offset": 0,
... | [
"Search",
"for",
"events",
"with",
"the",
"provided",
"title"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L471-L501 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.get_samples | def get_samples(self, md5='', sha1='', sha256=''):
"""
Searches for a sample in CRITs. Currently only hashes allowed.
Args:
md5: md5sum
sha1: sha1sum
sha256: sha256sum
Returns:
JSON response or None if not found
"""
params ... | python | def get_samples(self, md5='', sha1='', sha256=''):
"""
Searches for a sample in CRITs. Currently only hashes allowed.
Args:
md5: md5sum
sha1: sha1sum
sha256: sha256sum
Returns:
JSON response or None if not found
"""
params ... | [
"def",
"get_samples",
"(",
"self",
",",
"md5",
"=",
"''",
",",
"sha1",
"=",
"''",
",",
"sha256",
"=",
"''",
")",
":",
"params",
"=",
"{",
"'api_key'",
":",
"self",
".",
"api_key",
",",
"'username'",
":",
"self",
".",
"username",
"}",
"if",
"md5",
... | Searches for a sample in CRITs. Currently only hashes allowed.
Args:
md5: md5sum
sha1: sha1sum
sha256: sha256sum
Returns:
JSON response or None if not found | [
"Searches",
"for",
"a",
"sample",
"in",
"CRITs",
".",
"Currently",
"only",
"hashes",
"allowed",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L503-L533 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.get_backdoor | def get_backdoor(self, name, version=''):
"""
Searches for the backdoor based on name and version.
Args:
name: The name of the backdoor. This can be an alias.
version: The version.
Returns:
Returns a JSON object contain one or more backdoor results or... | python | def get_backdoor(self, name, version=''):
"""
Searches for the backdoor based on name and version.
Args:
name: The name of the backdoor. This can be an alias.
version: The version.
Returns:
Returns a JSON object contain one or more backdoor results or... | [
"def",
"get_backdoor",
"(",
"self",
",",
"name",
",",
"version",
"=",
"''",
")",
":",
"params",
"=",
"{",
"}",
"params",
"[",
"'or'",
"]",
"=",
"1",
"params",
"[",
"'c-name'",
"]",
"=",
"name",
"params",
"[",
"'c-aliases__in'",
"]",
"=",
"name",
"r... | Searches for the backdoor based on name and version.
Args:
name: The name of the backdoor. This can be an alias.
version: The version.
Returns:
Returns a JSON object contain one or more backdoor results or
None if not found. | [
"Searches",
"for",
"the",
"backdoor",
"based",
"on",
"name",
"and",
"version",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L563-L598 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.has_relationship | def has_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To'):
"""
Checks if the two objects are related
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
... | python | def has_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To'):
"""
Checks if the two objects are related
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
... | [
"def",
"has_relationship",
"(",
"self",
",",
"left_id",
",",
"left_type",
",",
"right_id",
",",
"right_type",
",",
"rel_type",
"=",
"'Related To'",
")",
":",
"data",
"=",
"self",
".",
"get_object",
"(",
"left_id",
",",
"left_type",
")",
"if",
"not",
"data"... | Checks if the two objects are related
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_typ... | [
"Checks",
"if",
"the",
"two",
"objects",
"are",
"related"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L600-L629 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.forge_relationship | def forge_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To', rel_date=None,
rel_confidence='high', rel_reason=''):
"""
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the fi... | python | def forge_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To', rel_date=None,
rel_confidence='high', rel_reason=''):
"""
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the fi... | [
"def",
"forge_relationship",
"(",
"self",
",",
"left_id",
",",
"left_type",
",",
"right_id",
",",
"right_type",
",",
"rel_type",
"=",
"'Related To'",
",",
"rel_date",
"=",
"None",
",",
"rel_confidence",
"=",
"'high'",
",",
"rel_reason",
"=",
"''",
")",
":",
... | Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_t... | [
"Forges",
"a",
"relationship",
"between",
"two",
"TLOs",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L631-L680 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.status_update | def status_update(self, crits_id, crits_type, status):
"""
Update the status of the TLO. By default, the options are:
- New
- In Progress
- Analyzed
- Deprecated
Args:
crits_id: The object id of the TLO
crits_type: The type of TLO. This mu... | python | def status_update(self, crits_id, crits_type, status):
"""
Update the status of the TLO. By default, the options are:
- New
- In Progress
- Analyzed
- Deprecated
Args:
crits_id: The object id of the TLO
crits_type: The type of TLO. This mu... | [
"def",
"status_update",
"(",
"self",
",",
"crits_id",
",",
"crits_type",
",",
"status",
")",
":",
"obj_type",
"=",
"self",
".",
"_type_translation",
"(",
"crits_type",
")",
"patch_url",
"=",
"\"{0}/{1}/{2}/\"",
".",
"format",
"(",
"self",
".",
"url",
",",
... | Update the status of the TLO. By default, the options are:
- New
- In Progress
- Analyzed
- Deprecated
Args:
crits_id: The object id of the TLO
crits_type: The type of TLO. This must be 'Indicator', ''
status: The status to change.
Ret... | [
"Update",
"the",
"status",
"of",
"the",
"TLO",
".",
"By",
"default",
"the",
"options",
"are",
":",
"-",
"New",
"-",
"In",
"Progress",
"-",
"Analyzed",
"-",
"Deprecated"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L682-L721 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.source_add_update | def source_add_update(self, crits_id, crits_type, source,
action_type='add', method='', reference='',
date=None):
"""
date must be in the format "%Y-%m-%d %H:%M:%S.%f"
"""
type_trans = self._type_translation(crits_type)
submit_u... | python | def source_add_update(self, crits_id, crits_type, source,
action_type='add', method='', reference='',
date=None):
"""
date must be in the format "%Y-%m-%d %H:%M:%S.%f"
"""
type_trans = self._type_translation(crits_type)
submit_u... | [
"def",
"source_add_update",
"(",
"self",
",",
"crits_id",
",",
"crits_type",
",",
"source",
",",
"action_type",
"=",
"'add'",
",",
"method",
"=",
"''",
",",
"reference",
"=",
"''",
",",
"date",
"=",
"None",
")",
":",
"type_trans",
"=",
"self",
".",
"_t... | date must be in the format "%Y-%m-%d %H:%M:%S.%f" | [
"date",
"must",
"be",
"in",
"the",
"format",
"%Y",
"-",
"%m",
"-",
"%d",
"%H",
":",
"%M",
":",
"%S",
".",
"%f"
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L723-L761 |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI._type_translation | def _type_translation(self, str_type):
"""
Internal method to translate the named CRITs TLO type to a URL
specific string.
"""
if str_type == 'Indicator':
return 'indicators'
if str_type == 'Domain':
return 'domains'
if str_type == 'IP':
... | python | def _type_translation(self, str_type):
"""
Internal method to translate the named CRITs TLO type to a URL
specific string.
"""
if str_type == 'Indicator':
return 'indicators'
if str_type == 'Domain':
return 'domains'
if str_type == 'IP':
... | [
"def",
"_type_translation",
"(",
"self",
",",
"str_type",
")",
":",
"if",
"str_type",
"==",
"'Indicator'",
":",
"return",
"'indicators'",
"if",
"str_type",
"==",
"'Domain'",
":",
"return",
"'domains'",
"if",
"str_type",
"==",
"'IP'",
":",
"return",
"'ips'",
... | Internal method to translate the named CRITs TLO type to a URL
specific string. | [
"Internal",
"method",
"to",
"translate",
"the",
"named",
"CRITs",
"TLO",
"type",
"to",
"a",
"URL",
"specific",
"string",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L763-L786 |
radjkarl/fancyTools | DUMP/intersection.py | lineSeqmentsDoIntersect | def lineSeqmentsDoIntersect(line1, line2):
"""
Return True if line segment line1 intersects line segment line2 and
line1 and line2 are not parallel.
"""
(x1, y1), (x2, y2) = line1
(u1, v1), (u2, v2) = line2
(a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2)
e, f = u1 - x1, v... | python | def lineSeqmentsDoIntersect(line1, line2):
"""
Return True if line segment line1 intersects line segment line2 and
line1 and line2 are not parallel.
"""
(x1, y1), (x2, y2) = line1
(u1, v1), (u2, v2) = line2
(a, b), (c, d) = (x2 - x1, u1 - u2), (y2 - y1, v1 - v2)
e, f = u1 - x1, v... | [
"def",
"lineSeqmentsDoIntersect",
"(",
"line1",
",",
"line2",
")",
":",
"(",
"x1",
",",
"y1",
")",
",",
"(",
"x2",
",",
"y2",
")",
"=",
"line1",
"(",
"u1",
",",
"v1",
")",
",",
"(",
"u2",
",",
"v2",
")",
"=",
"line2",
"(",
"a",
",",
"b",
")... | Return True if line segment line1 intersects line segment line2 and
line1 and line2 are not parallel. | [
"Return",
"True",
"if",
"line",
"segment",
"line1",
"intersects",
"line",
"segment",
"line2",
"and",
"line1",
"and",
"line2",
"are",
"not",
"parallel",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/DUMP/intersection.py#L41-L59 |
fakedrake/overlay_parse | overlay_parse/matchers.py | mf | def mf(pred, props=None, value_fn=None, props_on_match=False, priority=None):
"""
Matcher factory.
"""
if isinstance(pred, BaseMatcher):
ret = pred if props_on_match else pred.props
if isinstance(pred, basestring) or \
type(pred).__name__ == 'SRE_Pattern':
ret = RegexMatcher... | python | def mf(pred, props=None, value_fn=None, props_on_match=False, priority=None):
"""
Matcher factory.
"""
if isinstance(pred, BaseMatcher):
ret = pred if props_on_match else pred.props
if isinstance(pred, basestring) or \
type(pred).__name__ == 'SRE_Pattern':
ret = RegexMatcher... | [
"def",
"mf",
"(",
"pred",
",",
"props",
"=",
"None",
",",
"value_fn",
"=",
"None",
",",
"props_on_match",
"=",
"False",
",",
"priority",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"pred",
",",
"BaseMatcher",
")",
":",
"ret",
"=",
"pred",
"if",
... | Matcher factory. | [
"Matcher",
"factory",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L255-L279 |
fakedrake/overlay_parse | overlay_parse/matchers.py | RegexMatcher.offset_overlays | def offset_overlays(self, text, offset=0, **kw):
"""
Generate overlays after offset.
:param text: The text to be searched.
:param offset: Match starting that index. If none just search.
:returns: An overlay or None
"""
# This may be a bit slower but overlayedtext... | python | def offset_overlays(self, text, offset=0, **kw):
"""
Generate overlays after offset.
:param text: The text to be searched.
:param offset: Match starting that index. If none just search.
:returns: An overlay or None
"""
# This may be a bit slower but overlayedtext... | [
"def",
"offset_overlays",
"(",
"self",
",",
"text",
",",
"offset",
"=",
"0",
",",
"*",
"*",
"kw",
")",
":",
"# This may be a bit slower but overlayedtext takes care of",
"# unicode issues.",
"if",
"not",
"isinstance",
"(",
"text",
",",
"OverlayedText",
")",
":",
... | Generate overlays after offset.
:param text: The text to be searched.
:param offset: Match starting that index. If none just search.
:returns: An overlay or None | [
"Generate",
"overlays",
"after",
"offset",
".",
":",
"param",
"text",
":",
"The",
"text",
"to",
"be",
"searched",
".",
":",
"param",
"offset",
":",
"Match",
"starting",
"that",
"index",
".",
"If",
"none",
"just",
"search",
".",
":",
"returns",
":",
"An... | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L50-L66 |
fakedrake/overlay_parse | overlay_parse/matchers.py | RegexMatcher.fit_overlays | def fit_overlays(self, text, start=None, end=None, **kw):
"""
Get an overlay thet fits the range [start, end).
"""
_text = text[start or 0:]
if end:
_text = _text[:end]
m = self.regex.match(unicode(_text))
if m:
yield Overlay(text, (star... | python | def fit_overlays(self, text, start=None, end=None, **kw):
"""
Get an overlay thet fits the range [start, end).
"""
_text = text[start or 0:]
if end:
_text = _text[:end]
m = self.regex.match(unicode(_text))
if m:
yield Overlay(text, (star... | [
"def",
"fit_overlays",
"(",
"self",
",",
"text",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"_text",
"=",
"text",
"[",
"start",
"or",
"0",
":",
"]",
"if",
"end",
":",
"_text",
"=",
"_text",
"[",
":",
"e... | Get an overlay thet fits the range [start, end). | [
"Get",
"an",
"overlay",
"thet",
"fits",
"the",
"range",
"[",
"start",
"end",
")",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L68-L82 |
fakedrake/overlay_parse | overlay_parse/matchers.py | OverlayMatcher.offset_overlays | def offset_overlays(self, text, offset=0, **kw):
"""
Get overlays for the text.
:param text: The text to be searched. This is an overlay
object.
:param offset: Match starting that index. If none just search.
:returns: A generator for overlays.
"""
for ovl... | python | def offset_overlays(self, text, offset=0, **kw):
"""
Get overlays for the text.
:param text: The text to be searched. This is an overlay
object.
:param offset: Match starting that index. If none just search.
:returns: A generator for overlays.
"""
for ovl... | [
"def",
"offset_overlays",
"(",
"self",
",",
"text",
",",
"offset",
"=",
"0",
",",
"*",
"*",
"kw",
")",
":",
"for",
"ovl",
"in",
"text",
".",
"overlays",
":",
"if",
"ovl",
".",
"match",
"(",
"offset",
"=",
"offset",
",",
"props",
"=",
"self",
".",... | Get overlays for the text.
:param text: The text to be searched. This is an overlay
object.
:param offset: Match starting that index. If none just search.
:returns: A generator for overlays. | [
"Get",
"overlays",
"for",
"the",
"text",
".",
":",
"param",
"text",
":",
"The",
"text",
"to",
"be",
"searched",
".",
"This",
"is",
"an",
"overlay",
"object",
".",
":",
"param",
"offset",
":",
"Match",
"starting",
"that",
"index",
".",
"If",
"none",
"... | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L105-L117 |
fakedrake/overlay_parse | overlay_parse/matchers.py | OverlayMatcher.fit_overlays | def fit_overlays(self, text, start=None, end=None, **kw):
"""
Get an overlay thet fits the range [start, end).
"""
for ovl in text.overlays:
if ovl.match(props=self.props_match, rng=(start, end)):
yield ovl | python | def fit_overlays(self, text, start=None, end=None, **kw):
"""
Get an overlay thet fits the range [start, end).
"""
for ovl in text.overlays:
if ovl.match(props=self.props_match, rng=(start, end)):
yield ovl | [
"def",
"fit_overlays",
"(",
"self",
",",
"text",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"for",
"ovl",
"in",
"text",
".",
"overlays",
":",
"if",
"ovl",
".",
"match",
"(",
"props",
"=",
"self",
".",
"pr... | Get an overlay thet fits the range [start, end). | [
"Get",
"an",
"overlay",
"thet",
"fits",
"the",
"range",
"[",
"start",
"end",
")",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L119-L126 |
fakedrake/overlay_parse | overlay_parse/matchers.py | ListMatcher._merge_ovls | def _merge_ovls(self, ovls):
"""
Merge ovls and also setup the value and props.
"""
ret = reduce(lambda x, y: x.merge(y), ovls)
ret.value = self.value(ovls=ovls)
ret.set_props(self.props)
return ret | python | def _merge_ovls(self, ovls):
"""
Merge ovls and also setup the value and props.
"""
ret = reduce(lambda x, y: x.merge(y), ovls)
ret.value = self.value(ovls=ovls)
ret.set_props(self.props)
return ret | [
"def",
"_merge_ovls",
"(",
"self",
",",
"ovls",
")",
":",
"ret",
"=",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
".",
"merge",
"(",
"y",
")",
",",
"ovls",
")",
"ret",
".",
"value",
"=",
"self",
".",
"value",
"(",
"ovls",
"=",
"ovls",
"... | Merge ovls and also setup the value and props. | [
"Merge",
"ovls",
"and",
"also",
"setup",
"the",
"value",
"and",
"props",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L145-L153 |
fakedrake/overlay_parse | overlay_parse/matchers.py | ListMatcher._fit_overlay_lists | def _fit_overlay_lists(self, text, start, matchers, **kw):
"""
Return a list of overlays that start at start.
"""
if matchers:
for o in matchers[0].fit_overlays(text, start):
for rest in self._fit_overlay_lists(text, o.end, matchers[1:]):
... | python | def _fit_overlay_lists(self, text, start, matchers, **kw):
"""
Return a list of overlays that start at start.
"""
if matchers:
for o in matchers[0].fit_overlays(text, start):
for rest in self._fit_overlay_lists(text, o.end, matchers[1:]):
... | [
"def",
"_fit_overlay_lists",
"(",
"self",
",",
"text",
",",
"start",
",",
"matchers",
",",
"*",
"*",
"kw",
")",
":",
"if",
"matchers",
":",
"for",
"o",
"in",
"matchers",
"[",
"0",
"]",
".",
"fit_overlays",
"(",
"text",
",",
"start",
")",
":",
"for"... | Return a list of overlays that start at start. | [
"Return",
"a",
"list",
"of",
"overlays",
"that",
"start",
"at",
"start",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L155-L166 |
fakedrake/overlay_parse | overlay_parse/matchers.py | ListMatcher.offset_overlays | def offset_overlays(self, text, offset=0, run_deps=True, **kw):
"""
The heavy lifting is done by fit_overlays. Override just that for
alternatie implementation.
"""
if run_deps and self.dependencies:
text.overlay(self.dependencies)
for ovlf in self.matchers[... | python | def offset_overlays(self, text, offset=0, run_deps=True, **kw):
"""
The heavy lifting is done by fit_overlays. Override just that for
alternatie implementation.
"""
if run_deps and self.dependencies:
text.overlay(self.dependencies)
for ovlf in self.matchers[... | [
"def",
"offset_overlays",
"(",
"self",
",",
"text",
",",
"offset",
"=",
"0",
",",
"run_deps",
"=",
"True",
",",
"*",
"*",
"kw",
")",
":",
"if",
"run_deps",
"and",
"self",
".",
"dependencies",
":",
"text",
".",
"overlay",
"(",
"self",
".",
"dependenci... | The heavy lifting is done by fit_overlays. Override just that for
alternatie implementation. | [
"The",
"heavy",
"lifting",
"is",
"done",
"by",
"fit_overlays",
".",
"Override",
"just",
"that",
"for",
"alternatie",
"implementation",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L168-L182 |
fakedrake/overlay_parse | overlay_parse/matchers.py | MatcherMatcher._maybe_run_matchers | def _maybe_run_matchers(self, text, run_matchers):
"""
OverlayedText should be smart enough to not run twice the same
matchers but this is an extra handle of control over that.
"""
if run_matchers is True or \
(run_matchers is not False and text not in self._overlayed... | python | def _maybe_run_matchers(self, text, run_matchers):
"""
OverlayedText should be smart enough to not run twice the same
matchers but this is an extra handle of control over that.
"""
if run_matchers is True or \
(run_matchers is not False and text not in self._overlayed... | [
"def",
"_maybe_run_matchers",
"(",
"self",
",",
"text",
",",
"run_matchers",
")",
":",
"if",
"run_matchers",
"is",
"True",
"or",
"(",
"run_matchers",
"is",
"not",
"False",
"and",
"text",
"not",
"in",
"self",
".",
"_overlayed_already",
")",
":",
"text",
"."... | OverlayedText should be smart enough to not run twice the same
matchers but this is an extra handle of control over that. | [
"OverlayedText",
"should",
"be",
"smart",
"enough",
"to",
"not",
"run",
"twice",
"the",
"same",
"matchers",
"but",
"this",
"is",
"an",
"extra",
"handle",
"of",
"control",
"over",
"that",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L218-L227 |
fakedrake/overlay_parse | overlay_parse/matchers.py | MatcherMatcher.fit_overlays | def fit_overlays(self, text, run_matchers=None, **kw):
"""
First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments.
"""
self._maybe_run_matchers(tex... | python | def fit_overlays(self, text, run_matchers=None, **kw):
"""
First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments.
"""
self._maybe_run_matchers(tex... | [
"def",
"fit_overlays",
"(",
"self",
",",
"text",
",",
"run_matchers",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"_maybe_run_matchers",
"(",
"text",
",",
"run_matchers",
")",
"for",
"i",
"in",
"self",
".",
"_list_match",
".",
"fit_overlay",... | First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments. | [
"First",
"all",
"matchers",
"will",
"run",
"and",
"then",
"I",
"will",
"try",
"to",
"combine",
"them",
".",
"Use",
"run_matchers",
"to",
"force",
"running",
"(",
"True",
")",
"or",
"not",
"running",
"(",
"False",
")",
"the",
"matchers",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L229-L239 |
fakedrake/overlay_parse | overlay_parse/matchers.py | MatcherMatcher.offset_overlays | def offset_overlays(self, text, run_matchers=None, **kw):
"""
First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments.
"""
self._maybe_run_matchers... | python | def offset_overlays(self, text, run_matchers=None, **kw):
"""
First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments.
"""
self._maybe_run_matchers... | [
"def",
"offset_overlays",
"(",
"self",
",",
"text",
",",
"run_matchers",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"_maybe_run_matchers",
"(",
"text",
",",
"run_matchers",
")",
"for",
"i",
"in",
"self",
".",
"_list_match",
".",
"offset_ove... | First all matchers will run and then I will try to combine
them. Use run_matchers to force running(True) or not
running(False) the matchers.
See ListMatcher for arguments. | [
"First",
"all",
"matchers",
"will",
"run",
"and",
"then",
"I",
"will",
"try",
"to",
"combine",
"them",
".",
"Use",
"run_matchers",
"to",
"force",
"running",
"(",
"True",
")",
"or",
"not",
"running",
"(",
"False",
")",
"the",
"matchers",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/matchers.py#L241-L252 |
nefarioustim/parker | parker/parsedpage.py | ParsedPage.get_nodes_by_selector | def get_nodes_by_selector(self, selector, not_selector=None):
"""Return a collection of filtered nodes.
Filtered based on the @selector and @not_selector parameters.
"""
nodes = self.parsed(selector)
if not_selector is not None:
nodes = nodes.not_(not_selector)
... | python | def get_nodes_by_selector(self, selector, not_selector=None):
"""Return a collection of filtered nodes.
Filtered based on the @selector and @not_selector parameters.
"""
nodes = self.parsed(selector)
if not_selector is not None:
nodes = nodes.not_(not_selector)
... | [
"def",
"get_nodes_by_selector",
"(",
"self",
",",
"selector",
",",
"not_selector",
"=",
"None",
")",
":",
"nodes",
"=",
"self",
".",
"parsed",
"(",
"selector",
")",
"if",
"not_selector",
"is",
"not",
"None",
":",
"nodes",
"=",
"nodes",
".",
"not_",
"(",
... | Return a collection of filtered nodes.
Filtered based on the @selector and @not_selector parameters. | [
"Return",
"a",
"collection",
"of",
"filtered",
"nodes",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L21-L31 |
nefarioustim/parker | parker/parsedpage.py | ParsedPage.get_text_from_node | def get_text_from_node(self, node, regex=None, group=1):
"""Get text from node and filter if necessary."""
text = self._get_stripped_text_from_node(node)
if regex is not None:
text = self._filter_by_regex(regex, text, group)
return text | python | def get_text_from_node(self, node, regex=None, group=1):
"""Get text from node and filter if necessary."""
text = self._get_stripped_text_from_node(node)
if regex is not None:
text = self._filter_by_regex(regex, text, group)
return text | [
"def",
"get_text_from_node",
"(",
"self",
",",
"node",
",",
"regex",
"=",
"None",
",",
"group",
"=",
"1",
")",
":",
"text",
"=",
"self",
".",
"_get_stripped_text_from_node",
"(",
"node",
")",
"if",
"regex",
"is",
"not",
"None",
":",
"text",
"=",
"self"... | Get text from node and filter if necessary. | [
"Get",
"text",
"from",
"node",
"and",
"filter",
"if",
"necessary",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L33-L40 |
nefarioustim/parker | parker/parsedpage.py | ParsedPage.get_filtered_values_by_selector | def get_filtered_values_by_selector(self, selector, regex=None, group=1):
"""Return the text content of @selector.
Filter text content by @regex and @group.
"""
data = [
self.get_text_from_node(node, regex, group)
for node in self.get_nodes_by_selector(selector)
... | python | def get_filtered_values_by_selector(self, selector, regex=None, group=1):
"""Return the text content of @selector.
Filter text content by @regex and @group.
"""
data = [
self.get_text_from_node(node, regex, group)
for node in self.get_nodes_by_selector(selector)
... | [
"def",
"get_filtered_values_by_selector",
"(",
"self",
",",
"selector",
",",
"regex",
"=",
"None",
",",
"group",
"=",
"1",
")",
":",
"data",
"=",
"[",
"self",
".",
"get_text_from_node",
"(",
"node",
",",
"regex",
",",
"group",
")",
"for",
"node",
"in",
... | Return the text content of @selector.
Filter text content by @regex and @group. | [
"Return",
"the",
"text",
"content",
"of",
"@selector",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L42-L53 |
nefarioustim/parker | parker/parsedpage.py | ParsedPage._get_stripped_text_from_node | def _get_stripped_text_from_node(self, node):
"""Return the stripped text content of a node."""
return (
node.text_content()
.replace(u"\u00A0", " ")
.replace("\t", "")
.replace("\n", "")
.strip()
) | python | def _get_stripped_text_from_node(self, node):
"""Return the stripped text content of a node."""
return (
node.text_content()
.replace(u"\u00A0", " ")
.replace("\t", "")
.replace("\n", "")
.strip()
) | [
"def",
"_get_stripped_text_from_node",
"(",
"self",
",",
"node",
")",
":",
"return",
"(",
"node",
".",
"text_content",
"(",
")",
".",
"replace",
"(",
"u\"\\u00A0\"",
",",
"\" \"",
")",
".",
"replace",
"(",
"\"\\t\"",
",",
"\"\"",
")",
".",
"replace",
"("... | Return the stripped text content of a node. | [
"Return",
"the",
"stripped",
"text",
"content",
"of",
"a",
"node",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L55-L63 |
nefarioustim/parker | parker/parsedpage.py | ParsedPage._filter_by_regex | def _filter_by_regex(self, regex, text, group=1):
"""Filter @text by @regex."""
match = re.search(
regex,
text,
re.MULTILINE
)
return match.group(group).strip() if (
match and match.groups()
) else text | python | def _filter_by_regex(self, regex, text, group=1):
"""Filter @text by @regex."""
match = re.search(
regex,
text,
re.MULTILINE
)
return match.group(group).strip() if (
match and match.groups()
) else text | [
"def",
"_filter_by_regex",
"(",
"self",
",",
"regex",
",",
"text",
",",
"group",
"=",
"1",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"regex",
",",
"text",
",",
"re",
".",
"MULTILINE",
")",
"return",
"match",
".",
"group",
"(",
"group",
")",... | Filter @text by @regex. | [
"Filter"
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/parsedpage.py#L65-L75 |
PSU-OIT-ARC/django-local-settings | local_settings/__main__.py | make_local_settings | def make_local_settings(argv=None):
"""Generate a local settings file.
The most common usage is:
make-local-settings <env>
where env is replaced with and environment name such as stage or
prod. For example:
make-local-settings prod
This will create a local settings file named lo... | python | def make_local_settings(argv=None):
"""Generate a local settings file.
The most common usage is:
make-local-settings <env>
where env is replaced with and environment name such as stage or
prod. For example:
make-local-settings prod
This will create a local settings file named lo... | [
"def",
"make_local_settings",
"(",
"argv",
"=",
"None",
")",
":",
"description",
"=",
"textwrap",
".",
"dedent",
"(",
"' %s'",
"%",
"make_local_settings",
".",
"__doc__",
")",
"parser",
"=",
"ArgParser",
"(",
"description",
"=",
"description",
",",
"formatt... | Generate a local settings file.
The most common usage is:
make-local-settings <env>
where env is replaced with and environment name such as stage or
prod. For example:
make-local-settings prod
This will create a local settings file named local.prod.cfg with
a prod section if loc... | [
"Generate",
"a",
"local",
"settings",
"file",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/__main__.py#L23-L122 |
etcher-be/emiz | emiz/avwx/speech.py | wind | def wind(direction: Number,
speed: Number,
gust: Number,
vardir: typing.List[Number] = None,
unit: str = 'kt') -> str:
"""
Format wind details into a spoken word string
"""
unit = SPOKEN_UNITS.get(unit, unit)
val = translate.wind(direction, speed, gust, vardir, un... | python | def wind(direction: Number,
speed: Number,
gust: Number,
vardir: typing.List[Number] = None,
unit: str = 'kt') -> str:
"""
Format wind details into a spoken word string
"""
unit = SPOKEN_UNITS.get(unit, unit)
val = translate.wind(direction, speed, gust, vardir, un... | [
"def",
"wind",
"(",
"direction",
":",
"Number",
",",
"speed",
":",
"Number",
",",
"gust",
":",
"Number",
",",
"vardir",
":",
"typing",
".",
"List",
"[",
"Number",
"]",
"=",
"None",
",",
"unit",
":",
"str",
"=",
"'kt'",
")",
"->",
"str",
":",
"uni... | Format wind details into a spoken word string | [
"Format",
"wind",
"details",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L20-L31 |
etcher-be/emiz | emiz/avwx/speech.py | temperature | def temperature(header: str, temp: Number, unit: str = 'C') -> str:
"""
Format temperature details into a spoken word string
"""
if not (temp and temp.value):
return header + ' unknown'
if unit in SPOKEN_UNITS:
unit = SPOKEN_UNITS[unit]
use_s = '' if temp.spoken in ('one', 'minus... | python | def temperature(header: str, temp: Number, unit: str = 'C') -> str:
"""
Format temperature details into a spoken word string
"""
if not (temp and temp.value):
return header + ' unknown'
if unit in SPOKEN_UNITS:
unit = SPOKEN_UNITS[unit]
use_s = '' if temp.spoken in ('one', 'minus... | [
"def",
"temperature",
"(",
"header",
":",
"str",
",",
"temp",
":",
"Number",
",",
"unit",
":",
"str",
"=",
"'C'",
")",
"->",
"str",
":",
"if",
"not",
"(",
"temp",
"and",
"temp",
".",
"value",
")",
":",
"return",
"header",
"+",
"' unknown'",
"if",
... | Format temperature details into a spoken word string | [
"Format",
"temperature",
"details",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L34-L43 |
etcher-be/emiz | emiz/avwx/speech.py | visibility | def visibility(vis: Number, unit: str = 'm') -> str:
"""
Format visibility details into a spoken word string
"""
if not vis:
return 'Visibility unknown'
if vis.value is None or '/' in vis.repr:
ret_vis = vis.spoken
else:
ret_vis = translate.visibility(vis, unit=unit)
... | python | def visibility(vis: Number, unit: str = 'm') -> str:
"""
Format visibility details into a spoken word string
"""
if not vis:
return 'Visibility unknown'
if vis.value is None or '/' in vis.repr:
ret_vis = vis.spoken
else:
ret_vis = translate.visibility(vis, unit=unit)
... | [
"def",
"visibility",
"(",
"vis",
":",
"Number",
",",
"unit",
":",
"str",
"=",
"'m'",
")",
"->",
"str",
":",
"if",
"not",
"vis",
":",
"return",
"'Visibility unknown'",
"if",
"vis",
".",
"value",
"is",
"None",
"or",
"'/'",
"in",
"vis",
".",
"repr",
"... | Format visibility details into a spoken word string | [
"Format",
"visibility",
"details",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L46-L69 |
etcher-be/emiz | emiz/avwx/speech.py | altimeter | def altimeter(alt: Number, unit: str = 'inHg') -> str:
"""
Format altimeter details into a spoken word string
"""
ret = 'Altimeter '
if not alt:
ret += 'unknown'
elif unit == 'inHg':
ret += core.spoken_number(alt.repr[:2]) + ' point ' + core.spoken_number(alt.repr[2:])
elif u... | python | def altimeter(alt: Number, unit: str = 'inHg') -> str:
"""
Format altimeter details into a spoken word string
"""
ret = 'Altimeter '
if not alt:
ret += 'unknown'
elif unit == 'inHg':
ret += core.spoken_number(alt.repr[:2]) + ' point ' + core.spoken_number(alt.repr[2:])
elif u... | [
"def",
"altimeter",
"(",
"alt",
":",
"Number",
",",
"unit",
":",
"str",
"=",
"'inHg'",
")",
"->",
"str",
":",
"ret",
"=",
"'Altimeter '",
"if",
"not",
"alt",
":",
"ret",
"+=",
"'unknown'",
"elif",
"unit",
"==",
"'inHg'",
":",
"ret",
"+=",
"core",
"... | Format altimeter details into a spoken word string | [
"Format",
"altimeter",
"details",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L72-L83 |
etcher-be/emiz | emiz/avwx/speech.py | other | def other(wxcodes: typing.List[str]) -> str:
"""
Format wx codes into a spoken word string
"""
ret = []
for code in wxcodes:
item = translate.wxcode(code)
if item.startswith('Vicinity'):
item = item.lstrip('Vicinity ') + ' in the Vicinity'
ret.append(item)
ret... | python | def other(wxcodes: typing.List[str]) -> str:
"""
Format wx codes into a spoken word string
"""
ret = []
for code in wxcodes:
item = translate.wxcode(code)
if item.startswith('Vicinity'):
item = item.lstrip('Vicinity ') + ' in the Vicinity'
ret.append(item)
ret... | [
"def",
"other",
"(",
"wxcodes",
":",
"typing",
".",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"ret",
"=",
"[",
"]",
"for",
"code",
"in",
"wxcodes",
":",
"item",
"=",
"translate",
".",
"wxcode",
"(",
"code",
")",
"if",
"item",
".",
"startswi... | Format wx codes into a spoken word string | [
"Format",
"wx",
"codes",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L86-L96 |
etcher-be/emiz | emiz/avwx/speech.py | type_and_times | def type_and_times(type_: str, start: Timestamp, end: Timestamp, probability: Number = None) -> str:
"""
Format line type and times into the beginning of a spoken line string
"""
if not type_:
return ''
if type_ == 'BECMG':
return f"At {start.dt.hour or 'midnight'} zulu becoming"
... | python | def type_and_times(type_: str, start: Timestamp, end: Timestamp, probability: Number = None) -> str:
"""
Format line type and times into the beginning of a spoken line string
"""
if not type_:
return ''
if type_ == 'BECMG':
return f"At {start.dt.hour or 'midnight'} zulu becoming"
... | [
"def",
"type_and_times",
"(",
"type_",
":",
"str",
",",
"start",
":",
"Timestamp",
",",
"end",
":",
"Timestamp",
",",
"probability",
":",
"Number",
"=",
"None",
")",
"->",
"str",
":",
"if",
"not",
"type_",
":",
"return",
"''",
"if",
"type_",
"==",
"'... | Format line type and times into the beginning of a spoken line string | [
"Format",
"line",
"type",
"and",
"times",
"into",
"the",
"beginning",
"of",
"a",
"spoken",
"line",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L99-L114 |
etcher-be/emiz | emiz/avwx/speech.py | wind_shear | def wind_shear(shear: str, unit_alt: str = 'ft', unit_wind: str = 'kt') -> str:
"""
Format wind shear string into a spoken word string
"""
unit_alt = SPOKEN_UNITS.get(unit_alt, unit_alt)
unit_wind = SPOKEN_UNITS.get(unit_wind, unit_wind)
return translate.wind_shear(shear, unit_alt, unit_wind, sp... | python | def wind_shear(shear: str, unit_alt: str = 'ft', unit_wind: str = 'kt') -> str:
"""
Format wind shear string into a spoken word string
"""
unit_alt = SPOKEN_UNITS.get(unit_alt, unit_alt)
unit_wind = SPOKEN_UNITS.get(unit_wind, unit_wind)
return translate.wind_shear(shear, unit_alt, unit_wind, sp... | [
"def",
"wind_shear",
"(",
"shear",
":",
"str",
",",
"unit_alt",
":",
"str",
"=",
"'ft'",
",",
"unit_wind",
":",
"str",
"=",
"'kt'",
")",
"->",
"str",
":",
"unit_alt",
"=",
"SPOKEN_UNITS",
".",
"get",
"(",
"unit_alt",
",",
"unit_alt",
")",
"unit_wind",
... | Format wind shear string into a spoken word string | [
"Format",
"wind",
"shear",
"string",
"into",
"a",
"spoken",
"word",
"string"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L117-L123 |
etcher-be/emiz | emiz/avwx/speech.py | metar | def metar(data: MetarData, units: Units) -> str:
"""
Convert MetarData into a string for text-to-speech
"""
speech = []
if data.wind_direction and data.wind_speed:
speech.append(wind(data.wind_direction, data.wind_speed,
data.wind_gust, data.wind_variable_direction... | python | def metar(data: MetarData, units: Units) -> str:
"""
Convert MetarData into a string for text-to-speech
"""
speech = []
if data.wind_direction and data.wind_speed:
speech.append(wind(data.wind_direction, data.wind_speed,
data.wind_gust, data.wind_variable_direction... | [
"def",
"metar",
"(",
"data",
":",
"MetarData",
",",
"units",
":",
"Units",
")",
"->",
"str",
":",
"speech",
"=",
"[",
"]",
"if",
"data",
".",
"wind_direction",
"and",
"data",
".",
"wind_speed",
":",
"speech",
".",
"append",
"(",
"wind",
"(",
"data",
... | Convert MetarData into a string for text-to-speech | [
"Convert",
"MetarData",
"into",
"a",
"string",
"for",
"text",
"-",
"to",
"-",
"speech"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L126-L147 |
etcher-be/emiz | emiz/avwx/speech.py | taf_line | def taf_line(line: TafLineData, units: Units) -> str:
"""
Convert TafLineData into a string for text-to-speech
"""
speech = []
start = type_and_times(line.type, line.start_time, line.end_time, line.probability)
if line.wind_direction and line.wind_speed:
speech.append(wind(line.wind_dire... | python | def taf_line(line: TafLineData, units: Units) -> str:
"""
Convert TafLineData into a string for text-to-speech
"""
speech = []
start = type_and_times(line.type, line.start_time, line.end_time, line.probability)
if line.wind_direction and line.wind_speed:
speech.append(wind(line.wind_dire... | [
"def",
"taf_line",
"(",
"line",
":",
"TafLineData",
",",
"units",
":",
"Units",
")",
"->",
"str",
":",
"speech",
"=",
"[",
"]",
"start",
"=",
"type_and_times",
"(",
"line",
".",
"type",
",",
"line",
".",
"start_time",
",",
"line",
".",
"end_time",
",... | Convert TafLineData into a string for text-to-speech | [
"Convert",
"TafLineData",
"into",
"a",
"string",
"for",
"text",
"-",
"to",
"-",
"speech"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L150-L173 |
etcher-be/emiz | emiz/avwx/speech.py | taf | def taf(data: TafData, units: Units) -> str:
"""
Convert TafData into a string for text-to-speech
"""
try:
month = data.start_time.dt.strftime(r'%B')
day = ordinal(data.start_time.dt.day)
ret = f"Starting on {month} {day} - "
except AttributeError:
ret = ''
return... | python | def taf(data: TafData, units: Units) -> str:
"""
Convert TafData into a string for text-to-speech
"""
try:
month = data.start_time.dt.strftime(r'%B')
day = ordinal(data.start_time.dt.day)
ret = f"Starting on {month} {day} - "
except AttributeError:
ret = ''
return... | [
"def",
"taf",
"(",
"data",
":",
"TafData",
",",
"units",
":",
"Units",
")",
"->",
"str",
":",
"try",
":",
"month",
"=",
"data",
".",
"start_time",
".",
"dt",
".",
"strftime",
"(",
"r'%B'",
")",
"day",
"=",
"ordinal",
"(",
"data",
".",
"start_time",... | Convert TafData into a string for text-to-speech | [
"Convert",
"TafData",
"into",
"a",
"string",
"for",
"text",
"-",
"to",
"-",
"speech"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/speech.py#L176-L186 |
fogcitymarathoner/s3_mysql_backup | s3_mysql_backup/scripts/get_bucket.py | get_bucket | def get_bucket():
"""
Get listing of S3 Bucket
"""
args = parser.parse_args()
bucket = s3_bucket(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name)
for b in bucket.list():
print(''.join([i if ord(i) < 128 else ' ' for i in b.name])) | python | def get_bucket():
"""
Get listing of S3 Bucket
"""
args = parser.parse_args()
bucket = s3_bucket(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name)
for b in bucket.list():
print(''.join([i if ord(i) < 128 else ' ' for i in b.name])) | [
"def",
"get_bucket",
"(",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"bucket",
"=",
"s3_bucket",
"(",
"args",
".",
"aws_access_key_id",
",",
"args",
".",
"aws_secret_access_key",
",",
"args",
".",
"bucket_name",
")",
"for",
"b",
"in",
... | Get listing of S3 Bucket | [
"Get",
"listing",
"of",
"S3",
"Bucket"
] | train | https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/scripts/get_bucket.py#L13-L21 |
collectiveacuity/labPack | labpack/mapping/data.py | walk_data | def walk_data(input_data):
''' a generator function for retrieving data in a nested dictionary
:param input_data: dictionary or list with nested data
:return: string with dot_path, object with value of endpoint
'''
def _walk_dict(input_dict, path_to_root):
if not path_to_root:
... | python | def walk_data(input_data):
''' a generator function for retrieving data in a nested dictionary
:param input_data: dictionary or list with nested data
:return: string with dot_path, object with value of endpoint
'''
def _walk_dict(input_dict, path_to_root):
if not path_to_root:
... | [
"def",
"walk_data",
"(",
"input_data",
")",
":",
"def",
"_walk_dict",
"(",
"input_dict",
",",
"path_to_root",
")",
":",
"if",
"not",
"path_to_root",
":",
"yield",
"'.'",
",",
"input_dict",
"for",
"key",
",",
"value",
"in",
"input_dict",
".",
"items",
"(",
... | a generator function for retrieving data in a nested dictionary
:param input_data: dictionary or list with nested data
:return: string with dot_path, object with value of endpoint | [
"a",
"generator",
"function",
"for",
"retrieving",
"data",
"in",
"a",
"nested",
"dictionary"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L5-L46 |
collectiveacuity/labPack | labpack/mapping/data.py | transform_data | def transform_data(function, input_data):
''' a function to apply a function to each value in a nested dictionary
:param function: callable function with a single input of any datatype
:param input_data: dictionary or list with nested data to transform
:return: dictionary or list with data transformed... | python | def transform_data(function, input_data):
''' a function to apply a function to each value in a nested dictionary
:param function: callable function with a single input of any datatype
:param input_data: dictionary or list with nested data to transform
:return: dictionary or list with data transformed... | [
"def",
"transform_data",
"(",
"function",
",",
"input_data",
")",
":",
"# construct copy",
"try",
":",
"from",
"copy",
"import",
"deepcopy",
"output_data",
"=",
"deepcopy",
"(",
"input_data",
")",
"except",
":",
"raise",
"ValueError",
"(",
"'transform_data() input... | a function to apply a function to each value in a nested dictionary
:param function: callable function with a single input of any datatype
:param input_data: dictionary or list with nested data to transform
:return: dictionary or list with data transformed by function | [
"a",
"function",
"to",
"apply",
"a",
"function",
"to",
"each",
"value",
"in",
"a",
"nested",
"dictionary"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L69-L102 |
collectiveacuity/labPack | labpack/mapping/data.py | clean_data | def clean_data(input_value):
''' a function to transform a value into a json or yaml valid datatype
:param input_value: object of any datatype
:return: object with json valid datatype
'''
# pass normal json/yaml datatypes
if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneT... | python | def clean_data(input_value):
''' a function to transform a value into a json or yaml valid datatype
:param input_value: object of any datatype
:return: object with json valid datatype
'''
# pass normal json/yaml datatypes
if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneT... | [
"def",
"clean_data",
"(",
"input_value",
")",
":",
"# pass normal json/yaml datatypes",
"if",
"input_value",
".",
"__class__",
".",
"__name__",
"in",
"[",
"'bool'",
",",
"'str'",
",",
"'float'",
",",
"'int'",
",",
"'NoneType'",
"]",
":",
"pass",
"# transform byt... | a function to transform a value into a json or yaml valid datatype
:param input_value: object of any datatype
:return: object with json valid datatype | [
"a",
"function",
"to",
"transform",
"a",
"value",
"into",
"a",
"json",
"or",
"yaml",
"valid",
"datatype"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L104-L135 |
collectiveacuity/labPack | labpack/mapping/data.py | reconstruct_dict | def reconstruct_dict(dot_paths, values):
''' a method for reconstructing a dictionary from the values along dot paths '''
output_dict = {}
for i in range(len(dot_paths)):
if i + 1 <= len(values):
path_segments = segment_path(dot_paths[i])
current_nest = output_... | python | def reconstruct_dict(dot_paths, values):
''' a method for reconstructing a dictionary from the values along dot paths '''
output_dict = {}
for i in range(len(dot_paths)):
if i + 1 <= len(values):
path_segments = segment_path(dot_paths[i])
current_nest = output_... | [
"def",
"reconstruct_dict",
"(",
"dot_paths",
",",
"values",
")",
":",
"output_dict",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"dot_paths",
")",
")",
":",
"if",
"i",
"+",
"1",
"<=",
"len",
"(",
"values",
")",
":",
"path_segments",
... | a method for reconstructing a dictionary from the values along dot paths | [
"a",
"method",
"for",
"reconstructing",
"a",
"dictionary",
"from",
"the",
"values",
"along",
"dot",
"paths"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/mapping/data.py#L137-L177 |
fogcitymarathoner/s3_mysql_backup | s3_mysql_backup/scripts/copy_file_to_s3_bucket.py | cp_file | def cp_file():
"""
dumps databases into /backups, uploads to s3, deletes backups older than a month
fab -f ./fabfile.py backup_dbs
"""
args = parser.parse_args()
copy_file(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name, args.file, args.s3_folder) | python | def cp_file():
"""
dumps databases into /backups, uploads to s3, deletes backups older than a month
fab -f ./fabfile.py backup_dbs
"""
args = parser.parse_args()
copy_file(args.aws_access_key_id, args.aws_secret_access_key, args.bucket_name, args.file, args.s3_folder) | [
"def",
"cp_file",
"(",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"copy_file",
"(",
"args",
".",
"aws_access_key_id",
",",
"args",
".",
"aws_secret_access_key",
",",
"args",
".",
"bucket_name",
",",
"args",
".",
"file",
",",
"args",
".... | dumps databases into /backups, uploads to s3, deletes backups older than a month
fab -f ./fabfile.py backup_dbs | [
"dumps",
"databases",
"into",
"/",
"backups",
"uploads",
"to",
"s3",
"deletes",
"backups",
"older",
"than",
"a",
"month",
"fab",
"-",
"f",
".",
"/",
"fabfile",
".",
"py",
"backup_dbs"
] | train | https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/scripts/copy_file_to_s3_bucket.py#L17-L24 |
mbodenhamer/syn | syn/base_utils/order.py | topological_sorting | def topological_sorting(nodes, relations):
'''An implementation of Kahn's algorithm.
'''
ret = []
nodes = set(nodes) | _nodes(relations)
inc = _incoming(relations)
out = _outgoing(relations)
free = _free_nodes(nodes, inc)
while free:
n = free.pop()
ret.append(n)
... | python | def topological_sorting(nodes, relations):
'''An implementation of Kahn's algorithm.
'''
ret = []
nodes = set(nodes) | _nodes(relations)
inc = _incoming(relations)
out = _outgoing(relations)
free = _free_nodes(nodes, inc)
while free:
n = free.pop()
ret.append(n)
... | [
"def",
"topological_sorting",
"(",
"nodes",
",",
"relations",
")",
":",
"ret",
"=",
"[",
"]",
"nodes",
"=",
"set",
"(",
"nodes",
")",
"|",
"_nodes",
"(",
"relations",
")",
"inc",
"=",
"_incoming",
"(",
"relations",
")",
"out",
"=",
"_outgoing",
"(",
... | An implementation of Kahn's algorithm. | [
"An",
"implementation",
"of",
"Kahn",
"s",
"algorithm",
"."
] | train | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/order.py#L47-L69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.