id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
244,600 | tlatsas/wigiki | wigiki/config.py | ConfigManager.cli | def cli(self):
"""Read program parameters from command line and configuration files
We support both command line arguments and configuration files.
The command line arguments have always precedence over any
configuration file parameters. This allows us to have most of
our option... | python | def cli(self):
"""Read program parameters from command line and configuration files
We support both command line arguments and configuration files.
The command line arguments have always precedence over any
configuration file parameters. This allows us to have most of
our option... | [
"def",
"cli",
"(",
"self",
")",
":",
"# first we parse only for a configuration file with an initial parser",
"init_parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatte... | Read program parameters from command line and configuration files
We support both command line arguments and configuration files.
The command line arguments have always precedence over any
configuration file parameters. This allows us to have most of
our options in files but override th... | [
"Read",
"program",
"parameters",
"from",
"command",
"line",
"and",
"configuration",
"files"
] | baf9c5a6523a9b90db7572330d04e3e199391273 | https://github.com/tlatsas/wigiki/blob/baf9c5a6523a9b90db7572330d04e3e199391273/wigiki/config.py#L46-L104 |
244,601 | tlatsas/wigiki | wigiki/config.py | ConfigManager.detect_config | def detect_config(self):
"""check in the current working directory for configuration files"""
default_files = ("config.json", "config.yml")
for file_ in default_files:
if os.path.exists(file_):
return file_ | python | def detect_config(self):
"""check in the current working directory for configuration files"""
default_files = ("config.json", "config.yml")
for file_ in default_files:
if os.path.exists(file_):
return file_ | [
"def",
"detect_config",
"(",
"self",
")",
":",
"default_files",
"=",
"(",
"\"config.json\"",
",",
"\"config.yml\"",
")",
"for",
"file_",
"in",
"default_files",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_",
")",
":",
"return",
"file_"
] | check in the current working directory for configuration files | [
"check",
"in",
"the",
"current",
"working",
"directory",
"for",
"configuration",
"files"
] | baf9c5a6523a9b90db7572330d04e3e199391273 | https://github.com/tlatsas/wigiki/blob/baf9c5a6523a9b90db7572330d04e3e199391273/wigiki/config.py#L106-L111 |
244,602 | tlatsas/wigiki | wigiki/config.py | ConfigManager.merge_with_default_options | def merge_with_default_options(self, config_opts):
"""merge options from configuration file with the default options"""
return dict(list(self.defaults.items()) + list(config_opts.items())) | python | def merge_with_default_options(self, config_opts):
"""merge options from configuration file with the default options"""
return dict(list(self.defaults.items()) + list(config_opts.items())) | [
"def",
"merge_with_default_options",
"(",
"self",
",",
"config_opts",
")",
":",
"return",
"dict",
"(",
"list",
"(",
"self",
".",
"defaults",
".",
"items",
"(",
")",
")",
"+",
"list",
"(",
"config_opts",
".",
"items",
"(",
")",
")",
")"
] | merge options from configuration file with the default options | [
"merge",
"options",
"from",
"configuration",
"file",
"with",
"the",
"default",
"options"
] | baf9c5a6523a9b90db7572330d04e3e199391273 | https://github.com/tlatsas/wigiki/blob/baf9c5a6523a9b90db7572330d04e3e199391273/wigiki/config.py#L113-L115 |
244,603 | Kjwon15/autotweet | autotweet/twitter.py | authorize | def authorize():
"""Authorize to twitter.
Use PIN authentification.
:returns: Token for authentificate with Twitter.
:rtype: :class:`autotweet.twitter.OAuthToken`
"""
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
url = auth.get_authorization_url()
print('Open this url on y... | python | def authorize():
"""Authorize to twitter.
Use PIN authentification.
:returns: Token for authentificate with Twitter.
:rtype: :class:`autotweet.twitter.OAuthToken`
"""
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
url = auth.get_authorization_url()
print('Open this url on y... | [
"def",
"authorize",
"(",
")",
":",
"auth",
"=",
"tweepy",
".",
"OAuthHandler",
"(",
"CONSUMER_KEY",
",",
"CONSUMER_SECRET",
")",
"url",
"=",
"auth",
".",
"get_authorization_url",
"(",
")",
"print",
"(",
"'Open this url on your webbrowser: {0}'",
".",
"format",
"... | Authorize to twitter.
Use PIN authentification.
:returns: Token for authentificate with Twitter.
:rtype: :class:`autotweet.twitter.OAuthToken` | [
"Authorize",
"to",
"twitter",
"."
] | c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e | https://github.com/Kjwon15/autotweet/blob/c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e/autotweet/twitter.py#L61-L78 |
244,604 | Kjwon15/autotweet | autotweet/twitter.py | expand_url | def expand_url(status):
"""Expand url on statuses.
:param status: A tweepy status to expand urls.
:type status: :class:`tweepy.models.Status`
:returns: A string with expanded urls.
:rtype: :class:`str`
"""
try:
txt = get_full_text(status)
for url in status.entities['urls']:... | python | def expand_url(status):
"""Expand url on statuses.
:param status: A tweepy status to expand urls.
:type status: :class:`tweepy.models.Status`
:returns: A string with expanded urls.
:rtype: :class:`str`
"""
try:
txt = get_full_text(status)
for url in status.entities['urls']:... | [
"def",
"expand_url",
"(",
"status",
")",
":",
"try",
":",
"txt",
"=",
"get_full_text",
"(",
"status",
")",
"for",
"url",
"in",
"status",
".",
"entities",
"[",
"'urls'",
"]",
":",
"txt",
"=",
"txt",
".",
"replace",
"(",
"url",
"[",
"'url'",
"]",
","... | Expand url on statuses.
:param status: A tweepy status to expand urls.
:type status: :class:`tweepy.models.Status`
:returns: A string with expanded urls.
:rtype: :class:`str` | [
"Expand",
"url",
"on",
"statuses",
"."
] | c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e | https://github.com/Kjwon15/autotweet/blob/c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e/autotweet/twitter.py#L92-L115 |
244,605 | Kjwon15/autotweet | autotweet/twitter.py | strip_tweet | def strip_tweet(text, remove_url=True):
"""Strip tweet message.
This method removes mentions strings and urls(optional).
:param text: tweet message
:type text: :class:`str`
:param remove_url: Remove urls. default :const:`True`.
:type remove_url: :class:`boolean`
:returns: Striped tweet m... | python | def strip_tweet(text, remove_url=True):
"""Strip tweet message.
This method removes mentions strings and urls(optional).
:param text: tweet message
:type text: :class:`str`
:param remove_url: Remove urls. default :const:`True`.
:type remove_url: :class:`boolean`
:returns: Striped tweet m... | [
"def",
"strip_tweet",
"(",
"text",
",",
"remove_url",
"=",
"True",
")",
":",
"if",
"remove_url",
":",
"text",
"=",
"url_pattern",
".",
"sub",
"(",
"''",
",",
"text",
")",
"else",
":",
"text",
"=",
"expand_url",
"(",
"text",
")",
"text",
"=",
"mention... | Strip tweet message.
This method removes mentions strings and urls(optional).
:param text: tweet message
:type text: :class:`str`
:param remove_url: Remove urls. default :const:`True`.
:type remove_url: :class:`boolean`
:returns: Striped tweet message
:rtype: :class:`str` | [
"Strip",
"tweet",
"message",
"."
] | c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e | https://github.com/Kjwon15/autotweet/blob/c35b68ee1814916fbe9e5a5bd6ea6e75b3cc596e/autotweet/twitter.py#L127-L149 |
244,606 | fizyk/pyramid_yml | setup.py | read | def read(fname):
"""Quick way to read a file content."""
content = None
with open(os.path.join(here, fname)) as f:
content = f.read()
return content | python | def read(fname):
"""Quick way to read a file content."""
content = None
with open(os.path.join(here, fname)) as f:
content = f.read()
return content | [
"def",
"read",
"(",
"fname",
")",
":",
"content",
"=",
"None",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"here",
",",
"fname",
")",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"read",
"(",
")",
"return",
"content"
] | Quick way to read a file content. | [
"Quick",
"way",
"to",
"read",
"a",
"file",
"content",
"."
] | 1b36c4e74194c04d7d69b4d7f86801757e78f0a6 | https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/setup.py#L8-L13 |
244,607 | sahilchinoy/django-irs-filings | irs/management/commands/downloadIRS.py | Command.download | def download(self):
"""
Download the archive from the IRS website.
"""
url = 'http://forms.irs.gov/app/pod/dataDownload/fullData'
r = requests.get(url, stream=True)
with open(self.zip_path, 'wb') as f:
# This is a big file, so we download in chunks
... | python | def download(self):
"""
Download the archive from the IRS website.
"""
url = 'http://forms.irs.gov/app/pod/dataDownload/fullData'
r = requests.get(url, stream=True)
with open(self.zip_path, 'wb') as f:
# This is a big file, so we download in chunks
... | [
"def",
"download",
"(",
"self",
")",
":",
"url",
"=",
"'http://forms.irs.gov/app/pod/dataDownload/fullData'",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
"with",
"open",
"(",
"self",
".",
"zip_path",
",",
"'wb'",
")",
"as... | Download the archive from the IRS website. | [
"Download",
"the",
"archive",
"from",
"the",
"IRS",
"website",
"."
] | efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b | https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/downloadIRS.py#L63-L74 |
244,608 | sahilchinoy/django-irs-filings | irs/management/commands/downloadIRS.py | Command.unzip | def unzip(self):
"""
Unzip the archive.
"""
logger.info('Unzipping archive')
with zipfile.ZipFile(self.zip_path, 'r') as zipped_archive:
data_file = zipped_archive.namelist()[0]
zipped_archive.extract(data_file, self.extract_path) | python | def unzip(self):
"""
Unzip the archive.
"""
logger.info('Unzipping archive')
with zipfile.ZipFile(self.zip_path, 'r') as zipped_archive:
data_file = zipped_archive.namelist()[0]
zipped_archive.extract(data_file, self.extract_path) | [
"def",
"unzip",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Unzipping archive'",
")",
"with",
"zipfile",
".",
"ZipFile",
"(",
"self",
".",
"zip_path",
",",
"'r'",
")",
"as",
"zipped_archive",
":",
"data_file",
"=",
"zipped_archive",
".",
"namelist... | Unzip the archive. | [
"Unzip",
"the",
"archive",
"."
] | efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b | https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/downloadIRS.py#L76-L83 |
244,609 | sahilchinoy/django-irs-filings | irs/management/commands/downloadIRS.py | Command.clean | def clean(self):
"""
Get the .txt file from within the many-layered
directory structure, then delete the directories.
"""
logger.info('Cleaning up archive')
shutil.move(
os.path.join(
self.data_dir,
'var/IRS/data/scripts/pofd/do... | python | def clean(self):
"""
Get the .txt file from within the many-layered
directory structure, then delete the directories.
"""
logger.info('Cleaning up archive')
shutil.move(
os.path.join(
self.data_dir,
'var/IRS/data/scripts/pofd/do... | [
"def",
"clean",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Cleaning up archive'",
")",
"shutil",
".",
"move",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_dir",
",",
"'var/IRS/data/scripts/pofd/download/FullDataFile.txt'",
")",
",",
... | Get the .txt file from within the many-layered
directory structure, then delete the directories. | [
"Get",
"the",
".",
"txt",
"file",
"from",
"within",
"the",
"many",
"-",
"layered",
"directory",
"structure",
"then",
"delete",
"the",
"directories",
"."
] | efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b | https://github.com/sahilchinoy/django-irs-filings/blob/efe80cc57ce1d9d8488f4e9496cf2347e29b6d8b/irs/management/commands/downloadIRS.py#L85-L100 |
244,610 | rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | TypeCode.get_parse_and_errorlist | def get_parse_and_errorlist(self):
"""Get the parselist and human-readable version, errorlist is returned,
because it is used in error messages.
"""
d = self.__class__.__dict__
parselist = d.get('parselist')
errorlist = d.get('errorlist')
if parselist and not erro... | python | def get_parse_and_errorlist(self):
"""Get the parselist and human-readable version, errorlist is returned,
because it is used in error messages.
"""
d = self.__class__.__dict__
parselist = d.get('parselist')
errorlist = d.get('errorlist')
if parselist and not erro... | [
"def",
"get_parse_and_errorlist",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"__class__",
".",
"__dict__",
"parselist",
"=",
"d",
".",
"get",
"(",
"'parselist'",
")",
"errorlist",
"=",
"d",
".",
"get",
"(",
"'errorlist'",
")",
"if",
"parselist",
"and"... | Get the parselist and human-readable version, errorlist is returned,
because it is used in error messages. | [
"Get",
"the",
"parselist",
"and",
"human",
"-",
"readable",
"version",
"errorlist",
"is",
"returned",
"because",
"it",
"is",
"used",
"in",
"error",
"messages",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L159-L172 |
244,611 | rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | String.text_to_data | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
Encode all strings as UTF-8, which will be type 'str'
not 'unicode'
'''
if self.strip: text = text.strip()
if self.pyclass is not None:
return self.pyclass(text.encode(UNICODE_... | python | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
Encode all strings as UTF-8, which will be type 'str'
not 'unicode'
'''
if self.strip: text = text.strip()
if self.pyclass is not None:
return self.pyclass(text.encode(UNICODE_... | [
"def",
"text_to_data",
"(",
"self",
",",
"text",
",",
"elt",
",",
"ps",
")",
":",
"if",
"self",
".",
"strip",
":",
"text",
"=",
"text",
".",
"strip",
"(",
")",
"if",
"self",
".",
"pyclass",
"is",
"not",
"None",
":",
"return",
"self",
".",
"pyclas... | convert text into typecode specific data.
Encode all strings as UTF-8, which will be type 'str'
not 'unicode' | [
"convert",
"text",
"into",
"typecode",
"specific",
"data",
".",
"Encode",
"all",
"strings",
"as",
"UTF",
"-",
"8",
"which",
"will",
"be",
"type",
"str",
"not",
"unicode"
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L709-L717 |
244,612 | rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | QName.set_prefix | def set_prefix(self, elt, pyobj):
'''use this method to set the prefix of the QName,
method looks in DOM to find prefix or set new prefix.
This method must be called before get_formatted_content.
'''
if isinstance(pyobj, tuple):
namespaceURI,localName = pyobj
... | python | def set_prefix(self, elt, pyobj):
'''use this method to set the prefix of the QName,
method looks in DOM to find prefix or set new prefix.
This method must be called before get_formatted_content.
'''
if isinstance(pyobj, tuple):
namespaceURI,localName = pyobj
... | [
"def",
"set_prefix",
"(",
"self",
",",
"elt",
",",
"pyobj",
")",
":",
"if",
"isinstance",
"(",
"pyobj",
",",
"tuple",
")",
":",
"namespaceURI",
",",
"localName",
"=",
"pyobj",
"self",
".",
"prefix",
"=",
"elt",
".",
"getPrefix",
"(",
"namespaceURI",
")... | use this method to set the prefix of the QName,
method looks in DOM to find prefix or set new prefix.
This method must be called before get_formatted_content. | [
"use",
"this",
"method",
"to",
"set",
"the",
"prefix",
"of",
"the",
"QName",
"method",
"looks",
"in",
"DOM",
"to",
"find",
"prefix",
"or",
"set",
"new",
"prefix",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"get_formatted_content",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L771-L778 |
244,613 | rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | Union.parse | def parse(self, elt, ps, **kw):
'''attempt to parse sequentially. No way to know ahead of time
what this instance represents. Must be simple type so it can
not have attributes nor children, so this isn't too bad.
'''
self.setMemberTypeCodes()
(nsuri,typeName) = self.che... | python | def parse(self, elt, ps, **kw):
'''attempt to parse sequentially. No way to know ahead of time
what this instance represents. Must be simple type so it can
not have attributes nor children, so this isn't too bad.
'''
self.setMemberTypeCodes()
(nsuri,typeName) = self.che... | [
"def",
"parse",
"(",
"self",
",",
"elt",
",",
"ps",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"setMemberTypeCodes",
"(",
")",
"(",
"nsuri",
",",
"typeName",
")",
"=",
"self",
".",
"checkname",
"(",
"elt",
",",
"ps",
")",
"#if (nsuri,typeName) not i... | attempt to parse sequentially. No way to know ahead of time
what this instance represents. Must be simple type so it can
not have attributes nor children, so this isn't too bad. | [
"attempt",
"to",
"parse",
"sequentially",
".",
"No",
"way",
"to",
"know",
"ahead",
"of",
"time",
"what",
"this",
"instance",
"represents",
".",
"Must",
"be",
"simple",
"type",
"so",
"it",
"can",
"not",
"have",
"attributes",
"nor",
"children",
"so",
"this",... | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1540-L1570 |
244,614 | rameshg87/pyremotevbox | pyremotevbox/ZSI/TC.py | List.text_to_data | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data. items in
list are space separated.
'''
v = []
items = text.split()
for item in items:
v.append(self.itemTypeCode.text_to_data(item, elt, ps))
if self.pyclass is not N... | python | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data. items in
list are space separated.
'''
v = []
items = text.split()
for item in items:
v.append(self.itemTypeCode.text_to_data(item, elt, ps))
if self.pyclass is not N... | [
"def",
"text_to_data",
"(",
"self",
",",
"text",
",",
"elt",
",",
"ps",
")",
":",
"v",
"=",
"[",
"]",
"items",
"=",
"text",
".",
"split",
"(",
")",
"for",
"item",
"in",
"items",
":",
"v",
".",
"append",
"(",
"self",
".",
"itemTypeCode",
".",
"t... | convert text into typecode specific data. items in
list are space separated. | [
"convert",
"text",
"into",
"typecode",
"specific",
"data",
".",
"items",
"in",
"list",
"are",
"space",
"separated",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1636-L1647 |
244,615 | nefarioustim/parker | parker/workers.py | consumer | def consumer(site, uri):
"""Consume URI using site config."""
config = load_site_config(site)
model = _get_model('consume', config, uri)
consumestore = get_consumestore(
model=model,
method=_config.get('storage', 'file'),
bucket=_config.get('s3_data_bucket', None)
)
consu... | python | def consumer(site, uri):
"""Consume URI using site config."""
config = load_site_config(site)
model = _get_model('consume', config, uri)
consumestore = get_consumestore(
model=model,
method=_config.get('storage', 'file'),
bucket=_config.get('s3_data_bucket', None)
)
consu... | [
"def",
"consumer",
"(",
"site",
",",
"uri",
")",
":",
"config",
"=",
"load_site_config",
"(",
"site",
")",
"model",
"=",
"_get_model",
"(",
"'consume'",
",",
"config",
",",
"uri",
")",
"consumestore",
"=",
"get_consumestore",
"(",
"model",
"=",
"model",
... | Consume URI using site config. | [
"Consume",
"URI",
"using",
"site",
"config",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L21-L31 |
244,616 | nefarioustim/parker | parker/workers.py | crawler | def crawler(site, uri=None):
"""Crawl URI using site config."""
config = load_site_config(site)
model = _get_model('crawl', config, uri)
visited_set, visited_uri_set, consume_set, crawl_set = get_site_sets(
site, config
)
if not visited_set.has(model.hash):
visited_set.add(model... | python | def crawler(site, uri=None):
"""Crawl URI using site config."""
config = load_site_config(site)
model = _get_model('crawl', config, uri)
visited_set, visited_uri_set, consume_set, crawl_set = get_site_sets(
site, config
)
if not visited_set.has(model.hash):
visited_set.add(model... | [
"def",
"crawler",
"(",
"site",
",",
"uri",
"=",
"None",
")",
":",
"config",
"=",
"load_site_config",
"(",
"site",
")",
"model",
"=",
"_get_model",
"(",
"'crawl'",
",",
"config",
",",
"uri",
")",
"visited_set",
",",
"visited_uri_set",
",",
"consume_set",
... | Crawl URI using site config. | [
"Crawl",
"URI",
"using",
"site",
"config",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L34-L67 |
244,617 | nefarioustim/parker | parker/workers.py | killer | def killer(site):
"""Kill queues and Redis sets."""
config = load_site_config(site)
crawl_q.empty()
consume_q.empty()
for site_set in get_site_sets(site, config):
site_set.destroy() | python | def killer(site):
"""Kill queues and Redis sets."""
config = load_site_config(site)
crawl_q.empty()
consume_q.empty()
for site_set in get_site_sets(site, config):
site_set.destroy() | [
"def",
"killer",
"(",
"site",
")",
":",
"config",
"=",
"load_site_config",
"(",
"site",
")",
"crawl_q",
".",
"empty",
"(",
")",
"consume_q",
".",
"empty",
"(",
")",
"for",
"site_set",
"in",
"get_site_sets",
"(",
"site",
",",
"config",
")",
":",
"site_s... | Kill queues and Redis sets. | [
"Kill",
"queues",
"and",
"Redis",
"sets",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L70-L77 |
244,618 | rameshg87/pyremotevbox | pyremotevbox/ZSI/auth.py | ClientBinding.GetAuth | def GetAuth(self):
'''Return a tuple containing client authentication data.
'''
if self.auth: return self.auth
for elt in self.ps.GetMyHeaderElements():
if elt.localName == 'BasicAuth' \
and elt.namespaceURI == ZSI_SCHEMA_URI:
d = _auth_tc.parse(el... | python | def GetAuth(self):
'''Return a tuple containing client authentication data.
'''
if self.auth: return self.auth
for elt in self.ps.GetMyHeaderElements():
if elt.localName == 'BasicAuth' \
and elt.namespaceURI == ZSI_SCHEMA_URI:
d = _auth_tc.parse(el... | [
"def",
"GetAuth",
"(",
"self",
")",
":",
"if",
"self",
".",
"auth",
":",
"return",
"self",
".",
"auth",
"for",
"elt",
"in",
"self",
".",
"ps",
".",
"GetMyHeaderElements",
"(",
")",
":",
"if",
"elt",
".",
"localName",
"==",
"'BasicAuth'",
"and",
"elt"... | Return a tuple containing client authentication data. | [
"Return",
"a",
"tuple",
"containing",
"client",
"authentication",
"data",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/auth.py#L35-L53 |
244,619 | emory-libraries/eulcommon | eulcommon/djangoextras/auth/decorators.py | permission_required_with_403 | def permission_required_with_403(perm, login_url=None):
"""
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the login page or rendering a 403 as necessary.
See :meth:`django.contrib.auth.decorators.permission_required`.
"""
return user_passes_t... | python | def permission_required_with_403(perm, login_url=None):
"""
Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the login page or rendering a 403 as necessary.
See :meth:`django.contrib.auth.decorators.permission_required`.
"""
return user_passes_t... | [
"def",
"permission_required_with_403",
"(",
"perm",
",",
"login_url",
"=",
"None",
")",
":",
"return",
"user_passes_test_with_403",
"(",
"lambda",
"u",
":",
"u",
".",
"has_perm",
"(",
"perm",
")",
",",
"login_url",
"=",
"login_url",
")"
] | Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the login page or rendering a 403 as necessary.
See :meth:`django.contrib.auth.decorators.permission_required`. | [
"Decorator",
"for",
"views",
"that",
"checks",
"whether",
"a",
"user",
"has",
"a",
"particular",
"permission",
"enabled",
"redirecting",
"to",
"the",
"login",
"page",
"or",
"rendering",
"a",
"403",
"as",
"necessary",
"."
] | dc63a9b3b5e38205178235e0d716d1b28158d3a9 | https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/auth/decorators.py#L52-L59 |
244,620 | callowayproject/Transmogrify | transmogrify/optimize.py | convert_to_rgb | def convert_to_rgb(img):
"""
Convert an image to RGB if it isn't already RGB or grayscale
"""
if img.mode == 'CMYK' and HAS_PROFILE_TO_PROFILE:
profile_dir = os.path.join(os.path.dirname(__file__), 'profiles')
input_profile = os.path.join(profile_dir, "USWebUncoated.icc")
output_... | python | def convert_to_rgb(img):
"""
Convert an image to RGB if it isn't already RGB or grayscale
"""
if img.mode == 'CMYK' and HAS_PROFILE_TO_PROFILE:
profile_dir = os.path.join(os.path.dirname(__file__), 'profiles')
input_profile = os.path.join(profile_dir, "USWebUncoated.icc")
output_... | [
"def",
"convert_to_rgb",
"(",
"img",
")",
":",
"if",
"img",
".",
"mode",
"==",
"'CMYK'",
"and",
"HAS_PROFILE_TO_PROFILE",
":",
"profile_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'prof... | Convert an image to RGB if it isn't already RGB or grayscale | [
"Convert",
"an",
"image",
"to",
"RGB",
"if",
"it",
"isn",
"t",
"already",
"RGB",
"or",
"grayscale"
] | f1f891b8b923b3a1ede5eac7f60531c1c472379e | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/optimize.py#L20-L29 |
244,621 | callowayproject/Transmogrify | transmogrify/optimize.py | optimize | def optimize(image, fmt='jpeg', quality=80):
"""
Optimize the image if the IMAGE_OPTIMIZATION_CMD is set.
IMAGE_OPTIMIZATION_CMD must accept piped input
"""
from io import BytesIO
if IMAGE_OPTIMIZATION_CMD and is_tool(IMAGE_OPTIMIZATION_CMD):
image_buffer = BytesIO()
image.save... | python | def optimize(image, fmt='jpeg', quality=80):
"""
Optimize the image if the IMAGE_OPTIMIZATION_CMD is set.
IMAGE_OPTIMIZATION_CMD must accept piped input
"""
from io import BytesIO
if IMAGE_OPTIMIZATION_CMD and is_tool(IMAGE_OPTIMIZATION_CMD):
image_buffer = BytesIO()
image.save... | [
"def",
"optimize",
"(",
"image",
",",
"fmt",
"=",
"'jpeg'",
",",
"quality",
"=",
"80",
")",
":",
"from",
"io",
"import",
"BytesIO",
"if",
"IMAGE_OPTIMIZATION_CMD",
"and",
"is_tool",
"(",
"IMAGE_OPTIMIZATION_CMD",
")",
":",
"image_buffer",
"=",
"BytesIO",
"("... | Optimize the image if the IMAGE_OPTIMIZATION_CMD is set.
IMAGE_OPTIMIZATION_CMD must accept piped input | [
"Optimize",
"the",
"image",
"if",
"the",
"IMAGE_OPTIMIZATION_CMD",
"is",
"set",
"."
] | f1f891b8b923b3a1ede5eac7f60531c1c472379e | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/optimize.py#L32-L53 |
244,622 | pydsigner/pygu | pygu/pyslim.py | load | def load(filename, default=None):
'''
Try to load @filename. If there is no loader for @filename's filetype,
return @default.
'''
ext = get_ext(filename)
if ext in ldict:
return ldict[ext](filename)
else:
return default | python | def load(filename, default=None):
'''
Try to load @filename. If there is no loader for @filename's filetype,
return @default.
'''
ext = get_ext(filename)
if ext in ldict:
return ldict[ext](filename)
else:
return default | [
"def",
"load",
"(",
"filename",
",",
"default",
"=",
"None",
")",
":",
"ext",
"=",
"get_ext",
"(",
"filename",
")",
"if",
"ext",
"in",
"ldict",
":",
"return",
"ldict",
"[",
"ext",
"]",
"(",
"filename",
")",
"else",
":",
"return",
"default"
] | Try to load @filename. If there is no loader for @filename's filetype,
return @default. | [
"Try",
"to",
"load"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyslim.py#L33-L42 |
244,623 | edwards-lab/MVtest | meanvar/simple_timer.py | SimpleTimer.report | def report(self, msg, do_reset=False, file=sys.stdout):
"""Print to stdout msg followed by the runtime.
When true, do_reset will result in a reset of start time.
"""
print >> file, "%s (%s s)" % (msg, time.time() - self.start)
if do_reset:
self.start = time.time() | python | def report(self, msg, do_reset=False, file=sys.stdout):
"""Print to stdout msg followed by the runtime.
When true, do_reset will result in a reset of start time.
"""
print >> file, "%s (%s s)" % (msg, time.time() - self.start)
if do_reset:
self.start = time.time() | [
"def",
"report",
"(",
"self",
",",
"msg",
",",
"do_reset",
"=",
"False",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"print",
">>",
"file",
",",
"\"%s (%s s)\"",
"%",
"(",
"msg",
",",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"start"... | Print to stdout msg followed by the runtime.
When true, do_reset will result in a reset of start time. | [
"Print",
"to",
"stdout",
"msg",
"followed",
"by",
"the",
"runtime",
"."
] | fe8cf627464ef59d68b7eda628a19840d033882f | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L28-L36 |
244,624 | edwards-lab/MVtest | meanvar/simple_timer.py | SimpleTimer.result | def result(self, msg, do_reset=False):
"""Return log message containing ellapsed time as a string.
When true, do_reset will result in a reset of start time.
"""
result = "%s (%s s)" % (msg, time.time() - self.start)
if do_reset:
self.start = time.time()
retu... | python | def result(self, msg, do_reset=False):
"""Return log message containing ellapsed time as a string.
When true, do_reset will result in a reset of start time.
"""
result = "%s (%s s)" % (msg, time.time() - self.start)
if do_reset:
self.start = time.time()
retu... | [
"def",
"result",
"(",
"self",
",",
"msg",
",",
"do_reset",
"=",
"False",
")",
":",
"result",
"=",
"\"%s (%s s)\"",
"%",
"(",
"msg",
",",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"start",
")",
"if",
"do_reset",
":",
"self",
".",
"start",
"... | Return log message containing ellapsed time as a string.
When true, do_reset will result in a reset of start time. | [
"Return",
"log",
"message",
"containing",
"ellapsed",
"time",
"as",
"a",
"string",
"."
] | fe8cf627464ef59d68b7eda628a19840d033882f | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L38-L47 |
244,625 | edwards-lab/MVtest | meanvar/simple_timer.py | SimpleTimer.runtime | def runtime(self):
"""Return ellapsed time and reset start. """
t = time.time() - self.start
self.start = time.time()
return t | python | def runtime(self):
"""Return ellapsed time and reset start. """
t = time.time() - self.start
self.start = time.time()
return t | [
"def",
"runtime",
"(",
"self",
")",
":",
"t",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"start",
"self",
".",
"start",
"=",
"time",
".",
"time",
"(",
")",
"return",
"t"
] | Return ellapsed time and reset start. | [
"Return",
"ellapsed",
"time",
"and",
"reset",
"start",
"."
] | fe8cf627464ef59d68b7eda628a19840d033882f | https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L54-L58 |
244,626 | delfick/aws_syncr | aws_syncr/option_spec/apigateway.py | Gateways.sync_one | def sync_one(self, aws_syncr, amazon, gateway):
"""Make sure this gateway exists and has only attributes we want it to have"""
gateway_info = amazon.apigateway.gateway_info(gateway.name, gateway.location)
if not gateway_info:
amazon.apigateway.create_gateway(gateway.name, gateway.loc... | python | def sync_one(self, aws_syncr, amazon, gateway):
"""Make sure this gateway exists and has only attributes we want it to have"""
gateway_info = amazon.apigateway.gateway_info(gateway.name, gateway.location)
if not gateway_info:
amazon.apigateway.create_gateway(gateway.name, gateway.loc... | [
"def",
"sync_one",
"(",
"self",
",",
"aws_syncr",
",",
"amazon",
",",
"gateway",
")",
":",
"gateway_info",
"=",
"amazon",
".",
"apigateway",
".",
"gateway_info",
"(",
"gateway",
".",
"name",
",",
"gateway",
".",
"location",
")",
"if",
"not",
"gateway_info"... | Make sure this gateway exists and has only attributes we want it to have | [
"Make",
"sure",
"this",
"gateway",
"exists",
"and",
"has",
"only",
"attributes",
"we",
"want",
"it",
"to",
"have"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/apigateway.py#L362-L368 |
244,627 | fizyk/pyramid_yml | tzf/pyramid_yml/__init__.py | includeme | def includeme(configurator):
"""
Add yaml configuration utilities.
:param pyramid.config.Configurator configurator: pyramid's app configurator
"""
settings = configurator.registry.settings
# lets default it to running path
yaml_locations = settings.get('yaml.location',
... | python | def includeme(configurator):
"""
Add yaml configuration utilities.
:param pyramid.config.Configurator configurator: pyramid's app configurator
"""
settings = configurator.registry.settings
# lets default it to running path
yaml_locations = settings.get('yaml.location',
... | [
"def",
"includeme",
"(",
"configurator",
")",
":",
"settings",
"=",
"configurator",
".",
"registry",
".",
"settings",
"# lets default it to running path",
"yaml_locations",
"=",
"settings",
".",
"get",
"(",
"'yaml.location'",
",",
"settings",
".",
"get",
"(",
"'ym... | Add yaml configuration utilities.
:param pyramid.config.Configurator configurator: pyramid's app configurator | [
"Add",
"yaml",
"configuration",
"utilities",
"."
] | 1b36c4e74194c04d7d69b4d7f86801757e78f0a6 | https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L21-L55 |
244,628 | fizyk/pyramid_yml | tzf/pyramid_yml/__init__.py | _translate_config_path | def _translate_config_path(location):
"""
Translate location into fullpath according asset specification.
Might be package:path for package related paths, or simply path
:param str location: resource location
:returns: fullpath
:rtype: str
"""
# getting spec path
package_name, fil... | python | def _translate_config_path(location):
"""
Translate location into fullpath according asset specification.
Might be package:path for package related paths, or simply path
:param str location: resource location
:returns: fullpath
:rtype: str
"""
# getting spec path
package_name, fil... | [
"def",
"_translate_config_path",
"(",
"location",
")",
":",
"# getting spec path",
"package_name",
",",
"filename",
"=",
"resolve_asset_spec",
"(",
"location",
".",
"strip",
"(",
")",
")",
"if",
"not",
"package_name",
":",
"path",
"=",
"filename",
"else",
":",
... | Translate location into fullpath according asset specification.
Might be package:path for package related paths, or simply path
:param str location: resource location
:returns: fullpath
:rtype: str | [
"Translate",
"location",
"into",
"fullpath",
"according",
"asset",
"specification",
"."
] | 1b36c4e74194c04d7d69b4d7f86801757e78f0a6 | https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L105-L124 |
244,629 | fizyk/pyramid_yml | tzf/pyramid_yml/__init__.py | _env_filenames | def _env_filenames(filenames, env):
"""
Extend filenames with ennv indication of environments.
:param list filenames: list of strings indicating filenames
:param str env: environment indicator
:returns: list of filenames extended with environment version
:rtype: list
"""
env_filenames ... | python | def _env_filenames(filenames, env):
"""
Extend filenames with ennv indication of environments.
:param list filenames: list of strings indicating filenames
:param str env: environment indicator
:returns: list of filenames extended with environment version
:rtype: list
"""
env_filenames ... | [
"def",
"_env_filenames",
"(",
"filenames",
",",
"env",
")",
":",
"env_filenames",
"=",
"[",
"]",
"for",
"filename",
"in",
"filenames",
":",
"filename_parts",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
"filename_parts",
".",
"insert",
"(",
"1",
",",
... | Extend filenames with ennv indication of environments.
:param list filenames: list of strings indicating filenames
:param str env: environment indicator
:returns: list of filenames extended with environment version
:rtype: list | [
"Extend",
"filenames",
"with",
"ennv",
"indication",
"of",
"environments",
"."
] | 1b36c4e74194c04d7d69b4d7f86801757e78f0a6 | https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L127-L143 |
244,630 | fizyk/pyramid_yml | tzf/pyramid_yml/__init__.py | _extend_settings | def _extend_settings(settings, configurator_config, prefix=None):
"""
Extend settings dictionary with content of yaml's configurator key.
.. note::
This methods changes multilayered subkeys defined
within **configurator** into dotted keys in settings dictionary:
.. code-block:: y... | python | def _extend_settings(settings, configurator_config, prefix=None):
"""
Extend settings dictionary with content of yaml's configurator key.
.. note::
This methods changes multilayered subkeys defined
within **configurator** into dotted keys in settings dictionary:
.. code-block:: y... | [
"def",
"_extend_settings",
"(",
"settings",
",",
"configurator_config",
",",
"prefix",
"=",
"None",
")",
":",
"for",
"key",
"in",
"configurator_config",
":",
"settings_key",
"=",
"'.'",
".",
"join",
"(",
"[",
"prefix",
",",
"key",
"]",
")",
"if",
"prefix",... | Extend settings dictionary with content of yaml's configurator key.
.. note::
This methods changes multilayered subkeys defined
within **configurator** into dotted keys in settings dictionary:
.. code-block:: yaml
configurator:
sqlalchemy:
... | [
"Extend",
"settings",
"dictionary",
"with",
"content",
"of",
"yaml",
"s",
"configurator",
"key",
"."
] | 1b36c4e74194c04d7d69b4d7f86801757e78f0a6 | https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L146-L177 |
244,631 | nefarioustim/parker | parker/page.py | get_instance | def get_instance(uri):
"""Return an instance of Page."""
global _instances
try:
instance = _instances[uri]
except KeyError:
instance = Page(
uri,
client.get_instance()
)
_instances[uri] = instance
return instance | python | def get_instance(uri):
"""Return an instance of Page."""
global _instances
try:
instance = _instances[uri]
except KeyError:
instance = Page(
uri,
client.get_instance()
)
_instances[uri] = instance
return instance | [
"def",
"get_instance",
"(",
"uri",
")",
":",
"global",
"_instances",
"try",
":",
"instance",
"=",
"_instances",
"[",
"uri",
"]",
"except",
"KeyError",
":",
"instance",
"=",
"Page",
"(",
"uri",
",",
"client",
".",
"get_instance",
"(",
")",
")",
"_instance... | Return an instance of Page. | [
"Return",
"an",
"instance",
"of",
"Page",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/page.py#L10-L22 |
244,632 | nefarioustim/parker | parker/page.py | Page.fetch | def fetch(self):
"""Fetch Page.content from client."""
self.content = self.client.get_content(
uri=self.uri
)
self.hash = hashlib.sha256(
self.content
).hexdigest() | python | def fetch(self):
"""Fetch Page.content from client."""
self.content = self.client.get_content(
uri=self.uri
)
self.hash = hashlib.sha256(
self.content
).hexdigest() | [
"def",
"fetch",
"(",
"self",
")",
":",
"self",
".",
"content",
"=",
"self",
".",
"client",
".",
"get_content",
"(",
"uri",
"=",
"self",
".",
"uri",
")",
"self",
".",
"hash",
"=",
"hashlib",
".",
"sha256",
"(",
"self",
".",
"content",
")",
".",
"h... | Fetch Page.content from client. | [
"Fetch",
"Page",
".",
"content",
"from",
"client",
"."
] | ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6 | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/page.py#L39-L46 |
244,633 | pydsigner/pygu | pygu/pyramid.py | Resources.load_objects | def load_objects(self, dirs=[], callwith={}):
'''
Call this to load resources from each dir in @dirs. Code resources will
receive @callwith as an argument.
'''
for d in dirs:
contents = ls(d)
for t in contents:
first = join(d, t)
... | python | def load_objects(self, dirs=[], callwith={}):
'''
Call this to load resources from each dir in @dirs. Code resources will
receive @callwith as an argument.
'''
for d in dirs:
contents = ls(d)
for t in contents:
first = join(d, t)
... | [
"def",
"load_objects",
"(",
"self",
",",
"dirs",
"=",
"[",
"]",
",",
"callwith",
"=",
"{",
"}",
")",
":",
"for",
"d",
"in",
"dirs",
":",
"contents",
"=",
"ls",
"(",
"d",
")",
"for",
"t",
"in",
"contents",
":",
"first",
"=",
"join",
"(",
"d",
... | Call this to load resources from each dir in @dirs. Code resources will
receive @callwith as an argument. | [
"Call",
"this",
"to",
"load",
"resources",
"from",
"each",
"dir",
"in"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L215-L242 |
244,634 | pydsigner/pygu | pygu/pyramid.py | Resources.set_music | def set_music(self, plylst, force=False):
'''
Use to set the playlist to @plylst. If @force is False, the playlist
will not be set if it is @plylst already.
'''
plylst = plylst.lower()
if plylst != self.cur_playlist or force:
self.cur_playlist = plylst
... | python | def set_music(self, plylst, force=False):
'''
Use to set the playlist to @plylst. If @force is False, the playlist
will not be set if it is @plylst already.
'''
plylst = plylst.lower()
if plylst != self.cur_playlist or force:
self.cur_playlist = plylst
... | [
"def",
"set_music",
"(",
"self",
",",
"plylst",
",",
"force",
"=",
"False",
")",
":",
"plylst",
"=",
"plylst",
".",
"lower",
"(",
")",
"if",
"plylst",
"!=",
"self",
".",
"cur_playlist",
"or",
"force",
":",
"self",
".",
"cur_playlist",
"=",
"plylst",
... | Use to set the playlist to @plylst. If @force is False, the playlist
will not be set if it is @plylst already. | [
"Use",
"to",
"set",
"the",
"playlist",
"to"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L248-L256 |
244,635 | pydsigner/pygu | pygu/pyramid.py | Resources.set_m_vol | def set_m_vol(self, vol=None, relative=False):
'''
Set the music volume. If @vol != None, It will be changed to it (or by
it, if @relative is True.)
'''
if vol != None:
if relative:
vol += self.m_vol
self.m_vol = min(max(vol, 0), 1)
... | python | def set_m_vol(self, vol=None, relative=False):
'''
Set the music volume. If @vol != None, It will be changed to it (or by
it, if @relative is True.)
'''
if vol != None:
if relative:
vol += self.m_vol
self.m_vol = min(max(vol, 0), 1)
... | [
"def",
"set_m_vol",
"(",
"self",
",",
"vol",
"=",
"None",
",",
"relative",
"=",
"False",
")",
":",
"if",
"vol",
"!=",
"None",
":",
"if",
"relative",
":",
"vol",
"+=",
"self",
".",
"m_vol",
"self",
".",
"m_vol",
"=",
"min",
"(",
"max",
"(",
"vol",... | Set the music volume. If @vol != None, It will be changed to it (or by
it, if @relative is True.) | [
"Set",
"the",
"music",
"volume",
".",
"If"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L274-L283 |
244,636 | pydsigner/pygu | pygu/pyramid.py | Resources.set_s_vol | def set_s_vol(self, vol=None, relative=False):
'''
Set the volume of all sounds. If @vol != None, It will be changed to
it (or by it, if @relative is True.)
'''
if vol != None:
if relative:
vol += self.s_vol
self.s_vol = min(max(vol, 0), 1... | python | def set_s_vol(self, vol=None, relative=False):
'''
Set the volume of all sounds. If @vol != None, It will be changed to
it (or by it, if @relative is True.)
'''
if vol != None:
if relative:
vol += self.s_vol
self.s_vol = min(max(vol, 0), 1... | [
"def",
"set_s_vol",
"(",
"self",
",",
"vol",
"=",
"None",
",",
"relative",
"=",
"False",
")",
":",
"if",
"vol",
"!=",
"None",
":",
"if",
"relative",
":",
"vol",
"+=",
"self",
".",
"s_vol",
"self",
".",
"s_vol",
"=",
"min",
"(",
"max",
"(",
"vol",... | Set the volume of all sounds. If @vol != None, It will be changed to
it (or by it, if @relative is True.) | [
"Set",
"the",
"volume",
"of",
"all",
"sounds",
".",
"If"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L285-L296 |
244,637 | pydsigner/pygu | pygu/pyramid.py | Resources.get_channel | def get_channel(self):
'''
Used internally when playing sounds.
'''
c = pygame.mixer.find_channel(not self.dynamic)
while c is None:
self.channels += 1
pygame.mixer.set_num_channels(self.channels)
c = pygame.mixer.find_channel()
return ... | python | def get_channel(self):
'''
Used internally when playing sounds.
'''
c = pygame.mixer.find_channel(not self.dynamic)
while c is None:
self.channels += 1
pygame.mixer.set_num_channels(self.channels)
c = pygame.mixer.find_channel()
return ... | [
"def",
"get_channel",
"(",
"self",
")",
":",
"c",
"=",
"pygame",
".",
"mixer",
".",
"find_channel",
"(",
"not",
"self",
".",
"dynamic",
")",
"while",
"c",
"is",
"None",
":",
"self",
".",
"channels",
"+=",
"1",
"pygame",
".",
"mixer",
".",
"set_num_ch... | Used internally when playing sounds. | [
"Used",
"internally",
"when",
"playing",
"sounds",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L316-L325 |
244,638 | pydsigner/pygu | pygu/pyramid.py | EventManager.event | def event(self, utype, **kw):
'''
Make a meta-event with a utype of @type. **@kw works the same as for
pygame.event.Event().
'''
d = {'utype': utype}
d.update(kw)
pygame.event.post(pygame.event.Event(METAEVENT, d)) | python | def event(self, utype, **kw):
'''
Make a meta-event with a utype of @type. **@kw works the same as for
pygame.event.Event().
'''
d = {'utype': utype}
d.update(kw)
pygame.event.post(pygame.event.Event(METAEVENT, d)) | [
"def",
"event",
"(",
"self",
",",
"utype",
",",
"*",
"*",
"kw",
")",
":",
"d",
"=",
"{",
"'utype'",
":",
"utype",
"}",
"d",
".",
"update",
"(",
"kw",
")",
"pygame",
".",
"event",
".",
"post",
"(",
"pygame",
".",
"event",
".",
"Event",
"(",
"M... | Make a meta-event with a utype of @type. **@kw works the same as for
pygame.event.Event(). | [
"Make",
"a",
"meta",
"-",
"event",
"with",
"a",
"utype",
"of"
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L431-L438 |
244,639 | pydsigner/pygu | pygu/pyramid.py | EventManager.loop | def loop(self, events=[]):
'''
Run the loop.
'''
try:
for e in events:
if e.type == METAEVENT:
e = self.MetaEvent(e)
for func in self.event_funcs.get(e.type, []):
func(self, self.gstate, e)
except... | python | def loop(self, events=[]):
'''
Run the loop.
'''
try:
for e in events:
if e.type == METAEVENT:
e = self.MetaEvent(e)
for func in self.event_funcs.get(e.type, []):
func(self, self.gstate, e)
except... | [
"def",
"loop",
"(",
"self",
",",
"events",
"=",
"[",
"]",
")",
":",
"try",
":",
"for",
"e",
"in",
"events",
":",
"if",
"e",
".",
"type",
"==",
"METAEVENT",
":",
"e",
"=",
"self",
".",
"MetaEvent",
"(",
"e",
")",
"for",
"func",
"in",
"self",
"... | Run the loop. | [
"Run",
"the",
"loop",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L442-L453 |
244,640 | johnwlockwood/cooperative | cooperative/__init__.py | accumulate | def accumulate(a_generator, cooperator=None):
"""
Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator.
:param a_generator: An iterator which yields some not None values.
:return: A Deferred to which the next callback will be called with
the... | python | def accumulate(a_generator, cooperator=None):
"""
Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator.
:param a_generator: An iterator which yields some not None values.
:return: A Deferred to which the next callback will be called with
the... | [
"def",
"accumulate",
"(",
"a_generator",
",",
"cooperator",
"=",
"None",
")",
":",
"if",
"cooperator",
":",
"own_cooperate",
"=",
"cooperator",
".",
"cooperate",
"else",
":",
"own_cooperate",
"=",
"cooperate",
"spigot",
"=",
"ValueBucket",
"(",
")",
"items",
... | Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator.
:param a_generator: An iterator which yields some not None values.
:return: A Deferred to which the next callback will be called with
the yielded contents of the generator function. | [
"Start",
"a",
"Deferred",
"whose",
"callBack",
"arg",
"is",
"a",
"deque",
"of",
"the",
"accumulation",
"of",
"the",
"values",
"yielded",
"from",
"a_generator",
"."
] | bec25451a6d2b06260be809b72cfd6287c75da39 | https://github.com/johnwlockwood/cooperative/blob/bec25451a6d2b06260be809b72cfd6287c75da39/cooperative/__init__.py#L59-L77 |
244,641 | johnwlockwood/cooperative | cooperative/__init__.py | batch_accumulate | def batch_accumulate(max_batch_size, a_generator, cooperator=None):
"""
Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator which is iterated over
in batches the size of max_batch_size.
It should be more efficient to iterate over the generator i... | python | def batch_accumulate(max_batch_size, a_generator, cooperator=None):
"""
Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator which is iterated over
in batches the size of max_batch_size.
It should be more efficient to iterate over the generator i... | [
"def",
"batch_accumulate",
"(",
"max_batch_size",
",",
"a_generator",
",",
"cooperator",
"=",
"None",
")",
":",
"if",
"cooperator",
":",
"own_cooperate",
"=",
"cooperator",
".",
"cooperate",
"else",
":",
"own_cooperate",
"=",
"cooperate",
"spigot",
"=",
"ValueBu... | Start a Deferred whose callBack arg is a deque of the accumulation
of the values yielded from a_generator which is iterated over
in batches the size of max_batch_size.
It should be more efficient to iterate over the generator in
batches and still provide enough speed for non-blocking execution.
:... | [
"Start",
"a",
"Deferred",
"whose",
"callBack",
"arg",
"is",
"a",
"deque",
"of",
"the",
"accumulation",
"of",
"the",
"values",
"yielded",
"from",
"a_generator",
"which",
"is",
"iterated",
"over",
"in",
"batches",
"the",
"size",
"of",
"max_batch_size",
"."
] | bec25451a6d2b06260be809b72cfd6287c75da39 | https://github.com/johnwlockwood/cooperative/blob/bec25451a6d2b06260be809b72cfd6287c75da39/cooperative/__init__.py#L80-L105 |
244,642 | alexpearce/jobmonitor | jobmonitor/start_worker.py | create_connection | def create_connection():
"""Return a redis.Redis instance connected to REDIS_URL."""
# REDIS_URL is defined in .env and loaded into the environment by Honcho
redis_url = os.getenv('REDIS_URL')
# If it's not defined, use the Redis default
if not redis_url:
redis_url = 'redis://localhost:6379'... | python | def create_connection():
"""Return a redis.Redis instance connected to REDIS_URL."""
# REDIS_URL is defined in .env and loaded into the environment by Honcho
redis_url = os.getenv('REDIS_URL')
# If it's not defined, use the Redis default
if not redis_url:
redis_url = 'redis://localhost:6379'... | [
"def",
"create_connection",
"(",
")",
":",
"# REDIS_URL is defined in .env and loaded into the environment by Honcho",
"redis_url",
"=",
"os",
".",
"getenv",
"(",
"'REDIS_URL'",
")",
"# If it's not defined, use the Redis default",
"if",
"not",
"redis_url",
":",
"redis_url",
"... | Return a redis.Redis instance connected to REDIS_URL. | [
"Return",
"a",
"redis",
".",
"Redis",
"instance",
"connected",
"to",
"REDIS_URL",
"."
] | c08955ed3c357b2b3518aa0853b43bc237bc0814 | https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/start_worker.py#L16-L30 |
244,643 | alexpearce/jobmonitor | jobmonitor/start_worker.py | work | def work():
"""Start an rq worker on the connection provided by create_connection."""
with rq.Connection(create_connection()):
worker = rq.Worker(list(map(rq.Queue, listen)))
worker.work() | python | def work():
"""Start an rq worker on the connection provided by create_connection."""
with rq.Connection(create_connection()):
worker = rq.Worker(list(map(rq.Queue, listen)))
worker.work() | [
"def",
"work",
"(",
")",
":",
"with",
"rq",
".",
"Connection",
"(",
"create_connection",
"(",
")",
")",
":",
"worker",
"=",
"rq",
".",
"Worker",
"(",
"list",
"(",
"map",
"(",
"rq",
".",
"Queue",
",",
"listen",
")",
")",
")",
"worker",
".",
"work"... | Start an rq worker on the connection provided by create_connection. | [
"Start",
"an",
"rq",
"worker",
"on",
"the",
"connection",
"provided",
"by",
"create_connection",
"."
] | c08955ed3c357b2b3518aa0853b43bc237bc0814 | https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/start_worker.py#L33-L37 |
244,644 | pydsigner/pygu | pygu/pms.py | Playlist._gen_shuffles | def _gen_shuffles(self):
'''
Used internally to build a list for mapping between a random number and
a song index.
'''
# The current metasong index
si = 0
# The shuffle mapper list
self.shuffles = []
# Go through all our songs...
for song... | python | def _gen_shuffles(self):
'''
Used internally to build a list for mapping between a random number and
a song index.
'''
# The current metasong index
si = 0
# The shuffle mapper list
self.shuffles = []
# Go through all our songs...
for song... | [
"def",
"_gen_shuffles",
"(",
"self",
")",
":",
"# The current metasong index ",
"si",
"=",
"0",
"# The shuffle mapper list",
"self",
".",
"shuffles",
"=",
"[",
"]",
"# Go through all our songs...",
"for",
"song",
"in",
"self",
".",
"loop",
":",
"# And add them to th... | Used internally to build a list for mapping between a random number and
a song index. | [
"Used",
"internally",
"to",
"build",
"a",
"list",
"for",
"mapping",
"between",
"a",
"random",
"number",
"and",
"a",
"song",
"index",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L109-L123 |
244,645 | pydsigner/pygu | pygu/pms.py | Playlist._new_song | def _new_song(self):
'''
Used internally to get a metasong index.
'''
# We'll need this later
s = self.song
if self.shuffle:
# If shuffle is on, we need to (1) get a random song that
# (2) accounts for weighting. This line does both.
... | python | def _new_song(self):
'''
Used internally to get a metasong index.
'''
# We'll need this later
s = self.song
if self.shuffle:
# If shuffle is on, we need to (1) get a random song that
# (2) accounts for weighting. This line does both.
... | [
"def",
"_new_song",
"(",
"self",
")",
":",
"# We'll need this later",
"s",
"=",
"self",
".",
"song",
"if",
"self",
".",
"shuffle",
":",
"# If shuffle is on, we need to (1) get a random song that ",
"# (2) accounts for weighting. This line does both.",
"self",
".",
"song",
... | Used internally to get a metasong index. | [
"Used",
"internally",
"to",
"get",
"a",
"metasong",
"index",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L125-L146 |
244,646 | pydsigner/pygu | pygu/pms.py | Playlist._get_selectable | def _get_selectable(self):
'''
Used internally to get a group of choosable tracks.
'''
# Save some typing
cursong = self.loop[self.song][0]
if self.dif_song and len(cursong) > 1:
# Position is relative to the intro of the track,
# so we we... | python | def _get_selectable(self):
'''
Used internally to get a group of choosable tracks.
'''
# Save some typing
cursong = self.loop[self.song][0]
if self.dif_song and len(cursong) > 1:
# Position is relative to the intro of the track,
# so we we... | [
"def",
"_get_selectable",
"(",
"self",
")",
":",
"# Save some typing",
"cursong",
"=",
"self",
".",
"loop",
"[",
"self",
".",
"song",
"]",
"[",
"0",
"]",
"if",
"self",
".",
"dif_song",
"and",
"len",
"(",
"cursong",
")",
">",
"1",
":",
"# Position is re... | Used internally to get a group of choosable tracks. | [
"Used",
"internally",
"to",
"get",
"a",
"group",
"of",
"choosable",
"tracks",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L148-L163 |
244,647 | pydsigner/pygu | pygu/pms.py | Playlist._get_song | def _get_song(self):
'''
Used internally to get the current track and make sure it exists.
'''
# Try to get the current track from the start metasong
if self.at_beginning:
# Make sure it exists.
if self.pos < len(self.start):
# It exists, s... | python | def _get_song(self):
'''
Used internally to get the current track and make sure it exists.
'''
# Try to get the current track from the start metasong
if self.at_beginning:
# Make sure it exists.
if self.pos < len(self.start):
# It exists, s... | [
"def",
"_get_song",
"(",
"self",
")",
":",
"# Try to get the current track from the start metasong",
"if",
"self",
".",
"at_beginning",
":",
"# Make sure it exists.",
"if",
"self",
".",
"pos",
"<",
"len",
"(",
"self",
".",
"start",
")",
":",
"# It exists, so return ... | Used internally to get the current track and make sure it exists. | [
"Used",
"internally",
"to",
"get",
"the",
"current",
"track",
"and",
"make",
"sure",
"it",
"exists",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L165-L190 |
244,648 | pydsigner/pygu | pygu/pms.py | Playlist.begin | def begin(self):
'''
Start over and get a track.
'''
# Check for a start metasong
if self.start:
# We are in the beginning song
self.at_beginning = True
# And on the first track.
self.pos = 0
else:
# We aren't in... | python | def begin(self):
'''
Start over and get a track.
'''
# Check for a start metasong
if self.start:
# We are in the beginning song
self.at_beginning = True
# And on the first track.
self.pos = 0
else:
# We aren't in... | [
"def",
"begin",
"(",
"self",
")",
":",
"# Check for a start metasong",
"if",
"self",
".",
"start",
":",
"# We are in the beginning song",
"self",
".",
"at_beginning",
"=",
"True",
"# And on the first track.",
"self",
".",
"pos",
"=",
"0",
"else",
":",
"# We aren't... | Start over and get a track. | [
"Start",
"over",
"and",
"get",
"a",
"track",
"."
] | 09fe71534900933908ab83db12f5659b7827e31c | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L192-L207 |
244,649 | Nixiware/viper | nx/viper/service/mysql.py | Service._applicationStart | def _applicationStart(self, data):
"""
Initializes the database connection pool.
:param data: <object> event data object
:return: <void>
"""
checkup = False
if "viper.mysql" in self.application.config \
and isinstance(self.application.config["vipe... | python | def _applicationStart(self, data):
"""
Initializes the database connection pool.
:param data: <object> event data object
:return: <void>
"""
checkup = False
if "viper.mysql" in self.application.config \
and isinstance(self.application.config["vipe... | [
"def",
"_applicationStart",
"(",
"self",
",",
"data",
")",
":",
"checkup",
"=",
"False",
"if",
"\"viper.mysql\"",
"in",
"self",
".",
"application",
".",
"config",
"and",
"isinstance",
"(",
"self",
".",
"application",
".",
"config",
"[",
"\"viper.mysql\"",
"]... | Initializes the database connection pool.
:param data: <object> event data object
:return: <void> | [
"Initializes",
"the",
"database",
"connection",
"pool",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L27-L82 |
244,650 | Nixiware/viper | nx/viper/service/mysql.py | Service._checkIfDatabaseIsEmpty | def _checkIfDatabaseIsEmpty(self, successHandler=None, failHandler=None):
"""
Check if database contains any tables.
:param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument
is a boolean flag specifying if t... | python | def _checkIfDatabaseIsEmpty(self, successHandler=None, failHandler=None):
"""
Check if database contains any tables.
:param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument
is a boolean flag specifying if t... | [
"def",
"_checkIfDatabaseIsEmpty",
"(",
"self",
",",
"successHandler",
"=",
"None",
",",
"failHandler",
"=",
"None",
")",
":",
"def",
"failCallback",
"(",
"error",
")",
":",
"errorMessage",
"=",
"str",
"(",
"error",
")",
"if",
"isinstance",
"(",
"error",
",... | Check if database contains any tables.
:param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument
is a boolean flag specifying if the database is empty or not
:param failHandler: <function(<str>)> method called if int... | [
"Check",
"if",
"database",
"contains",
"any",
"tables",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L84-L125 |
244,651 | Nixiware/viper | nx/viper/service/mysql.py | Service._initDatabase | def _initDatabase(self):
"""
Initializes the database structure based on application configuration.
:return: <void>
"""
queries = []
if len(self.application.config["viper.mysql"]["init"]["scripts"]) > 0:
for scriptFilePath in self.application.config["viper.m... | python | def _initDatabase(self):
"""
Initializes the database structure based on application configuration.
:return: <void>
"""
queries = []
if len(self.application.config["viper.mysql"]["init"]["scripts"]) > 0:
for scriptFilePath in self.application.config["viper.m... | [
"def",
"_initDatabase",
"(",
"self",
")",
":",
"queries",
"=",
"[",
"]",
"if",
"len",
"(",
"self",
".",
"application",
".",
"config",
"[",
"\"viper.mysql\"",
"]",
"[",
"\"init\"",
"]",
"[",
"\"scripts\"",
"]",
")",
">",
"0",
":",
"for",
"scriptFilePath... | Initializes the database structure based on application configuration.
:return: <void> | [
"Initializes",
"the",
"database",
"structure",
"based",
"on",
"application",
"configuration",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L127-L162 |
244,652 | Nixiware/viper | nx/viper/service/mysql.py | Service.extractFromSQLFile | def extractFromSQLFile(self, filePointer, delimiter=";"):
"""
Process an SQL file and extract all the queries sorted.
:param filePointer: <io.TextIOWrapper> file pointer to SQL file
:return: <list> list of queries
"""
data = filePointer.read()
# reading file and... | python | def extractFromSQLFile(self, filePointer, delimiter=";"):
"""
Process an SQL file and extract all the queries sorted.
:param filePointer: <io.TextIOWrapper> file pointer to SQL file
:return: <list> list of queries
"""
data = filePointer.read()
# reading file and... | [
"def",
"extractFromSQLFile",
"(",
"self",
",",
"filePointer",
",",
"delimiter",
"=",
"\";\"",
")",
":",
"data",
"=",
"filePointer",
".",
"read",
"(",
")",
"# reading file and splitting it into lines",
"dataLines",
"=",
"[",
"]",
"dataLinesIndex",
"=",
"0",
"for"... | Process an SQL file and extract all the queries sorted.
:param filePointer: <io.TextIOWrapper> file pointer to SQL file
:return: <list> list of queries | [
"Process",
"an",
"SQL",
"file",
"and",
"extract",
"all",
"the",
"queries",
"sorted",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L174-L226 |
244,653 | Nixiware/viper | nx/viper/service/mysql.py | Service.runInteraction | def runInteraction(self, interaction, *args, **kwargs):
"""
Interact with the database and return the result.
:param interaction: <function> method with first argument is a <adbapi.Transaction> instance
:param args: additional positional arguments to be passed to interaction
:pa... | python | def runInteraction(self, interaction, *args, **kwargs):
"""
Interact with the database and return the result.
:param interaction: <function> method with first argument is a <adbapi.Transaction> instance
:param args: additional positional arguments to be passed to interaction
:pa... | [
"def",
"runInteraction",
"(",
"self",
",",
"interaction",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"_connectionPool",
".",
"runInteraction",
"(",
"interaction",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | Interact with the database and return the result.
:param interaction: <function> method with first argument is a <adbapi.Transaction> instance
:param args: additional positional arguments to be passed to interaction
:param kwargs: keyword arguments to be passed to interaction
:return: <... | [
"Interact",
"with",
"the",
"database",
"and",
"return",
"the",
"result",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L228-L246 |
244,654 | Nixiware/viper | nx/viper/service/mysql.py | Service.runQuery | def runQuery(self, *args, **kwargs):
"""
Execute an SQL query and return the result.
:param args: additional positional arguments to be passed to cursor execute method
:param kwargs: keyword arguments to be passed to cursor execute method
:return: <defer>
"""
try... | python | def runQuery(self, *args, **kwargs):
"""
Execute an SQL query and return the result.
:param args: additional positional arguments to be passed to cursor execute method
:param kwargs: keyword arguments to be passed to cursor execute method
:return: <defer>
"""
try... | [
"def",
"runQuery",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"self",
".",
"_connectionPool",
".",
"runQuery",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
":",
"d",
"=",
"defer",
".",
"De... | Execute an SQL query and return the result.
:param args: additional positional arguments to be passed to cursor execute method
:param kwargs: keyword arguments to be passed to cursor execute method
:return: <defer> | [
"Execute",
"an",
"SQL",
"query",
"and",
"return",
"the",
"result",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L248-L261 |
244,655 | twidi/py-dataql | dataql/solvers/resources.py | Solver.solve | def solve(self, value, resource):
"""Solve a resource with a value.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the result of the previous
... | python | def solve(self, value, resource):
"""Solve a resource with a value.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the result of the previous
... | [
"def",
"solve",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"result",
"=",
"self",
".",
"solve_value",
"(",
"value",
",",
"resource",
")",
"return",
"self",
".",
"coerce",
"(",
"result",
",",
"resource",
")"
] | Solve a resource with a value.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the result of the previous
filter).
resource : dataql... | [
"Solve",
"a",
"resource",
"with",
"a",
"value",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L80-L110 |
244,656 | twidi/py-dataql | dataql/solvers/resources.py | Solver.solve_value | def solve_value(self, value, resource):
"""Solve a resource with a value, without coercing.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the ... | python | def solve_value(self, value, resource):
"""Solve a resource with a value, without coercing.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the ... | [
"def",
"solve_value",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"# The given value is the starting point on which we apply the first filter.",
"result",
"=",
"value",
"# Apply filters one by one on the previous result.",
"if",
"result",
"is",
"not",
"None",
":",
... | Solve a resource with a value, without coercing.
Arguments
---------
value : ?
A value to solve in combination with the given resource. The first filter of the
resource will be applied on this value (next filters on the result of the previous
filter).
... | [
"Solve",
"a",
"resource",
"with",
"a",
"value",
"without",
"coercing",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L112-L192 |
244,657 | twidi/py-dataql | dataql/solvers/resources.py | Solver.can_solve | def can_solve(cls, resource):
"""Tells if the solver is able to resolve the given resource.
Arguments
---------
resource : subclass of ``dataql.resources.Resource``
The resource to check if it is solvable by the current solver class
Returns
-------
b... | python | def can_solve(cls, resource):
"""Tells if the solver is able to resolve the given resource.
Arguments
---------
resource : subclass of ``dataql.resources.Resource``
The resource to check if it is solvable by the current solver class
Returns
-------
b... | [
"def",
"can_solve",
"(",
"cls",
",",
"resource",
")",
":",
"for",
"solvable_resource",
"in",
"cls",
".",
"solvable_resources",
":",
"if",
"isinstance",
"(",
"resource",
",",
"solvable_resource",
")",
":",
"return",
"True",
"return",
"False"
] | Tells if the solver is able to resolve the given resource.
Arguments
---------
resource : subclass of ``dataql.resources.Resource``
The resource to check if it is solvable by the current solver class
Returns
-------
boolean
``True`` if the curren... | [
"Tells",
"if",
"the",
"solver",
"is",
"able",
"to",
"resolve",
"the",
"given",
"resource",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L205-L233 |
244,658 | twidi/py-dataql | dataql/solvers/resources.py | AttributeSolver.coerce | def coerce(self, value, resource):
"""Coerce the value to an acceptable one.
Only these kinds of values are returned as is:
- str
- int
- float
- True
- False
- None
For all others values, it will be coerced using ``self.coerce_default`` (with co... | python | def coerce(self, value, resource):
"""Coerce the value to an acceptable one.
Only these kinds of values are returned as is:
- str
- int
- float
- True
- False
- None
For all others values, it will be coerced using ``self.coerce_default`` (with co... | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"if",
"value",
"in",
"(",
"True",
",",
"False",
",",
"None",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"retu... | Coerce the value to an acceptable one.
Only these kinds of values are returned as is:
- str
- int
- float
- True
- False
- None
For all others values, it will be coerced using ``self.coerce_default`` (with convert the
value to a string in the def... | [
"Coerce",
"the",
"value",
"to",
"an",
"acceptable",
"one",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L261-L316 |
244,659 | twidi/py-dataql | dataql/solvers/resources.py | ObjectSolver.coerce | def coerce(self, value, resource):
"""Get a dict with attributes from ``value``.
Arguments
---------
value : ?
The value to get some resources from.
resource : dataql.resources.Object
The ``Object`` object used to obtain this value from the original one.
... | python | def coerce(self, value, resource):
"""Get a dict with attributes from ``value``.
Arguments
---------
value : ?
The value to get some resources from.
resource : dataql.resources.Object
The ``Object`` object used to obtain this value from the original one.
... | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"return",
"{",
"r",
".",
"name",
":",
"self",
".",
"registry",
".",
"solve_resource",
"(",
"value",
",",
"r",
")",
"for",
"r",
"in",
"resource",
".",
"resources",
"}"
] | Get a dict with attributes from ``value``.
Arguments
---------
value : ?
The value to get some resources from.
resource : dataql.resources.Object
The ``Object`` object used to obtain this value from the original one.
Returns
-------
dict
... | [
"Get",
"a",
"dict",
"with",
"attributes",
"from",
"value",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L382-L400 |
244,660 | twidi/py-dataql | dataql/solvers/resources.py | ListSolver.coerce | def coerce(self, value, resource):
"""Convert a list of objects in a list of dicts.
Arguments
---------
value : iterable
The list (or other iterable) to get values to get some resources from.
resource : dataql.resources.List
The ``List`` object used to ob... | python | def coerce(self, value, resource):
"""Convert a list of objects in a list of dicts.
Arguments
---------
value : iterable
The list (or other iterable) to get values to get some resources from.
resource : dataql.resources.List
The ``List`` object used to ob... | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"Iterable",
")",
":",
"raise",
"NotIterable",
"(",
"resource",
",",
"self",
".",
"registry",
"[",
"value",
"]",
")",
"# Case #1: we only ... | Convert a list of objects in a list of dicts.
Arguments
---------
value : iterable
The list (or other iterable) to get values to get some resources from.
resource : dataql.resources.List
The ``List`` object used to obtain this value from the original one.
... | [
"Convert",
"a",
"list",
"of",
"objects",
"in",
"a",
"list",
"of",
"dicts",
"."
] | 5841a3fd559829193ed709c255166085bdde1c52 | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L469-L509 |
244,661 | rikrd/inspire | inspirespeech/common.py | create_recordings_dictionary | def create_recordings_dictionary(list_selected, pronunciation_dictionary_filename, out_dictionary_filename, htk_trace,
additional_dictionary_filenames=[]):
"""Create a pronunciation dictionary specific to a list of recordings"""
temp_words_fd, temp_words_file = tempfile.mkstemp(... | python | def create_recordings_dictionary(list_selected, pronunciation_dictionary_filename, out_dictionary_filename, htk_trace,
additional_dictionary_filenames=[]):
"""Create a pronunciation dictionary specific to a list of recordings"""
temp_words_fd, temp_words_file = tempfile.mkstemp(... | [
"def",
"create_recordings_dictionary",
"(",
"list_selected",
",",
"pronunciation_dictionary_filename",
",",
"out_dictionary_filename",
",",
"htk_trace",
",",
"additional_dictionary_filenames",
"=",
"[",
"]",
")",
":",
"temp_words_fd",
",",
"temp_words_file",
"=",
"tempfile"... | Create a pronunciation dictionary specific to a list of recordings | [
"Create",
"a",
"pronunciation",
"dictionary",
"specific",
"to",
"a",
"list",
"of",
"recordings"
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L197-L218 |
244,662 | rikrd/inspire | inspirespeech/common.py | utf8_normalize | def utf8_normalize(input_filename, comment_char='#', to_upper=False):
"""Normalize UTF-8 characters of a file
"""
# Prepare the input dictionary file in UTF-8 and NFC
temp_dict_fd, output_filename = tempfile.mkstemp()
logging.debug('to_nfc from file {} to file {}'.format(input_filename, output_file... | python | def utf8_normalize(input_filename, comment_char='#', to_upper=False):
"""Normalize UTF-8 characters of a file
"""
# Prepare the input dictionary file in UTF-8 and NFC
temp_dict_fd, output_filename = tempfile.mkstemp()
logging.debug('to_nfc from file {} to file {}'.format(input_filename, output_file... | [
"def",
"utf8_normalize",
"(",
"input_filename",
",",
"comment_char",
"=",
"'#'",
",",
"to_upper",
"=",
"False",
")",
":",
"# Prepare the input dictionary file in UTF-8 and NFC",
"temp_dict_fd",
",",
"output_filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"loggin... | Normalize UTF-8 characters of a file | [
"Normalize",
"UTF",
"-",
"8",
"characters",
"of",
"a",
"file"
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L244-L262 |
244,663 | rikrd/inspire | inspirespeech/common.py | create_flat_start_model | def create_flat_start_model(feature_filename,
state_stay_probabilities,
symbol_list,
output_model_directory,
output_prototype_filename,
htk_trace):
"""
Creates a flat start... | python | def create_flat_start_model(feature_filename,
state_stay_probabilities,
symbol_list,
output_model_directory,
output_prototype_filename,
htk_trace):
"""
Creates a flat start... | [
"def",
"create_flat_start_model",
"(",
"feature_filename",
",",
"state_stay_probabilities",
",",
"symbol_list",
",",
"output_model_directory",
",",
"output_prototype_filename",
",",
"htk_trace",
")",
":",
"# Create a prototype model",
"create_prototype_model",
"(",
"feature_fil... | Creates a flat start model by using HCompV to compute the global mean and variance.
Then uses these global mean and variance to create an N-state model for each symbol in the given list.
:param feature_filename: The filename containing the audio and feature file pairs
:param output_model_directory: The dir... | [
"Creates",
"a",
"flat",
"start",
"model",
"by",
"using",
"HCompV",
"to",
"compute",
"the",
"global",
"mean",
"and",
"variance",
".",
"Then",
"uses",
"these",
"global",
"mean",
"and",
"variance",
"to",
"create",
"an",
"N",
"-",
"state",
"model",
"for",
"e... | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L571-L615 |
244,664 | rikrd/inspire | inspirespeech/common.py | recognise_model | def recognise_model(feature_filename,
symbollist_filename,
model_directory,
recognition_filename,
pronunciation_dictionary_filename,
list_words_filename='',
cmllr_directory=None,
t... | python | def recognise_model(feature_filename,
symbollist_filename,
model_directory,
recognition_filename,
pronunciation_dictionary_filename,
list_words_filename='',
cmllr_directory=None,
t... | [
"def",
"recognise_model",
"(",
"feature_filename",
",",
"symbollist_filename",
",",
"model_directory",
",",
"recognition_filename",
",",
"pronunciation_dictionary_filename",
",",
"list_words_filename",
"=",
"''",
",",
"cmllr_directory",
"=",
"None",
",",
"tokens_count",
"... | Perform recognition using a model and assuming a single word language.
If the list_words_filename is == '' then all the words in the dictionary are used as language words. | [
"Perform",
"recognition",
"using",
"a",
"model",
"and",
"assuming",
"a",
"single",
"word",
"language",
"."
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L989-L1061 |
244,665 | sassoo/goldman | goldman/stores/postgres/connect.py | Connect.connect | def connect(self):
""" Construct the psycopg2 connection instance
:return: psycopg2.connect instance
"""
if self._conn:
return self._conn
self._conn = psycopg2.connect(
self.config,
cursor_factory=psycopg2.extras.RealDictCursor,
)
... | python | def connect(self):
""" Construct the psycopg2 connection instance
:return: psycopg2.connect instance
"""
if self._conn:
return self._conn
self._conn = psycopg2.connect(
self.config,
cursor_factory=psycopg2.extras.RealDictCursor,
)
... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_conn",
":",
"return",
"self",
".",
"_conn",
"self",
".",
"_conn",
"=",
"psycopg2",
".",
"connect",
"(",
"self",
".",
"config",
",",
"cursor_factory",
"=",
"psycopg2",
".",
"extras",
".",
"... | Construct the psycopg2 connection instance
:return: psycopg2.connect instance | [
"Construct",
"the",
"psycopg2",
"connection",
"instance"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/stores/postgres/connect.py#L27-L44 |
244,666 | praekelt/panya | panya/templatetags/panya_inclusion_tags.py | pager | def pager(parser, token):
"""
Output pagination links.
"""
try:
tag_name, page_obj = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('pager tag requires 1 argument (page_obj), %s given' % (len(token.split_contents()) - 1))
return PagerNode(page_obj) | python | def pager(parser, token):
"""
Output pagination links.
"""
try:
tag_name, page_obj = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('pager tag requires 1 argument (page_obj), %s given' % (len(token.split_contents()) - 1))
return PagerNode(page_obj) | [
"def",
"pager",
"(",
"parser",
",",
"token",
")",
":",
"try",
":",
"tag_name",
",",
"page_obj",
"=",
"token",
".",
"split_contents",
"(",
")",
"except",
"ValueError",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"'pager tag requires 1 argument (pag... | Output pagination links. | [
"Output",
"pagination",
"links",
"."
] | 0fd621e15a7c11a2716a9554a2f820d6259818e5 | https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/templatetags/panya_inclusion_tags.py#L34-L42 |
244,667 | praekelt/panya | panya/templatetags/panya_inclusion_tags.py | view_modifier | def view_modifier(parser, token):
"""
Output view modifier.
"""
try:
tag_name, view_modifier = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('view_modifier tag requires 1 argument (view_modifier), %s given' % (len(token.split_contents()) - 1))
retur... | python | def view_modifier(parser, token):
"""
Output view modifier.
"""
try:
tag_name, view_modifier = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('view_modifier tag requires 1 argument (view_modifier), %s given' % (len(token.split_contents()) - 1))
retur... | [
"def",
"view_modifier",
"(",
"parser",
",",
"token",
")",
":",
"try",
":",
"tag_name",
",",
"view_modifier",
"=",
"token",
".",
"split_contents",
"(",
")",
"except",
"ValueError",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"'view_modifier tag req... | Output view modifier. | [
"Output",
"view",
"modifier",
"."
] | 0fd621e15a7c11a2716a9554a2f820d6259818e5 | https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/templatetags/panya_inclusion_tags.py#L94-L102 |
244,668 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.initializerepo | def initializerepo(self):
""" Fill empty directory with products and make first commit """
try:
os.mkdir(self.repopath)
except OSError:
pass
cmd = self.repo.init(bare=self.bare, shared=self.shared)
if not self.bare:
self.write_testing_data([... | python | def initializerepo(self):
""" Fill empty directory with products and make first commit """
try:
os.mkdir(self.repopath)
except OSError:
pass
cmd = self.repo.init(bare=self.bare, shared=self.shared)
if not self.bare:
self.write_testing_data([... | [
"def",
"initializerepo",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"mkdir",
"(",
"self",
".",
"repopath",
")",
"except",
"OSError",
":",
"pass",
"cmd",
"=",
"self",
".",
"repo",
".",
"init",
"(",
"bare",
"=",
"self",
".",
"bare",
",",
"shared",... | Fill empty directory with products and make first commit | [
"Fill",
"empty",
"directory",
"with",
"products",
"and",
"make",
"first",
"commit"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L54-L75 |
244,669 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.isvalid | def isvalid(self):
""" Checks whether contents of repo are consistent with standard set. """
gcontents = [gf.rstrip('\n') for gf in self.repo.bake('ls-files')()]
fcontents = os.listdir(self.repopath)
return all([sf in gcontents for sf in std_files]) and all([sf in fcontents for sf in st... | python | def isvalid(self):
""" Checks whether contents of repo are consistent with standard set. """
gcontents = [gf.rstrip('\n') for gf in self.repo.bake('ls-files')()]
fcontents = os.listdir(self.repopath)
return all([sf in gcontents for sf in std_files]) and all([sf in fcontents for sf in st... | [
"def",
"isvalid",
"(",
"self",
")",
":",
"gcontents",
"=",
"[",
"gf",
".",
"rstrip",
"(",
"'\\n'",
")",
"for",
"gf",
"in",
"self",
".",
"repo",
".",
"bake",
"(",
"'ls-files'",
")",
"(",
")",
"]",
"fcontents",
"=",
"os",
".",
"listdir",
"(",
"self... | Checks whether contents of repo are consistent with standard set. | [
"Checks",
"whether",
"contents",
"of",
"repo",
"are",
"consistent",
"with",
"standard",
"set",
"."
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L97-L102 |
244,670 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.set_version | def set_version(self, version, force=True):
""" Sets the version name for the current state of repo """
if version in self.versions:
self._version = version
if 'working' in self.repo.branch().stdout:
if force:
logger.info('Found working branch... | python | def set_version(self, version, force=True):
""" Sets the version name for the current state of repo """
if version in self.versions:
self._version = version
if 'working' in self.repo.branch().stdout:
if force:
logger.info('Found working branch... | [
"def",
"set_version",
"(",
"self",
",",
"version",
",",
"force",
"=",
"True",
")",
":",
"if",
"version",
"in",
"self",
".",
"versions",
":",
"self",
".",
"_version",
"=",
"version",
"if",
"'working'",
"in",
"self",
".",
"repo",
".",
"branch",
"(",
")... | Sets the version name for the current state of repo | [
"Sets",
"the",
"version",
"name",
"for",
"the",
"current",
"state",
"of",
"repo"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L105-L122 |
244,671 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.training_data | def training_data(self):
""" Returns data dictionary from training.pkl """
data = pickle.load(open(os.path.join(self.repopath, 'training.pkl')))
return data.keys(), data.values() | python | def training_data(self):
""" Returns data dictionary from training.pkl """
data = pickle.load(open(os.path.join(self.repopath, 'training.pkl')))
return data.keys(), data.values() | [
"def",
"training_data",
"(",
"self",
")",
":",
"data",
"=",
"pickle",
".",
"load",
"(",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"repopath",
",",
"'training.pkl'",
")",
")",
")",
"return",
"data",
".",
"keys",
"(",
")",
",",
... | Returns data dictionary from training.pkl | [
"Returns",
"data",
"dictionary",
"from",
"training",
".",
"pkl"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L137-L141 |
244,672 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.classifier | def classifier(self):
""" Returns classifier from classifier.pkl """
clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl')))
return clf | python | def classifier(self):
""" Returns classifier from classifier.pkl """
clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl')))
return clf | [
"def",
"classifier",
"(",
"self",
")",
":",
"clf",
"=",
"pickle",
".",
"load",
"(",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"repopath",
",",
"'classifier.pkl'",
")",
")",
")",
"return",
"clf"
] | Returns classifier from classifier.pkl | [
"Returns",
"classifier",
"from",
"classifier",
".",
"pkl"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L153-L157 |
244,673 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.write_training_data | def write_training_data(self, features, targets):
""" Writes data dictionary to filename """
assert len(features) == len(targets)
data = dict(zip(features, targets))
with open(os.path.join(self.repopath, 'training.pkl'), 'w') as fp:
pickle.dump(data, fp) | python | def write_training_data(self, features, targets):
""" Writes data dictionary to filename """
assert len(features) == len(targets)
data = dict(zip(features, targets))
with open(os.path.join(self.repopath, 'training.pkl'), 'w') as fp:
pickle.dump(data, fp) | [
"def",
"write_training_data",
"(",
"self",
",",
"features",
",",
"targets",
")",
":",
"assert",
"len",
"(",
"features",
")",
"==",
"len",
"(",
"targets",
")",
"data",
"=",
"dict",
"(",
"zip",
"(",
"features",
",",
"targets",
")",
")",
"with",
"open",
... | Writes data dictionary to filename | [
"Writes",
"data",
"dictionary",
"to",
"filename"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L161-L169 |
244,674 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.write_classifier | def write_classifier(self, clf):
""" Writes classifier object to pickle file """
with open(os.path.join(self.repopath, 'classifier.pkl'), 'w') as fp:
pickle.dump(clf, fp) | python | def write_classifier(self, clf):
""" Writes classifier object to pickle file """
with open(os.path.join(self.repopath, 'classifier.pkl'), 'w') as fp:
pickle.dump(clf, fp) | [
"def",
"write_classifier",
"(",
"self",
",",
"clf",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"repopath",
",",
"'classifier.pkl'",
")",
",",
"'w'",
")",
"as",
"fp",
":",
"pickle",
".",
"dump",
"(",
"clf",
",",... | Writes classifier object to pickle file | [
"Writes",
"classifier",
"object",
"to",
"pickle",
"file"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L183-L187 |
244,675 | caseyjlaw/activegit | activegit/activegit.py | ActiveGit.commit_version | def commit_version(self, version, msg=None):
""" Add tag, commit, and push changes """
assert version not in self.versions, 'Will not overwrite a version name.'
if not msg:
feat, targ = self.training_data
msg = 'Training set has {0} examples. '.format(len(feat))
... | python | def commit_version(self, version, msg=None):
""" Add tag, commit, and push changes """
assert version not in self.versions, 'Will not overwrite a version name.'
if not msg:
feat, targ = self.training_data
msg = 'Training set has {0} examples. '.format(len(feat))
... | [
"def",
"commit_version",
"(",
"self",
",",
"version",
",",
"msg",
"=",
"None",
")",
":",
"assert",
"version",
"not",
"in",
"self",
".",
"versions",
",",
"'Will not overwrite a version name.'",
"if",
"not",
"msg",
":",
"feat",
",",
"targ",
"=",
"self",
".",... | Add tag, commit, and push changes | [
"Add",
"tag",
"commit",
"and",
"push",
"changes"
] | 2b4a0ee0fecf13345b5257130ba98b48f46e1098 | https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L191-L214 |
244,676 | pioneers/python-grizzly | grizzly/__init__.py | GrizzlyUSB.get_all_usb_devices | def get_all_usb_devices(idVendor, idProduct):
""" Returns a list of all the usb devices matching the provided vendor ID and product ID."""
all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct))
for dev in all_dev:
try:
dev.detach_ke... | python | def get_all_usb_devices(idVendor, idProduct):
""" Returns a list of all the usb devices matching the provided vendor ID and product ID."""
all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct))
for dev in all_dev:
try:
dev.detach_ke... | [
"def",
"get_all_usb_devices",
"(",
"idVendor",
",",
"idProduct",
")",
":",
"all_dev",
"=",
"list",
"(",
"usb",
".",
"core",
".",
"find",
"(",
"find_all",
"=",
"True",
",",
"idVendor",
"=",
"idVendor",
",",
"idProduct",
"=",
"idProduct",
")",
")",
"for",
... | Returns a list of all the usb devices matching the provided vendor ID and product ID. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"usb",
"devices",
"matching",
"the",
"provided",
"vendor",
"ID",
"and",
"product",
"ID",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L41-L49 |
244,677 | pioneers/python-grizzly | grizzly/__init__.py | GrizzlyUSB.get_device_address | def get_device_address(usb_device):
""" Returns the grizzly's internal address value. Returns a negative error value in case of error. """
try:
usb_device.ctrl_transfer(0x21, 0x09, 0x0300, 0, GrizzlyUSB.COMMAND_GET_ADDR)
internal_addr = usb_device.ctrl_transfer(0xa1, 0x01, 0x0301... | python | def get_device_address(usb_device):
""" Returns the grizzly's internal address value. Returns a negative error value in case of error. """
try:
usb_device.ctrl_transfer(0x21, 0x09, 0x0300, 0, GrizzlyUSB.COMMAND_GET_ADDR)
internal_addr = usb_device.ctrl_transfer(0xa1, 0x01, 0x0301... | [
"def",
"get_device_address",
"(",
"usb_device",
")",
":",
"try",
":",
"usb_device",
".",
"ctrl_transfer",
"(",
"0x21",
",",
"0x09",
",",
"0x0300",
",",
"0",
",",
"GrizzlyUSB",
".",
"COMMAND_GET_ADDR",
")",
"internal_addr",
"=",
"usb_device",
".",
"ctrl_transfe... | Returns the grizzly's internal address value. Returns a negative error value in case of error. | [
"Returns",
"the",
"grizzly",
"s",
"internal",
"address",
"value",
".",
"Returns",
"a",
"negative",
"error",
"value",
"in",
"case",
"of",
"error",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L52-L59 |
244,678 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.get_all_ids | def get_all_ids(idVendor = GrizzlyUSB.ID_VENDOR, idProduct=GrizzlyUSB.ID_PRODUCT):
""" Scans for grizzlies that have not been bound, or constructed, and returns a list
of their id's, or motor number."""
all_dev = GrizzlyUSB.get_all_usb_devices(idVendor, idProduct)
if len(all... | python | def get_all_ids(idVendor = GrizzlyUSB.ID_VENDOR, idProduct=GrizzlyUSB.ID_PRODUCT):
""" Scans for grizzlies that have not been bound, or constructed, and returns a list
of their id's, or motor number."""
all_dev = GrizzlyUSB.get_all_usb_devices(idVendor, idProduct)
if len(all... | [
"def",
"get_all_ids",
"(",
"idVendor",
"=",
"GrizzlyUSB",
".",
"ID_VENDOR",
",",
"idProduct",
"=",
"GrizzlyUSB",
".",
"ID_PRODUCT",
")",
":",
"all_dev",
"=",
"GrizzlyUSB",
".",
"get_all_usb_devices",
"(",
"idVendor",
",",
"idProduct",
")",
"if",
"len",
"(",
... | Scans for grizzlies that have not been bound, or constructed, and returns a list
of their id's, or motor number. | [
"Scans",
"for",
"grizzlies",
"that",
"have",
"not",
"been",
"bound",
"or",
"constructed",
"and",
"returns",
"a",
"list",
"of",
"their",
"id",
"s",
"or",
"motor",
"number",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L100-L124 |
244,679 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.set_register | def set_register(self, addr, data):
"""Sets an arbitrary register at @addr and subsequent registers depending
on how much data you decide to write. It will automatically fill extra
bytes with zeros. You cannot write more than 14 bytes at a time.
@addr should be a static constant from the... | python | def set_register(self, addr, data):
"""Sets an arbitrary register at @addr and subsequent registers depending
on how much data you decide to write. It will automatically fill extra
bytes with zeros. You cannot write more than 14 bytes at a time.
@addr should be a static constant from the... | [
"def",
"set_register",
"(",
"self",
",",
"addr",
",",
"data",
")",
":",
"assert",
"len",
"(",
"data",
")",
"<=",
"14",
",",
"\"Cannot write more than 14 bytes at a time\"",
"cmd",
"=",
"chr",
"(",
"addr",
")",
"+",
"chr",
"(",
"len",
"(",
"data",
")",
... | Sets an arbitrary register at @addr and subsequent registers depending
on how much data you decide to write. It will automatically fill extra
bytes with zeros. You cannot write more than 14 bytes at a time.
@addr should be a static constant from the Addr class, e.g. Addr.Speed | [
"Sets",
"an",
"arbitrary",
"register",
"at"
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L136-L146 |
244,680 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.set_mode | def set_mode(self, controlmode, drivemode):
"""Higher level abstraction for setting the mode register. This will
set the mode according the the @controlmode and @drivemode you specify.
@controlmode and @drivemode should come from the ControlMode and DriveMode
class respectively."""
... | python | def set_mode(self, controlmode, drivemode):
"""Higher level abstraction for setting the mode register. This will
set the mode according the the @controlmode and @drivemode you specify.
@controlmode and @drivemode should come from the ControlMode and DriveMode
class respectively."""
... | [
"def",
"set_mode",
"(",
"self",
",",
"controlmode",
",",
"drivemode",
")",
":",
"self",
".",
"set_register",
"(",
"Addr",
".",
"Mode",
",",
"[",
"0x01",
"|",
"controlmode",
"|",
"drivemode",
"]",
")"
] | Higher level abstraction for setting the mode register. This will
set the mode according the the @controlmode and @drivemode you specify.
@controlmode and @drivemode should come from the ControlMode and DriveMode
class respectively. | [
"Higher",
"level",
"abstraction",
"for",
"setting",
"the",
"mode",
"register",
".",
"This",
"will",
"set",
"the",
"mode",
"according",
"the",
"the"
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L158-L163 |
244,681 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly._read_as_int | def _read_as_int(self, addr, numBytes):
"""Convenience method. Oftentimes we need to read a range of
registers to represent an int. This method will automatically read
@numBytes registers starting at @addr and convert the array into an int."""
buf = self.read_register(addr, numBytes)
... | python | def _read_as_int(self, addr, numBytes):
"""Convenience method. Oftentimes we need to read a range of
registers to represent an int. This method will automatically read
@numBytes registers starting at @addr and convert the array into an int."""
buf = self.read_register(addr, numBytes)
... | [
"def",
"_read_as_int",
"(",
"self",
",",
"addr",
",",
"numBytes",
")",
":",
"buf",
"=",
"self",
".",
"read_register",
"(",
"addr",
",",
"numBytes",
")",
"if",
"len",
"(",
"buf",
")",
">=",
"4",
":",
"return",
"struct",
".",
"unpack_from",
"(",
"\"<i\... | Convenience method. Oftentimes we need to read a range of
registers to represent an int. This method will automatically read
@numBytes registers starting at @addr and convert the array into an int. | [
"Convenience",
"method",
".",
"Oftentimes",
"we",
"need",
"to",
"read",
"a",
"range",
"of",
"registers",
"to",
"represent",
"an",
"int",
".",
"This",
"method",
"will",
"automatically",
"read"
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L191-L202 |
244,682 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly._set_as_int | def _set_as_int(self, addr, val, numBytes = 1):
"""Convenience method. Oftentimes we need to set a range of registers
to represent an int. This method will automatically set @numBytes registers
starting at @addr. It will convert the int @val into an array of bytes."""
if not isinstance(v... | python | def _set_as_int(self, addr, val, numBytes = 1):
"""Convenience method. Oftentimes we need to set a range of registers
to represent an int. This method will automatically set @numBytes registers
starting at @addr. It will convert the int @val into an array of bytes."""
if not isinstance(v... | [
"def",
"_set_as_int",
"(",
"self",
",",
"addr",
",",
"val",
",",
"numBytes",
"=",
"1",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"int",
")",
":",
"raise",
"ValueError",
"(",
"\"val must be an int. You provided: %s\"",
"%",
"str",
"(",
"val",
... | Convenience method. Oftentimes we need to set a range of registers
to represent an int. This method will automatically set @numBytes registers
starting at @addr. It will convert the int @val into an array of bytes. | [
"Convenience",
"method",
".",
"Oftentimes",
"we",
"need",
"to",
"set",
"a",
"range",
"of",
"registers",
"to",
"represent",
"an",
"int",
".",
"This",
"method",
"will",
"automatically",
"set"
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L204-L213 |
244,683 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.has_reset | def has_reset(self):
"""Checks the grizzly to see if it reset itself because of
voltage sag or other reasons. Useful to reinitialize acceleration or
current limiting."""
currentTime = self._read_as_int(Addr.Uptime, 4)
if currentTime <= self._ticks:
self._ticks = curre... | python | def has_reset(self):
"""Checks the grizzly to see if it reset itself because of
voltage sag or other reasons. Useful to reinitialize acceleration or
current limiting."""
currentTime = self._read_as_int(Addr.Uptime, 4)
if currentTime <= self._ticks:
self._ticks = curre... | [
"def",
"has_reset",
"(",
"self",
")",
":",
"currentTime",
"=",
"self",
".",
"_read_as_int",
"(",
"Addr",
".",
"Uptime",
",",
"4",
")",
"if",
"currentTime",
"<=",
"self",
".",
"_ticks",
":",
"self",
".",
"_ticks",
"=",
"currentTime",
"return",
"True",
"... | Checks the grizzly to see if it reset itself because of
voltage sag or other reasons. Useful to reinitialize acceleration or
current limiting. | [
"Checks",
"the",
"grizzly",
"to",
"see",
"if",
"it",
"reset",
"itself",
"because",
"of",
"voltage",
"sag",
"or",
"other",
"reasons",
".",
"Useful",
"to",
"reinitialize",
"acceleration",
"or",
"current",
"limiting",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L231-L240 |
244,684 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.limit_current | def limit_current(self, curr):
"""Sets the current limit on the Grizzly. The units are in amps. The
internal default value is 5 amps."""
if curr <= 0:
raise ValueError("Current limit must be a positive number. You provided: %s" % str(curr))
current = int(curr * (1024.0 / 5.0)... | python | def limit_current(self, curr):
"""Sets the current limit on the Grizzly. The units are in amps. The
internal default value is 5 amps."""
if curr <= 0:
raise ValueError("Current limit must be a positive number. You provided: %s" % str(curr))
current = int(curr * (1024.0 / 5.0)... | [
"def",
"limit_current",
"(",
"self",
",",
"curr",
")",
":",
"if",
"curr",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"Current limit must be a positive number. You provided: %s\"",
"%",
"str",
"(",
"curr",
")",
")",
"current",
"=",
"int",
"(",
"curr",
"*",
... | Sets the current limit on the Grizzly. The units are in amps. The
internal default value is 5 amps. | [
"Sets",
"the",
"current",
"limit",
"on",
"the",
"Grizzly",
".",
"The",
"units",
"are",
"in",
"amps",
".",
"The",
"internal",
"default",
"value",
"is",
"5",
"amps",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L255-L261 |
244,685 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.init_pid | def init_pid(self, kp, ki, kd):
"""Sets the PID constants for the PID modes. Arguments are all
floating point numbers."""
p, i, d = map(lambda x: int(x * (2 ** 16)), (kp, ki, kd))
self._set_as_int(Addr.PConstant, p, 4)
self._set_as_int(Addr.IConstant, i, 4)
self._set_as_i... | python | def init_pid(self, kp, ki, kd):
"""Sets the PID constants for the PID modes. Arguments are all
floating point numbers."""
p, i, d = map(lambda x: int(x * (2 ** 16)), (kp, ki, kd))
self._set_as_int(Addr.PConstant, p, 4)
self._set_as_int(Addr.IConstant, i, 4)
self._set_as_i... | [
"def",
"init_pid",
"(",
"self",
",",
"kp",
",",
"ki",
",",
"kd",
")",
":",
"p",
",",
"i",
",",
"d",
"=",
"map",
"(",
"lambda",
"x",
":",
"int",
"(",
"x",
"*",
"(",
"2",
"**",
"16",
")",
")",
",",
"(",
"kp",
",",
"ki",
",",
"kd",
")",
... | Sets the PID constants for the PID modes. Arguments are all
floating point numbers. | [
"Sets",
"the",
"PID",
"constants",
"for",
"the",
"PID",
"modes",
".",
"Arguments",
"are",
"all",
"floating",
"point",
"numbers",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L263-L269 |
244,686 | pioneers/python-grizzly | grizzly/__init__.py | Grizzly.read_pid_constants | def read_pid_constants(self):
"""Reads back the PID constants stored on the Grizzly."""
p = self._read_as_int(Addr.PConstant, 4)
i = self._read_as_int(Addr.IConstant, 4)
d = self._read_as_int(Addr.DConstant, 4)
return map(lambda x: x / (2 ** 16), (p, i, d)) | python | def read_pid_constants(self):
"""Reads back the PID constants stored on the Grizzly."""
p = self._read_as_int(Addr.PConstant, 4)
i = self._read_as_int(Addr.IConstant, 4)
d = self._read_as_int(Addr.DConstant, 4)
return map(lambda x: x / (2 ** 16), (p, i, d)) | [
"def",
"read_pid_constants",
"(",
"self",
")",
":",
"p",
"=",
"self",
".",
"_read_as_int",
"(",
"Addr",
".",
"PConstant",
",",
"4",
")",
"i",
"=",
"self",
".",
"_read_as_int",
"(",
"Addr",
".",
"IConstant",
",",
"4",
")",
"d",
"=",
"self",
".",
"_r... | Reads back the PID constants stored on the Grizzly. | [
"Reads",
"back",
"the",
"PID",
"constants",
"stored",
"on",
"the",
"Grizzly",
"."
] | a6482c722d5712d6ebe12d48921815276c826c7f | https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L271-L277 |
244,687 | TC01/calcpkg | calcrepo/util.py | getReposPackageFolder | def getReposPackageFolder():
"""Returns the folder the package is located in."""
libdir = sysconfig.get_python_lib()
repodir = os.path.join(libdir, "calcrepo", "repos")
return repodir | python | def getReposPackageFolder():
"""Returns the folder the package is located in."""
libdir = sysconfig.get_python_lib()
repodir = os.path.join(libdir, "calcrepo", "repos")
return repodir | [
"def",
"getReposPackageFolder",
"(",
")",
":",
"libdir",
"=",
"sysconfig",
".",
"get_python_lib",
"(",
")",
"repodir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"libdir",
",",
"\"calcrepo\"",
",",
"\"repos\"",
")",
"return",
"repodir"
] | Returns the folder the package is located in. | [
"Returns",
"the",
"folder",
"the",
"package",
"is",
"located",
"in",
"."
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/util.py#L7-L11 |
244,688 | TC01/calcpkg | calcrepo/util.py | replaceNewlines | def replaceNewlines(string, newlineChar):
"""There's probably a way to do this with string functions but I was lazy.
Replace all instances of \r or \n in a string with something else."""
if newlineChar in string:
segments = string.split(newlineChar)
string = ""
for segment in segments:
string += segment
r... | python | def replaceNewlines(string, newlineChar):
"""There's probably a way to do this with string functions but I was lazy.
Replace all instances of \r or \n in a string with something else."""
if newlineChar in string:
segments = string.split(newlineChar)
string = ""
for segment in segments:
string += segment
r... | [
"def",
"replaceNewlines",
"(",
"string",
",",
"newlineChar",
")",
":",
"if",
"newlineChar",
"in",
"string",
":",
"segments",
"=",
"string",
".",
"split",
"(",
"newlineChar",
")",
"string",
"=",
"\"\"",
"for",
"segment",
"in",
"segments",
":",
"string",
"+=... | There's probably a way to do this with string functions but I was lazy.
Replace all instances of \r or \n in a string with something else. | [
"There",
"s",
"probably",
"a",
"way",
"to",
"do",
"this",
"with",
"string",
"functions",
"but",
"I",
"was",
"lazy",
".",
"Replace",
"all",
"instances",
"of",
"\\",
"r",
"or",
"\\",
"n",
"in",
"a",
"string",
"with",
"something",
"else",
"."
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/util.py#L13-L21 |
244,689 | TC01/calcpkg | calcrepo/util.py | getScriptLocation | def getScriptLocation():
"""Helper function to get the location of a Python file."""
location = os.path.abspath("./")
if __file__.rfind("/") != -1:
location = __file__[:__file__.rfind("/")]
return location | python | def getScriptLocation():
"""Helper function to get the location of a Python file."""
location = os.path.abspath("./")
if __file__.rfind("/") != -1:
location = __file__[:__file__.rfind("/")]
return location | [
"def",
"getScriptLocation",
"(",
")",
":",
"location",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"\"./\"",
")",
"if",
"__file__",
".",
"rfind",
"(",
"\"/\"",
")",
"!=",
"-",
"1",
":",
"location",
"=",
"__file__",
"[",
":",
"__file__",
".",
"rfind"... | Helper function to get the location of a Python file. | [
"Helper",
"function",
"to",
"get",
"the",
"location",
"of",
"a",
"Python",
"file",
"."
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/util.py#L31-L36 |
244,690 | sassoo/goldman | goldman/queryparams/fields.py | _parse_param | def _parse_param(key, val):
""" Parse the query param looking for sparse fields params
Ensure the `val` or what will become the sparse fields
is always an array. If the query param is not a sparse
fields query param then return None.
:param key:
the query parameter key in the request (left... | python | def _parse_param(key, val):
""" Parse the query param looking for sparse fields params
Ensure the `val` or what will become the sparse fields
is always an array. If the query param is not a sparse
fields query param then return None.
:param key:
the query parameter key in the request (left... | [
"def",
"_parse_param",
"(",
"key",
",",
"val",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"r'fields\\[([A-Za-z]+)\\]'",
")",
"match",
"=",
"regex",
".",
"match",
"(",
"key",
")",
"if",
"match",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
... | Parse the query param looking for sparse fields params
Ensure the `val` or what will become the sparse fields
is always an array. If the query param is not a sparse
fields query param then return None.
:param key:
the query parameter key in the request (left of =)
:param val:
the q... | [
"Parse",
"the",
"query",
"param",
"looking",
"for",
"sparse",
"fields",
"params"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/fields.py#L24-L50 |
244,691 | sassoo/goldman | goldman/queryparams/fields.py | _validate_param | def _validate_param(rtype, fields):
""" Ensure the sparse fields exists on the models """
try:
# raises ValueError if not found
model = rtype_to_model(rtype)
model_fields = model.all_fields
except ValueError:
raise InvalidQueryParams(**{
'detail': 'The fields que... | python | def _validate_param(rtype, fields):
""" Ensure the sparse fields exists on the models """
try:
# raises ValueError if not found
model = rtype_to_model(rtype)
model_fields = model.all_fields
except ValueError:
raise InvalidQueryParams(**{
'detail': 'The fields que... | [
"def",
"_validate_param",
"(",
"rtype",
",",
"fields",
")",
":",
"try",
":",
"# raises ValueError if not found",
"model",
"=",
"rtype_to_model",
"(",
"rtype",
")",
"model_fields",
"=",
"model",
".",
"all_fields",
"except",
"ValueError",
":",
"raise",
"InvalidQuery... | Ensure the sparse fields exists on the models | [
"Ensure",
"the",
"sparse",
"fields",
"exists",
"on",
"the",
"models"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/fields.py#L53-L76 |
244,692 | sassoo/goldman | goldman/queryparams/fields.py | init | def init(req, model): # pylint: disable=unused-argument
""" Determine the sparse fields to limit the response to
Return a dict where the key is the resource type (rtype) &
the value is an array of string fields names to whitelist
against.
:return:
dict
"""
params = {}
for ke... | python | def init(req, model): # pylint: disable=unused-argument
""" Determine the sparse fields to limit the response to
Return a dict where the key is the resource type (rtype) &
the value is an array of string fields names to whitelist
against.
:return:
dict
"""
params = {}
for ke... | [
"def",
"init",
"(",
"req",
",",
"model",
")",
":",
"# pylint: disable=unused-argument",
"params",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"req",
".",
"params",
".",
"items",
"(",
")",
":",
"try",
":",
"rtype",
",",
"fields",
"=",
"_parse_param",... | Determine the sparse fields to limit the response to
Return a dict where the key is the resource type (rtype) &
the value is an array of string fields names to whitelist
against.
:return:
dict | [
"Determine",
"the",
"sparse",
"fields",
"to",
"limit",
"the",
"response",
"to"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/fields.py#L99-L123 |
244,693 | jorgebg/lumpy | lumpy/mail.py | Mail.query_mxrecords | def query_mxrecords(self):
"""
Looks up for the MX DNS records of the recipient SMTP server
"""
import dns.resolver
logging.info('Resolving DNS query...')
answers = dns.resolver.query(self.domain, 'MX')
addresses = [answer.exchange.to_text() for answer in answers]... | python | def query_mxrecords(self):
"""
Looks up for the MX DNS records of the recipient SMTP server
"""
import dns.resolver
logging.info('Resolving DNS query...')
answers = dns.resolver.query(self.domain, 'MX')
addresses = [answer.exchange.to_text() for answer in answers]... | [
"def",
"query_mxrecords",
"(",
"self",
")",
":",
"import",
"dns",
".",
"resolver",
"logging",
".",
"info",
"(",
"'Resolving DNS query...'",
")",
"answers",
"=",
"dns",
".",
"resolver",
".",
"query",
"(",
"self",
".",
"domain",
",",
"'MX'",
")",
"addresses"... | Looks up for the MX DNS records of the recipient SMTP server | [
"Looks",
"up",
"for",
"the",
"MX",
"DNS",
"records",
"of",
"the",
"recipient",
"SMTP",
"server"
] | 1555151a5c36a327591ff9ba7ca88d6812eb9949 | https://github.com/jorgebg/lumpy/blob/1555151a5c36a327591ff9ba7ca88d6812eb9949/lumpy/mail.py#L48-L59 |
244,694 | jorgebg/lumpy | lumpy/mail.py | Mail.send | def send(self):
"""
Attempts the delivery through recipient's domain MX records.
"""
try:
for mx in self.mxrecords:
logging.info('Connecting to {} {}...'.format(mx, self.port))
server = smtplib.SMTP(mx, self.port)
server.set_deb... | python | def send(self):
"""
Attempts the delivery through recipient's domain MX records.
"""
try:
for mx in self.mxrecords:
logging.info('Connecting to {} {}...'.format(mx, self.port))
server = smtplib.SMTP(mx, self.port)
server.set_deb... | [
"def",
"send",
"(",
"self",
")",
":",
"try",
":",
"for",
"mx",
"in",
"self",
".",
"mxrecords",
":",
"logging",
".",
"info",
"(",
"'Connecting to {} {}...'",
".",
"format",
"(",
"mx",
",",
"self",
".",
"port",
")",
")",
"server",
"=",
"smtplib",
".",
... | Attempts the delivery through recipient's domain MX records. | [
"Attempts",
"the",
"delivery",
"through",
"recipient",
"s",
"domain",
"MX",
"records",
"."
] | 1555151a5c36a327591ff9ba7ca88d6812eb9949 | https://github.com/jorgebg/lumpy/blob/1555151a5c36a327591ff9ba7ca88d6812eb9949/lumpy/mail.py#L61-L82 |
244,695 | Nixiware/viper | nx/viper/dispatcher.py | Dispatcher.dispatch | def dispatch(self, requestProtocol, requestPayload):
"""
Dispatch the request to the appropriate handler.
:param requestProtocol: <AbstractApplicationInterfaceProtocol> request protocol
:param requestPayload: <dict> request
:param version: <float> version
:param ... | python | def dispatch(self, requestProtocol, requestPayload):
"""
Dispatch the request to the appropriate handler.
:param requestProtocol: <AbstractApplicationInterfaceProtocol> request protocol
:param requestPayload: <dict> request
:param version: <float> version
:param ... | [
"def",
"dispatch",
"(",
"self",
",",
"requestProtocol",
",",
"requestPayload",
")",
":",
"# method decoding",
"method",
"=",
"requestPayload",
"[",
"\"method\"",
"]",
".",
"split",
"(",
"\".\"",
")",
"if",
"len",
"(",
"method",
")",
"!=",
"3",
":",
"reques... | Dispatch the request to the appropriate handler.
:param requestProtocol: <AbstractApplicationInterfaceProtocol> request protocol
:param requestPayload: <dict> request
:param version: <float> version
:param method: <str> method name
:param parameters: <dict> data para... | [
"Dispatch",
"the",
"request",
"to",
"the",
"appropriate",
"handler",
"."
] | fbe6057facd8d46103e9955880dfd99e63b7acb3 | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/dispatcher.py#L16-L89 |
244,696 | delfick/aws_syncr | aws_syncr/collector.py | Collector.prepare | def prepare(self, configuration_folder, args_dict, environment):
"""Make a temporary configuration file from the files in our folder"""
self.configuration_folder = configuration_folder
if not os.path.isdir(configuration_folder):
raise BadOption("Specified configuration folder is not ... | python | def prepare(self, configuration_folder, args_dict, environment):
"""Make a temporary configuration file from the files in our folder"""
self.configuration_folder = configuration_folder
if not os.path.isdir(configuration_folder):
raise BadOption("Specified configuration folder is not ... | [
"def",
"prepare",
"(",
"self",
",",
"configuration_folder",
",",
"args_dict",
",",
"environment",
")",
":",
"self",
".",
"configuration_folder",
"=",
"configuration_folder",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"configuration_folder",
")",
":",
"... | Make a temporary configuration file from the files in our folder | [
"Make",
"a",
"temporary",
"configuration",
"file",
"from",
"the",
"files",
"in",
"our",
"folder"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/collector.py#L38-L61 |
244,697 | delfick/aws_syncr | aws_syncr/collector.py | Collector.extra_prepare_after_activation | def extra_prepare_after_activation(self, configuration, args_dict):
"""Setup our connection to amazon"""
aws_syncr = configuration['aws_syncr']
configuration["amazon"] = Amazon(configuration['aws_syncr'].environment, configuration['accounts'], debug=aws_syncr.debug, dry_run=aws_syncr.dry_run) | python | def extra_prepare_after_activation(self, configuration, args_dict):
"""Setup our connection to amazon"""
aws_syncr = configuration['aws_syncr']
configuration["amazon"] = Amazon(configuration['aws_syncr'].environment, configuration['accounts'], debug=aws_syncr.debug, dry_run=aws_syncr.dry_run) | [
"def",
"extra_prepare_after_activation",
"(",
"self",
",",
"configuration",
",",
"args_dict",
")",
":",
"aws_syncr",
"=",
"configuration",
"[",
"'aws_syncr'",
"]",
"configuration",
"[",
"\"amazon\"",
"]",
"=",
"Amazon",
"(",
"configuration",
"[",
"'aws_syncr'",
"]... | Setup our connection to amazon | [
"Setup",
"our",
"connection",
"to",
"amazon"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/collector.py#L81-L84 |
244,698 | delfick/aws_syncr | aws_syncr/collector.py | Collector.add_configuration | def add_configuration(self, configuration, collect_another_source, done, result, src):
"""Used to add a file to the configuration, result here is the yaml.load of the src"""
if "includes" in result:
for include in result["includes"]:
collect_another_source(include)
co... | python | def add_configuration(self, configuration, collect_another_source, done, result, src):
"""Used to add a file to the configuration, result here is the yaml.load of the src"""
if "includes" in result:
for include in result["includes"]:
collect_another_source(include)
co... | [
"def",
"add_configuration",
"(",
"self",
",",
"configuration",
",",
"collect_another_source",
",",
"done",
",",
"result",
",",
"src",
")",
":",
"if",
"\"includes\"",
"in",
"result",
":",
"for",
"include",
"in",
"result",
"[",
"\"includes\"",
"]",
":",
"colle... | Used to add a file to the configuration, result here is the yaml.load of the src | [
"Used",
"to",
"add",
"a",
"file",
"to",
"the",
"configuration",
"result",
"here",
"is",
"the",
"yaml",
".",
"load",
"of",
"the",
"src"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/collector.py#L100-L105 |
244,699 | stephanepechard/projy | projy/cmdline.py | template_name_from_class_name | def template_name_from_class_name(class_name):
""" Remove the last 'Template' in the name. """
suffix = 'Template'
output = class_name
if (class_name.endswith(suffix)):
output = class_name[:-len(suffix)]
return output | python | def template_name_from_class_name(class_name):
""" Remove the last 'Template' in the name. """
suffix = 'Template'
output = class_name
if (class_name.endswith(suffix)):
output = class_name[:-len(suffix)]
return output | [
"def",
"template_name_from_class_name",
"(",
"class_name",
")",
":",
"suffix",
"=",
"'Template'",
"output",
"=",
"class_name",
"if",
"(",
"class_name",
".",
"endswith",
"(",
"suffix",
")",
")",
":",
"output",
"=",
"class_name",
"[",
":",
"-",
"len",
"(",
"... | Remove the last 'Template' in the name. | [
"Remove",
"the",
"last",
"Template",
"in",
"the",
"name",
"."
] | 3146b0e3c207b977e1b51fcb33138746dae83c23 | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/cmdline.py#L32-L38 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.