partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Rule.execute_actions | Iterates over the actions and executes them in order. | hook/model.py | def execute_actions(self, cwd):
"""Iterates over the actions and executes them in order."""
self._execute_globals(cwd)
for action in self.actions:
logger.info("executing {}".format(action))
p = subprocess.Popen(action, shell=True, cwd=cwd)
p.wait() | def execute_actions(self, cwd):
"""Iterates over the actions and executes them in order."""
self._execute_globals(cwd)
for action in self.actions:
logger.info("executing {}".format(action))
p = subprocess.Popen(action, shell=True, cwd=cwd)
p.wait() | [
"Iterates",
"over",
"the",
"actions",
"and",
"executes",
"them",
"in",
"order",
"."
] | ssherar/hook | python | https://github.com/ssherar/hook/blob/54160df554d8b2ed65d762168e5808487e873ed9/hook/model.py#L57-L63 | [
"def",
"execute_actions",
"(",
"self",
",",
"cwd",
")",
":",
"self",
".",
"_execute_globals",
"(",
"cwd",
")",
"for",
"action",
"in",
"self",
".",
"actions",
":",
"logger",
".",
"info",
"(",
"\"executing {}\"",
".",
"format",
"(",
"action",
")",
")",
"... | 54160df554d8b2ed65d762168e5808487e873ed9 |
test | CommandSet.from_yaml | Creates a new instance of a rule by merging two dictionaries.
This allows for independant configuration files to be merged
into the defaults. | hook/model.py | def from_yaml(cls, defaults, **kwargs):
"""Creates a new instance of a rule by merging two dictionaries.
This allows for independant configuration files to be merged
into the defaults."""
# TODO: I hate myself for this. Fix it later mmkay?
if "token" not in defaults:
... | def from_yaml(cls, defaults, **kwargs):
"""Creates a new instance of a rule by merging two dictionaries.
This allows for independant configuration files to be merged
into the defaults."""
# TODO: I hate myself for this. Fix it later mmkay?
if "token" not in defaults:
... | [
"Creates",
"a",
"new",
"instance",
"of",
"a",
"rule",
"by",
"merging",
"two",
"dictionaries",
"."
] | ssherar/hook | python | https://github.com/ssherar/hook/blob/54160df554d8b2ed65d762168e5808487e873ed9/hook/model.py#L76-L91 | [
"def",
"from_yaml",
"(",
"cls",
",",
"defaults",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: I hate myself for this. Fix it later mmkay?",
"if",
"\"token\"",
"not",
"in",
"defaults",
":",
"kwargs",
"[",
"\"token\"",
"]",
"=",
"None",
"defaults",
"=",
"copy",
"... | 54160df554d8b2ed65d762168e5808487e873ed9 |
test | parse_address | :param formatted_address: A string like "email@address.com" or "My Email <email@address.com>"
:return: Tuple: (address, name) | littlefish/lfsmailer.py | def parse_address(formatted_address):
"""
:param formatted_address: A string like "email@address.com" or "My Email <email@address.com>"
:return: Tuple: (address, name)
"""
if email_regex.match(formatted_address):
# Just a raw address
return (formatted_address, None)
mat... | def parse_address(formatted_address):
"""
:param formatted_address: A string like "email@address.com" or "My Email <email@address.com>"
:return: Tuple: (address, name)
"""
if email_regex.match(formatted_address):
# Just a raw address
return (formatted_address, None)
mat... | [
":",
"param",
"formatted_address",
":",
"A",
"string",
"like",
"email"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/lfsmailer.py#L69-L85 | [
"def",
"parse_address",
"(",
"formatted_address",
")",
":",
"if",
"email_regex",
".",
"match",
"(",
"formatted_address",
")",
":",
"# Just a raw address",
"return",
"(",
"formatted_address",
",",
"None",
")",
"match",
"=",
"formatted_address_regex",
".",
"match",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | send_mail | :param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
:param subject: The subject
:param body: The email body
:param html: Is this a html email? Defaults to False
:param from_address: From email address or name and address i.e. 'Test System <errors@test.... | littlefish/lfsmailer.py | def send_mail(recipient_list, subject, body, html=False, from_address=None):
"""
:param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
:param subject: The subject
:param body: The email body
:param html: Is this a html email? Defaults to False
:p... | def send_mail(recipient_list, subject, body, html=False, from_address=None):
"""
:param recipient_list: List of recipients i.e. ['testing@fig14.com', 'Stephen Brown <steve@fig14.com>']
:param subject: The subject
:param body: The email body
:param html: Is this a html email? Defaults to False
:p... | [
":",
"param",
"recipient_list",
":",
"List",
"of",
"recipients",
"i",
".",
"e",
".",
"[",
"testing"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/lfsmailer.py#L108-L150 | [
"def",
"send_mail",
"(",
"recipient_list",
",",
"subject",
",",
"body",
",",
"html",
"=",
"False",
",",
"from_address",
"=",
"None",
")",
":",
"if",
"not",
"_configured",
":",
"raise",
"Exception",
"(",
"'LFS Mailer hasn\\'t been configured'",
")",
"if",
"from... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | LfsSmtpHandler.add_details | Add extra details to the message. Separate so that it can be overridden | littlefish/lfsmailer.py | def add_details(self, message):
"""
Add extra details to the message. Separate so that it can be overridden
"""
msg = message
# Try to append Flask request details
try:
from flask import request
url = request.url
method = request.metho... | def add_details(self, message):
"""
Add extra details to the message. Separate so that it can be overridden
"""
msg = message
# Try to append Flask request details
try:
from flask import request
url = request.url
method = request.metho... | [
"Add",
"extra",
"details",
"to",
"the",
"message",
".",
"Separate",
"so",
"that",
"it",
"can",
"be",
"overridden"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/lfsmailer.py#L196-L236 | [
"def",
"add_details",
"(",
"self",
",",
"message",
")",
":",
"msg",
"=",
"message",
"# Try to append Flask request details",
"try",
":",
"from",
"flask",
"import",
"request",
"url",
"=",
"request",
".",
"url",
"method",
"=",
"request",
".",
"method",
"endpoint... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | LfsSmtpHandler.emit | Emit a record.
Format the record and send it to the specified addressees. | littlefish/lfsmailer.py | def emit(self, record):
"""
Emit a record.
Format the record and send it to the specified addressees.
"""
try:
# First, remove all records from the rate limiter list that are over a minute old
now = timetool.unix_time()
one_minute_ago = now - ... | def emit(self, record):
"""
Emit a record.
Format the record and send it to the specified addressees.
"""
try:
# First, remove all records from the rate limiter list that are over a minute old
now = timetool.unix_time()
one_minute_ago = now - ... | [
"Emit",
"a",
"record",
"."
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/lfsmailer.py#L238-L274 | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"try",
":",
"# First, remove all records from the rate limiter list that are over a minute old",
"now",
"=",
"timetool",
".",
"unix_time",
"(",
")",
"one_minute_ago",
"=",
"now",
"-",
"60",
"new_rate_limiter",
"=",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | RenditionAwareStructBlock.get_context | Ensure `image_rendition` is added to the global context. | streamfield_tools/blocks/struct_block.py | def get_context(self, value):
"""Ensure `image_rendition` is added to the global context."""
context = super(RenditionAwareStructBlock, self).get_context(value)
context['image_rendition'] = self.rendition.\
image_rendition or 'original'
return context | def get_context(self, value):
"""Ensure `image_rendition` is added to the global context."""
context = super(RenditionAwareStructBlock, self).get_context(value)
context['image_rendition'] = self.rendition.\
image_rendition or 'original'
return context | [
"Ensure",
"image_rendition",
"is",
"added",
"to",
"the",
"global",
"context",
"."
] | WGBH/wagtail-streamfieldtools | python | https://github.com/WGBH/wagtail-streamfieldtools/blob/192f86845532742b0b7d432bef3987357833b8ed/streamfield_tools/blocks/struct_block.py#L118-L123 | [
"def",
"get_context",
"(",
"self",
",",
"value",
")",
":",
"context",
"=",
"super",
"(",
"RenditionAwareStructBlock",
",",
"self",
")",
".",
"get_context",
"(",
"value",
")",
"context",
"[",
"'image_rendition'",
"]",
"=",
"self",
".",
"rendition",
".",
"im... | 192f86845532742b0b7d432bef3987357833b8ed |
test | AttackProtect.log_attempt | Log an attempt against key, incrementing the number of attempts for that key and potentially adding a lock to
the lock table | littlefish/attackprotect.py | def log_attempt(self, key):
"""
Log an attempt against key, incrementing the number of attempts for that key and potentially adding a lock to
the lock table
"""
with self.lock:
if key not in self.attempts:
self.attempts[key] = 1
else:
... | def log_attempt(self, key):
"""
Log an attempt against key, incrementing the number of attempts for that key and potentially adding a lock to
the lock table
"""
with self.lock:
if key not in self.attempts:
self.attempts[key] = 1
else:
... | [
"Log",
"an",
"attempt",
"against",
"key",
"incrementing",
"the",
"number",
"of",
"attempts",
"for",
"that",
"key",
"and",
"potentially",
"adding",
"a",
"lock",
"to",
"the",
"lock",
"table"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/attackprotect.py#L38-L52 | [
"def",
"log_attempt",
"(",
"self",
",",
"key",
")",
":",
"with",
"self",
".",
"lock",
":",
"if",
"key",
"not",
"in",
"self",
".",
"attempts",
":",
"self",
".",
"attempts",
"[",
"key",
"]",
"=",
"1",
"else",
":",
"self",
".",
"attempts",
"[",
"key... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | AttackProtect.service | Decrease the countdowns, and remove any expired locks. Should be called once every <decrease_every> seconds. | littlefish/attackprotect.py | def service(self):
"""
Decrease the countdowns, and remove any expired locks. Should be called once every <decrease_every> seconds.
"""
with self.lock:
# Decrement / remove all attempts
for key in list(self.attempts.keys()):
log.debug('Decrementin... | def service(self):
"""
Decrease the countdowns, and remove any expired locks. Should be called once every <decrease_every> seconds.
"""
with self.lock:
# Decrement / remove all attempts
for key in list(self.attempts.keys()):
log.debug('Decrementin... | [
"Decrease",
"the",
"countdowns",
"and",
"remove",
"any",
"expired",
"locks",
".",
"Should",
"be",
"called",
"once",
"every",
"<decrease_every",
">",
"seconds",
"."
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/attackprotect.py#L61-L80 | [
"def",
"service",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"# Decrement / remove all attempts",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"attempts",
".",
"keys",
"(",
")",
")",
":",
"log",
".",
"debug",
"(",
"'Decrementing count for %s... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | Music2Storage.add_to_queue | Adds an URL to the download queue.
:param str url: URL to the music service track | music2storage/__init__.py | def add_to_queue(self, url):
"""
Adds an URL to the download queue.
:param str url: URL to the music service track
"""
if self.connection_handler.current_music is None:
log.error('Music service is not initialized. URL was not added to queue.')
elif self.conn... | def add_to_queue(self, url):
"""
Adds an URL to the download queue.
:param str url: URL to the music service track
"""
if self.connection_handler.current_music is None:
log.error('Music service is not initialized. URL was not added to queue.')
elif self.conn... | [
"Adds",
"an",
"URL",
"to",
"the",
"download",
"queue",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/__init__.py#L36-L48 | [
"def",
"add_to_queue",
"(",
"self",
",",
"url",
")",
":",
"if",
"self",
".",
"connection_handler",
".",
"current_music",
"is",
"None",
":",
"log",
".",
"error",
"(",
"'Music service is not initialized. URL was not added to queue.'",
")",
"elif",
"self",
".",
"conn... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | Music2Storage.use_music_service | Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary | music2storage/__init__.py | def use_music_service(self, service_name, api_key=None):
"""
Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary
"""
self.connection_handler.use_music_service(servic... | def use_music_service(self, service_name, api_key=None):
"""
Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary
"""
self.connection_handler.use_music_service(servic... | [
"Sets",
"the",
"current",
"music",
"service",
"to",
"service_name",
".",
":",
"param",
"str",
"service_name",
":",
"Name",
"of",
"the",
"music",
"service",
":",
"param",
"str",
"api_key",
":",
"Optional",
"API",
"key",
"if",
"necessary"
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/__init__.py#L50-L58 | [
"def",
"use_music_service",
"(",
"self",
",",
"service_name",
",",
"api_key",
"=",
"None",
")",
":",
"self",
".",
"connection_handler",
".",
"use_music_service",
"(",
"service_name",
",",
"api_key",
"=",
"api_key",
")"
] | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | Music2Storage.use_storage_service | Sets the current storage service to service_name and attempts to connect to it.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage (optional, and must already exist, use absolute paths only) | music2storage/__init__.py | def use_storage_service(self, service_name, custom_path=None):
"""
Sets the current storage service to service_name and attempts to connect to it.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage ... | def use_storage_service(self, service_name, custom_path=None):
"""
Sets the current storage service to service_name and attempts to connect to it.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage ... | [
"Sets",
"the",
"current",
"storage",
"service",
"to",
"service_name",
"and",
"attempts",
"to",
"connect",
"to",
"it",
".",
":",
"param",
"str",
"service_name",
":",
"Name",
"of",
"the",
"storage",
"service",
":",
"param",
"str",
"custom_path",
":",
"Custom",... | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/__init__.py#L60-L68 | [
"def",
"use_storage_service",
"(",
"self",
",",
"service_name",
",",
"custom_path",
"=",
"None",
")",
":",
"self",
".",
"connection_handler",
".",
"use_storage_service",
"(",
"service_name",
",",
"custom_path",
"=",
"custom_path",
")"
] | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | Music2Storage.start_workers | Creates and starts the workers, as well as attaching a handler to terminate them gracefully when a SIGINT signal is received.
:param int workers_per_task: Number of workers to create for each task in the pipeline | music2storage/__init__.py | def start_workers(self, workers_per_task=1):
"""
Creates and starts the workers, as well as attaching a handler to terminate them gracefully when a SIGINT signal is received.
:param int workers_per_task: Number of workers to create for each task in the pipeline
"""
if not self.... | def start_workers(self, workers_per_task=1):
"""
Creates and starts the workers, as well as attaching a handler to terminate them gracefully when a SIGINT signal is received.
:param int workers_per_task: Number of workers to create for each task in the pipeline
"""
if not self.... | [
"Creates",
"and",
"starts",
"the",
"workers",
"as",
"well",
"as",
"attaching",
"a",
"handler",
"to",
"terminate",
"them",
"gracefully",
"when",
"a",
"SIGINT",
"signal",
"is",
"received",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/__init__.py#L70-L88 | [
"def",
"start_workers",
"(",
"self",
",",
"workers_per_task",
"=",
"1",
")",
":",
"if",
"not",
"self",
".",
"workers",
":",
"for",
"_",
"in",
"range",
"(",
"workers_per_task",
")",
":",
"self",
".",
"workers",
".",
"append",
"(",
"Worker",
"(",
"self",... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | Client.set | Add or update a key, value pair to the database | kvstore.py | def set(self, k, v):
"""Add or update a key, value pair to the database"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
r = requests.put(url, data=str(v))
if r.status_code != 200 or r.json() is not True:
raise KVStoreError('PUT returned {}'.format(r.status... | def set(self, k, v):
"""Add or update a key, value pair to the database"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
r = requests.put(url, data=str(v))
if r.status_code != 200 or r.json() is not True:
raise KVStoreError('PUT returned {}'.format(r.status... | [
"Add",
"or",
"update",
"a",
"key",
"value",
"pair",
"to",
"the",
"database"
] | bigdatacesga/kvstore | python | https://github.com/bigdatacesga/kvstore/blob/8ad2222b39d47defc8ad30deda3da06798e2a9a4/kvstore.py#L31-L37 | [
"def",
"set",
"(",
"self",
",",
"k",
",",
"v",
")",
":",
"k",
"=",
"k",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"endpoint",
",",
"k",
")",
"r",
"=",
"requests",
".",
"put",
"(",
"url",
",",
"d... | 8ad2222b39d47defc8ad30deda3da06798e2a9a4 |
test | Client.get | Get the value of a given key | kvstore.py | def get(self, k, wait=False, wait_index=False, timeout='5m'):
"""Get the value of a given key"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if wait:
params['index'] = wait_index
params['wait'] = timeout
r = requests.get(ur... | def get(self, k, wait=False, wait_index=False, timeout='5m'):
"""Get the value of a given key"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if wait:
params['index'] = wait_index
params['wait'] = timeout
r = requests.get(ur... | [
"Get",
"the",
"value",
"of",
"a",
"given",
"key"
] | bigdatacesga/kvstore | python | https://github.com/bigdatacesga/kvstore/blob/8ad2222b39d47defc8ad30deda3da06798e2a9a4/kvstore.py#L39-L57 | [
"def",
"get",
"(",
"self",
",",
"k",
",",
"wait",
"=",
"False",
",",
"wait_index",
"=",
"False",
",",
"timeout",
"=",
"'5m'",
")",
":",
"k",
"=",
"k",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"endp... | 8ad2222b39d47defc8ad30deda3da06798e2a9a4 |
test | Client.recurse | Recursively get the tree below the given key | kvstore.py | def recurse(self, k, wait=False, wait_index=None, timeout='5m'):
"""Recursively get the tree below the given key"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
params['recurse'] = 'true'
if wait:
params['wait'] = timeout
if... | def recurse(self, k, wait=False, wait_index=None, timeout='5m'):
"""Recursively get the tree below the given key"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
params['recurse'] = 'true'
if wait:
params['wait'] = timeout
if... | [
"Recursively",
"get",
"the",
"tree",
"below",
"the",
"given",
"key"
] | bigdatacesga/kvstore | python | https://github.com/bigdatacesga/kvstore/blob/8ad2222b39d47defc8ad30deda3da06798e2a9a4/kvstore.py#L60-L83 | [
"def",
"recurse",
"(",
"self",
",",
"k",
",",
"wait",
"=",
"False",
",",
"wait_index",
"=",
"None",
",",
"timeout",
"=",
"'5m'",
")",
":",
"k",
"=",
"k",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"e... | 8ad2222b39d47defc8ad30deda3da06798e2a9a4 |
test | Client.index | Get the current index of the key or the subtree.
This is needed for later creating long polling requests | kvstore.py | def index(self, k, recursive=False):
"""Get the current index of the key or the subtree.
This is needed for later creating long polling requests
"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if recursive:
params['recurse'] = ... | def index(self, k, recursive=False):
"""Get the current index of the key or the subtree.
This is needed for later creating long polling requests
"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if recursive:
params['recurse'] = ... | [
"Get",
"the",
"current",
"index",
"of",
"the",
"key",
"or",
"the",
"subtree",
".",
"This",
"is",
"needed",
"for",
"later",
"creating",
"long",
"polling",
"requests"
] | bigdatacesga/kvstore | python | https://github.com/bigdatacesga/kvstore/blob/8ad2222b39d47defc8ad30deda3da06798e2a9a4/kvstore.py#L85-L95 | [
"def",
"index",
"(",
"self",
",",
"k",
",",
"recursive",
"=",
"False",
")",
":",
"k",
"=",
"k",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"endpoint",
",",
"k",
")",
"params",
"=",
"{",
"}",
"if",
... | 8ad2222b39d47defc8ad30deda3da06798e2a9a4 |
test | Client.delete | Delete a given key or recursively delete the tree below it | kvstore.py | def delete(self, k, recursive=False):
"""Delete a given key or recursively delete the tree below it"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if recursive:
params['recurse'] = ''
r = requests.delete(url, params=params)
if ... | def delete(self, k, recursive=False):
"""Delete a given key or recursively delete the tree below it"""
k = k.lstrip('/')
url = '{}/{}'.format(self.endpoint, k)
params = {}
if recursive:
params['recurse'] = ''
r = requests.delete(url, params=params)
if ... | [
"Delete",
"a",
"given",
"key",
"or",
"recursively",
"delete",
"the",
"tree",
"below",
"it"
] | bigdatacesga/kvstore | python | https://github.com/bigdatacesga/kvstore/blob/8ad2222b39d47defc8ad30deda3da06798e2a9a4/kvstore.py#L97-L106 | [
"def",
"delete",
"(",
"self",
",",
"k",
",",
"recursive",
"=",
"False",
")",
":",
"k",
"=",
"k",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"endpoint",
",",
"k",
")",
"params",
"=",
"{",
"}",
"if",
... | 8ad2222b39d47defc8ad30deda3da06798e2a9a4 |
test | internal_error | Render an "internal error" page. The following variables will be populated when rendering the
template:
title: The page title
message: The body of the error message to display to the user
preformat: Boolean stating whether to wrap the error message in a pre
As well as rendering the error mess... | littlefish/viewutil.py | def internal_error(exception, template_path, is_admin, db=None):
"""
Render an "internal error" page. The following variables will be populated when rendering the
template:
title: The page title
message: The body of the error message to display to the user
preformat: Boolean stating whethe... | def internal_error(exception, template_path, is_admin, db=None):
"""
Render an "internal error" page. The following variables will be populated when rendering the
template:
title: The page title
message: The body of the error message to display to the user
preformat: Boolean stating whethe... | [
"Render",
"an",
"internal",
"error",
"page",
".",
"The",
"following",
"variables",
"will",
"be",
"populated",
"when",
"rendering",
"the",
"template",
":",
"title",
":",
"The",
"page",
"title",
"message",
":",
"The",
"body",
"of",
"the",
"error",
"message",
... | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/viewutil.py#L15-L63 | [
"def",
"internal_error",
"(",
"exception",
",",
"template_path",
",",
"is_admin",
",",
"db",
"=",
"None",
")",
":",
"if",
"db",
":",
"try",
":",
"db",
".",
"session",
".",
"rollback",
"(",
")",
"except",
":",
"# noqa: E722",
"pass",
"title",
"=",
"str"... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | plot_heatmap | Plot heatmap which shows features with classes.
:param X: list of dict
:param y: labels
:param top_n: most important n feature
:param metric: metric which will be used for clustering
:param method: method which will be used for clustering | sklearn_utils/visualization/heatmap.py | def plot_heatmap(X, y, top_n=10, metric='correlation', method='complete'):
'''
Plot heatmap which shows features with classes.
:param X: list of dict
:param y: labels
:param top_n: most important n feature
:param metric: metric which will be used for clustering
:param method: method which w... | def plot_heatmap(X, y, top_n=10, metric='correlation', method='complete'):
'''
Plot heatmap which shows features with classes.
:param X: list of dict
:param y: labels
:param top_n: most important n feature
:param metric: metric which will be used for clustering
:param method: method which w... | [
"Plot",
"heatmap",
"which",
"shows",
"features",
"with",
"classes",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/visualization/heatmap.py#L7-L28 | [
"def",
"plot_heatmap",
"(",
"X",
",",
"y",
",",
"top_n",
"=",
"10",
",",
"metric",
"=",
"'correlation'",
",",
"method",
"=",
"'complete'",
")",
":",
"sns",
".",
"set",
"(",
"color_codes",
"=",
"True",
")",
"df",
"=",
"feature_importance_report",
"(",
"... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | get_setup_version | 获取打包使用的版本号,符合 PYPI 官方推荐的版本号方案
:return: PYPI 打包版本号
:rtype: str | source/mohand/version.py | def get_setup_version():
"""
获取打包使用的版本号,符合 PYPI 官方推荐的版本号方案
:return: PYPI 打包版本号
:rtype: str
"""
ver = '.'.join(map(str, VERSION[:3]))
# 若后缀描述字串为 None ,则直接返回主版本号
if not VERSION[3]:
return ver
# 否则,追加版本号后缀
hyphen = ''
suffix = hyphen.join(map(str, VERSION[-2:]))
i... | def get_setup_version():
"""
获取打包使用的版本号,符合 PYPI 官方推荐的版本号方案
:return: PYPI 打包版本号
:rtype: str
"""
ver = '.'.join(map(str, VERSION[:3]))
# 若后缀描述字串为 None ,则直接返回主版本号
if not VERSION[3]:
return ver
# 否则,追加版本号后缀
hyphen = ''
suffix = hyphen.join(map(str, VERSION[-2:]))
i... | [
"获取打包使用的版本号,符合",
"PYPI",
"官方推荐的版本号方案"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/version.py#L22-L42 | [
"def",
"get_setup_version",
"(",
")",
":",
"ver",
"=",
"'.'",
".",
"join",
"(",
"map",
"(",
"str",
",",
"VERSION",
"[",
":",
"3",
"]",
")",
")",
"# 若后缀描述字串为 None ,则直接返回主版本号",
"if",
"not",
"VERSION",
"[",
"3",
"]",
":",
"return",
"ver",
"# 否则,追加版本号后缀",
... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | get_cli_version | 获取终端命令版本号,若存在VERSION文件则使用其中的版本号,
否则使用 :meth:`.get_setup_version`
:return: 终端命令版本号
:rtype: str | source/mohand/version.py | def get_cli_version():
"""
获取终端命令版本号,若存在VERSION文件则使用其中的版本号,
否则使用 :meth:`.get_setup_version`
:return: 终端命令版本号
:rtype: str
"""
directory = os.path.dirname(os.path.abspath(__file__))
version_path = os.path.join(directory, 'VERSION')
if os.path.exists(version_path):
with open(ve... | def get_cli_version():
"""
获取终端命令版本号,若存在VERSION文件则使用其中的版本号,
否则使用 :meth:`.get_setup_version`
:return: 终端命令版本号
:rtype: str
"""
directory = os.path.dirname(os.path.abspath(__file__))
version_path = os.path.join(directory, 'VERSION')
if os.path.exists(version_path):
with open(ve... | [
"获取终端命令版本号,若存在VERSION文件则使用其中的版本号,",
"否则使用",
":",
"meth",
":",
".",
"get_setup_version"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/version.py#L45-L60 | [
"def",
"get_cli_version",
"(",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"version_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'VERSION'",
... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | add_months | Add a number of months to a timestamp | littlefish/timetool.py | def add_months(months, timestamp=datetime.datetime.utcnow()):
"""Add a number of months to a timestamp"""
month = timestamp.month
new_month = month + months
years = 0
while new_month < 1:
new_month += 12
years -= 1
while new_month > 12:
new_month -= 12
y... | def add_months(months, timestamp=datetime.datetime.utcnow()):
"""Add a number of months to a timestamp"""
month = timestamp.month
new_month = month + months
years = 0
while new_month < 1:
new_month += 12
years -= 1
while new_month > 12:
new_month -= 12
y... | [
"Add",
"a",
"number",
"of",
"months",
"to",
"a",
"timestamp"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L218-L251 | [
"def",
"add_months",
"(",
"months",
",",
"timestamp",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
")",
":",
"month",
"=",
"timestamp",
".",
"month",
"new_month",
"=",
"month",
"+",
"months",
"years",
"=",
"0",
"while",
"new_month",
"<",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | add_months_to_date | Add a number of months to a date | littlefish/timetool.py | def add_months_to_date(months, date):
"""Add a number of months to a date"""
month = date.month
new_month = month + months
years = 0
while new_month < 1:
new_month += 12
years -= 1
while new_month > 12:
new_month -= 12
years += 1
# month = timestamp.month
... | def add_months_to_date(months, date):
"""Add a number of months to a date"""
month = date.month
new_month = month + months
years = 0
while new_month < 1:
new_month += 12
years -= 1
while new_month > 12:
new_month -= 12
years += 1
# month = timestamp.month
... | [
"Add",
"a",
"number",
"of",
"months",
"to",
"a",
"date"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L254-L287 | [
"def",
"add_months_to_date",
"(",
"months",
",",
"date",
")",
":",
"month",
"=",
"date",
".",
"month",
"new_month",
"=",
"month",
"+",
"months",
"years",
"=",
"0",
"while",
"new_month",
"<",
"1",
":",
"new_month",
"+=",
"12",
"years",
"-=",
"1",
"while... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | unix_time | Generate a unix style timestamp (in seconds) | littlefish/timetool.py | def unix_time(dt=None, as_int=False):
"""Generate a unix style timestamp (in seconds)"""
if dt is None:
dt = datetime.datetime.utcnow()
if type(dt) is datetime.date:
dt = date_to_datetime(dt)
epoch = datetime.datetime.utcfromtimestamp(0)
delta = dt - epoch
if as_int:
... | def unix_time(dt=None, as_int=False):
"""Generate a unix style timestamp (in seconds)"""
if dt is None:
dt = datetime.datetime.utcnow()
if type(dt) is datetime.date:
dt = date_to_datetime(dt)
epoch = datetime.datetime.utcfromtimestamp(0)
delta = dt - epoch
if as_int:
... | [
"Generate",
"a",
"unix",
"style",
"timestamp",
"(",
"in",
"seconds",
")"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L290-L304 | [
"def",
"unix_time",
"(",
"dt",
"=",
"None",
",",
"as_int",
"=",
"False",
")",
":",
"if",
"dt",
"is",
"None",
":",
"dt",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"type",
"(",
"dt",
")",
"is",
"datetime",
".",
"date",
":",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | is_christmas_period | Is this the christmas period? | littlefish/timetool.py | def is_christmas_period():
"""Is this the christmas period?"""
now = datetime.date.today()
if now.month != 12:
return False
if now.day < 15:
return False
if now.day > 27:
return False
return True | def is_christmas_period():
"""Is this the christmas period?"""
now = datetime.date.today()
if now.month != 12:
return False
if now.day < 15:
return False
if now.day > 27:
return False
return True | [
"Is",
"this",
"the",
"christmas",
"period?"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L320-L329 | [
"def",
"is_christmas_period",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"if",
"now",
".",
"month",
"!=",
"12",
":",
"return",
"False",
"if",
"now",
".",
"day",
"<",
"15",
":",
"return",
"False",
"if",
"now",
".",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | get_end_of_day | Given a date or a datetime, return a datetime at 23:59:59 on that day | littlefish/timetool.py | def get_end_of_day(timestamp):
"""
Given a date or a datetime, return a datetime at 23:59:59 on that day
"""
return datetime.datetime(timestamp.year, timestamp.month, timestamp.day, 23, 59, 59) | def get_end_of_day(timestamp):
"""
Given a date or a datetime, return a datetime at 23:59:59 on that day
"""
return datetime.datetime(timestamp.year, timestamp.month, timestamp.day, 23, 59, 59) | [
"Given",
"a",
"date",
"or",
"a",
"datetime",
"return",
"a",
"datetime",
"at",
"23",
":",
"59",
":",
"59",
"on",
"that",
"day"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/timetool.py#L332-L336 | [
"def",
"get_end_of_day",
"(",
"timestamp",
")",
":",
"return",
"datetime",
".",
"datetime",
"(",
"timestamp",
".",
"year",
",",
"timestamp",
".",
"month",
",",
"timestamp",
".",
"day",
",",
"23",
",",
"59",
",",
"59",
")"
] | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | DictInput.transform | :param X: features. | sklearn_utils/preprocessing/dict_input.py | def transform(self, X):
'''
:param X: features.
'''
inverser_tranformer = self.dict_vectorizer_
if self.feature_selection:
inverser_tranformer = self.clone_dict_vectorizer_
return inverser_tranformer.inverse_transform(
self.transformer.transform(
... | def transform(self, X):
'''
:param X: features.
'''
inverser_tranformer = self.dict_vectorizer_
if self.feature_selection:
inverser_tranformer = self.clone_dict_vectorizer_
return inverser_tranformer.inverse_transform(
self.transformer.transform(
... | [
":",
"param",
"X",
":",
"features",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/preprocessing/dict_input.py#L29-L39 | [
"def",
"transform",
"(",
"self",
",",
"X",
")",
":",
"inverser_tranformer",
"=",
"self",
".",
"dict_vectorizer_",
"if",
"self",
".",
"feature_selection",
":",
"inverser_tranformer",
"=",
"self",
".",
"clone_dict_vectorizer_",
"return",
"inverser_tranformer",
".",
... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | ConnectionHandler.use_music_service | Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary | music2storage/connection.py | def use_music_service(self, service_name, api_key):
"""
Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary
"""
try:
self.current_music = self.music_services[ser... | def use_music_service(self, service_name, api_key):
"""
Sets the current music service to service_name.
:param str service_name: Name of the music service
:param str api_key: Optional API key if necessary
"""
try:
self.current_music = self.music_services[ser... | [
"Sets",
"the",
"current",
"music",
"service",
"to",
"service_name",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/connection.py#L16-L34 | [
"def",
"use_music_service",
"(",
"self",
",",
"service_name",
",",
"api_key",
")",
":",
"try",
":",
"self",
".",
"current_music",
"=",
"self",
".",
"music_services",
"[",
"service_name",
"]",
"except",
"KeyError",
":",
"if",
"service_name",
"==",
"'youtube'",
... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | ConnectionHandler.use_storage_service | Sets the current storage service to service_name and runs the connect method on the service.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage (optional, and must already exist, use absolute paths only) | music2storage/connection.py | def use_storage_service(self, service_name, custom_path):
"""
Sets the current storage service to service_name and runs the connect method on the service.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage ... | def use_storage_service(self, service_name, custom_path):
"""
Sets the current storage service to service_name and runs the connect method on the service.
:param str service_name: Name of the storage service
:param str custom_path: Custom path where to download tracks for local storage ... | [
"Sets",
"the",
"current",
"storage",
"service",
"to",
"service_name",
"and",
"runs",
"the",
"connect",
"method",
"on",
"the",
"service",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/connection.py#L36-L58 | [
"def",
"use_storage_service",
"(",
"self",
",",
"service_name",
",",
"custom_path",
")",
":",
"try",
":",
"self",
".",
"current_storage",
"=",
"self",
".",
"storage_services",
"[",
"service_name",
"]",
"except",
"KeyError",
":",
"if",
"service_name",
"==",
"'g... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | SkUtilsIO.from_csv | Read dataset from csv. | sklearn_utils/utils/skutils_io.py | def from_csv(self, label_column='labels'):
'''
Read dataset from csv.
'''
df = pd.read_csv(self.path, header=0)
X = df.loc[:, df.columns != label_column].to_dict('records')
X = map_dict_list(X, if_func=lambda k, v: v and math.isfinite(v))
y = list(df[label_column]... | def from_csv(self, label_column='labels'):
'''
Read dataset from csv.
'''
df = pd.read_csv(self.path, header=0)
X = df.loc[:, df.columns != label_column].to_dict('records')
X = map_dict_list(X, if_func=lambda k, v: v and math.isfinite(v))
y = list(df[label_column]... | [
"Read",
"dataset",
"from",
"csv",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/skutils_io.py#L23-L31 | [
"def",
"from_csv",
"(",
"self",
",",
"label_column",
"=",
"'labels'",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"self",
".",
"path",
",",
"header",
"=",
"0",
")",
"X",
"=",
"df",
".",
"loc",
"[",
":",
",",
"df",
".",
"columns",
"!=",
"la... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | SkUtilsIO.from_json | Reads dataset from json. | sklearn_utils/utils/skutils_io.py | def from_json(self):
'''
Reads dataset from json.
'''
with gzip.open('%s.gz' % self.path,
'rt') if self.gz else open(self.path) as file:
return list(map(list, zip(*json.load(file))))[::-1] | def from_json(self):
'''
Reads dataset from json.
'''
with gzip.open('%s.gz' % self.path,
'rt') if self.gz else open(self.path) as file:
return list(map(list, zip(*json.load(file))))[::-1] | [
"Reads",
"dataset",
"from",
"json",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/skutils_io.py#L40-L46 | [
"def",
"from_json",
"(",
"self",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"'%s.gz'",
"%",
"self",
".",
"path",
",",
"'rt'",
")",
"if",
"self",
".",
"gz",
"else",
"open",
"(",
"self",
".",
"path",
")",
"as",
"file",
":",
"return",
"list",
"(",
... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | SkUtilsIO.to_json | Reads dataset to csv.
:param X: dataset as list of dict.
:param y: labels. | sklearn_utils/utils/skutils_io.py | def to_json(self, X, y):
'''
Reads dataset to csv.
:param X: dataset as list of dict.
:param y: labels.
'''
with gzip.open('%s.gz' % self.path, 'wt') if self.gz else open(
self.path, 'w') as file:
json.dump(list(zip(y, X)), file) | def to_json(self, X, y):
'''
Reads dataset to csv.
:param X: dataset as list of dict.
:param y: labels.
'''
with gzip.open('%s.gz' % self.path, 'wt') if self.gz else open(
self.path, 'w') as file:
json.dump(list(zip(y, X)), file) | [
"Reads",
"dataset",
"to",
"csv",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/skutils_io.py#L48-L57 | [
"def",
"to_json",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"with",
"gzip",
".",
"open",
"(",
"'%s.gz'",
"%",
"self",
".",
"path",
",",
"'wt'",
")",
"if",
"self",
".",
"gz",
"else",
"open",
"(",
"self",
".",
"path",
",",
"'w'",
")",
"as",
"f... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | filter_by_label | Select items with label from dataset.
:param X: dataset
:param y: labels
:param ref_label: reference label
:param bool reverse: if false selects ref_labels else eliminates | sklearn_utils/utils/data_utils.py | def filter_by_label(X, y, ref_label, reverse=False):
'''
Select items with label from dataset.
:param X: dataset
:param y: labels
:param ref_label: reference label
:param bool reverse: if false selects ref_labels else eliminates
'''
check_reference_label(y, ref_label)
return list(z... | def filter_by_label(X, y, ref_label, reverse=False):
'''
Select items with label from dataset.
:param X: dataset
:param y: labels
:param ref_label: reference label
:param bool reverse: if false selects ref_labels else eliminates
'''
check_reference_label(y, ref_label)
return list(z... | [
"Select",
"items",
"with",
"label",
"from",
"dataset",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L8-L20 | [
"def",
"filter_by_label",
"(",
"X",
",",
"y",
",",
"ref_label",
",",
"reverse",
"=",
"False",
")",
":",
"check_reference_label",
"(",
"y",
",",
"ref_label",
")",
"return",
"list",
"(",
"zip",
"(",
"*",
"filter",
"(",
"lambda",
"t",
":",
"(",
"not",
"... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | average_by_label | Calculates average dictinary from list of dictionary for give label
:param List[Dict] X: dataset
:param list y: labels
:param ref_label: reference label | sklearn_utils/utils/data_utils.py | def average_by_label(X, y, ref_label):
'''
Calculates average dictinary from list of dictionary for give label
:param List[Dict] X: dataset
:param list y: labels
:param ref_label: reference label
'''
# TODO: consider to delete defaultdict
return defaultdict(float,
... | def average_by_label(X, y, ref_label):
'''
Calculates average dictinary from list of dictionary for give label
:param List[Dict] X: dataset
:param list y: labels
:param ref_label: reference label
'''
# TODO: consider to delete defaultdict
return defaultdict(float,
... | [
"Calculates",
"average",
"dictinary",
"from",
"list",
"of",
"dictionary",
"for",
"give",
"label"
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L23-L35 | [
"def",
"average_by_label",
"(",
"X",
",",
"y",
",",
"ref_label",
")",
":",
"# TODO: consider to delete defaultdict",
"return",
"defaultdict",
"(",
"float",
",",
"pd",
".",
"DataFrame",
".",
"from_records",
"(",
"filter_by_label",
"(",
"X",
",",
"y",
",",
"ref_... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | map_dict | :param dict d: dictionary
:param func key_func: func which will run on key.
:param func value_func: func which will run on values. | sklearn_utils/utils/data_utils.py | def map_dict(d, key_func=None, value_func=None, if_func=None):
'''
:param dict d: dictionary
:param func key_func: func which will run on key.
:param func value_func: func which will run on values.
'''
key_func = key_func or (lambda k, v: k)
value_func = value_func or (lambda k, v: v)
if... | def map_dict(d, key_func=None, value_func=None, if_func=None):
'''
:param dict d: dictionary
:param func key_func: func which will run on key.
:param func value_func: func which will run on values.
'''
key_func = key_func or (lambda k, v: k)
value_func = value_func or (lambda k, v: v)
if... | [
":",
"param",
"dict",
"d",
":",
"dictionary",
":",
"param",
"func",
"key_func",
":",
"func",
"which",
"will",
"run",
"on",
"key",
".",
":",
"param",
"func",
"value_func",
":",
"func",
"which",
"will",
"run",
"on",
"values",
"."
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L38-L50 | [
"def",
"map_dict",
"(",
"d",
",",
"key_func",
"=",
"None",
",",
"value_func",
"=",
"None",
",",
"if_func",
"=",
"None",
")",
":",
"key_func",
"=",
"key_func",
"or",
"(",
"lambda",
"k",
",",
"v",
":",
"k",
")",
"value_func",
"=",
"value_func",
"or",
... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | map_dict_list | :param List[Dict] ds: list of dict
:param func key_func: func which will run on key.
:param func value_func: func which will run on values. | sklearn_utils/utils/data_utils.py | def map_dict_list(ds, key_func=None, value_func=None, if_func=None):
'''
:param List[Dict] ds: list of dict
:param func key_func: func which will run on key.
:param func value_func: func which will run on values.
'''
return [map_dict(d, key_func, value_func, if_func) for d in ds] | def map_dict_list(ds, key_func=None, value_func=None, if_func=None):
'''
:param List[Dict] ds: list of dict
:param func key_func: func which will run on key.
:param func value_func: func which will run on values.
'''
return [map_dict(d, key_func, value_func, if_func) for d in ds] | [
":",
"param",
"List",
"[",
"Dict",
"]",
"ds",
":",
"list",
"of",
"dict",
":",
"param",
"func",
"key_func",
":",
"func",
"which",
"will",
"run",
"on",
"key",
".",
":",
"param",
"func",
"value_func",
":",
"func",
"which",
"will",
"run",
"on",
"values",... | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L53-L59 | [
"def",
"map_dict_list",
"(",
"ds",
",",
"key_func",
"=",
"None",
",",
"value_func",
"=",
"None",
",",
"if_func",
"=",
"None",
")",
":",
"return",
"[",
"map_dict",
"(",
"d",
",",
"key_func",
",",
"value_func",
",",
"if_func",
")",
"for",
"d",
"in",
"d... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | check_reference_label | :param list y: label
:param ref_label: reference label | sklearn_utils/utils/data_utils.py | def check_reference_label(y, ref_label):
'''
:param list y: label
:param ref_label: reference label
'''
set_y = set(y)
if ref_label not in set_y:
raise ValueError('There is not reference label in dataset. '
"Reference label: '%s' "
'Label... | def check_reference_label(y, ref_label):
'''
:param list y: label
:param ref_label: reference label
'''
set_y = set(y)
if ref_label not in set_y:
raise ValueError('There is not reference label in dataset. '
"Reference label: '%s' "
'Label... | [
":",
"param",
"list",
"y",
":",
"label",
":",
"param",
"ref_label",
":",
"reference",
"label"
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L62-L71 | [
"def",
"check_reference_label",
"(",
"y",
",",
"ref_label",
")",
":",
"set_y",
"=",
"set",
"(",
"y",
")",
"if",
"ref_label",
"not",
"in",
"set_y",
":",
"raise",
"ValueError",
"(",
"'There is not reference label in dataset. '",
"\"Reference label: '%s' \"",
"'Labels ... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | feature_importance_report | Provide signifance for features in dataset with anova using multiple hypostesis testing
:param X: List of dict with key as feature names and values as features
:param y: Labels
:param threshold: Low-variens threshold to eliminate low varience features
:param correcting_multiple_hypotesis: corrects p-va... | sklearn_utils/utils/data_utils.py | def feature_importance_report(X,
y,
threshold=0.001,
correcting_multiple_hypotesis=True,
method='fdr_bh',
alpha=0.1,
sort_by='pval'):
''... | def feature_importance_report(X,
y,
threshold=0.001,
correcting_multiple_hypotesis=True,
method='fdr_bh',
alpha=0.1,
sort_by='pval'):
''... | [
"Provide",
"signifance",
"for",
"features",
"in",
"dataset",
"with",
"anova",
"using",
"multiple",
"hypostesis",
"testing"
] | MuhammedHasan/sklearn_utils | python | https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/utils/data_utils.py#L80-L113 | [
"def",
"feature_importance_report",
"(",
"X",
",",
"y",
",",
"threshold",
"=",
"0.001",
",",
"correcting_multiple_hypotesis",
"=",
"True",
",",
"method",
"=",
"'fdr_bh'",
",",
"alpha",
"=",
"0.1",
",",
"sort_by",
"=",
"'pval'",
")",
":",
"df",
"=",
"varian... | 337c3b7a27f4921d12da496f66a2b83ef582b413 |
test | SessionData.restore_data | Restore the data dict - update the flask session and this object | littlefish/sessiondata/framework.py | def restore_data(self, data_dict):
"""
Restore the data dict - update the flask session and this object
"""
session[self._base_key] = data_dict
self._data_dict = session[self._base_key] | def restore_data(self, data_dict):
"""
Restore the data dict - update the flask session and this object
"""
session[self._base_key] = data_dict
self._data_dict = session[self._base_key] | [
"Restore",
"the",
"data",
"dict",
"-",
"update",
"the",
"flask",
"session",
"and",
"this",
"object"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/sessiondata/framework.py#L119-L124 | [
"def",
"restore_data",
"(",
"self",
",",
"data_dict",
")",
":",
"session",
"[",
"self",
".",
"_base_key",
"]",
"=",
"data_dict",
"self",
".",
"_data_dict",
"=",
"session",
"[",
"self",
".",
"_base_key",
"]"
] | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | _mergedict | Recusively merge the 2 dicts.
Destructive on argument 'a'. | src/pyproxyfs/__init__.py | def _mergedict(a, b):
"""Recusively merge the 2 dicts.
Destructive on argument 'a'.
"""
for p, d1 in b.items():
if p in a:
if not isinstance(d1, dict):
continue
_mergedict(a[p], d1)
else:
a[p] = d1
return a | def _mergedict(a, b):
"""Recusively merge the 2 dicts.
Destructive on argument 'a'.
"""
for p, d1 in b.items():
if p in a:
if not isinstance(d1, dict):
continue
_mergedict(a[p], d1)
else:
a[p] = d1
return a | [
"Recusively",
"merge",
"the",
"2",
"dicts",
"."
] | nicferrier/pyproxyfs | python | https://github.com/nicferrier/pyproxyfs/blob/7db09bb07bdeece56b7b1c4bf78c9f0b0a03c14b/src/pyproxyfs/__init__.py#L51-L63 | [
"def",
"_mergedict",
"(",
"a",
",",
"b",
")",
":",
"for",
"p",
",",
"d1",
"in",
"b",
".",
"items",
"(",
")",
":",
"if",
"p",
"in",
"a",
":",
"if",
"not",
"isinstance",
"(",
"d1",
",",
"dict",
")",
":",
"continue",
"_mergedict",
"(",
"a",
"[",... | 7db09bb07bdeece56b7b1c4bf78c9f0b0a03c14b |
test | multi | A decorator for a function to dispatch on.
The value returned by the dispatch function is used to look up the
implementation function based on its dispatch key.
The dispatch function is available using the `dispatch_fn` function. | dialogue/multi_method/__init__.py | def multi(dispatch_fn, default=None):
"""A decorator for a function to dispatch on.
The value returned by the dispatch function is used to look up the
implementation function based on its dispatch key.
The dispatch function is available using the `dispatch_fn` function.
"""
def _inner(*args, ... | def multi(dispatch_fn, default=None):
"""A decorator for a function to dispatch on.
The value returned by the dispatch function is used to look up the
implementation function based on its dispatch key.
The dispatch function is available using the `dispatch_fn` function.
"""
def _inner(*args, ... | [
"A",
"decorator",
"for",
"a",
"function",
"to",
"dispatch",
"on",
"."
] | dialoguemd/multi-method | python | https://github.com/dialoguemd/multi-method/blob/8b405d4c5ad74a2a36a4ecf88283262defa2e737/dialogue/multi_method/__init__.py#L5-L27 | [
"def",
"multi",
"(",
"dispatch_fn",
",",
"default",
"=",
"None",
")",
":",
"def",
"_inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"dispatch_value",
"=",
"dispatch_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"f",
"=",
"_inner... | 8b405d4c5ad74a2a36a4ecf88283262defa2e737 |
test | method | A decorator for a function implementing dispatch_fn for dispatch_key.
If no dispatch_key is specified, the function is used as the
default dispacth function. | dialogue/multi_method/__init__.py | def method(dispatch_fn, dispatch_key=None):
"""A decorator for a function implementing dispatch_fn for dispatch_key.
If no dispatch_key is specified, the function is used as the
default dispacth function.
"""
def apply_decorator(fn):
if dispatch_key is None:
# Default case
... | def method(dispatch_fn, dispatch_key=None):
"""A decorator for a function implementing dispatch_fn for dispatch_key.
If no dispatch_key is specified, the function is used as the
default dispacth function.
"""
def apply_decorator(fn):
if dispatch_key is None:
# Default case
... | [
"A",
"decorator",
"for",
"a",
"function",
"implementing",
"dispatch_fn",
"for",
"dispatch_key",
"."
] | dialoguemd/multi-method | python | https://github.com/dialoguemd/multi-method/blob/8b405d4c5ad74a2a36a4ecf88283262defa2e737/dialogue/multi_method/__init__.py#L30-L45 | [
"def",
"method",
"(",
"dispatch_fn",
",",
"dispatch_key",
"=",
"None",
")",
":",
"def",
"apply_decorator",
"(",
"fn",
")",
":",
"if",
"dispatch_key",
"is",
"None",
":",
"# Default case",
"dispatch_fn",
".",
"__multi_default__",
"=",
"fn",
"else",
":",
"dispa... | 8b405d4c5ad74a2a36a4ecf88283262defa2e737 |
test | find_blocks | Auto-discover INSTALLED_APPS registered_blocks.py modules and fail
silently when not present. This forces an import on them thereby
registering their blocks.
This is a near 1-to-1 copy of how django's admin application registers
models. | streamfield_tools/registry.py | def find_blocks():
"""
Auto-discover INSTALLED_APPS registered_blocks.py modules and fail
silently when not present. This forces an import on them thereby
registering their blocks.
This is a near 1-to-1 copy of how django's admin application registers
models.
"""
for app in settings.IN... | def find_blocks():
"""
Auto-discover INSTALLED_APPS registered_blocks.py modules and fail
silently when not present. This forces an import on them thereby
registering their blocks.
This is a near 1-to-1 copy of how django's admin application registers
models.
"""
for app in settings.IN... | [
"Auto",
"-",
"discover",
"INSTALLED_APPS",
"registered_blocks",
".",
"py",
"modules",
"and",
"fail",
"silently",
"when",
"not",
"present",
".",
"This",
"forces",
"an",
"import",
"on",
"them",
"thereby",
"registering",
"their",
"blocks",
"."
] | WGBH/wagtail-streamfieldtools | python | https://github.com/WGBH/wagtail-streamfieldtools/blob/192f86845532742b0b7d432bef3987357833b8ed/streamfield_tools/registry.py#L78-L107 | [
"def",
"find_blocks",
"(",
")",
":",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"mod",
"=",
"import_module",
"(",
"app",
")",
"# Attempt to import the app's sizedimage module.",
"try",
":",
"before_import_block_registry",
"=",
"copy",
".",
"copy",
... | 192f86845532742b0b7d432bef3987357833b8ed |
test | RegisteredBlockStreamFieldRegistry._verify_block | Verifies a block prior to registration. | streamfield_tools/registry.py | def _verify_block(self, block_type, block):
"""
Verifies a block prior to registration.
"""
if block_type in self._registry:
raise AlreadyRegistered(
"A block has already been registered to the {} `block_type` "
"in the registry. Either unregis... | def _verify_block(self, block_type, block):
"""
Verifies a block prior to registration.
"""
if block_type in self._registry:
raise AlreadyRegistered(
"A block has already been registered to the {} `block_type` "
"in the registry. Either unregis... | [
"Verifies",
"a",
"block",
"prior",
"to",
"registration",
"."
] | WGBH/wagtail-streamfieldtools | python | https://github.com/WGBH/wagtail-streamfieldtools/blob/192f86845532742b0b7d432bef3987357833b8ed/streamfield_tools/registry.py#L32-L49 | [
"def",
"_verify_block",
"(",
"self",
",",
"block_type",
",",
"block",
")",
":",
"if",
"block_type",
"in",
"self",
".",
"_registry",
":",
"raise",
"AlreadyRegistered",
"(",
"\"A block has already been registered to the {} `block_type` \"",
"\"in the registry. Either unregist... | 192f86845532742b0b7d432bef3987357833b8ed |
test | RegisteredBlockStreamFieldRegistry.register_block | Registers `block` to `block_type` in the registry. | streamfield_tools/registry.py | def register_block(self, block_type, block):
"""
Registers `block` to `block_type` in the registry.
"""
self._verify_block(block_type, block)
self._registry[block_type] = block | def register_block(self, block_type, block):
"""
Registers `block` to `block_type` in the registry.
"""
self._verify_block(block_type, block)
self._registry[block_type] = block | [
"Registers",
"block",
"to",
"block_type",
"in",
"the",
"registry",
"."
] | WGBH/wagtail-streamfieldtools | python | https://github.com/WGBH/wagtail-streamfieldtools/blob/192f86845532742b0b7d432bef3987357833b8ed/streamfield_tools/registry.py#L51-L57 | [
"def",
"register_block",
"(",
"self",
",",
"block_type",
",",
"block",
")",
":",
"self",
".",
"_verify_block",
"(",
"block_type",
",",
"block",
")",
"self",
".",
"_registry",
"[",
"block_type",
"]",
"=",
"block"
] | 192f86845532742b0b7d432bef3987357833b8ed |
test | RegisteredBlockStreamFieldRegistry.unregister_block | Unregisters the block associated with `block_type` from the registry.
If no block is registered to `block_type`, NotRegistered will raise. | streamfield_tools/registry.py | def unregister_block(self, block_type):
"""
Unregisters the block associated with `block_type` from the registry.
If no block is registered to `block_type`, NotRegistered will raise.
"""
if block_type not in self._registry:
raise NotRegistered(
'There... | def unregister_block(self, block_type):
"""
Unregisters the block associated with `block_type` from the registry.
If no block is registered to `block_type`, NotRegistered will raise.
"""
if block_type not in self._registry:
raise NotRegistered(
'There... | [
"Unregisters",
"the",
"block",
"associated",
"with",
"block_type",
"from",
"the",
"registry",
"."
] | WGBH/wagtail-streamfieldtools | python | https://github.com/WGBH/wagtail-streamfieldtools/blob/192f86845532742b0b7d432bef3987357833b8ed/streamfield_tools/registry.py#L59-L73 | [
"def",
"unregister_block",
"(",
"self",
",",
"block_type",
")",
":",
"if",
"block_type",
"not",
"in",
"self",
".",
"_registry",
":",
"raise",
"NotRegistered",
"(",
"'There is no block registered as \"{}\" with the '",
"'RegisteredBlockStreamFieldRegistry registry.'",
".",
... | 192f86845532742b0b7d432bef3987357833b8ed |
test | convert_to_mp3 | Converts the file associated with the file_name passed into a MP3 file.
:param str file_name: Filename of the original file in local storage
:param Queue delete_queue: Delete queue to add the original file to after conversion is done
:return str: Filename of the new file in local storage | music2storage/helpers.py | def convert_to_mp3(file_name, delete_queue):
"""
Converts the file associated with the file_name passed into a MP3 file.
:param str file_name: Filename of the original file in local storage
:param Queue delete_queue: Delete queue to add the original file to after conversion is done
:return str: Fil... | def convert_to_mp3(file_name, delete_queue):
"""
Converts the file associated with the file_name passed into a MP3 file.
:param str file_name: Filename of the original file in local storage
:param Queue delete_queue: Delete queue to add the original file to after conversion is done
:return str: Fil... | [
"Converts",
"the",
"file",
"associated",
"with",
"the",
"file_name",
"passed",
"into",
"a",
"MP3",
"file",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/helpers.py#L12-L46 | [
"def",
"convert_to_mp3",
"(",
"file_name",
",",
"delete_queue",
")",
":",
"file",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name",
")",
"if",
"file",
"[",
"1",
"]",
"==",
"'.mp3'",
":",
"log",
".",
"info",
"(",
"f\"{file_name} is already a MP3 fi... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | delete_local_file | Deletes the file associated with the file_name passed from local storage.
:param str file_name: Filename of the file to be deleted
:return str: Filename of the file that was just deleted | music2storage/helpers.py | def delete_local_file(file_name):
"""
Deletes the file associated with the file_name passed from local storage.
:param str file_name: Filename of the file to be deleted
:return str: Filename of the file that was just deleted
"""
try:
os.remove(file_name)
log.info(f"Deletion... | def delete_local_file(file_name):
"""
Deletes the file associated with the file_name passed from local storage.
:param str file_name: Filename of the file to be deleted
:return str: Filename of the file that was just deleted
"""
try:
os.remove(file_name)
log.info(f"Deletion... | [
"Deletes",
"the",
"file",
"associated",
"with",
"the",
"file_name",
"passed",
"from",
"local",
"storage",
".",
":",
"param",
"str",
"file_name",
":",
"Filename",
"of",
"the",
"file",
"to",
"be",
"deleted",
":",
"return",
"str",
":",
"Filename",
"of",
"the"... | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/helpers.py#L49-L62 | [
"def",
"delete_local_file",
"(",
"file_name",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"file_name",
")",
"log",
".",
"info",
"(",
"f\"Deletion for {file_name} has finished\"",
")",
"return",
"file_name",
"except",
"OSError",
":",
"pass"
] | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | cli | 通用自动化处理工具
详情参考 `GitHub <https://github.com/littlemo/mohand>`_ | source/mohand/main.py | def cli(*args, **kwargs):
"""
通用自动化处理工具
详情参考 `GitHub <https://github.com/littlemo/mohand>`_
"""
log.debug('cli: {} {}'.format(args, kwargs))
# 使用终端传入的 option 更新 env 中的配置值
env.update(kwargs) | def cli(*args, **kwargs):
"""
通用自动化处理工具
详情参考 `GitHub <https://github.com/littlemo/mohand>`_
"""
log.debug('cli: {} {}'.format(args, kwargs))
# 使用终端传入的 option 更新 env 中的配置值
env.update(kwargs) | [
"通用自动化处理工具"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/main.py#L86-L95 | [
"def",
"cli",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"'cli: {} {}'",
".",
"format",
"(",
"args",
",",
"kwargs",
")",
")",
"# 使用终端传入的 option 更新 env 中的配置值",
"env",
".",
"update",
"(",
"kwargs",
")"
] | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | _is_package | 判断传入的路径是否为一个 Python 模块包
:param str path: 待判断的路径
:return: 返回是,则传入 path 为一个 Python 包,否则不是
:rtype: bool | source/mohand/load_file.py | def _is_package(path):
"""
判断传入的路径是否为一个 Python 模块包
:param str path: 待判断的路径
:return: 返回是,则传入 path 为一个 Python 包,否则不是
:rtype: bool
"""
def _exists(s):
return os.path.exists(os.path.join(path, s))
return (
os.path.isdir(path) and
(_exists('__init__.py') or _exists('... | def _is_package(path):
"""
判断传入的路径是否为一个 Python 模块包
:param str path: 待判断的路径
:return: 返回是,则传入 path 为一个 Python 包,否则不是
:rtype: bool
"""
def _exists(s):
return os.path.exists(os.path.join(path, s))
return (
os.path.isdir(path) and
(_exists('__init__.py') or _exists('... | [
"判断传入的路径是否为一个",
"Python",
"模块包"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/load_file.py#L11-L25 | [
"def",
"_is_package",
"(",
"path",
")",
":",
"def",
"_exists",
"(",
"s",
")",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"s",
")",
")",
"return",
"(",
"os",
".",
"path",
".",
"isdir",... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | find_handfile | 尝试定位 ``handfile`` 文件,明确指定或逐级搜索父路径
:param str names: 可选,待查找的文件名,主要用于调试,默认使用终端传入的配置
:return: ``handfile`` 文件所在的绝对路径,默认为 None
:rtype: str | source/mohand/load_file.py | def find_handfile(names=None):
"""
尝试定位 ``handfile`` 文件,明确指定或逐级搜索父路径
:param str names: 可选,待查找的文件名,主要用于调试,默认使用终端传入的配置
:return: ``handfile`` 文件所在的绝对路径,默认为 None
:rtype: str
"""
# 如果没有明确指定,则包含 env 中的值
names = names or [env.handfile]
# 若无 ``.py`` 扩展名,则作为待查询名称,追加到 names 末尾
if not nam... | def find_handfile(names=None):
"""
尝试定位 ``handfile`` 文件,明确指定或逐级搜索父路径
:param str names: 可选,待查找的文件名,主要用于调试,默认使用终端传入的配置
:return: ``handfile`` 文件所在的绝对路径,默认为 None
:rtype: str
"""
# 如果没有明确指定,则包含 env 中的值
names = names or [env.handfile]
# 若无 ``.py`` 扩展名,则作为待查询名称,追加到 names 末尾
if not nam... | [
"尝试定位",
"handfile",
"文件,明确指定或逐级搜索父路径"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/load_file.py#L28-L64 | [
"def",
"find_handfile",
"(",
"names",
"=",
"None",
")",
":",
"# 如果没有明确指定,则包含 env 中的值",
"names",
"=",
"names",
"or",
"[",
"env",
".",
"handfile",
"]",
"# 若无 ``.py`` 扩展名,则作为待查询名称,追加到 names 末尾",
"if",
"not",
"names",
"[",
"0",
"]",
".",
"endswith",
"(",
"'.py'",
... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | get_commands_from_module | 从传入的 ``imported`` 中获取所有 ``click.core.Command``
:param module imported: 导入的Python包
:return: 包描述文档,仅含终端命令函数的对象字典
:rtype: (str, dict(str, object)) | source/mohand/load_file.py | def get_commands_from_module(imported):
"""
从传入的 ``imported`` 中获取所有 ``click.core.Command``
:param module imported: 导入的Python包
:return: 包描述文档,仅含终端命令函数的对象字典
:rtype: (str, dict(str, object))
"""
# 如果存在 <module>.__all__ ,则遵守
imported_vars = vars(imported)
if "__all__" in imported_vars:
... | def get_commands_from_module(imported):
"""
从传入的 ``imported`` 中获取所有 ``click.core.Command``
:param module imported: 导入的Python包
:return: 包描述文档,仅含终端命令函数的对象字典
:rtype: (str, dict(str, object))
"""
# 如果存在 <module>.__all__ ,则遵守
imported_vars = vars(imported)
if "__all__" in imported_vars:
... | [
"从传入的",
"imported",
"中获取所有",
"click",
".",
"core",
".",
"Command"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/load_file.py#L67-L85 | [
"def",
"get_commands_from_module",
"(",
"imported",
")",
":",
"# 如果存在 <module>.__all__ ,则遵守",
"imported_vars",
"=",
"vars",
"(",
"imported",
")",
"if",
"\"__all__\"",
"in",
"imported_vars",
":",
"imported_vars",
"=",
"[",
"(",
"name",
",",
"imported_vars",
"[",
"n... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | extract_commands | 从传入的变量列表中提取命令( ``click.core.Command`` )对象
:param dict_items imported_vars: 字典的键值条目列表
:return: 判定为终端命令的对象字典
:rtype: dict(str, object) | source/mohand/load_file.py | def extract_commands(imported_vars):
"""
从传入的变量列表中提取命令( ``click.core.Command`` )对象
:param dict_items imported_vars: 字典的键值条目列表
:return: 判定为终端命令的对象字典
:rtype: dict(str, object)
"""
commands = dict()
for tup in imported_vars:
name, obj = tup
if is_command_object(obj):
... | def extract_commands(imported_vars):
"""
从传入的变量列表中提取命令( ``click.core.Command`` )对象
:param dict_items imported_vars: 字典的键值条目列表
:return: 判定为终端命令的对象字典
:rtype: dict(str, object)
"""
commands = dict()
for tup in imported_vars:
name, obj = tup
if is_command_object(obj):
... | [
"从传入的变量列表中提取命令",
"(",
"click",
".",
"core",
".",
"Command",
")",
"对象"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/load_file.py#L99-L112 | [
"def",
"extract_commands",
"(",
"imported_vars",
")",
":",
"commands",
"=",
"dict",
"(",
")",
"for",
"tup",
"in",
"imported_vars",
":",
"name",
",",
"obj",
"=",
"tup",
"if",
"is_command_object",
"(",
"obj",
")",
":",
"commands",
".",
"setdefault",
"(",
"... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | load_handfile | 导入传入的 ``handfile`` 文件路径,并返回(docstring, callables)
也就是 handfile 包的 ``__doc__`` 属性 (字符串) 和一个 ``{'name': callable}``
的字典,包含所有通过 mohand 的 command 测试的 callables
:param str path: 待导入的 handfile 文件路径
:param function importer: 可选,包导入函数,默认为 ``__import__``
:return: 包描述文档,仅含终端命令函数的对象字典
:rtype: (str, dict(... | source/mohand/load_file.py | def load_handfile(path, importer=None):
"""
导入传入的 ``handfile`` 文件路径,并返回(docstring, callables)
也就是 handfile 包的 ``__doc__`` 属性 (字符串) 和一个 ``{'name': callable}``
的字典,包含所有通过 mohand 的 command 测试的 callables
:param str path: 待导入的 handfile 文件路径
:param function importer: 可选,包导入函数,默认为 ``__import__``
... | def load_handfile(path, importer=None):
"""
导入传入的 ``handfile`` 文件路径,并返回(docstring, callables)
也就是 handfile 包的 ``__doc__`` 属性 (字符串) 和一个 ``{'name': callable}``
的字典,包含所有通过 mohand 的 command 测试的 callables
:param str path: 待导入的 handfile 文件路径
:param function importer: 可选,包导入函数,默认为 ``__import__``
... | [
"导入传入的",
"handfile",
"文件路径,并返回",
"(",
"docstring",
"callables",
")"
] | littlemo/mohand | python | https://github.com/littlemo/mohand/blob/9bd4591e457d594f2ce3a0c089ef28d3b4e027e8/source/mohand/load_file.py#L115-L170 | [
"def",
"load_handfile",
"(",
"path",
",",
"importer",
"=",
"None",
")",
":",
"if",
"importer",
"is",
"None",
":",
"importer",
"=",
"__import__",
"# 获取路径&文件名",
"directory",
",",
"handfile",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"# 如果路径不在... | 9bd4591e457d594f2ce3a0c089ef28d3b4e027e8 |
test | GitReleaseChecks.reasonable_desired_version | Determine whether the desired version is a reasonable next version.
Parameters
----------
desired_version: str
the proposed next version name | autorelease/git_repo_checks.py | def reasonable_desired_version(self, desired_version, allow_equal=False,
allow_patch_skip=False):
"""
Determine whether the desired version is a reasonable next version.
Parameters
----------
desired_version: str
the proposed next ve... | def reasonable_desired_version(self, desired_version, allow_equal=False,
allow_patch_skip=False):
"""
Determine whether the desired version is a reasonable next version.
Parameters
----------
desired_version: str
the proposed next ve... | [
"Determine",
"whether",
"the",
"desired",
"version",
"is",
"a",
"reasonable",
"next",
"version",
"."
] | dwhswenson/autorelease | python | https://github.com/dwhswenson/autorelease/blob/339c32c3934e4751857f35aaa2bfffaaaf3b39c4/autorelease/git_repo_checks.py#L50-L96 | [
"def",
"reasonable_desired_version",
"(",
"self",
",",
"desired_version",
",",
"allow_equal",
"=",
"False",
",",
"allow_patch_skip",
"=",
"False",
")",
":",
"try",
":",
"desired_version",
"=",
"desired_version",
".",
"base_version",
"except",
":",
"pass",
"(",
"... | 339c32c3934e4751857f35aaa2bfffaaaf3b39c4 |
test | handle_ssl_redirect | Check if a route needs ssl, and redirect it if not. Also redirects back to http for non-ssl routes. Static routes
are served as both http and https
:return: A response to be returned or None | littlefish/sslutil.py | def handle_ssl_redirect():
"""
Check if a route needs ssl, and redirect it if not. Also redirects back to http for non-ssl routes. Static routes
are served as both http and https
:return: A response to be returned or None
"""
if request.endpoint and request.endpoint not in ['static', 'fileman... | def handle_ssl_redirect():
"""
Check if a route needs ssl, and redirect it if not. Also redirects back to http for non-ssl routes. Static routes
are served as both http and https
:return: A response to be returned or None
"""
if request.endpoint and request.endpoint not in ['static', 'fileman... | [
"Check",
"if",
"a",
"route",
"needs",
"ssl",
"and",
"redirect",
"it",
"if",
"not",
".",
"Also",
"redirects",
"back",
"to",
"http",
"for",
"non",
"-",
"ssl",
"routes",
".",
"Static",
"routes",
"are",
"served",
"as",
"both",
"http",
"and",
"https"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/sslutil.py#L44-L75 | [
"def",
"handle_ssl_redirect",
"(",
")",
":",
"if",
"request",
".",
"endpoint",
"and",
"request",
".",
"endpoint",
"not",
"in",
"[",
"'static'",
",",
"'filemanager.static'",
"]",
":",
"needs_ssl",
"=",
"False",
"ssl_enabled",
"=",
"False",
"view_function",
"=",... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | init | Initialise this library. The following config variables need to be in your Flask config:
REDIS_HOST: The host of the Redis server
REDIS_PORT: The port of the Redis server
REDIS_PASSWORD: The password used to connect to Redis or None
REDIS_GLOBAL_KEY_PREFIX: A short string unique to your application i.... | littlefish/redisutil.py | def init(app):
"""
Initialise this library. The following config variables need to be in your Flask config:
REDIS_HOST: The host of the Redis server
REDIS_PORT: The port of the Redis server
REDIS_PASSWORD: The password used to connect to Redis or None
REDIS_GLOBAL_KEY_PREFIX: A short string un... | def init(app):
"""
Initialise this library. The following config variables need to be in your Flask config:
REDIS_HOST: The host of the Redis server
REDIS_PORT: The port of the Redis server
REDIS_PASSWORD: The password used to connect to Redis or None
REDIS_GLOBAL_KEY_PREFIX: A short string un... | [
"Initialise",
"this",
"library",
".",
"The",
"following",
"config",
"variables",
"need",
"to",
"be",
"in",
"your",
"Flask",
"config",
":"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/redisutil.py#L62-L86 | [
"def",
"init",
"(",
"app",
")",
":",
"global",
"connection",
",",
"LOCK_TIMEOUT",
",",
"GLOBAL_KEY_PREFIX",
"host",
"=",
"app",
".",
"config",
"[",
"'REDIS_HOST'",
"]",
"port",
"=",
"app",
".",
"config",
"[",
"'REDIS_PORT'",
"]",
"password",
"=",
"app",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | get_enable_celery_error_reporting_function | Use this to enable error reporting. You need to put the following in your tasks.py or wherever you
want to create your celery instance:
celery = Celery(__name__)
enable_celery_email_logging = get_enable_celery_error_reporting_function('My Website [LIVE]', 'errors@mywebsite.com')
after_setup_logger.co... | littlefish/celeryutil.py | def get_enable_celery_error_reporting_function(site_name, from_address):
"""
Use this to enable error reporting. You need to put the following in your tasks.py or wherever you
want to create your celery instance:
celery = Celery(__name__)
enable_celery_email_logging = get_enable_celery_error_repo... | def get_enable_celery_error_reporting_function(site_name, from_address):
"""
Use this to enable error reporting. You need to put the following in your tasks.py or wherever you
want to create your celery instance:
celery = Celery(__name__)
enable_celery_email_logging = get_enable_celery_error_repo... | [
"Use",
"this",
"to",
"enable",
"error",
"reporting",
".",
"You",
"need",
"to",
"put",
"the",
"following",
"in",
"your",
"tasks",
".",
"py",
"or",
"wherever",
"you",
"want",
"to",
"create",
"your",
"celery",
"instance",
":"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/celeryutil.py#L24-L54 | [
"def",
"get_enable_celery_error_reporting_function",
"(",
"site_name",
",",
"from_address",
")",
":",
"def",
"enable_celery_email_logging",
"(",
"sender",
",",
"signal",
",",
"logger",
",",
"loglevel",
",",
"logfile",
",",
"format",
",",
"colorize",
",",
"*",
"*",... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | init_celery | Initialise Celery and set up logging
:param app: Flask app
:param celery: Celery instance | littlefish/celeryutil.py | def init_celery(app, celery):
"""
Initialise Celery and set up logging
:param app: Flask app
:param celery: Celery instance
"""
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
... | def init_celery(app, celery):
"""
Initialise Celery and set up logging
:param app: Flask app
:param celery: Celery instance
"""
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
... | [
"Initialise",
"Celery",
"and",
"set",
"up",
"logging"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/celeryutil.py#L57-L77 | [
"def",
"init_celery",
"(",
"app",
",",
"celery",
")",
":",
"celery",
".",
"conf",
".",
"update",
"(",
"app",
".",
"config",
")",
"TaskBase",
"=",
"celery",
".",
"Task",
"class",
"ContextTask",
"(",
"TaskBase",
")",
":",
"abstract",
"=",
"True",
"def",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | queue_email | Add a mail to the queue to be sent.
WARNING: Commits by default!
:param to_addresses: The names and addresses to send the email to, i.e. "Steve<steve@fig14.com>, info@fig14.com"
:param from_address: Who the email is from i.e. "Stephen Brown <s@fig14.com>"
:param subject: The email subject
:param b... | littlefish/background/emailqueue.py | def queue_email(to_addresses, from_address, subject, body, commit=True, html=True, session=None):
"""
Add a mail to the queue to be sent.
WARNING: Commits by default!
:param to_addresses: The names and addresses to send the email to, i.e. "Steve<steve@fig14.com>, info@fig14.com"
:param from_addres... | def queue_email(to_addresses, from_address, subject, body, commit=True, html=True, session=None):
"""
Add a mail to the queue to be sent.
WARNING: Commits by default!
:param to_addresses: The names and addresses to send the email to, i.e. "Steve<steve@fig14.com>, info@fig14.com"
:param from_addres... | [
"Add",
"a",
"mail",
"to",
"the",
"queue",
"to",
"be",
"sent",
"."
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/background/emailqueue.py#L113-L137 | [
"def",
"queue_email",
"(",
"to_addresses",
",",
"from_address",
",",
"subject",
",",
"body",
",",
"commit",
"=",
"True",
",",
"html",
"=",
"True",
",",
"session",
"=",
"None",
")",
":",
"from",
"models",
"import",
"QueuedEmail",
"if",
"session",
"is",
"N... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | parse_accept | Parse an HTTP accept-like header.
:param str header_value: the header value to parse
:return: a :class:`list` of :class:`.ContentType` instances
in decreasing quality order. Each instance is augmented
with the associated quality as a ``float`` property
named ``quality``.
``Accept`... | ietfparse/headers.py | def parse_accept(header_value):
"""Parse an HTTP accept-like header.
:param str header_value: the header value to parse
:return: a :class:`list` of :class:`.ContentType` instances
in decreasing quality order. Each instance is augmented
with the associated quality as a ``float`` property
... | def parse_accept(header_value):
"""Parse an HTTP accept-like header.
:param str header_value: the header value to parse
:return: a :class:`list` of :class:`.ContentType` instances
in decreasing quality order. Each instance is augmented
with the associated quality as a ``float`` property
... | [
"Parse",
"an",
"HTTP",
"accept",
"-",
"like",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L34-L86 | [
"def",
"parse_accept",
"(",
"header_value",
")",
":",
"next_explicit_q",
"=",
"decimal",
".",
"ExtendedContext",
".",
"next_plus",
"(",
"decimal",
".",
"Decimal",
"(",
"'5.0'",
")",
")",
"headers",
"=",
"[",
"parse_content_type",
"(",
"header",
")",
"for",
"... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_cache_control | Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.
Any of the ``Cache-Control`` parameters that do not have directives, such
as ``public`` or ``no-cache`` will be returned with a value of ``True``
if they are set in the header.
:param str header_value: ``Cache-Control`` header... | ietfparse/headers.py | def parse_cache_control(header_value):
"""
Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.
Any of the ``Cache-Control`` parameters that do not have directives, such
as ``public`` or ``no-cache`` will be returned with a value of ``True``
if they are set in the header.
... | def parse_cache_control(header_value):
"""
Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.
Any of the ``Cache-Control`` parameters that do not have directives, such
as ``public`` or ``no-cache`` will be returned with a value of ``True``
if they are set in the header.
... | [
"Parse",
"a",
"Cache",
"-",
"Control",
"_",
"header",
"returning",
"a",
"dictionary",
"of",
"key",
"-",
"value",
"pairs",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L165-L199 | [
"def",
"parse_cache_control",
"(",
"header_value",
")",
":",
"directives",
"=",
"{",
"}",
"for",
"segment",
"in",
"parse_list",
"(",
"header_value",
")",
":",
"name",
",",
"sep",
",",
"value",
"=",
"segment",
".",
"partition",
"(",
"'='",
")",
"if",
"sep... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_content_type | Parse a content type like header.
:param str content_type: the string to parse as a content type
:param bool normalize_parameter_values:
setting this to ``False`` will enable strict RFC2045 compliance
in which content parameter values are case preserving.
:return: a :class:`~ietfparse.datas... | ietfparse/headers.py | def parse_content_type(content_type, normalize_parameter_values=True):
"""Parse a content type like header.
:param str content_type: the string to parse as a content type
:param bool normalize_parameter_values:
setting this to ``False`` will enable strict RFC2045 compliance
in which content... | def parse_content_type(content_type, normalize_parameter_values=True):
"""Parse a content type like header.
:param str content_type: the string to parse as a content type
:param bool normalize_parameter_values:
setting this to ``False`` will enable strict RFC2045 compliance
in which content... | [
"Parse",
"a",
"content",
"type",
"like",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L202-L223 | [
"def",
"parse_content_type",
"(",
"content_type",
",",
"normalize_parameter_values",
"=",
"True",
")",
":",
"parts",
"=",
"_remove_comments",
"(",
"content_type",
")",
".",
"split",
"(",
"';'",
")",
"content_type",
",",
"content_subtype",
"=",
"parts",
".",
"pop... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_forwarded | Parse RFC7239 Forwarded header.
:param str header_value: value to parse
:keyword bool only_standard_parameters: if this keyword is specified
and given a *truthy* value, then a non-standard parameter name
will result in :exc:`~ietfparse.errors.StrictHeaderParsingFailure`
:return: an ordered ... | ietfparse/headers.py | def parse_forwarded(header_value, only_standard_parameters=False):
"""
Parse RFC7239 Forwarded header.
:param str header_value: value to parse
:keyword bool only_standard_parameters: if this keyword is specified
and given a *truthy* value, then a non-standard parameter name
will result ... | def parse_forwarded(header_value, only_standard_parameters=False):
"""
Parse RFC7239 Forwarded header.
:param str header_value: value to parse
:keyword bool only_standard_parameters: if this keyword is specified
and given a *truthy* value, then a non-standard parameter name
will result ... | [
"Parse",
"RFC7239",
"Forwarded",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L226-L256 | [
"def",
"parse_forwarded",
"(",
"header_value",
",",
"only_standard_parameters",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"for",
"entry",
"in",
"parse_list",
"(",
"header_value",
")",
":",
"param_tuples",
"=",
"_parse_parameter_list",
"(",
"entry",
".",
... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_link | Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive all parameters.
:return: a sequence of :class:`~ietfparse.d... | ietfparse/headers.py | def parse_link(header_value, strict=True):
"""
Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive all para... | def parse_link(header_value, strict=True):
"""
Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive all para... | [
"Parse",
"a",
"HTTP",
"Link",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L259-L318 | [
"def",
"parse_link",
"(",
"header_value",
",",
"strict",
"=",
"True",
")",
":",
"sanitized",
"=",
"_remove_comments",
"(",
"header_value",
")",
"links",
"=",
"[",
"]",
"def",
"parse_links",
"(",
"buf",
")",
":",
"\"\"\"\n Find quoted parts, these are allowe... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_list | Parse a comma-separated list header.
:param str value: header value to split into elements
:return: list of header elements as strings | ietfparse/headers.py | def parse_list(value):
"""
Parse a comma-separated list header.
:param str value: header value to split into elements
:return: list of header elements as strings
"""
segments = _QUOTED_SEGMENT_RE.findall(value)
for segment in segments:
left, match, right = value.partition(segment)
... | def parse_list(value):
"""
Parse a comma-separated list header.
:param str value: header value to split into elements
:return: list of header elements as strings
"""
segments = _QUOTED_SEGMENT_RE.findall(value)
for segment in segments:
left, match, right = value.partition(segment)
... | [
"Parse",
"a",
"comma",
"-",
"separated",
"list",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L321-L334 | [
"def",
"parse_list",
"(",
"value",
")",
":",
"segments",
"=",
"_QUOTED_SEGMENT_RE",
".",
"findall",
"(",
"value",
")",
"for",
"segment",
"in",
"segments",
":",
"left",
",",
"match",
",",
"right",
"=",
"value",
".",
"partition",
"(",
"segment",
")",
"valu... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | _parse_parameter_list | Parse a named parameter list in the "common" format.
:param parameter_list: sequence of string values to parse
:keyword bool normalize_parameter_names: if specified and *truthy*
then parameter names will be case-folded to lower case
:keyword bool normalize_parameter_values: if omitted or specified
... | ietfparse/headers.py | def _parse_parameter_list(parameter_list,
normalized_parameter_values=_DEF_PARAM_VALUE,
normalize_parameter_names=False,
normalize_parameter_values=True):
"""
Parse a named parameter list in the "common" format.
:param parameter_... | def _parse_parameter_list(parameter_list,
normalized_parameter_values=_DEF_PARAM_VALUE,
normalize_parameter_names=False,
normalize_parameter_values=True):
"""
Parse a named parameter list in the "common" format.
:param parameter_... | [
"Parse",
"a",
"named",
"parameter",
"list",
"in",
"the",
"common",
"format",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L337-L375 | [
"def",
"_parse_parameter_list",
"(",
"parameter_list",
",",
"normalized_parameter_values",
"=",
"_DEF_PARAM_VALUE",
",",
"normalize_parameter_names",
"=",
"False",
",",
"normalize_parameter_values",
"=",
"True",
")",
":",
"if",
"normalized_parameter_values",
"is",
"not",
... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | _parse_qualified_list | Parse a header value, returning a sorted list of values based upon
the quality rules specified in https://tools.ietf.org/html/rfc7231 for
the Accept-* headers.
:param str value: The value to parse into a list
:rtype: list | ietfparse/headers.py | def _parse_qualified_list(value):
"""
Parse a header value, returning a sorted list of values based upon
the quality rules specified in https://tools.ietf.org/html/rfc7231 for
the Accept-* headers.
:param str value: The value to parse into a list
:rtype: list
"""
found_wildcard = False... | def _parse_qualified_list(value):
"""
Parse a header value, returning a sorted list of values based upon
the quality rules specified in https://tools.ietf.org/html/rfc7231 for
the Accept-* headers.
:param str value: The value to parse into a list
:rtype: list
"""
found_wildcard = False... | [
"Parse",
"a",
"header",
"value",
"returning",
"a",
"sorted",
"list",
"of",
"values",
"based",
"upon",
"the",
"quality",
"rules",
"specified",
"in",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc7231",
"for",
"the",
"Accept",... | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L378-L411 | [
"def",
"_parse_qualified_list",
"(",
"value",
")",
":",
"found_wildcard",
"=",
"False",
"values",
",",
"rejected_values",
"=",
"[",
"]",
",",
"[",
"]",
"parsed",
"=",
"parse_list",
"(",
"value",
")",
"default",
"=",
"float",
"(",
"len",
"(",
"parsed",
")... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | parse_link_header | Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive all parameters.
:return: a sequence of :class:`~ietfparse.d... | ietfparse/headers.py | def parse_link_header(header_value, strict=True):
"""
Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive a... | def parse_link_header(header_value, strict=True):
"""
Parse a HTTP Link header.
:param str header_value: the header value to parse
:param bool strict: set this to ``False`` to disable semantic
checking. Syntactical errors will still raise an exception.
Use this if you want to receive a... | [
"Parse",
"a",
"HTTP",
"Link",
"header",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/headers.py#L475-L493 | [
"def",
"parse_link_header",
"(",
"header_value",
",",
"strict",
"=",
"True",
")",
":",
"warnings",
".",
"warn",
"(",
"\"deprecated\"",
",",
"DeprecationWarning",
")",
"return",
"parse_link",
"(",
"header_value",
",",
"strict",
")"
] | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | resize_image_to_fit | Resize the image to fit inside dest rectangle. Resultant image may be smaller than target
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled image | littlefish/imageutil.py | def resize_image_to_fit(image, dest_w, dest_h):
"""
Resize the image to fit inside dest rectangle. Resultant image may be smaller than target
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled image
"""
dest_w = float(dest_w)
dest_h = fl... | def resize_image_to_fit(image, dest_w, dest_h):
"""
Resize the image to fit inside dest rectangle. Resultant image may be smaller than target
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled image
"""
dest_w = float(dest_w)
dest_h = fl... | [
"Resize",
"the",
"image",
"to",
"fit",
"inside",
"dest",
"rectangle",
".",
"Resultant",
"image",
"may",
"be",
"smaller",
"than",
"target",
":",
"param",
"image",
":",
"PIL",
".",
"Image",
":",
"param",
"dest_w",
":",
"Target",
"width",
":",
"param",
"des... | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/imageutil.py#L16-L47 | [
"def",
"resize_image_to_fit",
"(",
"image",
",",
"dest_w",
",",
"dest_h",
")",
":",
"dest_w",
"=",
"float",
"(",
"dest_w",
")",
"dest_h",
"=",
"float",
"(",
"dest_h",
")",
"dest_ratio",
"=",
"dest_w",
"/",
"dest_h",
"# Calculate the apect ratio of the image",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | resize_crop_image | :param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled and cropped image | littlefish/imageutil.py | def resize_crop_image(image, dest_w, dest_h, pad_when_tall=False):
"""
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled and cropped image
"""
# Now we need to resize it
dest_w = float(dest_w)
dest_h = float(dest_h)
dest_ratio = des... | def resize_crop_image(image, dest_w, dest_h, pad_when_tall=False):
"""
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:return: Scaled and cropped image
"""
# Now we need to resize it
dest_w = float(dest_w)
dest_h = float(dest_h)
dest_ratio = des... | [
":",
"param",
"image",
":",
"PIL",
".",
"Image",
":",
"param",
"dest_w",
":",
"Target",
"width",
":",
"param",
"dest_h",
":",
"Target",
"height",
":",
"return",
":",
"Scaled",
"and",
"cropped",
"image"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/imageutil.py#L50-L112 | [
"def",
"resize_crop_image",
"(",
"image",
",",
"dest_w",
",",
"dest_h",
",",
"pad_when_tall",
"=",
"False",
")",
":",
"# Now we need to resize it",
"dest_w",
"=",
"float",
"(",
"dest_w",
")",
"dest_h",
"=",
"float",
"(",
"dest_h",
")",
"dest_ratio",
"=",
"de... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | resize_pad_image | Resize the image and pad to the correct aspect ratio.
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:param pad_with_transparent: If True, make additional padding transparent
:return: Scaled and padded image | littlefish/imageutil.py | def resize_pad_image(image, dest_w, dest_h, pad_with_transparent=False):
"""
Resize the image and pad to the correct aspect ratio.
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:param pad_with_transparent: If True, make additional padding transparent
:retu... | def resize_pad_image(image, dest_w, dest_h, pad_with_transparent=False):
"""
Resize the image and pad to the correct aspect ratio.
:param image: PIL.Image
:param dest_w: Target width
:param dest_h: Target height
:param pad_with_transparent: If True, make additional padding transparent
:retu... | [
"Resize",
"the",
"image",
"and",
"pad",
"to",
"the",
"correct",
"aspect",
"ratio",
".",
":",
"param",
"image",
":",
"PIL",
".",
"Image",
":",
"param",
"dest_w",
":",
"Target",
"width",
":",
"param",
"dest_h",
":",
"Target",
"height",
":",
"param",
"pad... | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/imageutil.py#L115-L181 | [
"def",
"resize_pad_image",
"(",
"image",
",",
"dest_w",
",",
"dest_h",
",",
"pad_with_transparent",
"=",
"False",
")",
":",
"dest_w",
"=",
"float",
"(",
"dest_w",
")",
"dest_h",
"=",
"float",
"(",
"dest_h",
")",
"dest_ratio",
"=",
"dest_w",
"/",
"dest_h",
... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | resize_image_to_fit_width | Resize and image to fit the passed in width, keeping the aspect ratio the same
:param image: PIL.Image
:param dest_w: The desired width | littlefish/imageutil.py | def resize_image_to_fit_width(image, dest_w):
"""
Resize and image to fit the passed in width, keeping the aspect ratio the same
:param image: PIL.Image
:param dest_w: The desired width
"""
scale_factor = dest_w / image.size[0]
dest_h = image.size[1] * scale_factor
scaled_image = i... | def resize_image_to_fit_width(image, dest_w):
"""
Resize and image to fit the passed in width, keeping the aspect ratio the same
:param image: PIL.Image
:param dest_w: The desired width
"""
scale_factor = dest_w / image.size[0]
dest_h = image.size[1] * scale_factor
scaled_image = i... | [
"Resize",
"and",
"image",
"to",
"fit",
"the",
"passed",
"in",
"width",
"keeping",
"the",
"aspect",
"ratio",
"the",
"same"
] | stevelittlefish/littlefish | python | https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/imageutil.py#L184-L196 | [
"def",
"resize_image_to_fit_width",
"(",
"image",
",",
"dest_w",
")",
":",
"scale_factor",
"=",
"dest_w",
"/",
"image",
".",
"size",
"[",
"0",
"]",
"dest_h",
"=",
"image",
".",
"size",
"[",
"1",
"]",
"*",
"scale_factor",
"scaled_image",
"=",
"image",
"."... | 6deee7f81fab30716c743efe2e94e786c6e17016 |
test | ParameterParser.add_value | Add a new value to the list.
:param str name: name of the value that is being parsed
:param str value: value that is being parsed
:raises ietfparse.errors.MalformedLinkValue:
if *strict mode* is enabled and a validation error
is detected
This method implements m... | ietfparse/_helpers.py | def add_value(self, name, value):
"""
Add a new value to the list.
:param str name: name of the value that is being parsed
:param str value: value that is being parsed
:raises ietfparse.errors.MalformedLinkValue:
if *strict mode* is enabled and a validation error
... | def add_value(self, name, value):
"""
Add a new value to the list.
:param str name: name of the value that is being parsed
:param str value: value that is being parsed
:raises ietfparse.errors.MalformedLinkValue:
if *strict mode* is enabled and a validation error
... | [
"Add",
"a",
"new",
"value",
"to",
"the",
"list",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/_helpers.py#L49-L80 | [
"def",
"add_value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"try",
":",
"if",
"self",
".",
"_rfc_values",
"[",
"name",
"]",
"is",
"None",
":",
"self",
".",
"_rfc_values",
"[",
"name",
"]",
"=",
"value",
"elif",
"self",
".",
"strict",
":",... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | ParameterParser.values | The name/value mapping that was parsed.
:returns: a sequence of name/value pairs. | ietfparse/_helpers.py | def values(self):
"""
The name/value mapping that was parsed.
:returns: a sequence of name/value pairs.
"""
values = self._values[:]
if self.strict:
if self._rfc_values['title*']:
values.append(('title*', self._rfc_values['title*']))
... | def values(self):
"""
The name/value mapping that was parsed.
:returns: a sequence of name/value pairs.
"""
values = self._values[:]
if self.strict:
if self._rfc_values['title*']:
values.append(('title*', self._rfc_values['title*']))
... | [
"The",
"name",
"/",
"value",
"mapping",
"that",
"was",
"parsed",
"."
] | dave-shawley/ietfparse | python | https://github.com/dave-shawley/ietfparse/blob/d28f360941316e45c1596589fa59bc7d25aa20e0/ietfparse/_helpers.py#L83-L98 | [
"def",
"values",
"(",
"self",
")",
":",
"values",
"=",
"self",
".",
"_values",
"[",
":",
"]",
"if",
"self",
".",
"strict",
":",
"if",
"self",
".",
"_rfc_values",
"[",
"'title*'",
"]",
":",
"values",
".",
"append",
"(",
"(",
"'title*'",
",",
"self",... | d28f360941316e45c1596589fa59bc7d25aa20e0 |
test | Youtube.download | Downloads a MP4 or WebM file that is associated with the video at the URL passed.
:param str url: URL of the video to be downloaded
:return str: Filename of the file in local storage | music2storage/service.py | def download(self, url):
"""
Downloads a MP4 or WebM file that is associated with the video at the URL passed.
:param str url: URL of the video to be downloaded
:return str: Filename of the file in local storage
"""
try:
yt = YouTube(url)
except Rege... | def download(self, url):
"""
Downloads a MP4 or WebM file that is associated with the video at the URL passed.
:param str url: URL of the video to be downloaded
:return str: Filename of the file in local storage
"""
try:
yt = YouTube(url)
except Rege... | [
"Downloads",
"a",
"MP4",
"or",
"WebM",
"file",
"that",
"is",
"associated",
"with",
"the",
"video",
"at",
"the",
"URL",
"passed",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L49-L68 | [
"def",
"download",
"(",
"self",
",",
"url",
")",
":",
"try",
":",
"yt",
"=",
"YouTube",
"(",
"url",
")",
"except",
"RegexMatchError",
":",
"log",
".",
"error",
"(",
"f\"Cannot download file at {url}\"",
")",
"else",
":",
"stream",
"=",
"yt",
".",
"stream... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | Soundcloud.download | Downloads a MP3 file that is associated with the track at the URL passed.
:param str url: URL of the track to be downloaded | music2storage/service.py | def download(self, url):
"""
Downloads a MP3 file that is associated with the track at the URL passed.
:param str url: URL of the track to be downloaded
"""
try:
track = self.client.get('/resolve', url=url)
except HTTPError:
log.error(f"{... | def download(self, url):
"""
Downloads a MP3 file that is associated with the track at the URL passed.
:param str url: URL of the track to be downloaded
"""
try:
track = self.client.get('/resolve', url=url)
except HTTPError:
log.error(f"{... | [
"Downloads",
"a",
"MP3",
"file",
"that",
"is",
"associated",
"with",
"the",
"track",
"at",
"the",
"URL",
"passed",
".",
":",
"param",
"str",
"url",
":",
"URL",
"of",
"the",
"track",
"to",
"be",
"downloaded"
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L82-L101 | [
"def",
"download",
"(",
"self",
",",
"url",
")",
":",
"try",
":",
"track",
"=",
"self",
".",
"client",
".",
"get",
"(",
"'/resolve'",
",",
"url",
"=",
"url",
")",
"except",
"HTTPError",
":",
"log",
".",
"error",
"(",
"f\"{url} is not a Soundcloud URL.\""... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | GoogleDrive.connect | Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist. | music2storage/service.py | def connect(self):
"""Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist."""
SCOPES = 'https://www.googleapis.com/auth/drive'
store = file.Storage('drive_credentials.json')
creds = store.get()
... | def connect(self):
"""Creates connection to the Google Drive API, sets the connection attribute to make requests, and creates the Music folder if it doesn't exist."""
SCOPES = 'https://www.googleapis.com/auth/drive'
store = file.Storage('drive_credentials.json')
creds = store.get()
... | [
"Creates",
"connection",
"to",
"the",
"Google",
"Drive",
"API",
"sets",
"the",
"connection",
"attribute",
"to",
"make",
"requests",
"and",
"creates",
"the",
"Music",
"folder",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L111-L132 | [
"def",
"connect",
"(",
"self",
")",
":",
"SCOPES",
"=",
"'https://www.googleapis.com/auth/drive'",
"store",
"=",
"file",
".",
"Storage",
"(",
"'drive_credentials.json'",
")",
"creds",
"=",
"store",
".",
"get",
"(",
")",
"if",
"not",
"creds",
"or",
"creds",
"... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | GoogleDrive.upload | Uploads the file associated with the file_name passed to Google Drive in the Music folder.
:param str file_name: Filename of the file to be uploaded
:return str: Original filename passed as an argument (in order for the worker to send it to the delete queue) | music2storage/service.py | def upload(self, file_name):
"""
Uploads the file associated with the file_name passed to Google Drive in the Music folder.
:param str file_name: Filename of the file to be uploaded
:return str: Original filename passed as an argument (in order for the worker to send it to the delete qu... | def upload(self, file_name):
"""
Uploads the file associated with the file_name passed to Google Drive in the Music folder.
:param str file_name: Filename of the file to be uploaded
:return str: Original filename passed as an argument (in order for the worker to send it to the delete qu... | [
"Uploads",
"the",
"file",
"associated",
"with",
"the",
"file_name",
"passed",
"to",
"Google",
"Drive",
"in",
"the",
"Music",
"folder",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L134-L153 | [
"def",
"upload",
"(",
"self",
",",
"file_name",
")",
":",
"response",
"=",
"self",
".",
"connection",
".",
"files",
"(",
")",
".",
"list",
"(",
"q",
"=",
"\"name='Music' and mimeType='application/vnd.google-apps.folder' and trashed=false\"",
")",
".",
"execute",
"... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | LocalStorage.connect | Initializes the connection attribute with the path to the user home folder's Music folder, and creates it if it doesn't exist. | music2storage/service.py | def connect(self):
"""Initializes the connection attribute with the path to the user home folder's Music folder, and creates it if it doesn't exist."""
if self.music_folder is None:
music_folder = os.path.join(os.path.expanduser('~'), 'Music')
if not os.path.exists(music_folder)... | def connect(self):
"""Initializes the connection attribute with the path to the user home folder's Music folder, and creates it if it doesn't exist."""
if self.music_folder is None:
music_folder = os.path.join(os.path.expanduser('~'), 'Music')
if not os.path.exists(music_folder)... | [
"Initializes",
"the",
"connection",
"attribute",
"with",
"the",
"path",
"to",
"the",
"user",
"home",
"folder",
"s",
"Music",
"folder",
"and",
"creates",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L167-L174 | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"music_folder",
"is",
"None",
":",
"music_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
",",
"'Music'",
")",
"if",
"not",
"os",
... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | LocalStorage.upload | Moves the file associated with the file_name passed to the Music folder in the local storage.
:param str file_name: Filename of the file to be uploaded | music2storage/service.py | def upload(self, file_name):
"""
Moves the file associated with the file_name passed to the Music folder in the local storage.
:param str file_name: Filename of the file to be uploaded
"""
log.info(f"Upload for {file_name} has started")
start_time = time... | def upload(self, file_name):
"""
Moves the file associated with the file_name passed to the Music folder in the local storage.
:param str file_name: Filename of the file to be uploaded
"""
log.info(f"Upload for {file_name} has started")
start_time = time... | [
"Moves",
"the",
"file",
"associated",
"with",
"the",
"file_name",
"passed",
"to",
"the",
"Music",
"folder",
"in",
"the",
"local",
"storage",
".",
":",
"param",
"str",
"file_name",
":",
"Filename",
"of",
"the",
"file",
"to",
"be",
"uploaded"
] | Music-Moo/music2storage | python | https://github.com/Music-Moo/music2storage/blob/de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2/music2storage/service.py#L176-L187 | [
"def",
"upload",
"(",
"self",
",",
"file_name",
")",
":",
"log",
".",
"info",
"(",
"f\"Upload for {file_name} has started\"",
")",
"start_time",
"=",
"time",
"(",
")",
"os",
".",
"rename",
"(",
"file_name",
",",
"os",
".",
"path",
".",
"join",
"(",
"self... | de12b9046dd227fc8c1512b5060e7f5fcd8b0ee2 |
test | RunParameters.write_run_parameters_to_file | All of the class properties are written to a text file
Each property is on a new line with the key and value seperated with an equals sign '='
This is the mane planarrad properties file used by slabtool | libplanarradpy/planrad.py | def write_run_parameters_to_file(self):
"""All of the class properties are written to a text file
Each property is on a new line with the key and value seperated with an equals sign '='
This is the mane planarrad properties file used by slabtool
"""
self.update_filenames()
... | def write_run_parameters_to_file(self):
"""All of the class properties are written to a text file
Each property is on a new line with the key and value seperated with an equals sign '='
This is the mane planarrad properties file used by slabtool
"""
self.update_filenames()
... | [
"All",
"of",
"the",
"class",
"properties",
"are",
"written",
"to",
"a",
"text",
"file"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L147-L232 | [
"def",
"write_run_parameters_to_file",
"(",
"self",
")",
":",
"self",
".",
"update_filenames",
"(",
")",
"lg",
".",
"info",
"(",
"'Writing Inputs to file : '",
"+",
"self",
".",
"project_file",
")",
"# First update the file names in case we changed the file values. the fil... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | RunParameters.write_sky_params_to_file | Writes the params to file that skytool_Free needs to generate the sky radiance distribution. | libplanarradpy/planrad.py | def write_sky_params_to_file(self):
"""Writes the params to file that skytool_Free needs to generate the sky radiance distribution."""
inp_file = self.sky_file + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
f = open(inp_file, 'w')
f.write('verbose= ' + str(sel... | def write_sky_params_to_file(self):
"""Writes the params to file that skytool_Free needs to generate the sky radiance distribution."""
inp_file = self.sky_file + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
f = open(inp_file, 'w')
f.write('verbose= ' + str(sel... | [
"Writes",
"the",
"params",
"to",
"file",
"that",
"skytool_Free",
"needs",
"to",
"generate",
"the",
"sky",
"radiance",
"distribution",
"."
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L234-L262 | [
"def",
"write_sky_params_to_file",
"(",
"self",
")",
":",
"inp_file",
"=",
"self",
".",
"sky_file",
"+",
"'_params.txt'",
"lg",
".",
"info",
"(",
"'Writing Inputs to file : '",
"+",
"inp_file",
")",
"f",
"=",
"open",
"(",
"inp_file",
",",
"'w'",
")",
"f",
... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | RunParameters.write_surf_params_to_file | Write the params to file that surftool_Free needs to generate the surface facets | libplanarradpy/planrad.py | def write_surf_params_to_file(self):
"""Write the params to file that surftool_Free needs to generate the surface facets"""
inp_file = self.water_surface_file + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
if self.surf_state == 'flat': # this is the only one that curr... | def write_surf_params_to_file(self):
"""Write the params to file that surftool_Free needs to generate the surface facets"""
inp_file = self.water_surface_file + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
if self.surf_state == 'flat': # this is the only one that curr... | [
"Write",
"the",
"params",
"to",
"file",
"that",
"surftool_Free",
"needs",
"to",
"generate",
"the",
"surface",
"facets"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L264-L298 | [
"def",
"write_surf_params_to_file",
"(",
"self",
")",
":",
"inp_file",
"=",
"self",
".",
"water_surface_file",
"+",
"'_params.txt'",
"lg",
".",
"info",
"(",
"'Writing Inputs to file : '",
"+",
"inp_file",
")",
"if",
"self",
".",
"surf_state",
"==",
"'flat'",
":"... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | RunParameters.write_phase_params_to_file | Write the params to file that surftool_Free needs to generate the surface facets | libplanarradpy/planrad.py | def write_phase_params_to_file(self):
"""Write the params to file that surftool_Free needs to generate the surface facets"""
inp_file = os.path.join(os.path.join(self.input_path, 'phase_files'), self.phase_function_file) + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
if... | def write_phase_params_to_file(self):
"""Write the params to file that surftool_Free needs to generate the surface facets"""
inp_file = os.path.join(os.path.join(self.input_path, 'phase_files'), self.phase_function_file) + '_params.txt'
lg.info('Writing Inputs to file : ' + inp_file)
if... | [
"Write",
"the",
"params",
"to",
"file",
"that",
"surftool_Free",
"needs",
"to",
"generate",
"the",
"surface",
"facets"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L300-L322 | [
"def",
"write_phase_params_to_file",
"(",
"self",
")",
":",
"inp_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"input_path",
",",
"'phase_files'",
")",
",",
"self",
".",
"phase_function_file",
")",
"+"... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | RunParameters.update_filenames | Does nothing currently. May not need this method | libplanarradpy/planrad.py | def update_filenames(self):
"""Does nothing currently. May not need this method"""
self.sky_file = os.path.abspath(os.path.join(os.path.join(self.input_path, 'sky_files'),
'sky_' + self.sky_state + '_z' + str(
... | def update_filenames(self):
"""Does nothing currently. May not need this method"""
self.sky_file = os.path.abspath(os.path.join(os.path.join(self.input_path, 'sky_files'),
'sky_' + self.sky_state + '_z' + str(
... | [
"Does",
"nothing",
"currently",
".",
"May",
"not",
"need",
"this",
"method"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L324-L330 | [
"def",
"update_filenames",
"(",
"self",
")",
":",
"self",
".",
"sky_file",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"input_path",
",",
"'sky_files'",
")",
",... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_bbp | Builds the particle backscattering function :math:`X(\\frac{550}{\\lambda})^Y`
:param x: function coefficient
:param y: order of the power function
:param wave_const: wave constant default 550 (nm)
:returns null: | libplanarradpy/planrad.py | def build_bbp(self, x, y, wave_const=550):
"""
Builds the particle backscattering function :math:`X(\\frac{550}{\\lambda})^Y`
:param x: function coefficient
:param y: order of the power function
:param wave_const: wave constant default 550 (nm)
:returns null:
""... | def build_bbp(self, x, y, wave_const=550):
"""
Builds the particle backscattering function :math:`X(\\frac{550}{\\lambda})^Y`
:param x: function coefficient
:param y: order of the power function
:param wave_const: wave constant default 550 (nm)
:returns null:
""... | [
"Builds",
"the",
"particle",
"backscattering",
"function",
":",
"math",
":",
"X",
"(",
"\\\\",
"frac",
"{",
"550",
"}",
"{",
"\\\\",
"lambda",
"}",
")",
"^Y"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L357-L367 | [
"def",
"build_bbp",
"(",
"self",
",",
"x",
",",
"y",
",",
"wave_const",
"=",
"550",
")",
":",
"lg",
".",
"info",
"(",
"'Building b_bp spectra'",
")",
"self",
".",
"b_bp",
"=",
"x",
"*",
"(",
"wave_const",
"/",
"self",
".",
"wavelengths",
")",
"**",
... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_a_cdom | Builds the CDOM absorption function :: :math:`G \exp (-S(\lambda - 400))`
:param g: function coefficient
:param s: slope factor
:param wave_const: wave constant default = 400 (nm)
:returns null: | libplanarradpy/planrad.py | def build_a_cdom(self, g, s, wave_const=400):
"""
Builds the CDOM absorption function :: :math:`G \exp (-S(\lambda - 400))`
:param g: function coefficient
:param s: slope factor
:param wave_const: wave constant default = 400 (nm)
:returns null:
"""
lg.inf... | def build_a_cdom(self, g, s, wave_const=400):
"""
Builds the CDOM absorption function :: :math:`G \exp (-S(\lambda - 400))`
:param g: function coefficient
:param s: slope factor
:param wave_const: wave constant default = 400 (nm)
:returns null:
"""
lg.inf... | [
"Builds",
"the",
"CDOM",
"absorption",
"function",
"::",
":",
"math",
":",
"G",
"\\",
"exp",
"(",
"-",
"S",
"(",
"\\",
"lambda",
"-",
"400",
"))"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L369-L379 | [
"def",
"build_a_cdom",
"(",
"self",
",",
"g",
",",
"s",
",",
"wave_const",
"=",
"400",
")",
":",
"lg",
".",
"info",
"(",
"'building CDOM absorption'",
")",
"self",
".",
"a_cdom",
"=",
"g",
"*",
"scipy",
".",
"exp",
"(",
"-",
"s",
"*",
"(",
"self",
... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.read_aphi_from_file | Read the phytoplankton absorption file from a csv formatted file
:param file_name: filename and path of the csv file | libplanarradpy/planrad.py | def read_aphi_from_file(self, file_name):
"""Read the phytoplankton absorption file from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading ahpi absorption')
try:
self.a_phi = self._read_iop_from_file(file_name)
exce... | def read_aphi_from_file(self, file_name):
"""Read the phytoplankton absorption file from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading ahpi absorption')
try:
self.a_phi = self._read_iop_from_file(file_name)
exce... | [
"Read",
"the",
"phytoplankton",
"absorption",
"file",
"from",
"a",
"csv",
"formatted",
"file"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L381-L391 | [
"def",
"read_aphi_from_file",
"(",
"self",
",",
"file_name",
")",
":",
"lg",
".",
"info",
"(",
"'Reading ahpi absorption'",
")",
"try",
":",
"self",
".",
"a_phi",
"=",
"self",
".",
"_read_iop_from_file",
"(",
"file_name",
")",
"except",
":",
"lg",
".",
"ex... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.scale_aphi | Scale the spectra by multiplying by linear scaling factor
:param scale_parameter: Linear scaling factor | libplanarradpy/planrad.py | def scale_aphi(self, scale_parameter):
"""Scale the spectra by multiplying by linear scaling factor
:param scale_parameter: Linear scaling factor
"""
lg.info('Scaling a_phi by :: ' + str(scale_parameter))
try:
self.a_phi = self.a_phi * scale_parameter
except:... | def scale_aphi(self, scale_parameter):
"""Scale the spectra by multiplying by linear scaling factor
:param scale_parameter: Linear scaling factor
"""
lg.info('Scaling a_phi by :: ' + str(scale_parameter))
try:
self.a_phi = self.a_phi * scale_parameter
except:... | [
"Scale",
"the",
"spectra",
"by",
"multiplying",
"by",
"linear",
"scaling",
"factor"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L393-L402 | [
"def",
"scale_aphi",
"(",
"self",
",",
"scale_parameter",
")",
":",
"lg",
".",
"info",
"(",
"'Scaling a_phi by :: '",
"+",
"str",
"(",
"scale_parameter",
")",
")",
"try",
":",
"self",
".",
"a_phi",
"=",
"self",
".",
"a_phi",
"*",
"scale_parameter",
"except... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.read_pure_water_absorption_from_file | Read the pure water absorption from a csv formatted file
:param file_name: filename and path of the csv file | libplanarradpy/planrad.py | def read_pure_water_absorption_from_file(self, file_name):
"""Read the pure water absorption from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading water absorption from file')
try:
self.a_water = self._read_iop_from_file(f... | def read_pure_water_absorption_from_file(self, file_name):
"""Read the pure water absorption from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading water absorption from file')
try:
self.a_water = self._read_iop_from_file(f... | [
"Read",
"the",
"pure",
"water",
"absorption",
"from",
"a",
"csv",
"formatted",
"file"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L404-L413 | [
"def",
"read_pure_water_absorption_from_file",
"(",
"self",
",",
"file_name",
")",
":",
"lg",
".",
"info",
"(",
"'Reading water absorption from file'",
")",
"try",
":",
"self",
".",
"a_water",
"=",
"self",
".",
"_read_iop_from_file",
"(",
"file_name",
")",
"except... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.read_pure_water_scattering_from_file | Read the pure water scattering from a csv formatted file
:param file_name: filename and path of the csv file | libplanarradpy/planrad.py | def read_pure_water_scattering_from_file(self, file_name):
"""Read the pure water scattering from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading water scattering from file')
try:
self.b_water = self._read_iop_from_file(f... | def read_pure_water_scattering_from_file(self, file_name):
"""Read the pure water scattering from a csv formatted file
:param file_name: filename and path of the csv file
"""
lg.info('Reading water scattering from file')
try:
self.b_water = self._read_iop_from_file(f... | [
"Read",
"the",
"pure",
"water",
"scattering",
"from",
"a",
"csv",
"formatted",
"file"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L416-L425 | [
"def",
"read_pure_water_scattering_from_file",
"(",
"self",
",",
"file_name",
")",
":",
"lg",
".",
"info",
"(",
"'Reading water scattering from file'",
")",
"try",
":",
"self",
".",
"b_water",
"=",
"self",
".",
"_read_iop_from_file",
"(",
"file_name",
")",
"except... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters._read_iop_from_file | Generic IOP reader that interpolates the iop to the common wavelengths defined in the constructor
:param file_name: filename and path of the csv file
:returns interpolated iop | libplanarradpy/planrad.py | def _read_iop_from_file(self, file_name):
"""
Generic IOP reader that interpolates the iop to the common wavelengths defined in the constructor
:param file_name: filename and path of the csv file
:returns interpolated iop
"""
lg.info('Reading :: ' + file_name + ' :: and ... | def _read_iop_from_file(self, file_name):
"""
Generic IOP reader that interpolates the iop to the common wavelengths defined in the constructor
:param file_name: filename and path of the csv file
:returns interpolated iop
"""
lg.info('Reading :: ' + file_name + ' :: and ... | [
"Generic",
"IOP",
"reader",
"that",
"interpolates",
"the",
"iop",
"to",
"the",
"common",
"wavelengths",
"defined",
"in",
"the",
"constructor"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L428-L451 | [
"def",
"_read_iop_from_file",
"(",
"self",
",",
"file_name",
")",
":",
"lg",
".",
"info",
"(",
"'Reading :: '",
"+",
"file_name",
"+",
"' :: and interpolating to '",
"+",
"str",
"(",
"self",
".",
"wavelengths",
")",
")",
"if",
"os",
".",
"path",
".",
"isfi... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters._write_iop_to_file | Generic iop file writer
:param iop numpy array to write to file
:param file_name the file and path to write the IOP to | libplanarradpy/planrad.py | def _write_iop_to_file(self, iop, file_name):
"""Generic iop file writer
:param iop numpy array to write to file
:param file_name the file and path to write the IOP to
"""
lg.info('Writing :: ' + file_name)
f = open(file_name, 'w')
for i in scipy.nditer(iop):
... | def _write_iop_to_file(self, iop, file_name):
"""Generic iop file writer
:param iop numpy array to write to file
:param file_name the file and path to write the IOP to
"""
lg.info('Writing :: ' + file_name)
f = open(file_name, 'w')
for i in scipy.nditer(iop):
... | [
"Generic",
"iop",
"file",
"writer"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L467-L476 | [
"def",
"_write_iop_to_file",
"(",
"self",
",",
"iop",
",",
"file_name",
")",
":",
"lg",
".",
"info",
"(",
"'Writing :: '",
"+",
"file_name",
")",
"f",
"=",
"open",
"(",
"file_name",
",",
"'w'",
")",
"for",
"i",
"in",
"scipy",
".",
"nditer",
"(",
"iop... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_b | Calculates the total scattering from back-scattering
:param scattering_fraction: the fraction of back-scattering to total scattering default = 0.01833
b = ( bb[sea water] + bb[p] ) /0.01833 | libplanarradpy/planrad.py | def build_b(self, scattering_fraction=0.01833):
"""Calculates the total scattering from back-scattering
:param scattering_fraction: the fraction of back-scattering to total scattering default = 0.01833
b = ( bb[sea water] + bb[p] ) /0.01833
"""
lg.info('Building b with scatteri... | def build_b(self, scattering_fraction=0.01833):
"""Calculates the total scattering from back-scattering
:param scattering_fraction: the fraction of back-scattering to total scattering default = 0.01833
b = ( bb[sea water] + bb[p] ) /0.01833
"""
lg.info('Building b with scatteri... | [
"Calculates",
"the",
"total",
"scattering",
"from",
"back",
"-",
"scattering"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L486-L494 | [
"def",
"build_b",
"(",
"self",
",",
"scattering_fraction",
"=",
"0.01833",
")",
":",
"lg",
".",
"info",
"(",
"'Building b with scattering fraction of :: '",
"+",
"str",
"(",
"scattering_fraction",
")",
")",
"self",
".",
"b",
"=",
"(",
"self",
".",
"b_b",
"+"... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_a | Calculates the total absorption from water, phytoplankton and CDOM
a = awater + acdom + aphi | libplanarradpy/planrad.py | def build_a(self):
"""Calculates the total absorption from water, phytoplankton and CDOM
a = awater + acdom + aphi
"""
lg.info('Building total absorption')
self.a = self.a_water + self.a_cdom + self.a_phi | def build_a(self):
"""Calculates the total absorption from water, phytoplankton and CDOM
a = awater + acdom + aphi
"""
lg.info('Building total absorption')
self.a = self.a_water + self.a_cdom + self.a_phi | [
"Calculates",
"the",
"total",
"absorption",
"from",
"water",
"phytoplankton",
"and",
"CDOM"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L496-L502 | [
"def",
"build_a",
"(",
"self",
")",
":",
"lg",
".",
"info",
"(",
"'Building total absorption'",
")",
"self",
".",
"a",
"=",
"self",
".",
"a_water",
"+",
"self",
".",
"a_cdom",
"+",
"self",
".",
"a_phi"
] | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_c | Calculates the total attenuation from the total absorption and total scattering
c = a + b | libplanarradpy/planrad.py | def build_c(self):
"""Calculates the total attenuation from the total absorption and total scattering
c = a + b
"""
lg.info('Building total attenuation C')
self.c = self.a + self.b | def build_c(self):
"""Calculates the total attenuation from the total absorption and total scattering
c = a + b
"""
lg.info('Building total attenuation C')
self.c = self.a + self.b | [
"Calculates",
"the",
"total",
"attenuation",
"from",
"the",
"total",
"absorption",
"and",
"total",
"scattering"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L504-L510 | [
"def",
"build_c",
"(",
"self",
")",
":",
"lg",
".",
"info",
"(",
"'Building total attenuation C'",
")",
"self",
".",
"c",
"=",
"self",
".",
"a",
"+",
"self",
".",
"b"
] | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BioOpticalParameters.build_all_iop | Meta method that calls all of the build methods in the correct order
self.build_a()
self.build_bb()
self.build_b()
self.build_c() | libplanarradpy/planrad.py | def build_all_iop(self):
"""Meta method that calls all of the build methods in the correct order
self.build_a()
self.build_bb()
self.build_b()
self.build_c()
"""
lg.info('Building all b and c from IOPs')
self.build_a()
self.build_bb()
sel... | def build_all_iop(self):
"""Meta method that calls all of the build methods in the correct order
self.build_a()
self.build_bb()
self.build_b()
self.build_c()
"""
lg.info('Building all b and c from IOPs')
self.build_a()
self.build_bb()
sel... | [
"Meta",
"method",
"that",
"calls",
"all",
"of",
"the",
"build",
"methods",
"in",
"the",
"correct",
"order"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L512-L525 | [
"def",
"build_all_iop",
"(",
"self",
")",
":",
"lg",
".",
"info",
"(",
"'Building all b and c from IOPs'",
")",
"self",
".",
"build_a",
"(",
")",
"self",
".",
"build_bb",
"(",
")",
"self",
".",
"build_b",
"(",
")",
"self",
".",
"build_c",
"(",
")"
] | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
test | BatchRun.run | Distributes the work across the CPUs. It actually uses _run() | libplanarradpy/planrad.py | def run(self):
"""Distributes the work across the CPUs. It actually uses _run()"""
done = False
dir_list = []
tic = time.clock()
lg.info('Starting batch run at :: ' + str(tic))
if self.run_params.num_cpus == -1: # user hasn't set a throttle
self.run_params.... | def run(self):
"""Distributes the work across the CPUs. It actually uses _run()"""
done = False
dir_list = []
tic = time.clock()
lg.info('Starting batch run at :: ' + str(tic))
if self.run_params.num_cpus == -1: # user hasn't set a throttle
self.run_params.... | [
"Distributes",
"the",
"work",
"across",
"the",
"CPUs",
".",
"It",
"actually",
"uses",
"_run",
"()"
] | marrabld/planarradpy | python | https://github.com/marrabld/planarradpy/blob/5095d1cb98d4f67a7c3108c9282f2d59253e89a8/libplanarradpy/planrad.py#L561-L637 | [
"def",
"run",
"(",
"self",
")",
":",
"done",
"=",
"False",
"dir_list",
"=",
"[",
"]",
"tic",
"=",
"time",
".",
"clock",
"(",
")",
"lg",
".",
"info",
"(",
"'Starting batch run at :: '",
"+",
"str",
"(",
"tic",
")",
")",
"if",
"self",
".",
"run_param... | 5095d1cb98d4f67a7c3108c9282f2d59253e89a8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.