repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
zeroSteiner/smoke-zephyr | smoke_zephyr/job.py | JobManager.job_delete | def job_delete(self, job_id, wait=True):
"""
Delete a job.
:param job_id: Job identifier to delete.
:type job_id: :py:class:`uuid.UUID`
:param bool wait: If the job is currently running, wait for it to complete before deleting it.
"""
job_id = normalize_job_id(job_id)
self.logger.info('deleting job wit... | python | def job_delete(self, job_id, wait=True):
"""
Delete a job.
:param job_id: Job identifier to delete.
:type job_id: :py:class:`uuid.UUID`
:param bool wait: If the job is currently running, wait for it to complete before deleting it.
"""
job_id = normalize_job_id(job_id)
self.logger.info('deleting job wit... | [
"def",
"job_delete",
"(",
"self",
",",
"job_id",
",",
"wait",
"=",
"True",
")",
":",
"job_id",
"=",
"normalize_job_id",
"(",
"job_id",
")",
"self",
".",
"logger",
".",
"info",
"(",
"'deleting job with id: '",
"+",
"str",
"(",
"job_id",
")",
"+",
"' and c... | Delete a job.
:param job_id: Job identifier to delete.
:type job_id: :py:class:`uuid.UUID`
:param bool wait: If the job is currently running, wait for it to complete before deleting it. | [
"Delete",
"a",
"job",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/job.py#L368-L383 |
zeroSteiner/smoke-zephyr | smoke_zephyr/job.py | JobManager.job_is_enabled | def job_is_enabled(self, job_id):
"""
Check if a job is enabled.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool
"""
job_id = normalize_job_id(job_id)
job_desc = self._jobs[job_id]
return job_desc['enabled'] | python | def job_is_enabled(self, job_id):
"""
Check if a job is enabled.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool
"""
job_id = normalize_job_id(job_id)
job_desc = self._jobs[job_id]
return job_desc['enabled'] | [
"def",
"job_is_enabled",
"(",
"self",
",",
"job_id",
")",
":",
"job_id",
"=",
"normalize_job_id",
"(",
"job_id",
")",
"job_desc",
"=",
"self",
".",
"_jobs",
"[",
"job_id",
"]",
"return",
"job_desc",
"[",
"'enabled'",
"]"
] | Check if a job is enabled.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool | [
"Check",
"if",
"a",
"job",
"is",
"enabled",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/job.py#L396-L406 |
zeroSteiner/smoke-zephyr | smoke_zephyr/job.py | JobManager.job_is_running | def job_is_running(self, job_id):
"""
Check if a job is currently running. False is returned if the job does
not exist.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool
"""
job_id = normalize_job_id(job_id)
if job_id not in self._jobs:
return F... | python | def job_is_running(self, job_id):
"""
Check if a job is currently running. False is returned if the job does
not exist.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool
"""
job_id = normalize_job_id(job_id)
if job_id not in self._jobs:
return F... | [
"def",
"job_is_running",
"(",
"self",
",",
"job_id",
")",
":",
"job_id",
"=",
"normalize_job_id",
"(",
"job_id",
")",
"if",
"job_id",
"not",
"in",
"self",
".",
"_jobs",
":",
"return",
"False",
"job_desc",
"=",
"self",
".",
"_jobs",
"[",
"job_id",
"]",
... | Check if a job is currently running. False is returned if the job does
not exist.
:param job_id: Job identifier to check the status of.
:type job_id: :py:class:`uuid.UUID`
:rtype: bool | [
"Check",
"if",
"a",
"job",
"is",
"currently",
"running",
".",
"False",
"is",
"returned",
"if",
"the",
"job",
"does",
"not",
"exist",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/job.py#L408-L423 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | bin_b64_type | def bin_b64_type(arg):
"""An argparse type representing binary data encoded in base64."""
try:
arg = base64.standard_b64decode(arg)
except (binascii.Error, TypeError):
raise argparse.ArgumentTypeError("{0} is invalid base64 data".format(repr(arg)))
return arg | python | def bin_b64_type(arg):
"""An argparse type representing binary data encoded in base64."""
try:
arg = base64.standard_b64decode(arg)
except (binascii.Error, TypeError):
raise argparse.ArgumentTypeError("{0} is invalid base64 data".format(repr(arg)))
return arg | [
"def",
"bin_b64_type",
"(",
"arg",
")",
":",
"try",
":",
"arg",
"=",
"base64",
".",
"standard_b64decode",
"(",
"arg",
")",
"except",
"(",
"binascii",
".",
"Error",
",",
"TypeError",
")",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"{0} is in... | An argparse type representing binary data encoded in base64. | [
"An",
"argparse",
"type",
"representing",
"binary",
"data",
"encoded",
"in",
"base64",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L78-L84 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | bin_hex_type | def bin_hex_type(arg):
"""An argparse type representing binary data encoded in hex."""
if re.match(r'^[a-f0-9]{2}(:[a-f0-9]{2})+$', arg, re.I):
arg = arg.replace(':', '')
elif re.match(r'^(\\x[a-f0-9]{2})+$', arg, re.I):
arg = arg.replace('\\x', '')
try:
arg = binascii.a2b_hex(arg)
except (binascii.Error, Ty... | python | def bin_hex_type(arg):
"""An argparse type representing binary data encoded in hex."""
if re.match(r'^[a-f0-9]{2}(:[a-f0-9]{2})+$', arg, re.I):
arg = arg.replace(':', '')
elif re.match(r'^(\\x[a-f0-9]{2})+$', arg, re.I):
arg = arg.replace('\\x', '')
try:
arg = binascii.a2b_hex(arg)
except (binascii.Error, Ty... | [
"def",
"bin_hex_type",
"(",
"arg",
")",
":",
"if",
"re",
".",
"match",
"(",
"r'^[a-f0-9]{2}(:[a-f0-9]{2})+$'",
",",
"arg",
",",
"re",
".",
"I",
")",
":",
"arg",
"=",
"arg",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"elif",
"re",
".",
"match",
"("... | An argparse type representing binary data encoded in hex. | [
"An",
"argparse",
"type",
"representing",
"binary",
"data",
"encoded",
"in",
"hex",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L86-L96 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | dir_type | def dir_type(arg):
"""An argparse type representing a valid directory."""
if not os.path.isdir(arg):
raise argparse.ArgumentTypeError("{0} is not a valid directory".format(repr(arg)))
return arg | python | def dir_type(arg):
"""An argparse type representing a valid directory."""
if not os.path.isdir(arg):
raise argparse.ArgumentTypeError("{0} is not a valid directory".format(repr(arg)))
return arg | [
"def",
"dir_type",
"(",
"arg",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"arg",
")",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"{0} is not a valid directory\"",
".",
"format",
"(",
"repr",
"(",
"arg",
")",
")",
")",
... | An argparse type representing a valid directory. | [
"An",
"argparse",
"type",
"representing",
"a",
"valid",
"directory",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L98-L102 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | email_type | def email_type(arg):
"""An argparse type representing an email address."""
if not is_valid_email_address(arg):
raise argparse.ArgumentTypeError("{0} is not a valid email address".format(repr(arg)))
return arg | python | def email_type(arg):
"""An argparse type representing an email address."""
if not is_valid_email_address(arg):
raise argparse.ArgumentTypeError("{0} is not a valid email address".format(repr(arg)))
return arg | [
"def",
"email_type",
"(",
"arg",
")",
":",
"if",
"not",
"is_valid_email_address",
"(",
"arg",
")",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"{0} is not a valid email address\"",
".",
"format",
"(",
"repr",
"(",
"arg",
")",
")",
")",
"return",... | An argparse type representing an email address. | [
"An",
"argparse",
"type",
"representing",
"an",
"email",
"address",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L104-L108 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | log_level_type | def log_level_type(arg):
"""An argparse type representing a logging level."""
if not arg.upper() in ('NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'):
raise argparse.ArgumentTypeError("{0} is not a valid log level".format(repr(arg)))
return getattr(logging, arg.upper()) | python | def log_level_type(arg):
"""An argparse type representing a logging level."""
if not arg.upper() in ('NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'):
raise argparse.ArgumentTypeError("{0} is not a valid log level".format(repr(arg)))
return getattr(logging, arg.upper()) | [
"def",
"log_level_type",
"(",
"arg",
")",
":",
"if",
"not",
"arg",
".",
"upper",
"(",
")",
"in",
"(",
"'NOTSET'",
",",
"'DEBUG'",
",",
"'INFO'",
",",
"'WARNING'",
",",
"'ERROR'",
",",
"'CRITICAL'",
")",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",... | An argparse type representing a logging level. | [
"An",
"argparse",
"type",
"representing",
"a",
"logging",
"level",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L110-L114 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | port_type | def port_type(arg):
"""An argparse type representing a tcp or udp port number."""
error_msg = "{0} is not a valid port".format(repr(arg))
try:
arg = ast.literal_eval(arg)
except ValueError:
raise argparse.ArgumentTypeError(error_msg)
if arg < 0 or arg > 65535:
raise argparse.ArgumentTypeError(error_msg)
ret... | python | def port_type(arg):
"""An argparse type representing a tcp or udp port number."""
error_msg = "{0} is not a valid port".format(repr(arg))
try:
arg = ast.literal_eval(arg)
except ValueError:
raise argparse.ArgumentTypeError(error_msg)
if arg < 0 or arg > 65535:
raise argparse.ArgumentTypeError(error_msg)
ret... | [
"def",
"port_type",
"(",
"arg",
")",
":",
"error_msg",
"=",
"\"{0} is not a valid port\"",
".",
"format",
"(",
"repr",
"(",
"arg",
")",
")",
"try",
":",
"arg",
"=",
"ast",
".",
"literal_eval",
"(",
"arg",
")",
"except",
"ValueError",
":",
"raise",
"argpa... | An argparse type representing a tcp or udp port number. | [
"An",
"argparse",
"type",
"representing",
"a",
"tcp",
"or",
"udp",
"port",
"number",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L116-L125 |
zeroSteiner/smoke-zephyr | smoke_zephyr/argparse_types.py | timespan_type | def timespan_type(arg):
"""An argparse type representing a timespan such as 6h for 6 hours."""
try:
arg = parse_timespan(arg)
except ValueError:
raise argparse.ArgumentTypeError("{0} is not a valid time span".format(repr(arg)))
return arg | python | def timespan_type(arg):
"""An argparse type representing a timespan such as 6h for 6 hours."""
try:
arg = parse_timespan(arg)
except ValueError:
raise argparse.ArgumentTypeError("{0} is not a valid time span".format(repr(arg)))
return arg | [
"def",
"timespan_type",
"(",
"arg",
")",
":",
"try",
":",
"arg",
"=",
"parse_timespan",
"(",
"arg",
")",
"except",
"ValueError",
":",
"raise",
"argparse",
".",
"ArgumentTypeError",
"(",
"\"{0} is not a valid time span\"",
".",
"format",
"(",
"repr",
"(",
"arg"... | An argparse type representing a timespan such as 6h for 6 hours. | [
"An",
"argparse",
"type",
"representing",
"a",
"timespan",
"such",
"as",
"6h",
"for",
"6",
"hours",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/argparse_types.py#L127-L133 |
thespacedoctor/sherlock | sherlock/catalogue_conesearch.py | catalogue_conesearch.search | def search(self):
"""
*trigger the conesearch*
**Return:**
- ``matchIndies`` -- the indicies of the input transient sources (syncs with ``uniqueMatchDicts``)
- ``uniqueMatchDicts`` -- the crossmatch results
**Usage:**
See class docstring for usage e... | python | def search(self):
"""
*trigger the conesearch*
**Return:**
- ``matchIndies`` -- the indicies of the input transient sources (syncs with ``uniqueMatchDicts``)
- ``uniqueMatchDicts`` -- the crossmatch results
**Usage:**
See class docstring for usage e... | [
"def",
"search",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``search`` method'",
")",
"# ACCOUNT FOR TYPE OF SEARCH",
"sqlWhere",
"=",
"False",
"magnitudeLimitFilter",
"=",
"self",
".",
"magnitudeLimitFilter",
"disCols",
"=",
"[",
... | *trigger the conesearch*
**Return:**
- ``matchIndies`` -- the indicies of the input transient sources (syncs with ``uniqueMatchDicts``)
- ``uniqueMatchDicts`` -- the crossmatch results
**Usage:**
See class docstring for usage examples
.. todo ::
... | [
"*",
"trigger",
"the",
"conesearch",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/catalogue_conesearch.py#L204-L289 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch.match | def match(self):
"""
*match the transients against the sherlock-catalogues according to the search algorithm and return matches alongside the predicted classification(s)*
**Return:**
- ``classification`` -- the crossmatch results and classifications assigned to the transients
... | python | def match(self):
"""
*match the transients against the sherlock-catalogues according to the search algorithm and return matches alongside the predicted classification(s)*
**Return:**
- ``classification`` -- the crossmatch results and classifications assigned to the transients
... | [
"def",
"match",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``match`` method'",
")",
"classifications",
"=",
"[",
"]",
"# COUNT NUMBER OF TRANSIENT TO CROSSMATCH",
"numberOfTransients",
"=",
"len",
"(",
"self",
".",
"transients",
"... | *match the transients against the sherlock-catalogues according to the search algorithm and return matches alongside the predicted classification(s)*
**Return:**
- ``classification`` -- the crossmatch results and classifications assigned to the transients
See the class docstring for usage.... | [
"*",
"match",
"the",
"transients",
"against",
"the",
"sherlock",
"-",
"catalogues",
"according",
"to",
"the",
"search",
"algorithm",
"and",
"return",
"matches",
"alongside",
"the",
"predicted",
"classification",
"(",
"s",
")",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L88-L262 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch.angular_crossmatch_against_catalogue | def angular_crossmatch_against_catalogue(
self,
objectList,
searchPara={},
search_name="",
brightnessFilter=False,
physicalSearch=False,
classificationType=False
):
"""*perform an angular separation crossmatch against a given catalogue in the database ... | python | def angular_crossmatch_against_catalogue(
self,
objectList,
searchPara={},
search_name="",
brightnessFilter=False,
physicalSearch=False,
classificationType=False
):
"""*perform an angular separation crossmatch against a given catalogue in the database ... | [
"def",
"angular_crossmatch_against_catalogue",
"(",
"self",
",",
"objectList",
",",
"searchPara",
"=",
"{",
"}",
",",
"search_name",
"=",
"\"\"",
",",
"brightnessFilter",
"=",
"False",
",",
"physicalSearch",
"=",
"False",
",",
"classificationType",
"=",
"False",
... | *perform an angular separation crossmatch against a given catalogue in the database and annotate the crossmatch with some value added parameters (distances, physical separations, sub-type of transient etc)*
**Key Arguments:**
- ``objectList`` -- the list of transient locations to match against the ... | [
"*",
"perform",
"an",
"angular",
"separation",
"crossmatch",
"against",
"a",
"given",
"catalogue",
"in",
"the",
"database",
"and",
"annotate",
"the",
"crossmatch",
"with",
"some",
"value",
"added",
"parameters",
"(",
"distances",
"physical",
"separations",
"sub",
... | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L264-L512 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch._annotate_crossmatch_with_value_added_parameters | def _annotate_crossmatch_with_value_added_parameters(
self,
crossmatchDict,
catalogueName,
searchPara,
search_name):
"""*annotate each crossmatch with physical parameters such are distances etc*
**Key Arguments:**
- ``crossmatchDic... | python | def _annotate_crossmatch_with_value_added_parameters(
self,
crossmatchDict,
catalogueName,
searchPara,
search_name):
"""*annotate each crossmatch with physical parameters such are distances etc*
**Key Arguments:**
- ``crossmatchDic... | [
"def",
"_annotate_crossmatch_with_value_added_parameters",
"(",
"self",
",",
"crossmatchDict",
",",
"catalogueName",
",",
"searchPara",
",",
"search_name",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_annotate_crossmatch_with_value_added_parameters`` met... | *annotate each crossmatch with physical parameters such are distances etc*
**Key Arguments:**
- ``crossmatchDict`` -- the crossmatch dictionary
- ``catalogueName`` -- the name of the catalogue the crossmatch results from
- ``searchPara`` -- the search parameters for this ind... | [
"*",
"annotate",
"each",
"crossmatch",
"with",
"physical",
"parameters",
"such",
"are",
"distances",
"etc",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L514-L621 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch._bright_star_match | def _bright_star_match(
self,
matchedObjects,
catalogueName,
magnitudeLimitFilter,
lowerMagnitudeLimit):
"""*perform a bright star match on the crossmatch results if required by the catalogue search*
**Key Arguments:**
- ``matchedO... | python | def _bright_star_match(
self,
matchedObjects,
catalogueName,
magnitudeLimitFilter,
lowerMagnitudeLimit):
"""*perform a bright star match on the crossmatch results if required by the catalogue search*
**Key Arguments:**
- ``matchedO... | [
"def",
"_bright_star_match",
"(",
"self",
",",
"matchedObjects",
",",
"catalogueName",
",",
"magnitudeLimitFilter",
",",
"lowerMagnitudeLimit",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_bright_star_match`` method'",
")",
"import",
"decimal",
"... | *perform a bright star match on the crossmatch results if required by the catalogue search*
**Key Arguments:**
- ``matchedObjects`` -- the list of matched sources from the catalogue crossmatch
- ``catalogueName`` -- the name of the catalogue the crossmatch results from
- ``m... | [
"*",
"perform",
"a",
"bright",
"star",
"match",
"on",
"the",
"crossmatch",
"results",
"if",
"required",
"by",
"the",
"catalogue",
"search",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L623-L665 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch._galaxy_association_cuts | def _galaxy_association_cuts(
self,
matchedObjects,
catalogueName,
magnitudeLimitFilter,
upperMagnitudeLimit,
lowerMagnitudeLimit):
"""*perform a bright star match on the crossmatch results if required by the catalogue search*
**Ke... | python | def _galaxy_association_cuts(
self,
matchedObjects,
catalogueName,
magnitudeLimitFilter,
upperMagnitudeLimit,
lowerMagnitudeLimit):
"""*perform a bright star match on the crossmatch results if required by the catalogue search*
**Ke... | [
"def",
"_galaxy_association_cuts",
"(",
"self",
",",
"matchedObjects",
",",
"catalogueName",
",",
"magnitudeLimitFilter",
",",
"upperMagnitudeLimit",
",",
"lowerMagnitudeLimit",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_galaxy_association_cuts`` m... | *perform a bright star match on the crossmatch results if required by the catalogue search*
**Key Arguments:**
- ``matchedObjects`` -- the list of matched sources from the catalogue crossmatch
- ``catalogueName`` -- the name of the catalogue the crossmatch results from
- ``m... | [
"*",
"perform",
"a",
"bright",
"star",
"match",
"on",
"the",
"crossmatch",
"results",
"if",
"required",
"by",
"the",
"catalogue",
"search",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L667-L714 |
thespacedoctor/sherlock | sherlock/transient_catalogue_crossmatch.py | transient_catalogue_crossmatch.physical_separation_crossmatch_against_catalogue | def physical_separation_crossmatch_against_catalogue(
self,
objectList,
searchPara,
search_name,
brightnessFilter=False,
classificationType=False
):
"""*perform an physical separation crossmatch against a given catalogue in the database*
This search i... | python | def physical_separation_crossmatch_against_catalogue(
self,
objectList,
searchPara,
search_name,
brightnessFilter=False,
classificationType=False
):
"""*perform an physical separation crossmatch against a given catalogue in the database*
This search i... | [
"def",
"physical_separation_crossmatch_against_catalogue",
"(",
"self",
",",
"objectList",
",",
"searchPara",
",",
"search_name",
",",
"brightnessFilter",
"=",
"False",
",",
"classificationType",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'sta... | *perform an physical separation crossmatch against a given catalogue in the database*
This search is basically the same as the angular separation search except extra filtering is done to exclude sources outside the physical search radius (matched sources require distance info to calulate physical separations)
... | [
"*",
"perform",
"an",
"physical",
"separation",
"crossmatch",
"against",
"a",
"given",
"catalogue",
"in",
"the",
"database",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/transient_catalogue_crossmatch.py#L716-L866 |
pytroll/posttroll | posttroll/publisher.py | get_own_ip | def get_own_ip():
"""Get the host's ip number.
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
sock.connect(("8.8.8.8", 80))
except socket.gaierror:
ip_ = "127.0.0.1"
else:
ip_ = sock.getsockname()[0]
finally:
sock.close()
return ip_ | python | def get_own_ip():
"""Get the host's ip number.
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
sock.connect(("8.8.8.8", 80))
except socket.gaierror:
ip_ = "127.0.0.1"
else:
ip_ = sock.getsockname()[0]
finally:
sock.close()
return ip_ | [
"def",
"get_own_ip",
"(",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"try",
":",
"sock",
".",
"connect",
"(",
"(",
"\"8.8.8.8\"",
",",
"80",
")",
")",
"except",
"socket",
".",... | Get the host's ip number. | [
"Get",
"the",
"host",
"s",
"ip",
"number",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L41-L53 |
pytroll/posttroll | posttroll/publisher.py | Publisher.send | def send(self, msg):
"""Send the given message.
"""
with self._pub_lock:
self.publish.send_string(msg)
return self | python | def send(self, msg):
"""Send the given message.
"""
with self._pub_lock:
self.publish.send_string(msg)
return self | [
"def",
"send",
"(",
"self",
",",
"msg",
")",
":",
"with",
"self",
".",
"_pub_lock",
":",
"self",
".",
"publish",
".",
"send_string",
"(",
"msg",
")",
"return",
"self"
] | Send the given message. | [
"Send",
"the",
"given",
"message",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L119-L124 |
pytroll/posttroll | posttroll/publisher.py | Publisher.stop | def stop(self):
"""Stop the publisher.
"""
self.publish.setsockopt(zmq.LINGER, 1)
self.publish.close()
return self | python | def stop(self):
"""Stop the publisher.
"""
self.publish.setsockopt(zmq.LINGER, 1)
self.publish.close()
return self | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"publish",
".",
"setsockopt",
"(",
"zmq",
".",
"LINGER",
",",
"1",
")",
"self",
".",
"publish",
".",
"close",
"(",
")",
"return",
"self"
] | Stop the publisher. | [
"Stop",
"the",
"publisher",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L126-L131 |
pytroll/posttroll | posttroll/publisher.py | Publisher.heartbeat | def heartbeat(self, min_interval=0):
"""Send a heartbeat ... but only if *min_interval* seconds has passed
since last beat.
"""
if not self._heartbeat:
self._heartbeat = _PublisherHeartbeat(self)
self._heartbeat(min_interval) | python | def heartbeat(self, min_interval=0):
"""Send a heartbeat ... but only if *min_interval* seconds has passed
since last beat.
"""
if not self._heartbeat:
self._heartbeat = _PublisherHeartbeat(self)
self._heartbeat(min_interval) | [
"def",
"heartbeat",
"(",
"self",
",",
"min_interval",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"_heartbeat",
":",
"self",
".",
"_heartbeat",
"=",
"_PublisherHeartbeat",
"(",
"self",
")",
"self",
".",
"_heartbeat",
"(",
"min_interval",
")"
] | Send a heartbeat ... but only if *min_interval* seconds has passed
since last beat. | [
"Send",
"a",
"heartbeat",
"...",
"but",
"only",
"if",
"*",
"min_interval",
"*",
"seconds",
"has",
"passed",
"since",
"last",
"beat",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L133-L139 |
pytroll/posttroll | posttroll/publisher.py | NoisyPublisher.start | def start(self):
"""Start the publisher.
"""
pub_addr = "tcp://*:" + str(self._port)
self._publisher = self._publisher_class(pub_addr, self._name)
LOGGER.debug("entering publish %s", str(self._publisher.destination))
addr = ("tcp://" + str(get_own_ip()) + ":" +
... | python | def start(self):
"""Start the publisher.
"""
pub_addr = "tcp://*:" + str(self._port)
self._publisher = self._publisher_class(pub_addr, self._name)
LOGGER.debug("entering publish %s", str(self._publisher.destination))
addr = ("tcp://" + str(get_own_ip()) + ":" +
... | [
"def",
"start",
"(",
"self",
")",
":",
"pub_addr",
"=",
"\"tcp://*:\"",
"+",
"str",
"(",
"self",
".",
"_port",
")",
"self",
".",
"_publisher",
"=",
"self",
".",
"_publisher_class",
"(",
"pub_addr",
",",
"self",
".",
"_name",
")",
"LOGGER",
".",
"debug"... | Start the publisher. | [
"Start",
"the",
"publisher",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L197-L209 |
pytroll/posttroll | posttroll/publisher.py | NoisyPublisher.stop | def stop(self):
"""Stop the publisher.
"""
LOGGER.debug("exiting publish")
if self._publisher is not None:
self._publisher.stop()
self._publisher = None
if self._broadcaster is not None:
self._broadcaster.stop()
self._broadcaster = ... | python | def stop(self):
"""Stop the publisher.
"""
LOGGER.debug("exiting publish")
if self._publisher is not None:
self._publisher.stop()
self._publisher = None
if self._broadcaster is not None:
self._broadcaster.stop()
self._broadcaster = ... | [
"def",
"stop",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"exiting publish\"",
")",
"if",
"self",
".",
"_publisher",
"is",
"not",
"None",
":",
"self",
".",
"_publisher",
".",
"stop",
"(",
")",
"self",
".",
"_publisher",
"=",
"None",
"if",
... | Stop the publisher. | [
"Stop",
"the",
"publisher",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/publisher.py#L216-L225 |
dfm/transit | transit/simple.py | SimpleSystem.light_curve | def light_curve(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the ex... | python | def light_curve(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the ex... | [
"def",
"light_curve",
"(",
"self",
",",
"t",
",",
"texp",
"=",
"0.0",
",",
"tol",
"=",
"1e-8",
",",
"maxdepth",
"=",
"4",
")",
":",
"t",
"=",
"np",
".",
"atleast_1d",
"(",
"t",
")",
"return",
"CythonSolver",
"(",
")",
".",
"simple_light_curve",
"("... | Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the exposure time integration.
:param maxdepth:
The maximum rec... | [
"Get",
"the",
"light",
"curve",
"evaluated",
"at",
"a",
"list",
"of",
"times",
"using",
"the",
"current",
"model",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/simple.py#L68-L85 |
dfm/transit | transit/simple.py | SimpleSystem.light_curve_gradient | def light_curve_gradient(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion f... | python | def light_curve_gradient(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion f... | [
"def",
"light_curve_gradient",
"(",
"self",
",",
"t",
",",
"texp",
"=",
"0.0",
",",
"tol",
"=",
"1e-8",
",",
"maxdepth",
"=",
"4",
")",
":",
"t",
"=",
"np",
".",
"atleast_1d",
"(",
"t",
")",
"f",
",",
"df",
"=",
"CythonSolver",
"(",
")",
".",
"... | Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the exposure time integration.
:param maxdepth:
The maximum rec... | [
"Get",
"the",
"light",
"curve",
"evaluated",
"at",
"a",
"list",
"of",
"times",
"using",
"the",
"current",
"model",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/simple.py#L87-L106 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | configure_stream_logger | def configure_stream_logger(logger='', level=None, formatter='%(levelname)-8s %(message)s'):
"""
Configure the default stream handler for logging messages to the console,
remove other logging handlers, and enable capturing warnings.
.. versionadded:: 1.3.0
:param str logger: The logger to add the stream handler ... | python | def configure_stream_logger(logger='', level=None, formatter='%(levelname)-8s %(message)s'):
"""
Configure the default stream handler for logging messages to the console,
remove other logging handlers, and enable capturing warnings.
.. versionadded:: 1.3.0
:param str logger: The logger to add the stream handler ... | [
"def",
"configure_stream_logger",
"(",
"logger",
"=",
"''",
",",
"level",
"=",
"None",
",",
"formatter",
"=",
"'%(levelname)-8s %(message)s'",
")",
":",
"level",
"=",
"level",
"or",
"logging",
".",
"WARNING",
"if",
"isinstance",
"(",
"level",
",",
"str",
")"... | Configure the default stream handler for logging messages to the console,
remove other logging handlers, and enable capturing warnings.
.. versionadded:: 1.3.0
:param str logger: The logger to add the stream handler for.
:param level: The level to set the logger to, will default to WARNING if no level is specifie... | [
"Configure",
"the",
"default",
"stream",
"handler",
"for",
"logging",
"messages",
"to",
"the",
"console",
"remove",
"other",
"logging",
"handlers",
"and",
"enable",
"capturing",
"warnings",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L420-L454 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | download | def download(url, filename=None):
"""
Download a file from a url and save it to disk.
:param str url: The URL to fetch the file from.
:param str filename: The destination file to write the data to.
"""
# requirements os, shutil, urllib.parse, urllib.request
if not filename:
url_parts = urllib.parse.urlparse(u... | python | def download(url, filename=None):
"""
Download a file from a url and save it to disk.
:param str url: The URL to fetch the file from.
:param str filename: The destination file to write the data to.
"""
# requirements os, shutil, urllib.parse, urllib.request
if not filename:
url_parts = urllib.parse.urlparse(u... | [
"def",
"download",
"(",
"url",
",",
"filename",
"=",
"None",
")",
":",
"# requirements os, shutil, urllib.parse, urllib.request",
"if",
"not",
"filename",
":",
"url_parts",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"filename",
"=",
"os",
"... | Download a file from a url and save it to disk.
:param str url: The URL to fetch the file from.
:param str filename: The destination file to write the data to. | [
"Download",
"a",
"file",
"from",
"a",
"url",
"and",
"save",
"it",
"to",
"disk",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L456-L471 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | format_bytes_size | def format_bytes_size(val):
"""
Take a number of bytes and convert it to a human readable number.
:param int val: The number of bytes to format.
:return: The size in a human readable format.
:rtype: str
"""
if not val:
return '0 bytes'
for sz_name in ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']:
if val < ... | python | def format_bytes_size(val):
"""
Take a number of bytes and convert it to a human readable number.
:param int val: The number of bytes to format.
:return: The size in a human readable format.
:rtype: str
"""
if not val:
return '0 bytes'
for sz_name in ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']:
if val < ... | [
"def",
"format_bytes_size",
"(",
"val",
")",
":",
"if",
"not",
"val",
":",
"return",
"'0 bytes'",
"for",
"sz_name",
"in",
"[",
"'bytes'",
",",
"'KB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TB'",
",",
"'PB'",
",",
"'EB'",
"]",
":",
"if",
"val",
"<",
"102... | Take a number of bytes and convert it to a human readable number.
:param int val: The number of bytes to format.
:return: The size in a human readable format.
:rtype: str | [
"Take",
"a",
"number",
"of",
"bytes",
"and",
"convert",
"it",
"to",
"a",
"human",
"readable",
"number",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L485-L499 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | grep | def grep(expression, file, flags=0, invert=False):
"""
Search a file and return a list of all lines that match a regular expression.
:param str expression: The regex to search for.
:param file: The file to search in.
:type file: str, file
:param int flags: The regex flags to use when searching.
:param bool inve... | python | def grep(expression, file, flags=0, invert=False):
"""
Search a file and return a list of all lines that match a regular expression.
:param str expression: The regex to search for.
:param file: The file to search in.
:type file: str, file
:param int flags: The regex flags to use when searching.
:param bool inve... | [
"def",
"grep",
"(",
"expression",
",",
"file",
",",
"flags",
"=",
"0",
",",
"invert",
"=",
"False",
")",
":",
"# requirements = re",
"if",
"isinstance",
"(",
"file",
",",
"str",
")",
":",
"file",
"=",
"open",
"(",
"file",
")",
"lines",
"=",
"[",
"]... | Search a file and return a list of all lines that match a regular expression.
:param str expression: The regex to search for.
:param file: The file to search in.
:type file: str, file
:param int flags: The regex flags to use when searching.
:param bool invert: Select non matching lines instead.
:return: All the ... | [
"Search",
"a",
"file",
"and",
"return",
"a",
"list",
"of",
"all",
"lines",
"that",
"match",
"a",
"regular",
"expression",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L501-L520 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | open_uri | def open_uri(uri):
"""
Open a URI in a platform intelligent way. On Windows this will use
'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
depending on which is available. If no suitable application can be
found to open the URI, a RuntimeError will be raised.
.. versionadded:: 1.3.0
:param s... | python | def open_uri(uri):
"""
Open a URI in a platform intelligent way. On Windows this will use
'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
depending on which is available. If no suitable application can be
found to open the URI, a RuntimeError will be raised.
.. versionadded:: 1.3.0
:param s... | [
"def",
"open_uri",
"(",
"uri",
")",
":",
"close_fds",
"=",
"True",
"startupinfo",
"=",
"None",
"proc_args",
"=",
"[",
"]",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
":",
"proc_args",
".",
"append",
"(",
"which",
"(",
"'cmd.exe... | Open a URI in a platform intelligent way. On Windows this will use
'cmd.exe /c start' and on Linux this will use gvfs-open or xdg-open
depending on which is available. If no suitable application can be
found to open the URI, a RuntimeError will be raised.
.. versionadded:: 1.3.0
:param str uri: The URI to open. | [
"Open",
"a",
"URI",
"in",
"a",
"platform",
"intelligent",
"way",
".",
"On",
"Windows",
"this",
"will",
"use",
"cmd",
".",
"exe",
"/",
"c",
"start",
"and",
"on",
"Linux",
"this",
"will",
"use",
"gvfs",
"-",
"open",
"or",
"xdg",
"-",
"open",
"depending... | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L533-L564 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | parse_case_snake_to_camel | def parse_case_snake_to_camel(snake, upper_first=True):
"""
Convert a string from snake_case to CamelCase.
:param str snake: The snake_case string to convert.
:param bool upper_first: Whether or not to capitalize the first
character of the string.
:return: The CamelCase version of string.
:rtype: str
"""
sna... | python | def parse_case_snake_to_camel(snake, upper_first=True):
"""
Convert a string from snake_case to CamelCase.
:param str snake: The snake_case string to convert.
:param bool upper_first: Whether or not to capitalize the first
character of the string.
:return: The CamelCase version of string.
:rtype: str
"""
sna... | [
"def",
"parse_case_snake_to_camel",
"(",
"snake",
",",
"upper_first",
"=",
"True",
")",
":",
"snake",
"=",
"snake",
".",
"split",
"(",
"'_'",
")",
"first_part",
"=",
"snake",
"[",
"0",
"]",
"if",
"upper_first",
":",
"first_part",
"=",
"first_part",
".",
... | Convert a string from snake_case to CamelCase.
:param str snake: The snake_case string to convert.
:param bool upper_first: Whether or not to capitalize the first
character of the string.
:return: The CamelCase version of string.
:rtype: str | [
"Convert",
"a",
"string",
"from",
"snake_case",
"to",
"CamelCase",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L577-L591 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | parse_server | def parse_server(server, default_port):
"""
Convert a server string to a tuple suitable for passing to connect, for
example converting 'www.google.com:443' to ('www.google.com', 443).
:param str server: The server string to convert.
:param int default_port: The port to use in case one is not specified
in the se... | python | def parse_server(server, default_port):
"""
Convert a server string to a tuple suitable for passing to connect, for
example converting 'www.google.com:443' to ('www.google.com', 443).
:param str server: The server string to convert.
:param int default_port: The port to use in case one is not specified
in the se... | [
"def",
"parse_server",
"(",
"server",
",",
"default_port",
")",
":",
"server",
"=",
"server",
".",
"rsplit",
"(",
"':'",
",",
"1",
")",
"host",
"=",
"server",
"[",
"0",
"]",
"if",
"host",
".",
"startswith",
"(",
"'['",
")",
"and",
"host",
".",
"end... | Convert a server string to a tuple suitable for passing to connect, for
example converting 'www.google.com:443' to ('www.google.com', 443).
:param str server: The server string to convert.
:param int default_port: The port to use in case one is not specified
in the server string.
:return: The parsed server infor... | [
"Convert",
"a",
"server",
"string",
"to",
"a",
"tuple",
"suitable",
"for",
"passing",
"to",
"connect",
"for",
"example",
"converting",
"www",
".",
"google",
".",
"com",
":",
"443",
"to",
"(",
"www",
".",
"google",
".",
"com",
"443",
")",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L593-L615 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | parse_timespan | def parse_timespan(timedef):
"""
Convert a string timespan definition to seconds, for example converting
'1m30s' to 90. If *timedef* is already an int, the value will be returned
unmodified.
:param timedef: The timespan definition to convert to seconds.
:type timedef: int, str
:return: The converted value in se... | python | def parse_timespan(timedef):
"""
Convert a string timespan definition to seconds, for example converting
'1m30s' to 90. If *timedef* is already an int, the value will be returned
unmodified.
:param timedef: The timespan definition to convert to seconds.
:type timedef: int, str
:return: The converted value in se... | [
"def",
"parse_timespan",
"(",
"timedef",
")",
":",
"if",
"isinstance",
"(",
"timedef",
",",
"int",
")",
":",
"return",
"timedef",
"converter_order",
"=",
"(",
"'w'",
",",
"'d'",
",",
"'h'",
",",
"'m'",
",",
"'s'",
")",
"converters",
"=",
"{",
"'w'",
... | Convert a string timespan definition to seconds, for example converting
'1m30s' to 90. If *timedef* is already an int, the value will be returned
unmodified.
:param timedef: The timespan definition to convert to seconds.
:type timedef: int, str
:return: The converted value in seconds.
:rtype: int | [
"Convert",
"a",
"string",
"timespan",
"definition",
"to",
"seconds",
"for",
"example",
"converting",
"1m30s",
"to",
"90",
".",
"If",
"*",
"timedef",
"*",
"is",
"already",
"an",
"int",
"the",
"value",
"will",
"be",
"returned",
"unmodified",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L617-L660 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | parse_to_slug | def parse_to_slug(words, maxlen=24):
"""
Parse a string into a slug format suitable for use in URLs and other
character restricted applications. Only utf-8 strings are supported at this
time.
:param str words: The words to parse.
:param int maxlen: The maximum length of the slug.
:return: The parsed words as a ... | python | def parse_to_slug(words, maxlen=24):
"""
Parse a string into a slug format suitable for use in URLs and other
character restricted applications. Only utf-8 strings are supported at this
time.
:param str words: The words to parse.
:param int maxlen: The maximum length of the slug.
:return: The parsed words as a ... | [
"def",
"parse_to_slug",
"(",
"words",
",",
"maxlen",
"=",
"24",
")",
":",
"slug",
"=",
"''",
"maxlen",
"=",
"min",
"(",
"maxlen",
",",
"len",
"(",
"words",
")",
")",
"for",
"c",
"in",
"words",
":",
"if",
"len",
"(",
"slug",
")",
"==",
"maxlen",
... | Parse a string into a slug format suitable for use in URLs and other
character restricted applications. Only utf-8 strings are supported at this
time.
:param str words: The words to parse.
:param int maxlen: The maximum length of the slug.
:return: The parsed words as a slug.
:rtype: str | [
"Parse",
"a",
"string",
"into",
"a",
"slug",
"format",
"suitable",
"for",
"use",
"in",
"URLs",
"and",
"other",
"character",
"restricted",
"applications",
".",
"Only",
"utf",
"-",
"8",
"strings",
"are",
"supported",
"at",
"this",
"time",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L662-L691 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | random_string_alphanumeric | def random_string_alphanumeric(size):
"""
Generate a random string of *size* length consisting of mixed case letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str
"""
# requ... | python | def random_string_alphanumeric(size):
"""
Generate a random string of *size* length consisting of mixed case letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str
"""
# requ... | [
"def",
"random_string_alphanumeric",
"(",
"size",
")",
":",
"# requirements = random, string",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
")",
"for",
"x",
"in",
"range",
"(",
... | Generate a random string of *size* length consisting of mixed case letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str | [
"Generate",
"a",
"random",
"string",
"of",
"*",
"size",
"*",
"length",
"consisting",
"of",
"mixed",
"case",
"letters",
"and",
"numbers",
".",
"This",
"function",
"is",
"not",
"meant",
"for",
"cryptographic",
"purposes",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L693-L703 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | random_string_lower_numeric | def random_string_lower_numeric(size):
"""
Generate a random string of *size* length consisting of lowercase letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str
"""
# requ... | python | def random_string_lower_numeric(size):
"""
Generate a random string of *size* length consisting of lowercase letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str
"""
# requ... | [
"def",
"random_string_lower_numeric",
"(",
"size",
")",
":",
"# requirements = random, string",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
"+",
"string",
".",
"digits",
")",
"for",
"x",
"in",
"range",
"(",... | Generate a random string of *size* length consisting of lowercase letters
and numbers. This function is not meant for cryptographic purposes.
:param int size: The length of the string to return.
:return: A string consisting of random characters.
:rtype: str | [
"Generate",
"a",
"random",
"string",
"of",
"*",
"size",
"*",
"length",
"consisting",
"of",
"lowercase",
"letters",
"and",
"numbers",
".",
"This",
"function",
"is",
"not",
"meant",
"for",
"cryptographic",
"purposes",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L705-L715 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | selection_collision | def selection_collision(selections, poolsize):
"""
Calculate the probability that two random values selected from an arbitrary
sized pool of unique values will be equal. This is commonly known as the
"Birthday Problem".
:param int selections: The number of random selections.
:param int poolsize: The number of un... | python | def selection_collision(selections, poolsize):
"""
Calculate the probability that two random values selected from an arbitrary
sized pool of unique values will be equal. This is commonly known as the
"Birthday Problem".
:param int selections: The number of random selections.
:param int poolsize: The number of un... | [
"def",
"selection_collision",
"(",
"selections",
",",
"poolsize",
")",
":",
"# requirments = sys",
"probability",
"=",
"100.0",
"poolsize",
"=",
"float",
"(",
"poolsize",
")",
"for",
"i",
"in",
"range",
"(",
"selections",
")",
":",
"probability",
"=",
"probabi... | Calculate the probability that two random values selected from an arbitrary
sized pool of unique values will be equal. This is commonly known as the
"Birthday Problem".
:param int selections: The number of random selections.
:param int poolsize: The number of unique random values in the pool to choose from.
:rtyp... | [
"Calculate",
"the",
"probability",
"that",
"two",
"random",
"values",
"selected",
"from",
"an",
"arbitrary",
"sized",
"pool",
"of",
"unique",
"values",
"will",
"be",
"equal",
".",
"This",
"is",
"commonly",
"known",
"as",
"the",
"Birthday",
"Problem",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L717-L734 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | unique | def unique(seq, key=None):
"""
Create a unique list or tuple from a provided list or tuple and preserve the
order.
:param seq: The list or tuple to preserve unique items from.
:type seq: list, tuple
:param key: If key is provided it will be called during the
comparison process.
:type key: function, None
"""
... | python | def unique(seq, key=None):
"""
Create a unique list or tuple from a provided list or tuple and preserve the
order.
:param seq: The list or tuple to preserve unique items from.
:type seq: list, tuple
:param key: If key is provided it will be called during the
comparison process.
:type key: function, None
"""
... | [
"def",
"unique",
"(",
"seq",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"lambda",
"x",
":",
"x",
"preserved_type",
"=",
"type",
"(",
"seq",
")",
"if",
"preserved_type",
"not",
"in",
"(",
"list",
",",
"tuple",
"... | Create a unique list or tuple from a provided list or tuple and preserve the
order.
:param seq: The list or tuple to preserve unique items from.
:type seq: list, tuple
:param key: If key is provided it will be called during the
comparison process.
:type key: function, None | [
"Create",
"a",
"unique",
"list",
"or",
"tuple",
"from",
"a",
"provided",
"list",
"or",
"tuple",
"and",
"preserve",
"the",
"order",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L748-L772 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | weighted_choice | def weighted_choice(choices, weight):
"""
Make a random selection from the specified choices. Apply the *weight*
function to each to return a positive integer representing shares of
selection pool the choice should received. The *weight* function is passed a
single argument of the choice from the *choices* iterabl... | python | def weighted_choice(choices, weight):
"""
Make a random selection from the specified choices. Apply the *weight*
function to each to return a positive integer representing shares of
selection pool the choice should received. The *weight* function is passed a
single argument of the choice from the *choices* iterabl... | [
"def",
"weighted_choice",
"(",
"choices",
",",
"weight",
")",
":",
"# requirements = random",
"weights",
"=",
"[",
"]",
"# get weight values for each of the choices",
"for",
"choice",
"in",
"choices",
":",
"choice_weight",
"=",
"weight",
"(",
"choice",
")",
"if",
... | Make a random selection from the specified choices. Apply the *weight*
function to each to return a positive integer representing shares of
selection pool the choice should received. The *weight* function is passed a
single argument of the choice from the *choices* iterable.
:param choices: The choices to select f... | [
"Make",
"a",
"random",
"selection",
"from",
"the",
"specified",
"choices",
".",
"Apply",
"the",
"*",
"weight",
"*",
"function",
"to",
"each",
"to",
"return",
"a",
"positive",
"integer",
"representing",
"shares",
"of",
"selection",
"pool",
"the",
"choice",
"s... | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L774-L803 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | xfrange | def xfrange(start, stop=None, step=1):
"""
Iterate through an arithmetic progression.
:param start: Starting number.
:type start: float, int, long
:param stop: Stopping number.
:type stop: float, int, long
:param step: Stepping size.
:type step: float, int, long
"""
if stop is None:
stop = start
start = ... | python | def xfrange(start, stop=None, step=1):
"""
Iterate through an arithmetic progression.
:param start: Starting number.
:type start: float, int, long
:param stop: Stopping number.
:type stop: float, int, long
:param step: Stepping size.
:type step: float, int, long
"""
if stop is None:
stop = start
start = ... | [
"def",
"xfrange",
"(",
"start",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
")",
":",
"if",
"stop",
"is",
"None",
":",
"stop",
"=",
"start",
"start",
"=",
"0.0",
"start",
"=",
"float",
"(",
"start",
")",
"while",
"start",
"<",
"stop",
":",
... | Iterate through an arithmetic progression.
:param start: Starting number.
:type start: float, int, long
:param stop: Stopping number.
:type stop: float, int, long
:param step: Stepping size.
:type step: float, int, long | [
"Iterate",
"through",
"an",
"arithmetic",
"progression",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L824-L841 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | Cache.cache_clean | def cache_clean(self):
"""
Remove expired items from the cache.
"""
now = time.time()
keys_for_removal = collections.deque()
for key, (_, expiration) in self.__cache.items():
if expiration < now:
keys_for_removal.append(key)
for key in keys_for_removal:
del self.__cache[key] | python | def cache_clean(self):
"""
Remove expired items from the cache.
"""
now = time.time()
keys_for_removal = collections.deque()
for key, (_, expiration) in self.__cache.items():
if expiration < now:
keys_for_removal.append(key)
for key in keys_for_removal:
del self.__cache[key] | [
"def",
"cache_clean",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"keys_for_removal",
"=",
"collections",
".",
"deque",
"(",
")",
"for",
"key",
",",
"(",
"_",
",",
"expiration",
")",
"in",
"self",
".",
"__cache",
".",
"items",
... | Remove expired items from the cache. | [
"Remove",
"expired",
"items",
"from",
"the",
"cache",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L210-L220 |
zeroSteiner/smoke-zephyr | smoke_zephyr/utilities.py | SectionConfigParser.set | def set(self, option, value):
"""
Set an option to an arbitrary value.
:param str option: The name of the option to set.
:param value: The value to set the option to.
"""
self.config_parser.set(self.section_name, option, value) | python | def set(self, option, value):
"""
Set an option to an arbitrary value.
:param str option: The name of the option to set.
:param value: The value to set the option to.
"""
self.config_parser.set(self.section_name, option, value) | [
"def",
"set",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"self",
".",
"config_parser",
".",
"set",
"(",
"self",
".",
"section_name",
",",
"option",
",",
"value",
")"
] | Set an option to an arbitrary value.
:param str option: The name of the option to set.
:param value: The value to set the option to. | [
"Set",
"an",
"option",
"to",
"an",
"arbitrary",
"value",
"."
] | train | https://github.com/zeroSteiner/smoke-zephyr/blob/a6d2498aeacc72ee52e7806f783a4d83d537ffb2/smoke_zephyr/utilities.py#L396-L403 |
dusktreader/py-buzz | buzz/__init__.py | Buzz.reformat_exception | def reformat_exception(cls, message, err, *format_args, **format_kwds):
"""
Reformats an exception by adding a message to it and reporting the
original exception name and message
"""
final_message = message.format(*format_args, **format_kwds)
final_message = "{} -- {}: {}... | python | def reformat_exception(cls, message, err, *format_args, **format_kwds):
"""
Reformats an exception by adding a message to it and reporting the
original exception name and message
"""
final_message = message.format(*format_args, **format_kwds)
final_message = "{} -- {}: {}... | [
"def",
"reformat_exception",
"(",
"cls",
",",
"message",
",",
"err",
",",
"*",
"format_args",
",",
"*",
"*",
"format_kwds",
")",
":",
"final_message",
"=",
"message",
".",
"format",
"(",
"*",
"format_args",
",",
"*",
"*",
"format_kwds",
")",
"final_message... | Reformats an exception by adding a message to it and reporting the
original exception name and message | [
"Reformats",
"an",
"exception",
"by",
"adding",
"a",
"message",
"to",
"it",
"and",
"reporting",
"the",
"original",
"exception",
"name",
"and",
"message"
] | train | https://github.com/dusktreader/py-buzz/blob/f2fd97abe158a1688188647992a5be6531058ec3/buzz/__init__.py#L52-L64 |
dusktreader/py-buzz | buzz/__init__.py | Buzz.handle_errors | def handle_errors(
cls, message, *format_args,
re_raise=True, exception_class=Exception,
do_finally=None, do_except=None, do_else=None,
**format_kwds
):
"""
provides a context manager that will intercept exceptions and repackage
them as Buzz in... | python | def handle_errors(
cls, message, *format_args,
re_raise=True, exception_class=Exception,
do_finally=None, do_except=None, do_else=None,
**format_kwds
):
"""
provides a context manager that will intercept exceptions and repackage
them as Buzz in... | [
"def",
"handle_errors",
"(",
"cls",
",",
"message",
",",
"*",
"format_args",
",",
"re_raise",
"=",
"True",
",",
"exception_class",
"=",
"Exception",
",",
"do_finally",
"=",
"None",
",",
"do_except",
"=",
"None",
",",
"do_else",
"=",
"None",
",",
"*",
"*"... | provides a context manager that will intercept exceptions and repackage
them as Buzz instances with a message attached:
.. code-block:: python
with Buzz.handle_errors("It didn't work"):
some_code_that_might_raise_an_exception()
:param: message: The message to attach... | [
"provides",
"a",
"context",
"manager",
"that",
"will",
"intercept",
"exceptions",
"and",
"repackage",
"them",
"as",
"Buzz",
"instances",
"with",
"a",
"message",
"attached",
":"
] | train | https://github.com/dusktreader/py-buzz/blob/f2fd97abe158a1688188647992a5be6531058ec3/buzz/__init__.py#L75-L133 |
dusktreader/py-buzz | buzz/__init__.py | Buzz.require_condition | def require_condition(cls, expr, message, *format_args, **format_kwds):
"""
used to assert a certain state. If the expression renders a false
value, an exception will be raised with the supplied message
:param: message: The failure message to attach to the raised Buzz
:param... | python | def require_condition(cls, expr, message, *format_args, **format_kwds):
"""
used to assert a certain state. If the expression renders a false
value, an exception will be raised with the supplied message
:param: message: The failure message to attach to the raised Buzz
:param... | [
"def",
"require_condition",
"(",
"cls",
",",
"expr",
",",
"message",
",",
"*",
"format_args",
",",
"*",
"*",
"format_kwds",
")",
":",
"if",
"not",
"expr",
":",
"raise",
"cls",
"(",
"message",
",",
"*",
"format_args",
",",
"*",
"*",
"format_kwds",
")"
] | used to assert a certain state. If the expression renders a false
value, an exception will be raised with the supplied message
:param: message: The failure message to attach to the raised Buzz
:param: expr: A boolean value indicating an evaluated expression
:param: format_arg... | [
"used",
"to",
"assert",
"a",
"certain",
"state",
".",
"If",
"the",
"expression",
"renders",
"a",
"false",
"value",
"an",
"exception",
"will",
"be",
"raised",
"with",
"the",
"supplied",
"message"
] | train | https://github.com/dusktreader/py-buzz/blob/f2fd97abe158a1688188647992a5be6531058ec3/buzz/__init__.py#L136-L147 |
ozgurgunes/django-manifest | manifest/accounts/managers.py | AccountActivationManager.create_user | def create_user(self, username, email, password, active=False,
send_email=True):
"""
A simple wrapper that creates a new :class:`User`.
:param username:
String containing the username of the new user.
:param email:
String containing the email... | python | def create_user(self, username, email, password, active=False,
send_email=True):
"""
A simple wrapper that creates a new :class:`User`.
:param username:
String containing the username of the new user.
:param email:
String containing the email... | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"email",
",",
"password",
",",
"active",
"=",
"False",
",",
"send_email",
"=",
"True",
")",
":",
"user",
"=",
"super",
"(",
"AccountActivationManager",
",",
"self",
")",
".",
"create_user",
"(",
"u... | A simple wrapper that creates a new :class:`User`.
:param username:
String containing the username of the new user.
:param email:
String containing the email address of the new user.
:param password:
String containing the password for the new user.
... | [
"A",
"simple",
"wrapper",
"that",
"creates",
"a",
"new",
":",
"class",
":",
"User",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/managers.py#L23-L62 |
ozgurgunes/django-manifest | manifest/accounts/managers.py | AccountActivationManager.activate_user | def activate_user(self, username, activation_key):
"""
Activate an :class:`User` by supplying a valid ``activation_key``.
If the key is valid and an user is found, activates the user and
return it. Also sends the ``activation_complete`` signal.
:param activation_key:
... | python | def activate_user(self, username, activation_key):
"""
Activate an :class:`User` by supplying a valid ``activation_key``.
If the key is valid and an user is found, activates the user and
return it. Also sends the ``activation_complete`` signal.
:param activation_key:
... | [
"def",
"activate_user",
"(",
"self",
",",
"username",
",",
"activation_key",
")",
":",
"if",
"SHA1_RE",
".",
"search",
"(",
"activation_key",
")",
":",
"try",
":",
"user",
"=",
"self",
".",
"get",
"(",
"activation_key",
"=",
"activation_key",
")",
"except"... | Activate an :class:`User` by supplying a valid ``activation_key``.
If the key is valid and an user is found, activates the user and
return it. Also sends the ``activation_complete`` signal.
:param activation_key:
String containing the secret SHA1 for a valid activation.
:r... | [
"Activate",
"an",
":",
"class",
":",
"User",
"by",
"supplying",
"a",
"valid",
"activation_key",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/managers.py#L64-L91 |
ozgurgunes/django-manifest | manifest/accounts/managers.py | AccountActivationManager.delete_expired_users | def delete_expired_users(self):
"""
Checks for expired users and delete's the ``User`` associated with
it. Skips if the user ``is_staff``.
:return: A list containing the deleted users.
"""
deleted_users = []
for user in self.filter(is_staff=False, is_active=Fals... | python | def delete_expired_users(self):
"""
Checks for expired users and delete's the ``User`` associated with
it. Skips if the user ``is_staff``.
:return: A list containing the deleted users.
"""
deleted_users = []
for user in self.filter(is_staff=False, is_active=Fals... | [
"def",
"delete_expired_users",
"(",
"self",
")",
":",
"deleted_users",
"=",
"[",
"]",
"for",
"user",
"in",
"self",
".",
"filter",
"(",
"is_staff",
"=",
"False",
",",
"is_active",
"=",
"False",
")",
":",
"if",
"user",
".",
"activation_key_expired",
"(",
"... | Checks for expired users and delete's the ``User`` associated with
it. Skips if the user ``is_staff``.
:return: A list containing the deleted users. | [
"Checks",
"for",
"expired",
"users",
"and",
"delete",
"s",
"the",
"User",
"associated",
"with",
"it",
".",
"Skips",
"if",
"the",
"user",
"is_staff",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/managers.py#L93-L106 |
ozgurgunes/django-manifest | manifest/accounts/managers.py | EmailConfirmationManager.confirm_email | def confirm_email(self, username, confirmation_key):
"""
Confirm an email address by checking a ``confirmation_key``.
A valid ``confirmation_key`` will set the newly wanted email address
as the current email address. Returns the user after success or
``False`` when the confirmat... | python | def confirm_email(self, username, confirmation_key):
"""
Confirm an email address by checking a ``confirmation_key``.
A valid ``confirmation_key`` will set the newly wanted email address
as the current email address. Returns the user after success or
``False`` when the confirmat... | [
"def",
"confirm_email",
"(",
"self",
",",
"username",
",",
"confirmation_key",
")",
":",
"if",
"SHA1_RE",
".",
"search",
"(",
"confirmation_key",
")",
":",
"try",
":",
"user",
"=",
"self",
".",
"select_related",
"(",
")",
".",
"get",
"(",
"username",
"="... | Confirm an email address by checking a ``confirmation_key``.
A valid ``confirmation_key`` will set the newly wanted email address
as the current email address. Returns the user after success or
``False`` when the confirmation key is invalid.
:param confirmation_key:
String ... | [
"Confirm",
"an",
"email",
"address",
"by",
"checking",
"a",
"confirmation_key",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/managers.py#L113-L143 |
ozgurgunes/django-manifest | manifest/accounts/managers.py | UserProfileManager.get_visible_profiles | def get_visible_profiles(self, user=None):
"""
Returns all the visible profiles available to this user.
For now keeps it simple by just applying the cases when a user is not
active, a user has it's profile closed to everyone or a user only
allows registered users to view their p... | python | def get_visible_profiles(self, user=None):
"""
Returns all the visible profiles available to this user.
For now keeps it simple by just applying the cases when a user is not
active, a user has it's profile closed to everyone or a user only
allows registered users to view their p... | [
"def",
"get_visible_profiles",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"profiles",
"=",
"self",
".",
"select_related",
"(",
")",
".",
"all",
"(",
")",
"filter_kwargs",
"=",
"{",
"'is_active'",
":",
"True",
"}",
"profiles",
"=",
"profiles",
".",
... | Returns all the visible profiles available to this user.
For now keeps it simple by just applying the cases when a user is not
active, a user has it's profile closed to everyone or a user only
allows registered users to view their profile.
:param user:
A Django :class:`User... | [
"Returns",
"all",
"the",
"visible",
"profiles",
"available",
"to",
"this",
"user",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/managers.py#L151-L173 |
Nic30/sphinx-hwt | sphinx_hwt/sphinx_hwt.py | SchematicLink.visit_html | def visit_html(self, node):
"""
Generate html elements and schematic json
"""
parentClsNode = node.parent.parent
assert parentClsNode.attributes['objtype'] == 'class'
assert parentClsNode.attributes['domain'] == 'py'
sign = node.parent.parent.children[0]
a... | python | def visit_html(self, node):
"""
Generate html elements and schematic json
"""
parentClsNode = node.parent.parent
assert parentClsNode.attributes['objtype'] == 'class'
assert parentClsNode.attributes['domain'] == 'py'
sign = node.parent.parent.children[0]
a... | [
"def",
"visit_html",
"(",
"self",
",",
"node",
")",
":",
"parentClsNode",
"=",
"node",
".",
"parent",
".",
"parent",
"assert",
"parentClsNode",
".",
"attributes",
"[",
"'objtype'",
"]",
"==",
"'class'",
"assert",
"parentClsNode",
".",
"attributes",
"[",
"'do... | Generate html elements and schematic json | [
"Generate",
"html",
"elements",
"and",
"schematic",
"json"
] | train | https://github.com/Nic30/sphinx-hwt/blob/3aee09f467be74433ae2a6b2de55c6b90e5920ae/sphinx_hwt/sphinx_hwt.py#L94-L155 |
Nic30/sphinx-hwt | setup.py | build_npm.run | def run(self):
has_npm = npm_installation_check()
if has_npm:
run_npm_install()
else:
print("Warning: npm not installed using prebuilded js files!",
file=sys.stderr)
"""
Download npm packages required by package.json and extract required
... | python | def run(self):
has_npm = npm_installation_check()
if has_npm:
run_npm_install()
else:
print("Warning: npm not installed using prebuilded js files!",
file=sys.stderr)
"""
Download npm packages required by package.json and extract required
... | [
"def",
"run",
"(",
"self",
")",
":",
"has_npm",
"=",
"npm_installation_check",
"(",
")",
"if",
"has_npm",
":",
"run_npm_install",
"(",
")",
"else",
":",
"print",
"(",
"\"Warning: npm not installed using prebuilded js files!\"",
",",
"file",
"=",
"sys",
".",
"std... | Download npm packages required by package.json and extract required
files from them | [
"Download",
"npm",
"packages",
"required",
"by",
"package",
".",
"json",
"and",
"extract",
"required",
"files",
"from",
"them"
] | train | https://github.com/Nic30/sphinx-hwt/blob/3aee09f467be74433ae2a6b2de55c6b90e5920ae/setup.py#L81-L106 |
dfm/transit | transit/transit.py | Central.density | def density(self):
"""Stellar density in CGS units
"""
r = self.radius * _Rsun
m = self.mass * _Msun
return 0.75 * m / (np.pi * r * r * r) | python | def density(self):
"""Stellar density in CGS units
"""
r = self.radius * _Rsun
m = self.mass * _Msun
return 0.75 * m / (np.pi * r * r * r) | [
"def",
"density",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"radius",
"*",
"_Rsun",
"m",
"=",
"self",
".",
"mass",
"*",
"_Msun",
"return",
"0.75",
"*",
"m",
"/",
"(",
"np",
".",
"pi",
"*",
"r",
"*",
"r",
"*",
"r",
")"
] | Stellar density in CGS units | [
"Stellar",
"density",
"in",
"CGS",
"units"
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/transit.py#L101-L106 |
dfm/transit | transit/transit.py | Body.duration | def duration(self):
"""
The approximate duration of the transit :math:`T_\mathrm{tot}` from
Equation (14) in Winn (2010).
"""
self._check_ps()
rstar = self.system.central.radius
k = self.r/rstar
dur = self.period / np.pi
arg = rstar/self.a * np.s... | python | def duration(self):
"""
The approximate duration of the transit :math:`T_\mathrm{tot}` from
Equation (14) in Winn (2010).
"""
self._check_ps()
rstar = self.system.central.radius
k = self.r/rstar
dur = self.period / np.pi
arg = rstar/self.a * np.s... | [
"def",
"duration",
"(",
"self",
")",
":",
"self",
".",
"_check_ps",
"(",
")",
"rstar",
"=",
"self",
".",
"system",
".",
"central",
".",
"radius",
"k",
"=",
"self",
".",
"r",
"/",
"rstar",
"dur",
"=",
"self",
".",
"period",
"/",
"np",
".",
"pi",
... | The approximate duration of the transit :math:`T_\mathrm{tot}` from
Equation (14) in Winn (2010). | [
"The",
"approximate",
"duration",
"of",
"the",
"transit",
":",
"math",
":",
"T_",
"\\",
"mathrm",
"{",
"tot",
"}",
"from",
"Equation",
"(",
"14",
")",
"in",
"Winn",
"(",
"2010",
")",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/transit.py#L348-L364 |
dfm/transit | transit/transit.py | System.add_body | def add_body(self, body):
"""
Add a :class:`Body` to the system. This function also sets the
``system`` attribute of the body.
:param body:
The :class:`Body` to add.
"""
body.system = self
self.bodies.append(body)
self.unfrozen = np.concatena... | python | def add_body(self, body):
"""
Add a :class:`Body` to the system. This function also sets the
``system`` attribute of the body.
:param body:
The :class:`Body` to add.
"""
body.system = self
self.bodies.append(body)
self.unfrozen = np.concatena... | [
"def",
"add_body",
"(",
"self",
",",
"body",
")",
":",
"body",
".",
"system",
"=",
"self",
"self",
".",
"bodies",
".",
"append",
"(",
"body",
")",
"self",
".",
"unfrozen",
"=",
"np",
".",
"concatenate",
"(",
"(",
"self",
".",
"unfrozen",
"[",
":",
... | Add a :class:`Body` to the system. This function also sets the
``system`` attribute of the body.
:param body:
The :class:`Body` to add. | [
"Add",
"a",
":",
"class",
":",
"Body",
"to",
"the",
"system",
".",
"This",
"function",
"also",
"sets",
"the",
"system",
"attribute",
"of",
"the",
"body",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/transit.py#L410-L423 |
dfm/transit | transit/transit.py | System.light_curve | def light_curve(self, t, texp=0.0, tol=1e-8, maxdepth=4, use_batman=False):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping cr... | python | def light_curve(self, t, texp=0.0, tol=1e-8, maxdepth=4, use_batman=False):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping cr... | [
"def",
"light_curve",
"(",
"self",
",",
"t",
",",
"texp",
"=",
"0.0",
",",
"tol",
"=",
"1e-8",
",",
"maxdepth",
"=",
"4",
",",
"use_batman",
"=",
"False",
")",
":",
"t",
"=",
"np",
".",
"atleast_1d",
"(",
"t",
")",
"if",
"len",
"(",
"self",
"."... | Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the exposure time integration.
:param maxdepth:
The maximum rec... | [
"Get",
"the",
"light",
"curve",
"evaluated",
"at",
"a",
"list",
"of",
"times",
"using",
"the",
"current",
"model",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/transit.py#L428-L450 |
dfm/transit | transit/transit.py | System.light_curve_gradient | def light_curve_gradient(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion f... | python | def light_curve_gradient(self, t, texp=0.0, tol=1e-8, maxdepth=4):
"""
Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion f... | [
"def",
"light_curve_gradient",
"(",
"self",
",",
"t",
",",
"texp",
"=",
"0.0",
",",
"tol",
"=",
"1e-8",
",",
"maxdepth",
"=",
"4",
")",
":",
"t",
"=",
"np",
".",
"atleast_1d",
"(",
"t",
")",
"if",
"len",
"(",
"self",
".",
"bodies",
")",
"==",
"... | Get the light curve evaluated at a list of times using the current
model.
:param t:
The times where the light curve should be evaluated (in days).
:param tol:
The stopping criterion for the exposure time integration.
:param maxdepth:
The maximum rec... | [
"Get",
"the",
"light",
"curve",
"evaluated",
"at",
"a",
"list",
"of",
"times",
"using",
"the",
"current",
"model",
"."
] | train | https://github.com/dfm/transit/blob/482d99b506657fa3fd54a388f9c6be13b9e57bce/transit/transit.py#L452-L476 |
ARMmbed/autoversion | scripts/tag_and_release.py | main | def main():
"""Tags the current repository
and commits changes to news files
"""
# see:
# https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
twine_repo = os.getenv('TWINE_REPOSITORY_URL') or os.getenv('TWINE_REPOSITORY')
print('tagging and releasing... | python | def main():
"""Tags the current repository
and commits changes to news files
"""
# see:
# https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
twine_repo = os.getenv('TWINE_REPOSITORY_URL') or os.getenv('TWINE_REPOSITORY')
print('tagging and releasing... | [
"def",
"main",
"(",
")",
":",
"# see:",
"# https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi",
"twine_repo",
"=",
"os",
".",
"getenv",
"(",
"'TWINE_REPOSITORY_URL'",
")",
"or",
"os",
".",
"getenv",
"(",
"'TWINE_REPOSITORY'",
")",
... | Tags the current repository
and commits changes to news files | [
"Tags",
"the",
"current",
"repository"
] | train | https://github.com/ARMmbed/autoversion/blob/c5b127d2059c8219f5637fe45bf9e1be3a0af2aa/scripts/tag_and_release.py#L39-L86 |
pytroll/posttroll | posttroll/__init__.py | get_context | def get_context():
"""Provide the context to use.
This function takes care of creating new contexts in case of forks.
"""
pid = os.getpid()
if pid not in context:
context[pid] = zmq.Context()
logger.debug('renewed context for PID %d', pid)
return context[pid] | python | def get_context():
"""Provide the context to use.
This function takes care of creating new contexts in case of forks.
"""
pid = os.getpid()
if pid not in context:
context[pid] = zmq.Context()
logger.debug('renewed context for PID %d', pid)
return context[pid] | [
"def",
"get_context",
"(",
")",
":",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"if",
"pid",
"not",
"in",
"context",
":",
"context",
"[",
"pid",
"]",
"=",
"zmq",
".",
"Context",
"(",
")",
"logger",
".",
"debug",
"(",
"'renewed context for PID %d'",
"... | Provide the context to use.
This function takes care of creating new contexts in case of forks. | [
"Provide",
"the",
"context",
"to",
"use",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/__init__.py#L37-L46 |
pytroll/posttroll | posttroll/__init__.py | strp_isoformat | def strp_isoformat(strg):
"""Decode an ISO formatted string to a datetime object.
Allow a time-string without microseconds.
We handle input like: 2011-11-14T12:51:25.123456
"""
if isinstance(strg, datetime):
return strg
if len(strg) < 19 or len(strg) > 26:
if len(strg) > 30:
... | python | def strp_isoformat(strg):
"""Decode an ISO formatted string to a datetime object.
Allow a time-string without microseconds.
We handle input like: 2011-11-14T12:51:25.123456
"""
if isinstance(strg, datetime):
return strg
if len(strg) < 19 or len(strg) > 26:
if len(strg) > 30:
... | [
"def",
"strp_isoformat",
"(",
"strg",
")",
":",
"if",
"isinstance",
"(",
"strg",
",",
"datetime",
")",
":",
"return",
"strg",
"if",
"len",
"(",
"strg",
")",
"<",
"19",
"or",
"len",
"(",
"strg",
")",
">",
"26",
":",
"if",
"len",
"(",
"strg",
")",
... | Decode an ISO formatted string to a datetime object.
Allow a time-string without microseconds.
We handle input like: 2011-11-14T12:51:25.123456 | [
"Decode",
"an",
"ISO",
"formatted",
"string",
"to",
"a",
"datetime",
"object",
".",
"Allow",
"a",
"time",
"-",
"string",
"without",
"microseconds",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/__init__.py#L49-L69 |
Clinical-Genomics/trailblazer | trailblazer/cli/delete.py | delete | def delete(context, force, yes, analysis_id):
"""Delete an analysis log from the database."""
analysis_obj = context.obj['store'].analysis(analysis_id)
if analysis_obj is None:
print(click.style('analysis log not found', fg='red'))
context.abort()
print(click.style(f"{analysis_obj.famil... | python | def delete(context, force, yes, analysis_id):
"""Delete an analysis log from the database."""
analysis_obj = context.obj['store'].analysis(analysis_id)
if analysis_obj is None:
print(click.style('analysis log not found', fg='red'))
context.abort()
print(click.style(f"{analysis_obj.famil... | [
"def",
"delete",
"(",
"context",
",",
"force",
",",
"yes",
",",
"analysis_id",
")",
":",
"analysis_obj",
"=",
"context",
".",
"obj",
"[",
"'store'",
"]",
".",
"analysis",
"(",
"analysis_id",
")",
"if",
"analysis_obj",
"is",
"None",
":",
"print",
"(",
"... | Delete an analysis log from the database. | [
"Delete",
"an",
"analysis",
"log",
"from",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/cli/delete.py#L12-L46 |
thespacedoctor/sherlock | sherlock/imports/_base_importer.py | _base_importer.add_data_to_database_table | def add_data_to_database_table(
self,
dictList,
createStatement=False):
"""*Import data in the list of dictionaries in the requested database table*
Also adds HTMIDs and updates the sherlock-catalogue database helper table with the time-stamp of when the imported cat... | python | def add_data_to_database_table(
self,
dictList,
createStatement=False):
"""*Import data in the list of dictionaries in the requested database table*
Also adds HTMIDs and updates the sherlock-catalogue database helper table with the time-stamp of when the imported cat... | [
"def",
"add_data_to_database_table",
"(",
"self",
",",
"dictList",
",",
"createStatement",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``add_data_to_database_table`` method'",
")",
"if",
"len",
"(",
"dictList",
")",
"==",
"0",
"... | *Import data in the list of dictionaries in the requested database table*
Also adds HTMIDs and updates the sherlock-catalogue database helper table with the time-stamp of when the imported catlogue was last updated
**Key Arguments:**
- ``dictList`` - a list of dictionaries containing all t... | [
"*",
"Import",
"data",
"in",
"the",
"list",
"of",
"dictionaries",
"in",
"the",
"requested",
"database",
"table",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/_base_importer.py#L135-L211 |
thespacedoctor/sherlock | sherlock/imports/_base_importer.py | _base_importer._add_htmids_to_database_table | def _add_htmids_to_database_table(
self):
"""*Add HTMIDs to database table once all the data has been imported (HTM Levels 10,13,16)*
**Usage:**
.. code-block:: python
self._add_htmids_to_database_table()
"""
self.log.debug('starting the ``add_... | python | def _add_htmids_to_database_table(
self):
"""*Add HTMIDs to database table once all the data has been imported (HTM Levels 10,13,16)*
**Usage:**
.. code-block:: python
self._add_htmids_to_database_table()
"""
self.log.debug('starting the ``add_... | [
"def",
"_add_htmids_to_database_table",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``add_htmids_to_database_table`` method'",
")",
"tableName",
"=",
"self",
".",
"dbTableName",
"self",
".",
"log",
".",
"info",
"(",
"\"Adding HTMIds ... | *Add HTMIDs to database table once all the data has been imported (HTM Levels 10,13,16)*
**Usage:**
.. code-block:: python
self._add_htmids_to_database_table() | [
"*",
"Add",
"HTMIDs",
"to",
"database",
"table",
"once",
"all",
"the",
"data",
"has",
"been",
"imported",
"(",
"HTM",
"Levels",
"10",
"13",
"16",
")",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/_base_importer.py#L213-L239 |
thespacedoctor/sherlock | sherlock/imports/_base_importer.py | _base_importer._update_database_helper_table | def _update_database_helper_table(
self):
"""*Update the sherlock catalogues database helper table with the time-stamp of when this catlogue was last updated*
**Usage:**
.. code-block:: python
self._update_database_helper_table()
"""
self.log.d... | python | def _update_database_helper_table(
self):
"""*Update the sherlock catalogues database helper table with the time-stamp of when this catlogue was last updated*
**Usage:**
.. code-block:: python
self._update_database_helper_table()
"""
self.log.d... | [
"def",
"_update_database_helper_table",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_update_database_helper_table`` method'",
")",
"tableName",
"=",
"self",
".",
"dbTableName",
"sqlQuery",
"=",
"u\"\"\"\n update tcs_helper_catal... | *Update the sherlock catalogues database helper table with the time-stamp of when this catlogue was last updated*
**Usage:**
.. code-block:: python
self._update_database_helper_table() | [
"*",
"Update",
"the",
"sherlock",
"catalogues",
"database",
"helper",
"table",
"with",
"the",
"time",
"-",
"stamp",
"of",
"when",
"this",
"catlogue",
"was",
"last",
"updated",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/_base_importer.py#L241-L267 |
contentful-labs/contentful.py | contentful/cda/resources.py | Array.resolve_links | def resolve_links(self):
"""Attempt to resolve all internal links (locally).
In case the linked resources are found either as members of the array or within
the `includes` element, those will be replaced and reference the actual resources.
No network calls will be performed.
... | python | def resolve_links(self):
"""Attempt to resolve all internal links (locally).
In case the linked resources are found either as members of the array or within
the `includes` element, those will be replaced and reference the actual resources.
No network calls will be performed.
... | [
"def",
"resolve_links",
"(",
"self",
")",
":",
"for",
"resource",
"in",
"self",
".",
"items_mapped",
"[",
"'Entry'",
"]",
".",
"values",
"(",
")",
":",
"for",
"dct",
"in",
"[",
"getattr",
"(",
"resource",
",",
"'_cf_cda'",
",",
"{",
"}",
")",
",",
... | Attempt to resolve all internal links (locally).
In case the linked resources are found either as members of the array or within
the `includes` element, those will be replaced and reference the actual resources.
No network calls will be performed. | [
"Attempt",
"to",
"resolve",
"all",
"internal",
"links",
"(",
"locally",
")",
"."
] | train | https://github.com/contentful-labs/contentful.py/blob/d9eb4a68abcad33e4766e2be8c7b35e605210b5a/contentful/cda/resources.py#L90-L111 |
ozgurgunes/django-manifest | manifest/accounts/backends.py | AuthenticationBackend.authenticate | def authenticate(self, request, identification, password=None,
check_password=True):
"""
Authenticates a user through the combination email/username with
password.
:param identification:
A string containing the username or email of the user that is
... | python | def authenticate(self, request, identification, password=None,
check_password=True):
"""
Authenticates a user through the combination email/username with
password.
:param identification:
A string containing the username or email of the user that is
... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
",",
"identification",
",",
"password",
"=",
"None",
",",
"check_password",
"=",
"True",
")",
":",
"UserModel",
"=",
"get_user_model",
"(",
")",
"try",
":",
"validators",
".",
"validate_email",
"(",
"identi... | Authenticates a user through the combination email/username with
password.
:param identification:
A string containing the username or email of the user that is
trying to authenticate.
:password:
Optional string containing the password for the user.
... | [
"Authenticates",
"a",
"user",
"through",
"the",
"combination",
"email",
"/",
"username",
"with",
"password",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/backends.py#L16-L55 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.find_analysis | def find_analysis(self, family, started_at, status):
"""Find a single analysis."""
query = self.Analysis.query.filter_by(
family=family,
started_at=started_at,
status=status,
)
return query.first() | python | def find_analysis(self, family, started_at, status):
"""Find a single analysis."""
query = self.Analysis.query.filter_by(
family=family,
started_at=started_at,
status=status,
)
return query.first() | [
"def",
"find_analysis",
"(",
"self",
",",
"family",
",",
"started_at",
",",
"status",
")",
":",
"query",
"=",
"self",
".",
"Analysis",
".",
"query",
".",
"filter_by",
"(",
"family",
"=",
"family",
",",
"started_at",
"=",
"started_at",
",",
"status",
"=",... | Find a single analysis. | [
"Find",
"a",
"single",
"analysis",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L26-L33 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.analyses | def analyses(self, *, family: str=None, query: str=None, status: str=None, deleted: bool=None,
temp: bool=False, before: dt.datetime=None, is_visible: bool=None):
"""Fetch analyses form the database."""
analysis_query = self.Analysis.query
if family:
analysis_query =... | python | def analyses(self, *, family: str=None, query: str=None, status: str=None, deleted: bool=None,
temp: bool=False, before: dt.datetime=None, is_visible: bool=None):
"""Fetch analyses form the database."""
analysis_query = self.Analysis.query
if family:
analysis_query =... | [
"def",
"analyses",
"(",
"self",
",",
"*",
",",
"family",
":",
"str",
"=",
"None",
",",
"query",
":",
"str",
"=",
"None",
",",
"status",
":",
"str",
"=",
"None",
",",
"deleted",
":",
"bool",
"=",
"None",
",",
"temp",
":",
"bool",
"=",
"False",
"... | Fetch analyses form the database. | [
"Fetch",
"analyses",
"form",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L35-L56 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.analysis | def analysis(self, analysis_id: int) -> models.Analysis:
"""Get a single analysis."""
return self.Analysis.query.get(analysis_id) | python | def analysis(self, analysis_id: int) -> models.Analysis:
"""Get a single analysis."""
return self.Analysis.query.get(analysis_id) | [
"def",
"analysis",
"(",
"self",
",",
"analysis_id",
":",
"int",
")",
"->",
"models",
".",
"Analysis",
":",
"return",
"self",
".",
"Analysis",
".",
"query",
".",
"get",
"(",
"analysis_id",
")"
] | Get a single analysis. | [
"Get",
"a",
"single",
"analysis",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L58-L60 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.track_update | def track_update(self):
"""Update the lastest updated date in the database."""
metadata = self.info()
metadata.updated_at = dt.datetime.now()
self.commit() | python | def track_update(self):
"""Update the lastest updated date in the database."""
metadata = self.info()
metadata.updated_at = dt.datetime.now()
self.commit() | [
"def",
"track_update",
"(",
"self",
")",
":",
"metadata",
"=",
"self",
".",
"info",
"(",
")",
"metadata",
".",
"updated_at",
"=",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
"self",
".",
"commit",
"(",
")"
] | Update the lastest updated date in the database. | [
"Update",
"the",
"lastest",
"updated",
"date",
"in",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L62-L66 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.is_running | def is_running(self, family: str) -> bool:
"""Check if an analysis is currently running/pending for a family."""
latest_analysis = self.analyses(family=family).first()
return latest_analysis and latest_analysis.status in TEMP_STATUSES | python | def is_running(self, family: str) -> bool:
"""Check if an analysis is currently running/pending for a family."""
latest_analysis = self.analyses(family=family).first()
return latest_analysis and latest_analysis.status in TEMP_STATUSES | [
"def",
"is_running",
"(",
"self",
",",
"family",
":",
"str",
")",
"->",
"bool",
":",
"latest_analysis",
"=",
"self",
".",
"analyses",
"(",
"family",
"=",
"family",
")",
".",
"first",
"(",
")",
"return",
"latest_analysis",
"and",
"latest_analysis",
".",
"... | Check if an analysis is currently running/pending for a family. | [
"Check",
"if",
"an",
"analysis",
"is",
"currently",
"running",
"/",
"pending",
"for",
"a",
"family",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L68-L71 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.add_pending | def add_pending(self, family: str, email: str=None) -> models.Analysis:
"""Add pending entry for an analysis."""
started_at = dt.datetime.now()
new_log = self.Analysis(family=family, status='pending', started_at=started_at)
new_log.user = self.user(email) if email else None
self.... | python | def add_pending(self, family: str, email: str=None) -> models.Analysis:
"""Add pending entry for an analysis."""
started_at = dt.datetime.now()
new_log = self.Analysis(family=family, status='pending', started_at=started_at)
new_log.user = self.user(email) if email else None
self.... | [
"def",
"add_pending",
"(",
"self",
",",
"family",
":",
"str",
",",
"email",
":",
"str",
"=",
"None",
")",
"->",
"models",
".",
"Analysis",
":",
"started_at",
"=",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
"new_log",
"=",
"self",
".",
"Analysis",
... | Add pending entry for an analysis. | [
"Add",
"pending",
"entry",
"for",
"an",
"analysis",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L77-L83 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.add_user | def add_user(self, name: str, email: str) -> models.User:
"""Add a new user to the database."""
new_user = self.User(name=name, email=email)
self.add_commit(new_user)
return new_user | python | def add_user(self, name: str, email: str) -> models.User:
"""Add a new user to the database."""
new_user = self.User(name=name, email=email)
self.add_commit(new_user)
return new_user | [
"def",
"add_user",
"(",
"self",
",",
"name",
":",
"str",
",",
"email",
":",
"str",
")",
"->",
"models",
".",
"User",
":",
"new_user",
"=",
"self",
".",
"User",
"(",
"name",
"=",
"name",
",",
"email",
"=",
"email",
")",
"self",
".",
"add_commit",
... | Add a new user to the database. | [
"Add",
"a",
"new",
"user",
"to",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L85-L89 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.user | def user(self, email: str) -> models.User:
"""Fetch a user from the database."""
return self.User.query.filter_by(email=email).first() | python | def user(self, email: str) -> models.User:
"""Fetch a user from the database."""
return self.User.query.filter_by(email=email).first() | [
"def",
"user",
"(",
"self",
",",
"email",
":",
"str",
")",
"->",
"models",
".",
"User",
":",
"return",
"self",
".",
"User",
".",
"query",
".",
"filter_by",
"(",
"email",
"=",
"email",
")",
".",
"first",
"(",
")"
] | Fetch a user from the database. | [
"Fetch",
"a",
"user",
"from",
"the",
"database",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L91-L93 |
Clinical-Genomics/trailblazer | trailblazer/store/api.py | BaseHandler.aggregate_failed | def aggregate_failed(self) -> List:
"""Count the number of failed jobs per category (name)."""
categories = self.session.query(
self.Job.name.label('name'),
sqa.func.count(self.Job.id).label('count')
).filter(self.Job.status != 'cancelled').group_by(self.Job.name).all()
... | python | def aggregate_failed(self) -> List:
"""Count the number of failed jobs per category (name)."""
categories = self.session.query(
self.Job.name.label('name'),
sqa.func.count(self.Job.id).label('count')
).filter(self.Job.status != 'cancelled').group_by(self.Job.name).all()
... | [
"def",
"aggregate_failed",
"(",
"self",
")",
"->",
"List",
":",
"categories",
"=",
"self",
".",
"session",
".",
"query",
"(",
"self",
".",
"Job",
".",
"name",
".",
"label",
"(",
"'name'",
")",
",",
"sqa",
".",
"func",
".",
"count",
"(",
"self",
"."... | Count the number of failed jobs per category (name). | [
"Count",
"the",
"number",
"of",
"failed",
"jobs",
"per",
"category",
"(",
"name",
")",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/store/api.py#L95-L102 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned.ingest | def ingest(self):
"""*Perform conesearches of the online NED database and import the results into a the sherlock-database*
The code:
1. uses the list of transient coordinates and queries NED for the results within the given search radius
2. Creates the `tcs_cat_ned_stream` tabl... | python | def ingest(self):
"""*Perform conesearches of the online NED database and import the results into a the sherlock-database*
The code:
1. uses the list of transient coordinates and queries NED for the results within the given search radius
2. Creates the `tcs_cat_ned_stream` tabl... | [
"def",
"ingest",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``ingest`` method'",
")",
"if",
"not",
"self",
".",
"radiusArcsec",
":",
"self",
".",
"log",
".",
"error",
"(",
"'please give a radius in arcsec with which to preform the... | *Perform conesearches of the online NED database and import the results into a the sherlock-database*
The code:
1. uses the list of transient coordinates and queries NED for the results within the given search radius
2. Creates the `tcs_cat_ned_stream` table if it doesn't exist
... | [
"*",
"Perform",
"conesearches",
"of",
"the",
"online",
"NED",
"database",
"and",
"import",
"the",
"results",
"into",
"a",
"the",
"sherlock",
"-",
"database",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L79-L167 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._create_dictionary_of_ned | def _create_dictionary_of_ned(
self):
"""*Create a list of dictionaries containing all the object ids (NED names) in the ned stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the object ids (NED names) in the ned stream
**Usage:**
.... | python | def _create_dictionary_of_ned(
self):
"""*Create a list of dictionaries containing all the object ids (NED names) in the ned stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the object ids (NED names) in the ned stream
**Usage:**
.... | [
"def",
"_create_dictionary_of_ned",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_create_dictionary_of_ned`` method'",
")",
"# GET THE NAMES (UNIQUE IDS) OF THE SOURCES WITHIN THE CONESEARCH FROM",
"# NED",
"names",
",",
"searchParams",
"=",
... | *Create a list of dictionaries containing all the object ids (NED names) in the ned stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the object ids (NED names) in the ned stream
**Usage:**
.. code-block:: python
dictList = stream._cre... | [
"*",
"Create",
"a",
"list",
"of",
"dictionaries",
"containing",
"all",
"the",
"object",
"ids",
"(",
"NED",
"names",
")",
"in",
"the",
"ned",
"stream",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L169-L203 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._update_ned_query_history | def _update_ned_query_history(
self):
"""*Update the database helper table to give details of the ned cone searches performed*
*Usage:*
.. code-block:: python
stream._update_ned_query_history()
"""
self.log.debug('starting the ``_update_ned_quer... | python | def _update_ned_query_history(
self):
"""*Update the database helper table to give details of the ned cone searches performed*
*Usage:*
.. code-block:: python
stream._update_ned_query_history()
"""
self.log.debug('starting the ``_update_ned_quer... | [
"def",
"_update_ned_query_history",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_update_ned_query_history`` method'",
")",
"myPid",
"=",
"self",
".",
"myPid",
"# ASTROCALC UNIT CONVERTER OBJECT",
"converter",
"=",
"unit_conversion",
"(... | *Update the database helper table to give details of the ned cone searches performed*
*Usage:*
.. code-block:: python
stream._update_ned_query_history() | [
"*",
"Update",
"the",
"database",
"helper",
"table",
"to",
"give",
"details",
"of",
"the",
"ned",
"cone",
"searches",
"performed",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L205-L296 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._download_ned_source_metadata | def _download_ned_source_metadata(
self):
"""*Query NED using the names of the NED sources in our local database to retrieve extra metadata*
*Usage:*
.. code-block:: python
stream._download_ned_source_metadata()
"""
self.log.debug('starting the ... | python | def _download_ned_source_metadata(
self):
"""*Query NED using the names of the NED sources in our local database to retrieve extra metadata*
*Usage:*
.. code-block:: python
stream._download_ned_source_metadata()
"""
self.log.debug('starting the ... | [
"def",
"_download_ned_source_metadata",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_download_ned_source_metadata`` method'",
")",
"self",
".",
"dbTableName",
"=",
"\"tcs_cat_ned_stream\"",
"total",
",",
"batches",
"=",
"self",
".",
... | *Query NED using the names of the NED sources in our local database to retrieve extra metadata*
*Usage:*
.. code-block:: python
stream._download_ned_source_metadata() | [
"*",
"Query",
"NED",
"using",
"the",
"names",
"of",
"the",
"NED",
"sources",
"in",
"our",
"local",
"database",
"to",
"retrieve",
"extra",
"metadata",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L298-L332 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._get_ned_sources_needing_metadata | def _get_ned_sources_needing_metadata(
self):
"""*Get the names of 50000 or less NED sources that still require metabase in the database*
**Return:**
- ``len(self.theseIds)`` -- the number of NED IDs returned
*Usage:*
.. code-block:: python
... | python | def _get_ned_sources_needing_metadata(
self):
"""*Get the names of 50000 or less NED sources that still require metabase in the database*
**Return:**
- ``len(self.theseIds)`` -- the number of NED IDs returned
*Usage:*
.. code-block:: python
... | [
"def",
"_get_ned_sources_needing_metadata",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_get_ned_sources_needing_metadata`` method'",
")",
"tableName",
"=",
"self",
".",
"dbTableName",
"# SELECT THE DATA FROM NED TABLE",
"sqlQuery",
"=",
... | *Get the names of 50000 or less NED sources that still require metabase in the database*
**Return:**
- ``len(self.theseIds)`` -- the number of NED IDs returned
*Usage:*
.. code-block:: python
numberSources = stream._get_ned_sources_needing_metadata() | [
"*",
"Get",
"the",
"names",
"of",
"50000",
"or",
"less",
"NED",
"sources",
"that",
"still",
"require",
"metabase",
"in",
"the",
"database",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L334-L369 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._do_ned_namesearch_queries_and_add_resulting_metadata_to_database | def _do_ned_namesearch_queries_and_add_resulting_metadata_to_database(
self,
batchCount):
"""*Query NED via name searcha and add result metadata to database*
**Key Arguments:**
- ``batchCount`` - the index number of the batch sent to NED (only needed for printing to ... | python | def _do_ned_namesearch_queries_and_add_resulting_metadata_to_database(
self,
batchCount):
"""*Query NED via name searcha and add result metadata to database*
**Key Arguments:**
- ``batchCount`` - the index number of the batch sent to NED (only needed for printing to ... | [
"def",
"_do_ned_namesearch_queries_and_add_resulting_metadata_to_database",
"(",
"self",
",",
"batchCount",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_do_ned_namesearch_queries_and_add_resulting_metadata_to_database`` method'",
")",
"# ASTROCALC UNIT CONVERTER... | *Query NED via name searcha and add result metadata to database*
**Key Arguments:**
- ``batchCount`` - the index number of the batch sent to NED (only needed for printing to STDOUT to give user idea of progress)
*Usage:*
.. code-block:: python
numberSources = ... | [
"*",
"Query",
"NED",
"via",
"name",
"searcha",
"and",
"add",
"result",
"metadata",
"to",
"database",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L371-L478 |
thespacedoctor/sherlock | sherlock/imports/ned.py | ned._count_ned_sources_in_database_requiring_metadata | def _count_ned_sources_in_database_requiring_metadata(
self):
"""*Count the sources in the NED table requiring metadata*
**Return:**
- ``self.total``, ``self.batches`` -- total number of galaxies needing metadata & the number of batches required to be sent to NED
*Usage... | python | def _count_ned_sources_in_database_requiring_metadata(
self):
"""*Count the sources in the NED table requiring metadata*
**Return:**
- ``self.total``, ``self.batches`` -- total number of galaxies needing metadata & the number of batches required to be sent to NED
*Usage... | [
"def",
"_count_ned_sources_in_database_requiring_metadata",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_count_ned_sources_in_database_requiring_metadata`` method'",
")",
"tableName",
"=",
"self",
".",
"dbTableName",
"sqlQuery",
"=",
"u\"\... | *Count the sources in the NED table requiring metadata*
**Return:**
- ``self.total``, ``self.batches`` -- total number of galaxies needing metadata & the number of batches required to be sent to NED
*Usage:*
.. code-block:: python
totalRemaining, numberOfBatch... | [
"*",
"Count",
"the",
"sources",
"in",
"the",
"NED",
"table",
"requiring",
"metadata",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ned.py#L480-L515 |
pytroll/posttroll | posttroll/address_receiver.py | AddressReceiver.start | def start(self):
"""Start the receiver.
"""
if not self._is_running:
self._do_run = True
self._thread.start()
return self | python | def start(self):
"""Start the receiver.
"""
if not self._is_running:
self._do_run = True
self._thread.start()
return self | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_is_running",
":",
"self",
".",
"_do_run",
"=",
"True",
"self",
".",
"_thread",
".",
"start",
"(",
")",
"return",
"self"
] | Start the receiver. | [
"Start",
"the",
"receiver",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/address_receiver.py#L80-L86 |
pytroll/posttroll | posttroll/address_receiver.py | AddressReceiver.get | def get(self, name=""):
"""Get the address(es).
"""
addrs = []
with self._address_lock:
for metadata in self._addresses.values():
if (name == "" or
(name and name in metadata["service"])):
mda = copy.copy(metadata)
... | python | def get(self, name=""):
"""Get the address(es).
"""
addrs = []
with self._address_lock:
for metadata in self._addresses.values():
if (name == "" or
(name and name in metadata["service"])):
mda = copy.copy(metadata)
... | [
"def",
"get",
"(",
"self",
",",
"name",
"=",
"\"\"",
")",
":",
"addrs",
"=",
"[",
"]",
"with",
"self",
".",
"_address_lock",
":",
"for",
"metadata",
"in",
"self",
".",
"_addresses",
".",
"values",
"(",
")",
":",
"if",
"(",
"name",
"==",
"\"\"",
"... | Get the address(es). | [
"Get",
"the",
"address",
"(",
"es",
")",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/address_receiver.py#L99-L112 |
pytroll/posttroll | posttroll/address_receiver.py | AddressReceiver._check_age | def _check_age(self, pub, min_interval=timedelta(seconds=0)):
"""Check the age of the receiver.
"""
now = datetime.utcnow()
if (now - self._last_age_check) <= min_interval:
return
LOGGER.debug("%s - checking addresses", str(datetime.utcnow()))
self._last_age_... | python | def _check_age(self, pub, min_interval=timedelta(seconds=0)):
"""Check the age of the receiver.
"""
now = datetime.utcnow()
if (now - self._last_age_check) <= min_interval:
return
LOGGER.debug("%s - checking addresses", str(datetime.utcnow()))
self._last_age_... | [
"def",
"_check_age",
"(",
"self",
",",
"pub",
",",
"min_interval",
"=",
"timedelta",
"(",
"seconds",
"=",
"0",
")",
")",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"if",
"(",
"now",
"-",
"self",
".",
"_last_age_check",
")",
"<=",
"min_inte... | Check the age of the receiver. | [
"Check",
"the",
"age",
"of",
"the",
"receiver",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/address_receiver.py#L114-L136 |
pytroll/posttroll | posttroll/address_receiver.py | AddressReceiver._run | def _run(self):
"""Run the receiver.
"""
port = broadcast_port
nameservers = []
if self._multicast_enabled:
recv = MulticastReceiver(port).settimeout(2.)
while True:
try:
recv = MulticastReceiver(port).settimeout(2.)
... | python | def _run(self):
"""Run the receiver.
"""
port = broadcast_port
nameservers = []
if self._multicast_enabled:
recv = MulticastReceiver(port).settimeout(2.)
while True:
try:
recv = MulticastReceiver(port).settimeout(2.)
... | [
"def",
"_run",
"(",
"self",
")",
":",
"port",
"=",
"broadcast_port",
"nameservers",
"=",
"[",
"]",
"if",
"self",
".",
"_multicast_enabled",
":",
"recv",
"=",
"MulticastReceiver",
"(",
"port",
")",
".",
"settimeout",
"(",
"2.",
")",
"while",
"True",
":",
... | Run the receiver. | [
"Run",
"the",
"receiver",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/address_receiver.py#L138-L198 |
pytroll/posttroll | posttroll/address_receiver.py | AddressReceiver._add | def _add(self, adr, metadata):
"""Add an address.
"""
with self._address_lock:
metadata["receive_time"] = datetime.utcnow()
self._addresses[adr] = metadata | python | def _add(self, adr, metadata):
"""Add an address.
"""
with self._address_lock:
metadata["receive_time"] = datetime.utcnow()
self._addresses[adr] = metadata | [
"def",
"_add",
"(",
"self",
",",
"adr",
",",
"metadata",
")",
":",
"with",
"self",
".",
"_address_lock",
":",
"metadata",
"[",
"\"receive_time\"",
"]",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"self",
".",
"_addresses",
"[",
"adr",
"]",
"=",
"metadata... | Add an address. | [
"Add",
"an",
"address",
"."
] | train | https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/address_receiver.py#L200-L205 |
thespacedoctor/sherlock | sherlock/imports/ifs.py | ifs.ingest | def ingest(self):
"""*Import the IFS catalogue into the sherlock-catalogues database*
The method first generates a list of python dictionaries from the IFS datafile, imports this list of dictionaries into a database table and then generates the HTMIDs for that table.
**Usage:**
S... | python | def ingest(self):
"""*Import the IFS catalogue into the sherlock-catalogues database*
The method first generates a list of python dictionaries from the IFS datafile, imports this list of dictionaries into a database table and then generates the HTMIDs for that table.
**Usage:**
S... | [
"def",
"ingest",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``get`` method'",
")",
"self",
".",
"primaryIdColumnName",
"=",
"\"primaryId\"",
"self",
".",
"raColName",
"=",
"\"raDeg\"",
"self",
".",
"declColName",
"=",
"\"decDe... | *Import the IFS catalogue into the sherlock-catalogues database*
The method first generates a list of python dictionaries from the IFS datafile, imports this list of dictionaries into a database table and then generates the HTMIDs for that table.
**Usage:**
See class docstring for usage | [
"*",
"Import",
"the",
"IFS",
"catalogue",
"into",
"the",
"sherlock",
"-",
"catalogues",
"database",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ifs.py#L58-L105 |
thespacedoctor/sherlock | sherlock/imports/ifs.py | ifs._create_dictionary_of_IFS | def _create_dictionary_of_IFS(
self):
"""*Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
... | python | def _create_dictionary_of_IFS(
self):
"""*Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
... | [
"def",
"_create_dictionary_of_IFS",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_create_dictionary_of_IFS`` method'",
")",
"# GRAB THE CONTENT OF THE IFS CSV",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"... | *Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stre... | [
"*",
"Generate",
"the",
"list",
"of",
"dictionaries",
"containing",
"all",
"the",
"rows",
"in",
"the",
"IFS",
"stream",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ifs.py#L107-L181 |
phoemur/wgetter | wgetter.py | approximate_size | def approximate_size(size, a_kilobyte_is_1024_bytes=True):
'''
Humansize.py from Dive into Python3
Mark Pilgrim - http://www.diveintopython3.net/
Copyright (c) 2009, Mark Pilgrim, All rights reserved.
Convert a file size to human-readable form.
Keyword arguments:
size -- file size in bytes
... | python | def approximate_size(size, a_kilobyte_is_1024_bytes=True):
'''
Humansize.py from Dive into Python3
Mark Pilgrim - http://www.diveintopython3.net/
Copyright (c) 2009, Mark Pilgrim, All rights reserved.
Convert a file size to human-readable form.
Keyword arguments:
size -- file size in bytes
... | [
"def",
"approximate_size",
"(",
"size",
",",
"a_kilobyte_is_1024_bytes",
"=",
"True",
")",
":",
"size",
"=",
"float",
"(",
"size",
")",
"if",
"size",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'number must be non-negative'",
")",
"multiple",
"=",
"1024",
"i... | Humansize.py from Dive into Python3
Mark Pilgrim - http://www.diveintopython3.net/
Copyright (c) 2009, Mark Pilgrim, All rights reserved.
Convert a file size to human-readable form.
Keyword arguments:
size -- file size in bytes
a_kilobyte_is_1024_bytes -- if True (default), use multiples of 102... | [
"Humansize",
".",
"py",
"from",
"Dive",
"into",
"Python3",
"Mark",
"Pilgrim",
"-",
"http",
":",
"//",
"www",
".",
"diveintopython3",
".",
"net",
"/",
"Copyright",
"(",
"c",
")",
"2009",
"Mark",
"Pilgrim",
"All",
"rights",
"reserved",
"."
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L41-L66 |
phoemur/wgetter | wgetter.py | get_console_width | def get_console_width():
"""Return width of available window area. Autodetection works for
Windows and POSIX platforms. Returns 80 for others
Code from http://bitbucket.org/techtonik/python-pager
"""
if os.name == 'nt':
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
S... | python | def get_console_width():
"""Return width of available window area. Autodetection works for
Windows and POSIX platforms. Returns 80 for others
Code from http://bitbucket.org/techtonik/python-pager
"""
if os.name == 'nt':
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
S... | [
"def",
"get_console_width",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"STD_INPUT_HANDLE",
"=",
"-",
"10",
"STD_OUTPUT_HANDLE",
"=",
"-",
"11",
"STD_ERROR_HANDLE",
"=",
"-",
"12",
"# get console handle",
"from",
"ctypes",
"import",
"windll",
... | Return width of available window area. Autodetection works for
Windows and POSIX platforms. Returns 80 for others
Code from http://bitbucket.org/techtonik/python-pager | [
"Return",
"width",
"of",
"available",
"window",
"area",
".",
"Autodetection",
"works",
"for",
"Windows",
"and",
"POSIX",
"platforms",
".",
"Returns",
"80",
"for",
"others"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L69-L125 |
phoemur/wgetter | wgetter.py | filename_from_url | def filename_from_url(url):
""":return: detected filename or None"""
fname = os.path.basename(urlparse.urlparse(url).path)
if len(fname.strip(" \n\t.")) == 0:
return None
return fname | python | def filename_from_url(url):
""":return: detected filename or None"""
fname = os.path.basename(urlparse.urlparse(url).path)
if len(fname.strip(" \n\t.")) == 0:
return None
return fname | [
"def",
"filename_from_url",
"(",
"url",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"urlparse",
".",
"urlparse",
"(",
"url",
")",
".",
"path",
")",
"if",
"len",
"(",
"fname",
".",
"strip",
"(",
"\" \\n\\t.\"",
")",
")",
"==",
"... | :return: detected filename or None | [
":",
"return",
":",
"detected",
"filename",
"or",
"None"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L133-L138 |
phoemur/wgetter | wgetter.py | filename_from_headers | def filename_from_headers(headers):
"""Detect filename from Content-Disposition headers if present.
http://greenbytes.de/tech/tc2231/
:param: headers as dict, list or string
:return: filename from content-disposition header or None
"""
if type(headers) == str:
headers = headers.splitlin... | python | def filename_from_headers(headers):
"""Detect filename from Content-Disposition headers if present.
http://greenbytes.de/tech/tc2231/
:param: headers as dict, list or string
:return: filename from content-disposition header or None
"""
if type(headers) == str:
headers = headers.splitlin... | [
"def",
"filename_from_headers",
"(",
"headers",
")",
":",
"if",
"type",
"(",
"headers",
")",
"==",
"str",
":",
"headers",
"=",
"headers",
".",
"splitlines",
"(",
")",
"if",
"type",
"(",
"headers",
")",
"==",
"list",
":",
"headers",
"=",
"dict",
"(",
... | Detect filename from Content-Disposition headers if present.
http://greenbytes.de/tech/tc2231/
:param: headers as dict, list or string
:return: filename from content-disposition header or None | [
"Detect",
"filename",
"from",
"Content",
"-",
"Disposition",
"headers",
"if",
"present",
".",
"http",
":",
"//",
"greenbytes",
".",
"de",
"/",
"tech",
"/",
"tc2231",
"/"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L141-L168 |
phoemur/wgetter | wgetter.py | filename_fix_existing | def filename_fix_existing(filename, dirname):
"""Expands name portion of filename with numeric ' (x)' suffix to
return filename that doesn't exist already.
"""
name, ext = filename.rsplit('.', 1)
names = [x for x in os.listdir(dirname) if x.startswith(name)]
names = [x.rsplit('.', 1)[0] for x in... | python | def filename_fix_existing(filename, dirname):
"""Expands name portion of filename with numeric ' (x)' suffix to
return filename that doesn't exist already.
"""
name, ext = filename.rsplit('.', 1)
names = [x for x in os.listdir(dirname) if x.startswith(name)]
names = [x.rsplit('.', 1)[0] for x in... | [
"def",
"filename_fix_existing",
"(",
"filename",
",",
"dirname",
")",
":",
"name",
",",
"ext",
"=",
"filename",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"names",
"=",
"[",
"x",
"for",
"x",
"in",
"os",
".",
"listdir",
"(",
"dirname",
")",
"if",
"x"... | Expands name portion of filename with numeric ' (x)' suffix to
return filename that doesn't exist already. | [
"Expands",
"name",
"portion",
"of",
"filename",
"with",
"numeric",
"(",
"x",
")",
"suffix",
"to",
"return",
"filename",
"that",
"doesn",
"t",
"exist",
"already",
"."
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L171-L187 |
phoemur/wgetter | wgetter.py | report_bar | def report_bar(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used to print the download bar
'''
percent = int(bytes_so_far * 100 / total_size)
current = approximate_size(bytes_so_far).center(9)
total = approximate_size(total_size).center(9)
shaded = in... | python | def report_bar(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used to print the download bar
'''
percent = int(bytes_so_far * 100 / total_size)
current = approximate_size(bytes_so_far).center(9)
total = approximate_size(total_size).center(9)
shaded = in... | [
"def",
"report_bar",
"(",
"bytes_so_far",
",",
"total_size",
",",
"speed",
",",
"eta",
")",
":",
"percent",
"=",
"int",
"(",
"bytes_so_far",
"*",
"100",
"/",
"total_size",
")",
"current",
"=",
"approximate_size",
"(",
"bytes_so_far",
")",
".",
"center",
"(... | This callback for the download function is used to print the download bar | [
"This",
"callback",
"for",
"the",
"download",
"function",
"is",
"used",
"to",
"print",
"the",
"download",
"bar"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L190-L208 |
phoemur/wgetter | wgetter.py | report_unknown | def report_unknown(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used
when the total size is unknown
'''
sys.stdout.write(
"Downloading: {0} / Unknown - {1}/s ".format(approximate_size(bytes_so_far),
... | python | def report_unknown(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used
when the total size is unknown
'''
sys.stdout.write(
"Downloading: {0} / Unknown - {1}/s ".format(approximate_size(bytes_so_far),
... | [
"def",
"report_unknown",
"(",
"bytes_so_far",
",",
"total_size",
",",
"speed",
",",
"eta",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"Downloading: {0} / Unknown - {1}/s \"",
".",
"format",
"(",
"approximate_size",
"(",
"bytes_so_far",
")",
",",
"... | This callback for the download function is used
when the total size is unknown | [
"This",
"callback",
"for",
"the",
"download",
"function",
"is",
"used",
"when",
"the",
"total",
"size",
"is",
"unknown"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L211-L221 |
phoemur/wgetter | wgetter.py | report_onlysize | def report_onlysize(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used when console width
is not enough to print the bar.
It prints only the sizes
'''
percent = int(bytes_so_far * 100 / total_size)
current = approximate_size(bytes_so_far).center(10)
... | python | def report_onlysize(bytes_so_far, total_size, speed, eta):
'''
This callback for the download function is used when console width
is not enough to print the bar.
It prints only the sizes
'''
percent = int(bytes_so_far * 100 / total_size)
current = approximate_size(bytes_so_far).center(10)
... | [
"def",
"report_onlysize",
"(",
"bytes_so_far",
",",
"total_size",
",",
"speed",
",",
"eta",
")",
":",
"percent",
"=",
"int",
"(",
"bytes_so_far",
"*",
"100",
"/",
"total_size",
")",
"current",
"=",
"approximate_size",
"(",
"bytes_so_far",
")",
".",
"center",... | This callback for the download function is used when console width
is not enough to print the bar.
It prints only the sizes | [
"This",
"callback",
"for",
"the",
"download",
"function",
"is",
"used",
"when",
"console",
"width",
"is",
"not",
"enough",
"to",
"print",
"the",
"bar",
".",
"It",
"prints",
"only",
"the",
"sizes"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L224-L235 |
phoemur/wgetter | wgetter.py | download | def download(link, outdir='.', chunk_size=4096):
'''
This is the Main function, which downloads a given link
and saves on outdir (default = current directory)
'''
url = None
fh = None
eta = 'unknown '
bytes_so_far = 0
filename = filename_from_url(link) or "."
cj = cjar.CookieJar(... | python | def download(link, outdir='.', chunk_size=4096):
'''
This is the Main function, which downloads a given link
and saves on outdir (default = current directory)
'''
url = None
fh = None
eta = 'unknown '
bytes_so_far = 0
filename = filename_from_url(link) or "."
cj = cjar.CookieJar(... | [
"def",
"download",
"(",
"link",
",",
"outdir",
"=",
"'.'",
",",
"chunk_size",
"=",
"4096",
")",
":",
"url",
"=",
"None",
"fh",
"=",
"None",
"eta",
"=",
"'unknown '",
"bytes_so_far",
"=",
"0",
"filename",
"=",
"filename_from_url",
"(",
"link",
")",
"or"... | This is the Main function, which downloads a given link
and saves on outdir (default = current directory) | [
"This",
"is",
"the",
"Main",
"function",
"which",
"downloads",
"a",
"given",
"link",
"and",
"saves",
"on",
"outdir",
"(",
"default",
"=",
"current",
"directory",
")"
] | train | https://github.com/phoemur/wgetter/blob/ac182a72480e150e4a800fbade4fbccc29e72b51/wgetter.py#L252-L365 |
Clinical-Genomics/trailblazer | trailblazer/cli/ls.py | ls_cmd | def ls_cmd(context, before, status):
"""Display recent logs for analyses."""
runs = context.obj['store'].analyses(
status=status,
deleted=False,
before=parse_date(before) if before else None,
).limit(30)
for run_obj in runs:
if run_obj.status == 'pending':
mes... | python | def ls_cmd(context, before, status):
"""Display recent logs for analyses."""
runs = context.obj['store'].analyses(
status=status,
deleted=False,
before=parse_date(before) if before else None,
).limit(30)
for run_obj in runs:
if run_obj.status == 'pending':
mes... | [
"def",
"ls_cmd",
"(",
"context",
",",
"before",
",",
"status",
")",
":",
"runs",
"=",
"context",
".",
"obj",
"[",
"'store'",
"]",
".",
"analyses",
"(",
"status",
"=",
"status",
",",
"deleted",
"=",
"False",
",",
"before",
"=",
"parse_date",
"(",
"bef... | Display recent logs for analyses. | [
"Display",
"recent",
"logs",
"for",
"analyses",
"."
] | train | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/cli/ls.py#L11-L30 |
ozgurgunes/django-manifest | manifest/core/templatetags/analytics.py | analytics | def analytics(account=None, *args, **kwargs):
"""
Simple Google Analytics integration.
First looks for an ``account`` parameter. If not supplied, uses
Django ``GOOGLE_ANALYTICS_ACCOUNT`` setting. If account not set,
raises ``TemplateSyntaxError``.
:param account:
Google Analytics acco... | python | def analytics(account=None, *args, **kwargs):
"""
Simple Google Analytics integration.
First looks for an ``account`` parameter. If not supplied, uses
Django ``GOOGLE_ANALYTICS_ACCOUNT`` setting. If account not set,
raises ``TemplateSyntaxError``.
:param account:
Google Analytics acco... | [
"def",
"analytics",
"(",
"account",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"account",
":",
"try",
":",
"account",
"=",
"settings",
".",
"GOOGLE_ANALYTICS_ACCOUNT",
"except",
":",
"raise",
"template",
".",
"Template... | Simple Google Analytics integration.
First looks for an ``account`` parameter. If not supplied, uses
Django ``GOOGLE_ANALYTICS_ACCOUNT`` setting. If account not set,
raises ``TemplateSyntaxError``.
:param account:
Google Analytics account id to be used. | [
"Simple",
"Google",
"Analytics",
"integration",
"."
] | train | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/core/templatetags/analytics.py#L8-L27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.