repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
OLC-Bioinformatics/sipprverse | method.py | Method.methods | def methods(self):
"""
Run the typing methods
"""
self.contamination_detection()
ReportImage(self, 'confindr')
self.run_genesippr()
ReportImage(self, 'genesippr')
self.run_sixteens()
self.run_mash()
self.run_gdcs()
ReportImage(self,... | python | def methods(self):
"""
Run the typing methods
"""
self.contamination_detection()
ReportImage(self, 'confindr')
self.run_genesippr()
ReportImage(self, 'genesippr')
self.run_sixteens()
self.run_mash()
self.run_gdcs()
ReportImage(self,... | [
"def",
"methods",
"(",
"self",
")",
":",
"self",
".",
"contamination_detection",
"(",
")",
"ReportImage",
"(",
"self",
",",
"'confindr'",
")",
"self",
".",
"run_genesippr",
"(",
")",
"ReportImage",
"(",
"self",
",",
"'genesippr'",
")",
"self",
".",
"run_si... | Run the typing methods | [
"Run",
"the",
"typing",
"methods"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L169-L180 | train | Run the typing methods |
OLC-Bioinformatics/sipprverse | method.py | Method.contamination_detection | def contamination_detection(self):
"""
Calculate the levels of contamination in the reads
"""
self.qualityobject = quality.Quality(self)
self.qualityobject.contamination_finder(input_path=self.sequencepath,
report_path=self.reportpa... | python | def contamination_detection(self):
"""
Calculate the levels of contamination in the reads
"""
self.qualityobject = quality.Quality(self)
self.qualityobject.contamination_finder(input_path=self.sequencepath,
report_path=self.reportpa... | [
"def",
"contamination_detection",
"(",
"self",
")",
":",
"self",
".",
"qualityobject",
"=",
"quality",
".",
"Quality",
"(",
"self",
")",
"self",
".",
"qualityobject",
".",
"contamination_finder",
"(",
"input_path",
"=",
"self",
".",
"sequencepath",
",",
"repor... | Calculate the levels of contamination in the reads | [
"Calculate",
"the",
"levels",
"of",
"contamination",
"in",
"the",
"reads"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L182-L188 | train | Calculate the levels of contamination in the reads
|
OLC-Bioinformatics/sipprverse | method.py | Method.run_genesippr | def run_genesippr(self):
"""
Run the genesippr analyses
"""
GeneSippr(args=self,
pipelinecommit=self.commit,
startingtime=self.starttime,
scriptpath=self.homepath,
analysistype='genesippr',
cutoff=0... | python | def run_genesippr(self):
"""
Run the genesippr analyses
"""
GeneSippr(args=self,
pipelinecommit=self.commit,
startingtime=self.starttime,
scriptpath=self.homepath,
analysistype='genesippr',
cutoff=0... | [
"def",
"run_genesippr",
"(",
"self",
")",
":",
"GeneSippr",
"(",
"args",
"=",
"self",
",",
"pipelinecommit",
"=",
"self",
".",
"commit",
",",
"startingtime",
"=",
"self",
".",
"starttime",
",",
"scriptpath",
"=",
"self",
".",
"homepath",
",",
"analysistype... | Run the genesippr analyses | [
"Run",
"the",
"genesippr",
"analyses"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L190-L201 | train | Run the genesippr analyses |
OLC-Bioinformatics/sipprverse | method.py | Method.run_sixteens | def run_sixteens(self):
"""
Run the 16S analyses using the filtered database
"""
SixteensFull(args=self,
pipelinecommit=self.commit,
startingtime=self.starttime,
scriptpath=self.homepath,
analysistype='si... | python | def run_sixteens(self):
"""
Run the 16S analyses using the filtered database
"""
SixteensFull(args=self,
pipelinecommit=self.commit,
startingtime=self.starttime,
scriptpath=self.homepath,
analysistype='si... | [
"def",
"run_sixteens",
"(",
"self",
")",
":",
"SixteensFull",
"(",
"args",
"=",
"self",
",",
"pipelinecommit",
"=",
"self",
".",
"commit",
",",
"startingtime",
"=",
"self",
".",
"starttime",
",",
"scriptpath",
"=",
"self",
".",
"homepath",
",",
"analysisty... | Run the 16S analyses using the filtered database | [
"Run",
"the",
"16S",
"analyses",
"using",
"the",
"filtered",
"database"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L203-L212 | train | Run the 16S analyses using the filtered database |
OLC-Bioinformatics/sipprverse | method.py | Method.run_mash | def run_mash(self):
"""
Run MASH to determine the closest refseq genomes
"""
self.pipeline = True
mash.Mash(inputobject=self,
analysistype='mash') | python | def run_mash(self):
"""
Run MASH to determine the closest refseq genomes
"""
self.pipeline = True
mash.Mash(inputobject=self,
analysistype='mash') | [
"def",
"run_mash",
"(",
"self",
")",
":",
"self",
".",
"pipeline",
"=",
"True",
"mash",
".",
"Mash",
"(",
"inputobject",
"=",
"self",
",",
"analysistype",
"=",
"'mash'",
")"
] | Run MASH to determine the closest refseq genomes | [
"Run",
"MASH",
"to",
"determine",
"the",
"closest",
"refseq",
"genomes"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L214-L220 | train | Run MASH to determine the closest refseq genomes |
OLC-Bioinformatics/sipprverse | method.py | Method.complete | def complete(self):
"""
Determine if the analyses of the strains are complete e.g. there are no missing GDCS genes, and the
sample.general.bestassemblyfile != 'NA'
"""
# Boolean to store the completeness of the analyses
allcomplete = True
# Clear the list of samp... | python | def complete(self):
"""
Determine if the analyses of the strains are complete e.g. there are no missing GDCS genes, and the
sample.general.bestassemblyfile != 'NA'
"""
# Boolean to store the completeness of the analyses
allcomplete = True
# Clear the list of samp... | [
"def",
"complete",
"(",
"self",
")",
":",
"# Boolean to store the completeness of the analyses",
"allcomplete",
"=",
"True",
"# Clear the list of samples that still require more sequence data",
"self",
".",
"incomplete",
"=",
"list",
"(",
")",
"for",
"sample",
"in",
"self",... | Determine if the analyses of the strains are complete e.g. there are no missing GDCS genes, and the
sample.general.bestassemblyfile != 'NA' | [
"Determine",
"if",
"the",
"analyses",
"of",
"the",
"strains",
"are",
"complete",
"e",
".",
"g",
".",
"there",
"are",
"no",
"missing",
"GDCS",
"genes",
"and",
"the",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!",
"=",
"NA"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/method.py#L228-L261 | train | Determine if the analyses of the strains are complete e. g. there are no missing GDCS genes and there are no missing GDCS genes. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/protected_resources.py | protected_operation | def protected_operation(fn):
"""
Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The parent_object must contain:
* a request
* with a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Sign... | python | def protected_operation(fn):
"""
Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The parent_object must contain:
* a request
* with a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Sign... | [
"def",
"protected_operation",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"advice",
"(",
"parent_object",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"response",
"=",
"_advice",
"(",
"parent_object",
".",
"request",... | Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The parent_object must contain:
* a request
* with a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Signals that we don't want to
delete ... | [
"Use",
"this",
"decorator",
"to",
"prevent",
"an",
"operation",
"from",
"being",
"executed",
"when",
"the",
"related",
"uri",
"resource",
"is",
"still",
"in",
"use",
".",
"The",
"parent_object",
"must",
"contain",
":",
"*",
"a",
"request",
"*",
"with",
"a"... | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/protected_resources.py#L83-L103 | train | Decorator to prevent an operation from being executed when the related uri resource is still in use. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/protected_resources.py | protected_operation_with_request | def protected_operation_with_request(fn):
"""
Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The request must contain a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Signals that we don't want to
... | python | def protected_operation_with_request(fn):
"""
Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The request must contain a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Signals that we don't want to
... | [
"def",
"protected_operation_with_request",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"_advice",
"(",
"request",
")",
"if"... | Use this decorator to prevent an operation from being executed
when the related uri resource is still in use.
The request must contain a registry.queryUtility(IReferencer)
:raises pyramid.httpexceptions.HTTPConflict: Signals that we don't want to
delete a certain URI because it's still in use somewh... | [
"Use",
"this",
"decorator",
"to",
"prevent",
"an",
"operation",
"from",
"being",
"executed",
"when",
"the",
"related",
"uri",
"resource",
"is",
"still",
"in",
"use",
".",
"The",
"request",
"must",
"contain",
"a",
"registry",
".",
"queryUtility",
"(",
"IRefer... | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/protected_resources.py#L106-L125 | train | Decorator to prevent an operation from being executed when the related uri resource is still in use. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/protected_resources.py | protected_view | def protected_view(view, info):
"""allows adding `protected=True` to a view_config`"""
if info.options.get('protected'):
def wrapper_view(context, request):
response = _advice(request)
if response is not None:
return response
else:
ret... | python | def protected_view(view, info):
"""allows adding `protected=True` to a view_config`"""
if info.options.get('protected'):
def wrapper_view(context, request):
response = _advice(request)
if response is not None:
return response
else:
ret... | [
"def",
"protected_view",
"(",
"view",
",",
"info",
")",
":",
"if",
"info",
".",
"options",
".",
"get",
"(",
"'protected'",
")",
":",
"def",
"wrapper_view",
"(",
"context",
",",
"request",
")",
":",
"response",
"=",
"_advice",
"(",
"request",
")",
"if",... | allows adding `protected=True` to a view_config` | [
"allows",
"adding",
"protected",
"=",
"True",
"to",
"a",
"view_config"
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/protected_resources.py#L128-L139 | train | allows adding protected = True to a view_config |
Riffstation/Flask-Philo-SQLAlchemy | flask_philo_sqlalchemy/__init__.py | syncdb | def syncdb(pool=None):
"""
Create tables if they don't exist
"""
from flask_philo_sqlalchemy.schema import Base # noqa
from flask_philo_sqlalchemy.orm import BaseModel # noqa
from flask_philo_sqlalchemy.connection import create_pool
if pool is None:
pool = create_pool()
for c... | python | def syncdb(pool=None):
"""
Create tables if they don't exist
"""
from flask_philo_sqlalchemy.schema import Base # noqa
from flask_philo_sqlalchemy.orm import BaseModel # noqa
from flask_philo_sqlalchemy.connection import create_pool
if pool is None:
pool = create_pool()
for c... | [
"def",
"syncdb",
"(",
"pool",
"=",
"None",
")",
":",
"from",
"flask_philo_sqlalchemy",
".",
"schema",
"import",
"Base",
"# noqa",
"from",
"flask_philo_sqlalchemy",
".",
"orm",
"import",
"BaseModel",
"# noqa",
"from",
"flask_philo_sqlalchemy",
".",
"connection",
"i... | Create tables if they don't exist | [
"Create",
"tables",
"if",
"they",
"don",
"t",
"exist"
] | 71598bb603b8458a2cf9f7989f71d8f1c77fafb9 | https://github.com/Riffstation/Flask-Philo-SQLAlchemy/blob/71598bb603b8458a2cf9f7989f71d8f1c77fafb9/flask_philo_sqlalchemy/__init__.py#L4-L16 | train | Create tables if they don t exist |
mikemelch/hallie | hallie/modules/install.py | checkInstalledPip | def checkInstalledPip(package, speak=True, speakSimilar=True):
"""checks if a given package is installed on pip"""
packages = sorted([i.key for i in pip.get_installed_distributions()])
installed = package in packages
similar = None
if not installed:
similar = [pkg for pkg in packages if pac... | python | def checkInstalledPip(package, speak=True, speakSimilar=True):
"""checks if a given package is installed on pip"""
packages = sorted([i.key for i in pip.get_installed_distributions()])
installed = package in packages
similar = None
if not installed:
similar = [pkg for pkg in packages if pac... | [
"def",
"checkInstalledPip",
"(",
"package",
",",
"speak",
"=",
"True",
",",
"speakSimilar",
"=",
"True",
")",
":",
"packages",
"=",
"sorted",
"(",
"[",
"i",
".",
"key",
"for",
"i",
"in",
"pip",
".",
"get_installed_distributions",
"(",
")",
"]",
")",
"i... | checks if a given package is installed on pip | [
"checks",
"if",
"a",
"given",
"package",
"is",
"installed",
"on",
"pip"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/install.py#L25-L37 | train | checks if a given package is installed on pip |
mikemelch/hallie | hallie/modules/install.py | checkInstalledBrew | def checkInstalledBrew(package, similar=True, speak=True, speakSimilar=True):
"""checks if a given package is installed on homebrew"""
packages = subprocess.check_output(['brew', 'list']).split()
installed = package in packages
similar = []
if not installed:
similar = [pkg for pkg in packag... | python | def checkInstalledBrew(package, similar=True, speak=True, speakSimilar=True):
"""checks if a given package is installed on homebrew"""
packages = subprocess.check_output(['brew', 'list']).split()
installed = package in packages
similar = []
if not installed:
similar = [pkg for pkg in packag... | [
"def",
"checkInstalledBrew",
"(",
"package",
",",
"similar",
"=",
"True",
",",
"speak",
"=",
"True",
",",
"speakSimilar",
"=",
"True",
")",
":",
"packages",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'brew'",
",",
"'list'",
"]",
")",
".",
"split"... | checks if a given package is installed on homebrew | [
"checks",
"if",
"a",
"given",
"package",
"is",
"installed",
"on",
"homebrew"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/install.py#L40-L51 | train | checks if a given package is installed on homebrew |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | init_module | def init_module(remote_credences=None,local_path=None):
"""Connnexion informations : remote_credences for remote acces OR local_path for local access"""
if remote_credences is not None:
RemoteConnexion.HOST = remote_credences["DB"]["host"]
RemoteConnexion.USER = remote_credences["DB"]["user"]
... | python | def init_module(remote_credences=None,local_path=None):
"""Connnexion informations : remote_credences for remote acces OR local_path for local access"""
if remote_credences is not None:
RemoteConnexion.HOST = remote_credences["DB"]["host"]
RemoteConnexion.USER = remote_credences["DB"]["user"]
... | [
"def",
"init_module",
"(",
"remote_credences",
"=",
"None",
",",
"local_path",
"=",
"None",
")",
":",
"if",
"remote_credences",
"is",
"not",
"None",
":",
"RemoteConnexion",
".",
"HOST",
"=",
"remote_credences",
"[",
"\"DB\"",
"]",
"[",
"\"host\"",
"]",
"Remo... | Connnexion informations : remote_credences for remote acces OR local_path for local access | [
"Connnexion",
"informations",
":",
"remote_credences",
"for",
"remote",
"acces",
"OR",
"local_path",
"for",
"local",
"access"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L23-L40 | train | Initialize the SQL module with the given credences. |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | cree_local_DB | def cree_local_DB(scheme):
"""Create emmpt DB according to the given scheme : dict { table : [ (column_name, column_type), .. ]}
Usefull at installation of application (and for developement)
"""
conn = LocalConnexion()
req = ""
for table, fields in scheme.items():
req += f"DROP TABLE IF ... | python | def cree_local_DB(scheme):
"""Create emmpt DB according to the given scheme : dict { table : [ (column_name, column_type), .. ]}
Usefull at installation of application (and for developement)
"""
conn = LocalConnexion()
req = ""
for table, fields in scheme.items():
req += f"DROP TABLE IF ... | [
"def",
"cree_local_DB",
"(",
"scheme",
")",
":",
"conn",
"=",
"LocalConnexion",
"(",
")",
"req",
"=",
"\"\"",
"for",
"table",
",",
"fields",
"in",
"scheme",
".",
"items",
"(",
")",
":",
"req",
"+=",
"f\"DROP TABLE IF EXISTS {table};\"",
"req_fields",
"=",
... | Create emmpt DB according to the given scheme : dict { table : [ (column_name, column_type), .. ]}
Usefull at installation of application (and for developement) | [
"Create",
"emmpt",
"DB",
"according",
"to",
"the",
"given",
"scheme",
":",
"dict",
"{",
"table",
":",
"[",
"(",
"column_name",
"column_type",
")",
"..",
"]",
"}",
"Usefull",
"at",
"installation",
"of",
"application",
"(",
"and",
"for",
"developement",
")"
... | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L209-L223 | train | Create emmpt DB according to the given scheme. |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractConnexion.execute | def execute(self, requete_SQL):
"""Execute one or many requests
requete_SQL may be a tuple(requete,args) or a list of such tuples
Return the result or a list of results
"""
try:
cursor = self.cursor()
if isinstance(requete_SQL,tuple):
res =... | python | def execute(self, requete_SQL):
"""Execute one or many requests
requete_SQL may be a tuple(requete,args) or a list of such tuples
Return the result or a list of results
"""
try:
cursor = self.cursor()
if isinstance(requete_SQL,tuple):
res =... | [
"def",
"execute",
"(",
"self",
",",
"requete_SQL",
")",
":",
"try",
":",
"cursor",
"=",
"self",
".",
"cursor",
"(",
")",
"if",
"isinstance",
"(",
"requete_SQL",
",",
"tuple",
")",
":",
"res",
"=",
"self",
".",
"_execute_one",
"(",
"cursor",
",",
"*",... | Execute one or many requests
requete_SQL may be a tuple(requete,args) or a list of such tuples
Return the result or a list of results | [
"Execute",
"one",
"or",
"many",
"requests",
"requete_SQL",
"may",
"be",
"a",
"tuple",
"(",
"requete",
"args",
")",
"or",
"a",
"list",
"of",
"such",
"tuples",
"Return",
"the",
"result",
"or",
"a",
"list",
"of",
"results"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L117-L138 | train | Execute one or many requests
requete_SQL may be a tuple or a list of such tuples Return the result or a list of results
|
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.placeholders | def placeholders(cls,dic):
"""Placeholders for fields names and value binds"""
keys = [str(x) for x in dic]
entete = ",".join(keys)
placeholders = ",".join(cls.named_style.format(x) for x in keys)
entete = f"({entete})"
placeholders = f"({placeholders})"
return en... | python | def placeholders(cls,dic):
"""Placeholders for fields names and value binds"""
keys = [str(x) for x in dic]
entete = ",".join(keys)
placeholders = ",".join(cls.named_style.format(x) for x in keys)
entete = f"({entete})"
placeholders = f"({placeholders})"
return en... | [
"def",
"placeholders",
"(",
"cls",
",",
"dic",
")",
":",
"keys",
"=",
"[",
"str",
"(",
"x",
")",
"for",
"x",
"in",
"dic",
"]",
"entete",
"=",
"\",\"",
".",
"join",
"(",
"keys",
")",
"placeholders",
"=",
"\",\"",
".",
"join",
"(",
"cls",
".",
"n... | Placeholders for fields names and value binds | [
"Placeholders",
"for",
"fields",
"names",
"and",
"value",
"binds"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L244-L251 | train | Placeholders for fields names and value binds |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.jsonise | def jsonise(dic):
"""Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None : il faut laisser None et non pas null"""
d = {}
for k, v in dic.items():
if type(v) in abstractRequetesSQL.TYPES_PERMIS:
d[k] = v
... | python | def jsonise(dic):
"""Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None : il faut laisser None et non pas null"""
d = {}
for k, v in dic.items():
if type(v) in abstractRequetesSQL.TYPES_PERMIS:
d[k] = v
... | [
"def",
"jsonise",
"(",
"dic",
")",
":",
"d",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
":",
"if",
"type",
"(",
"v",
")",
"in",
"abstractRequetesSQL",
".",
"TYPES_PERMIS",
":",
"d",
"[",
"k",
"]",
"=",
"v",
"els... | Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None : il faut laisser None et non pas null | [
"Renvoie",
"un",
"dictionnaire",
"dont",
"les",
"champs",
"dont",
"compatibles",
"avec",
"SQL",
"Utilise",
"Json",
".",
"Attention",
"à",
"None",
":",
"il",
"faut",
"laisser",
"None",
"et",
"non",
"pas",
"null"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L259-L272 | train | Renvoie un dictionnaire dont les champs dont compatibles avec SQL
Utilise Json. Attention à None et non - null et non - null |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.insert | def insert(table, datas, avoid_conflict=False):
""" Insert row from datas
:param table: Safe table name
:param datas: List of dicts.
:param avoid_conflict: Allows ignoring error if already exists (do nothing then)
:return:
"""
if avoid_conflict:
debut... | python | def insert(table, datas, avoid_conflict=False):
""" Insert row from datas
:param table: Safe table name
:param datas: List of dicts.
:param avoid_conflict: Allows ignoring error if already exists (do nothing then)
:return:
"""
if avoid_conflict:
debut... | [
"def",
"insert",
"(",
"table",
",",
"datas",
",",
"avoid_conflict",
"=",
"False",
")",
":",
"if",
"avoid_conflict",
":",
"debut",
"=",
"\"\"\"INSERT INTO {table} {ENTETE_INSERT} VALUES {BIND_INSERT} ON CONFLICT DO NOTHING\"\"\"",
"else",
":",
"debut",
"=",
"\"\"\"INSERT I... | Insert row from datas
:param table: Safe table name
:param datas: List of dicts.
:param avoid_conflict: Allows ignoring error if already exists (do nothing then)
:return: | [
"Insert",
"row",
"from",
"datas"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L287-L300 | train | Insert row from datas. |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.update | def update(cls,table, dic, Id):
""" Update row with Id from table. Set fields given by dic."""
if dic:
req = "UPDATE {table} SET {SET} WHERE id = " + cls.named_style.format('__id') + " RETURNING * "
r = abstractRequetesSQL.formate(req, SET=dic, table=table, args=dict(dic, __id=I... | python | def update(cls,table, dic, Id):
""" Update row with Id from table. Set fields given by dic."""
if dic:
req = "UPDATE {table} SET {SET} WHERE id = " + cls.named_style.format('__id') + " RETURNING * "
r = abstractRequetesSQL.formate(req, SET=dic, table=table, args=dict(dic, __id=I... | [
"def",
"update",
"(",
"cls",
",",
"table",
",",
"dic",
",",
"Id",
")",
":",
"if",
"dic",
":",
"req",
"=",
"\"UPDATE {table} SET {SET} WHERE id = \"",
"+",
"cls",
".",
"named_style",
".",
"format",
"(",
"'__id'",
")",
"+",
"\" RETURNING * \"",
"r",
"=",
"... | Update row with Id from table. Set fields given by dic. | [
"Update",
"row",
"with",
"Id",
"from",
"table",
".",
"Set",
"fields",
"given",
"by",
"dic",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L303-L310 | train | Update row with Id from table. Set fields given by dic. |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.cree | def cree(table, dic, avoid_conflict=False):
""" Create ONE row from dic and returns the entry created """
if avoid_conflict:
req = """ INSERT INTO {table} {ENTETE_INSERT} VALUES {BIND_INSERT} ON CONFLICT DO NOTHING RETURNING *"""
else:
req = """ INSERT INTO {table} {ENTET... | python | def cree(table, dic, avoid_conflict=False):
""" Create ONE row from dic and returns the entry created """
if avoid_conflict:
req = """ INSERT INTO {table} {ENTETE_INSERT} VALUES {BIND_INSERT} ON CONFLICT DO NOTHING RETURNING *"""
else:
req = """ INSERT INTO {table} {ENTET... | [
"def",
"cree",
"(",
"table",
",",
"dic",
",",
"avoid_conflict",
"=",
"False",
")",
":",
"if",
"avoid_conflict",
":",
"req",
"=",
"\"\"\" INSERT INTO {table} {ENTETE_INSERT} VALUES {BIND_INSERT} ON CONFLICT DO NOTHING RETURNING *\"\"\"",
"else",
":",
"req",
"=",
"\"\"\" IN... | Create ONE row from dic and returns the entry created | [
"Create",
"ONE",
"row",
"from",
"dic",
"and",
"returns",
"the",
"entry",
"created"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L314-L321 | train | Create ONE row from dic and returns the entry created |
benoitkugler/abstractDataLibrary | pyDLib/Core/sql.py | abstractRequetesSQL.supprime | def supprime(cls,table, **kwargs):
""" Remove entries matchin given condition
kwargs is a dict of column name : value , with length ONE.
"""
assert len(kwargs) == 1
field, value = kwargs.popitem()
req = f"""DELETE FROM {table} WHERE {field} = """ + cls.mark_style
... | python | def supprime(cls,table, **kwargs):
""" Remove entries matchin given condition
kwargs is a dict of column name : value , with length ONE.
"""
assert len(kwargs) == 1
field, value = kwargs.popitem()
req = f"""DELETE FROM {table} WHERE {field} = """ + cls.mark_style
... | [
"def",
"supprime",
"(",
"cls",
",",
"table",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"kwargs",
")",
"==",
"1",
"field",
",",
"value",
"=",
"kwargs",
".",
"popitem",
"(",
")",
"req",
"=",
"f\"\"\"DELETE FROM {table} WHERE {field} = \"\"\"",... | Remove entries matchin given condition
kwargs is a dict of column name : value , with length ONE. | [
"Remove",
"entries",
"matchin",
"given",
"condition",
"kwargs",
"is",
"a",
"dict",
"of",
"column",
"name",
":",
"value",
"with",
"length",
"ONE",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/sql.py#L333-L341 | train | Remove entries matchin given condition
|
marrow/web.dispatch.object | web/dispatch/object/dispatch.py | ObjectDispatch.trace | def trace(self, context, obj):
"""Enumerate the children of the given object, as would be visible and utilized by dispatch."""
root = obj
if isroutine(obj):
yield Crumb(self, root, endpoint=True, handler=obj, options=opts(obj))
return
for name, attr in getmembers(obj if isclass(obj) else obj.__cl... | python | def trace(self, context, obj):
"""Enumerate the children of the given object, as would be visible and utilized by dispatch."""
root = obj
if isroutine(obj):
yield Crumb(self, root, endpoint=True, handler=obj, options=opts(obj))
return
for name, attr in getmembers(obj if isclass(obj) else obj.__cl... | [
"def",
"trace",
"(",
"self",
",",
"context",
",",
"obj",
")",
":",
"root",
"=",
"obj",
"if",
"isroutine",
"(",
"obj",
")",
":",
"yield",
"Crumb",
"(",
"self",
",",
"root",
",",
"endpoint",
"=",
"True",
",",
"handler",
"=",
"obj",
",",
"options",
... | Enumerate the children of the given object, as would be visible and utilized by dispatch. | [
"Enumerate",
"the",
"children",
"of",
"the",
"given",
"object",
"as",
"would",
"be",
"visible",
"and",
"utilized",
"by",
"dispatch",
"."
] | 98af461a404aae8ae58e2cbc2e0acdbf62a705bc | https://github.com/marrow/web.dispatch.object/blob/98af461a404aae8ae58e2cbc2e0acdbf62a705bc/web/dispatch/object/dispatch.py#L23-L58 | train | Enumerate the children of the given object as would be visible and utilized by dispatch. |
hid-io/layouts-python | layouts/__init__.py | main | def main(argv=None):
'''
Main entry-point for calling layouts directly as a program.
'''
# Prep argparse
ap = argparse.ArgumentParser(
description='Basic query options for Python HID-IO Layouts repository',
)
ap.add_argument('--list', action='store_true', help='List available layout ... | python | def main(argv=None):
'''
Main entry-point for calling layouts directly as a program.
'''
# Prep argparse
ap = argparse.ArgumentParser(
description='Basic query options for Python HID-IO Layouts repository',
)
ap.add_argument('--list', action='store_true', help='List available layout ... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# Prep argparse",
"ap",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Basic query options for Python HID-IO Layouts repository'",
",",
")",
"ap",
".",
"add_argument",
"(",
"'--list'",
",",
"a... | Main entry-point for calling layouts directly as a program. | [
"Main",
"entry",
"-",
"point",
"for",
"calling",
"layouts",
"directly",
"as",
"a",
"program",
"."
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L462-L487 | train | Main entry - point for calling layouts directly as a program. |
hid-io/layouts-python | layouts/__init__.py | Layouts.retrieve_github_cache | def retrieve_github_cache(self, github_path, version, cache_dir, token):
'''
Retrieves a cache of the layouts git repo from GitHub
@param github_path: Location of the git repo on GitHub (e.g. hid-io/layouts)
@param version: git reference for the version to download (e.g. master)
... | python | def retrieve_github_cache(self, github_path, version, cache_dir, token):
'''
Retrieves a cache of the layouts git repo from GitHub
@param github_path: Location of the git repo on GitHub (e.g. hid-io/layouts)
@param version: git reference for the version to download (e.g. master)
... | [
"def",
"retrieve_github_cache",
"(",
"self",
",",
"github_path",
",",
"version",
",",
"cache_dir",
",",
"token",
")",
":",
"# Check for environment variable Github token",
"token",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'GITHUB_APIKEY'",
",",
"None",
")",
... | Retrieves a cache of the layouts git repo from GitHub
@param github_path: Location of the git repo on GitHub (e.g. hid-io/layouts)
@param version: git reference for the version to download (e.g. master)
@param cache_dir: Directory to operate on external cache from
@param token: GitHub a... | [
"Retrieves",
"a",
"cache",
"of",
"the",
"layouts",
"git",
"repo",
"from",
"GitHub"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L111-L170 | train | Retrieve a cache of the layouts git repo from GitHub and store it in cache_dir. |
hid-io/layouts-python | layouts/__init__.py | Layouts.get_layout | def get_layout(self, name):
'''
Returns the layout with the given name
'''
layout_chain = []
# Retrieve initial layout file
try:
json_data = self.json_files[self.layout_names[name]]
except KeyError:
log.error('Could not find layout: %s', n... | python | def get_layout(self, name):
'''
Returns the layout with the given name
'''
layout_chain = []
# Retrieve initial layout file
try:
json_data = self.json_files[self.layout_names[name]]
except KeyError:
log.error('Could not find layout: %s', n... | [
"def",
"get_layout",
"(",
"self",
",",
"name",
")",
":",
"layout_chain",
"=",
"[",
"]",
"# Retrieve initial layout file",
"try",
":",
"json_data",
"=",
"self",
".",
"json_files",
"[",
"self",
".",
"layout_names",
"[",
"name",
"]",
"]",
"except",
"KeyError",
... | Returns the layout with the given name | [
"Returns",
"the",
"layout",
"with",
"the",
"given",
"name"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L178-L215 | train | Returns the layout with the given name |
hid-io/layouts-python | layouts/__init__.py | Layouts.dict_merge | def dict_merge(self, merge_to, merge_in):
'''
Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite element... | python | def dict_merge(self, merge_to, merge_in):
'''
Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite element... | [
"def",
"dict_merge",
"(",
"self",
",",
"merge_to",
",",
"merge_in",
")",
":",
"for",
"key",
",",
"value",
"in",
"merge_in",
".",
"items",
"(",
")",
":",
"# Just add, if the key doesn't exist yet",
"# Or if set to None/Null",
"if",
"key",
"not",
"in",
"merge_to",... | Recursively merges two dicts
Overwrites any non-dictionary items
merge_to <- merge_in
Modifies merge_to dictionary
@param merge_to: Base dictionary to merge into
@param merge_in: Dictionary that may overwrite elements in merge_in | [
"Recursively",
"merges",
"two",
"dicts"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L217-L246 | train | Recursively merges two dicts containing items in merge_in into merge_to. |
hid-io/layouts-python | layouts/__init__.py | Layouts.squash_layouts | def squash_layouts(self, layouts):
'''
Returns a squashed layout
The first element takes precedence (i.e. left to right).
Dictionaries are recursively merged, overwrites only occur on non-dictionary entries.
[0,1]
0:
test: 'my data'
1:
test: 's... | python | def squash_layouts(self, layouts):
'''
Returns a squashed layout
The first element takes precedence (i.e. left to right).
Dictionaries are recursively merged, overwrites only occur on non-dictionary entries.
[0,1]
0:
test: 'my data'
1:
test: 's... | [
"def",
"squash_layouts",
"(",
"self",
",",
"layouts",
")",
":",
"top_layout",
"=",
"layouts",
"[",
"0",
"]",
"json_data",
"=",
"{",
"}",
"# Generate a new container Layout",
"layout",
"=",
"Layout",
"(",
"top_layout",
".",
"name",
"(",
")",
",",
"json_data",... | Returns a squashed layout
The first element takes precedence (i.e. left to right).
Dictionaries are recursively merged, overwrites only occur on non-dictionary entries.
[0,1]
0:
test: 'my data'
1:
test: 'stuff'
Result:
test: 'my data'
... | [
"Returns",
"a",
"squashed",
"layout"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L248-L281 | train | Squash a list of layouts into one Layout with the same data. |
hid-io/layouts-python | layouts/__init__.py | Layout.dict | def dict(self, name, key_caps=False, value_caps=False):
'''
Returns a JSON dict
@key_caps: Converts all dictionary keys to uppercase
@value_caps: Converts all dictionary values to uppercase
@return: JSON item (may be a variable, list or dictionary)
'''
# Invalid... | python | def dict(self, name, key_caps=False, value_caps=False):
'''
Returns a JSON dict
@key_caps: Converts all dictionary keys to uppercase
@value_caps: Converts all dictionary values to uppercase
@return: JSON item (may be a variable, list or dictionary)
'''
# Invalid... | [
"def",
"dict",
"(",
"self",
",",
"name",
",",
"key_caps",
"=",
"False",
",",
"value_caps",
"=",
"False",
")",
":",
"# Invalid Dictionary",
"if",
"not",
"isinstance",
"(",
"self",
".",
"json_data",
"[",
"name",
"]",
",",
"dict",
")",
":",
"raise",
"Inva... | Returns a JSON dict
@key_caps: Converts all dictionary keys to uppercase
@value_caps: Converts all dictionary values to uppercase
@return: JSON item (may be a variable, list or dictionary) | [
"Returns",
"a",
"JSON",
"dict"
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L347-L365 | train | Returns a JSON dictionary of the specified key and value. |
hid-io/layouts-python | layouts/__init__.py | Layout.locale | def locale(self):
'''
Do a lookup for the locale code that is set for this layout.
NOTE: USB HID specifies only 35 different locales. If your layout does not fit, it should be set to Undefined/0
@return: Tuple (<USB HID locale code>, <name>)
'''
name = self.json_data['h... | python | def locale(self):
'''
Do a lookup for the locale code that is set for this layout.
NOTE: USB HID specifies only 35 different locales. If your layout does not fit, it should be set to Undefined/0
@return: Tuple (<USB HID locale code>, <name>)
'''
name = self.json_data['h... | [
"def",
"locale",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"json_data",
"[",
"'hid_locale'",
"]",
"# Set to Undefined/0 if not set",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"\"Undefined\"",
"return",
"(",
"int",
"(",
"self",
".",
"json_data",
... | Do a lookup for the locale code that is set for this layout.
NOTE: USB HID specifies only 35 different locales. If your layout does not fit, it should be set to Undefined/0
@return: Tuple (<USB HID locale code>, <name>) | [
"Do",
"a",
"lookup",
"for",
"the",
"locale",
"code",
"that",
"is",
"set",
"for",
"this",
"layout",
"."
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L383-L397 | train | Do a lookup for the locale code that is set for this layout. |
hid-io/layouts-python | layouts/__init__.py | Layout.compose | def compose(self, text, minimal_clears=False, no_clears=False):
'''
Returns the sequence of combinations necessary to compose given text.
If the text expression is not possible with the given layout an ComposeException is thrown.
Iterate over the string, converting each character into ... | python | def compose(self, text, minimal_clears=False, no_clears=False):
'''
Returns the sequence of combinations necessary to compose given text.
If the text expression is not possible with the given layout an ComposeException is thrown.
Iterate over the string, converting each character into ... | [
"def",
"compose",
"(",
"self",
",",
"text",
",",
"minimal_clears",
"=",
"False",
",",
"no_clears",
"=",
"False",
")",
":",
"sequence",
"=",
"[",
"]",
"clear",
"=",
"self",
".",
"json_data",
"[",
"'to_hid_keyboard'",
"]",
"[",
"'0x00'",
"]",
"# No Event",... | Returns the sequence of combinations necessary to compose given text.
If the text expression is not possible with the given layout an ComposeException is thrown.
Iterate over the string, converting each character into a key sequence.
Between each character, an empty combo is inserted to handle... | [
"Returns",
"the",
"sequence",
"of",
"combinations",
"necessary",
"to",
"compose",
"given",
"text",
"."
] | b347578bfb4198fd812ecd7a2d9c7e551a856280 | https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L413-L456 | train | Generates a sequence of combinations needed to compose given text. |
OLC-Bioinformatics/sipprverse | sippr.py | Sipprverse.main | def main(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {at} analysis pipeline'.format(at=self.analysistype))
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
self.runmeta... | python | def main(self):
"""
Run the necessary methods in the correct order
"""
logging.info('Starting {at} analysis pipeline'.format(at=self.analysistype))
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.objectprep()
self.runmeta... | [
"def",
"main",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Starting {at} analysis pipeline'",
".",
"format",
"(",
"at",
"=",
"self",
".",
"analysistype",
")",
")",
"# Create the objects to be used in the analyses",
"objects",
"=",
"Objectprep",
"(",
"sel... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sippr.py#L26-L137 | train | Run the analyses in the correct order. |
OLC-Bioinformatics/sipprverse | sippr.py | Sipprverse.genus_specific | def genus_specific(self):
"""
For genus-specific targets, MLST and serotyping, determine if the closest refseq genus is known - i.e. if 16S
analyses have been performed. Perform the analyses if required
"""
# Initialise a variable to store whether the necessary analyses have alre... | python | def genus_specific(self):
"""
For genus-specific targets, MLST and serotyping, determine if the closest refseq genus is known - i.e. if 16S
analyses have been performed. Perform the analyses if required
"""
# Initialise a variable to store whether the necessary analyses have alre... | [
"def",
"genus_specific",
"(",
"self",
")",
":",
"# Initialise a variable to store whether the necessary analyses have already been performed",
"closestrefseqgenus",
"=",
"False",
"for",
"sample",
"in",
"self",
".",
"runmetadata",
".",
"samples",
":",
"if",
"sample",
".",
... | For genus-specific targets, MLST and serotyping, determine if the closest refseq genus is known - i.e. if 16S
analyses have been performed. Perform the analyses if required | [
"For",
"genus",
"-",
"specific",
"targets",
"MLST",
"and",
"serotyping",
"determine",
"if",
"the",
"closest",
"refseq",
"genus",
"is",
"known",
"-",
"i",
".",
"e",
".",
"if",
"16S",
"analyses",
"have",
"been",
"performed",
".",
"Perform",
"the",
"analyses"... | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/sippr.py#L139-L157 | train | Determine if the closest refseq genus is known - i. e. if the MASH analyses are performed and if required is True then perform the analyses if required is False then perform the analyses if required is True. |
mikemelch/hallie | hallie/modules/itunes.py | pause | def pause():
"""Tell iTunes to pause"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", PAUSE], stdout=subprocess.PIPE).communicate() | python | def pause():
"""Tell iTunes to pause"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", PAUSE], stdout=subprocess.PIPE).communicate() | [
"def",
"pause",
"(",
")",
":",
"if",
"not",
"settings",
".",
"platformCompatible",
"(",
")",
":",
"return",
"False",
"(",
"output",
",",
"error",
")",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"osascript\"",
",",
"\"-e\"",
",",
"PAUSE",
"]",
",",
... | Tell iTunes to pause | [
"Tell",
"iTunes",
"to",
"pause"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/itunes.py#L169-L175 | train | Tell iTunes to pause |
mikemelch/hallie | hallie/modules/itunes.py | resume | def resume():
"""Tell iTunes to resume"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", RESUME], stdout=subprocess.PIPE).communicate() | python | def resume():
"""Tell iTunes to resume"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", RESUME], stdout=subprocess.PIPE).communicate() | [
"def",
"resume",
"(",
")",
":",
"if",
"not",
"settings",
".",
"platformCompatible",
"(",
")",
":",
"return",
"False",
"(",
"output",
",",
"error",
")",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"osascript\"",
",",
"\"-e\"",
",",
"RESUME",
"]",
",",
... | Tell iTunes to resume | [
"Tell",
"iTunes",
"to",
"resume"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/itunes.py#L177-L183 | train | Tell iTunes to resume |
mikemelch/hallie | hallie/modules/itunes.py | skip | def skip():
"""Tell iTunes to skip a song"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", SKIP], stdout=subprocess.PIPE).communicate() | python | def skip():
"""Tell iTunes to skip a song"""
if not settings.platformCompatible():
return False
(output, error) = subprocess.Popen(["osascript", "-e", SKIP], stdout=subprocess.PIPE).communicate() | [
"def",
"skip",
"(",
")",
":",
"if",
"not",
"settings",
".",
"platformCompatible",
"(",
")",
":",
"return",
"False",
"(",
"output",
",",
"error",
")",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"osascript\"",
",",
"\"-e\"",
",",
"SKIP",
"]",
",",
"s... | Tell iTunes to skip a song | [
"Tell",
"iTunes",
"to",
"skip",
"a",
"song"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/itunes.py#L186-L192 | train | Tell iTunes to skip a song |
mikemelch/hallie | hallie/modules/itunes.py | play | def play(song, artist=None, album=None):
"""Tells iTunes to play a given song/artist/album - MACOSX ONLY"""
if not settings.platformCompatible():
return False
if song and not artist and not album:
(output, error) = subprocess.Popen(["osascript", "-e", DEFAULT_ITUNES_PLAY % (song, song, song)], stdout=subproces... | python | def play(song, artist=None, album=None):
"""Tells iTunes to play a given song/artist/album - MACOSX ONLY"""
if not settings.platformCompatible():
return False
if song and not artist and not album:
(output, error) = subprocess.Popen(["osascript", "-e", DEFAULT_ITUNES_PLAY % (song, song, song)], stdout=subproces... | [
"def",
"play",
"(",
"song",
",",
"artist",
"=",
"None",
",",
"album",
"=",
"None",
")",
":",
"if",
"not",
"settings",
".",
"platformCompatible",
"(",
")",
":",
"return",
"False",
"if",
"song",
"and",
"not",
"artist",
"and",
"not",
"album",
":",
"(",
... | Tells iTunes to play a given song/artist/album - MACOSX ONLY | [
"Tells",
"iTunes",
"to",
"play",
"a",
"given",
"song",
"/",
"artist",
"/",
"album",
"-",
"MACOSX",
"ONLY"
] | a6dbb691145a85b776a1919e4c7930e0ae598437 | https://github.com/mikemelch/hallie/blob/a6dbb691145a85b776a1919e4c7930e0ae598437/hallie/modules/itunes.py#L195-L234 | train | Tells iTunes to play a given song artist or album. |
innolitics/service-locator | servicelocator/lookup.py | service_provider | def service_provider(*services):
"""
This is a class decorator that declares a class to provide a set of services.
It is expected that the class has a no-arg constructor and will be instantiated
as a singleton.
"""
def real_decorator(clazz):
instance = clazz()
for service in ser... | python | def service_provider(*services):
"""
This is a class decorator that declares a class to provide a set of services.
It is expected that the class has a no-arg constructor and will be instantiated
as a singleton.
"""
def real_decorator(clazz):
instance = clazz()
for service in ser... | [
"def",
"service_provider",
"(",
"*",
"services",
")",
":",
"def",
"real_decorator",
"(",
"clazz",
")",
":",
"instance",
"=",
"clazz",
"(",
")",
"for",
"service",
"in",
"services",
":",
"global_lookup",
".",
"add",
"(",
"service",
",",
"instance",
")",
"r... | This is a class decorator that declares a class to provide a set of services.
It is expected that the class has a no-arg constructor and will be instantiated
as a singleton. | [
"This",
"is",
"a",
"class",
"decorator",
"that",
"declares",
"a",
"class",
"to",
"provide",
"a",
"set",
"of",
"services",
".",
"It",
"is",
"expected",
"that",
"the",
"class",
"has",
"a",
"no",
"-",
"arg",
"constructor",
"and",
"will",
"be",
"instantiated... | ddccac242587c800db3fde0abb9c1e9ed461369e | https://github.com/innolitics/service-locator/blob/ddccac242587c800db3fde0abb9c1e9ed461369e/servicelocator/lookup.py#L26-L39 | train | This is a class decorator that declares a class to provide a set of services. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | syllabify | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify_simplex
syllabifications = list(syllabify(word))
for word, rules in rank(syllabifications):
# post-proces... | python | def syllabify(word):
'''Syllabify the given word, whether simplex or complex.'''
compound = bool(re.search(r'(-| |=)', word))
syllabify = _syllabify_compound if compound else _syllabify_simplex
syllabifications = list(syllabify(word))
for word, rules in rank(syllabifications):
# post-proces... | [
"def",
"syllabify",
"(",
"word",
")",
":",
"compound",
"=",
"bool",
"(",
"re",
".",
"search",
"(",
"r'(-| |=)'",
",",
"word",
")",
")",
"syllabify",
"=",
"_syllabify_compound",
"if",
"compound",
"else",
"_syllabify_simplex",
"syllabifications",
"=",
"list",
... | Syllabify the given word, whether simplex or complex. | [
"Syllabify",
"the",
"given",
"word",
"whether",
"simplex",
"or",
"complex",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L33-L44 | train | Syllabify the given word whether simplex or complex. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | apply_T2 | def apply_T2(word):
'''There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
WORD = word
offset = 0
for vv in vv_sequences(WORD):
seq = vv.group(2)
if not is_diphthong(seq) and not is_long(seq):
... | python | def apply_T2(word):
'''There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa].'''
WORD = word
offset = 0
for vv in vv_sequences(WORD):
seq = vv.group(2)
if not is_diphthong(seq) and not is_long(seq):
... | [
"def",
"apply_T2",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vv",
"in",
"vv_sequences",
"(",
"WORD",
")",
":",
"seq",
"=",
"vv",
".",
"group",
"(",
"2",
")",
"if",
"not",
"is_diphthong",
"(",
"seq",
")",
"and",
"not"... | There is a syllable boundary within a VV sequence of two nonidentical
vowels that are not a genuine diphthong, e.g., [ta.e], [ko.et.taa]. | [
"There",
"is",
"a",
"syllable",
"boundary",
"within",
"a",
"VV",
"sequence",
"of",
"two",
"nonidentical",
"vowels",
"that",
"are",
"not",
"a",
"genuine",
"diphthong",
"e",
".",
"g",
".",
"[",
"ta",
".",
"e",
"]",
"[",
"ko",
".",
"et",
".",
"taa",
"... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L179-L195 | train | This function applies T2 to the given word. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | apply_T5 | def apply_T5(word):
'''If a (V)VVV sequence contains a VV sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me].'''
WORD = word
offset = 0
for v... | python | def apply_T5(word):
'''If a (V)VVV sequence contains a VV sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me].'''
WORD = word
offset = 0
for v... | [
"def",
"apply_T5",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vi",
"in",
"i_final_diphthong_vvv_sequences",
"(",
"WORD",
")",
":",
"s",
"=",
"max",
"(",
"vi",
".",
"start",
"(",
"1",
")",
",",
"vi",
".",
"start",
"(",
... | If a (V)VVV sequence contains a VV sequence that could be an /i/-final
diphthong, there is a syllable boundary between it and the third vowel,
e.g., [raa.ois.sa], [huo.uim.me], [la.eis.sa], [sel.vi.äi.si], [tai.an],
[säi.e], [oi.om.me]. | [
"If",
"a",
"(",
"V",
")",
"VVV",
"sequence",
"contains",
"a",
"VV",
"sequence",
"that",
"could",
"be",
"an",
"/",
"i",
"/",
"-",
"final",
"diphthong",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"it",
"and",
"the",
"third",
"vowel",
"e",
"... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L230-L252 | train | This function applies T5 to a word. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | apply_T6 | def apply_T6(word):
'''If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
WORD = word
offset = 0
for vvv in vvv_sequences(WORD):
seq = vvv.group(2)
j = 2 if is_long(seq[:2... | python | def apply_T6(word):
'''If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
WORD = word
offset = 0
for vvv in vvv_sequences(WORD):
seq = vvv.group(2)
j = 2 if is_long(seq[:2... | [
"def",
"apply_T6",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vvv",
"in",
"vvv_sequences",
"(",
"WORD",
")",
":",
"seq",
"=",
"vvv",
".",
"group",
"(",
"2",
")",
"j",
"=",
"2",
"if",
"is_long",
"(",
"seq",
"[",
":",... | If a VVV-sequence contains a long vowel, there is a syllable boundary
between it and the third vowel, e.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"contains",
"a",
"long",
"vowel",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"it",
"and",
"the",
"third",
"vowel",
"e",
".",
"g",
".",
"[",
"kor",
".",
"ke",
".",
"aa",
"]",
"[",
"yh",
".",
"ti",
"."... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L257-L275 | train | This function applies T6 to a word. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | apply_T7 | def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].'''
WORD = word
offset = 0
for vvv in vvv_sequences(WORD):
i = vvv.start(2) + 2 + offset
... | python | def apply_T7(word):
'''If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as].'''
WORD = word
offset = 0
for vvv in vvv_sequences(WORD):
i = vvv.start(2) + 2 + offset
... | [
"def",
"apply_T7",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vvv",
"in",
"vvv_sequences",
"(",
"WORD",
")",
":",
"i",
"=",
"vvv",
".",
"start",
"(",
"2",
")",
"+",
"2",
"+",
"offset",
"WORD",
"=",
"WORD",
"[",
":",... | If a VVV-sequence does not contain a potential /i/-final diphthong,
there is a syllable boundary between the second and third vowels, e.g.
[kau.an], [leu.an], [kiu.as]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"does",
"not",
"contain",
"a",
"potential",
"/",
"i",
"/",
"-",
"final",
"diphthong",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"the",
"second",
"and",
"third",
"vowels",
"e",
".",
"g",
".",
"[",
"kau",
... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L280-L294 | train | A function to apply T7 to a VVV - sequence. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | apply_T8 | def apply_T8(word):
'''Split /ie/, /uo/, or /yö/ sequences in syllables that do not take
primary stress.'''
WORD = word
offset = 0
for vv in tail_diphthongs(WORD):
i = vv.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T8' if word != WORD els... | python | def apply_T8(word):
'''Split /ie/, /uo/, or /yö/ sequences in syllables that do not take
primary stress.'''
WORD = word
offset = 0
for vv in tail_diphthongs(WORD):
i = vv.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T8' if word != WORD els... | [
"def",
"apply_T8",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vv",
"in",
"tail_diphthongs",
"(",
"WORD",
")",
":",
"i",
"=",
"vv",
".",
"start",
"(",
"1",
")",
"+",
"1",
"+",
"offset",
"WORD",
"=",
"WORD",
"[",
":",... | Split /ie/, /uo/, or /yö/ sequences in syllables that do not take
primary stress. | [
"Split",
"/",
"ie",
"/",
"/",
"uo",
"/",
"or",
"/",
"yö",
"/",
"sequences",
"in",
"syllables",
"that",
"do",
"not",
"take",
"primary",
"stress",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L299-L312 | train | Split the syllables that do not take
primary stress. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | wsp | def wsp(word):
'''Return the number of unstressed heavy syllables.'''
HEAVY = r'[ieaAoO]{1}[\.]*(u|y)[^ieaAoO]+(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = word[:word.rindex('.')]
# gather the indices of ... | python | def wsp(word):
'''Return the number of unstressed heavy syllables.'''
HEAVY = r'[ieaAoO]{1}[\.]*(u|y)[^ieaAoO]+(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = word[:word.rindex('.')]
# gather the indices of ... | [
"def",
"wsp",
"(",
"word",
")",
":",
"HEAVY",
"=",
"r'[ieaAoO]{1}[\\.]*(u|y)[^ieaAoO]+(\\.|$)'",
"# # if the word is not monosyllabic, lop off the final syllable, which is",
"# # extrametrical",
"# if '.' in word:",
"# word = word[:word.rindex('.')]",
"# gather the indices of syllable ... | Return the number of unstressed heavy syllables. | [
"Return",
"the",
"number",
"of",
"unstressed",
"heavy",
"syllables",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L382-L408 | train | Return the number of unstressed heavy syllables. |
tsnaomi/finnsyll | finnsyll/prev/v10.py | pk_prom | def pk_prom(word):
'''Return the number of stressed light syllables.'''
LIGHT = r'[ieaAoO]{1}[\.]*(u|y)(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = word[:word.rindex('.')]
# gather the indices of syllable... | python | def pk_prom(word):
'''Return the number of stressed light syllables.'''
LIGHT = r'[ieaAoO]{1}[\.]*(u|y)(\.|$)'
# # if the word is not monosyllabic, lop off the final syllable, which is
# # extrametrical
# if '.' in word:
# word = word[:word.rindex('.')]
# gather the indices of syllable... | [
"def",
"pk_prom",
"(",
"word",
")",
":",
"LIGHT",
"=",
"r'[ieaAoO]{1}[\\.]*(u|y)(\\.|$)'",
"# # if the word is not monosyllabic, lop off the final syllable, which is",
"# # extrametrical",
"# if '.' in word:",
"# word = word[:word.rindex('.')]",
"# gather the indices of syllable bounda... | Return the number of stressed light syllables. | [
"Return",
"the",
"number",
"of",
"stressed",
"light",
"syllables",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v10.py#L411-L437 | train | Return the number of stressed light syllables. |
crdoconnor/pathquery | pathquery/query.py | pathquery.ext | def ext(self, extension):
"""
Match files with an extension - e.g. 'js', 'txt'
"""
new_pathq = copy(self)
new_pathq._pattern.ext = extension
return new_pathq | python | def ext(self, extension):
"""
Match files with an extension - e.g. 'js', 'txt'
"""
new_pathq = copy(self)
new_pathq._pattern.ext = extension
return new_pathq | [
"def",
"ext",
"(",
"self",
",",
"extension",
")",
":",
"new_pathq",
"=",
"copy",
"(",
"self",
")",
"new_pathq",
".",
"_pattern",
".",
"ext",
"=",
"extension",
"return",
"new_pathq"
] | Match files with an extension - e.g. 'js', 'txt' | [
"Match",
"files",
"with",
"an",
"extension",
"-",
"e",
".",
"g",
".",
"js",
"txt"
] | 4905fef27fc666ea4511eb0eee5098f754bb52ed | https://github.com/crdoconnor/pathquery/blob/4905fef27fc666ea4511eb0eee5098f754bb52ed/pathquery/query.py#L104-L110 | train | Match files with an extension - e. g. js txt |
tsnaomi/finnsyll | finnsyll/prev/v04.py | apply_T8 | def apply_T8(word):
'''Split /ie/ sequences in syllables that do not take primary stress.'''
WORD = word
offset = 0
for ie in ie_sequences(WORD):
i = ie.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T8' if word != WORD else ''
return WORD,... | python | def apply_T8(word):
'''Split /ie/ sequences in syllables that do not take primary stress.'''
WORD = word
offset = 0
for ie in ie_sequences(WORD):
i = ie.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T8' if word != WORD else ''
return WORD,... | [
"def",
"apply_T8",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"ie",
"in",
"ie_sequences",
"(",
"WORD",
")",
":",
"i",
"=",
"ie",
".",
"start",
"(",
"1",
")",
"+",
"1",
"+",
"offset",
"WORD",
"=",
"WORD",
"[",
":",
... | Split /ie/ sequences in syllables that do not take primary stress. | [
"Split",
"/",
"ie",
"/",
"sequences",
"in",
"syllables",
"that",
"do",
"not",
"take",
"primary",
"stress",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v04.py#L252-L264 | train | Split / ie sequences in syllables that do not take primary stress. |
tsnaomi/finnsyll | finnsyll/prev/v04.py | apply_T9 | def apply_T9(word):
'''Split /iu/ sequences that do not appear in the first, second, or final
syllables.'''
WORD = word
index = 0
offset = 0
for iu in iu_sequences(WORD):
if iu.start(1) != index:
i = iu.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
... | python | def apply_T9(word):
'''Split /iu/ sequences that do not appear in the first, second, or final
syllables.'''
WORD = word
index = 0
offset = 0
for iu in iu_sequences(WORD):
if iu.start(1) != index:
i = iu.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
... | [
"def",
"apply_T9",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"index",
"=",
"0",
"offset",
"=",
"0",
"for",
"iu",
"in",
"iu_sequences",
"(",
"WORD",
")",
":",
"if",
"iu",
".",
"start",
"(",
"1",
")",
"!=",
"index",
":",
"i",
"=",
"iu",
".",
... | Split /iu/ sequences that do not appear in the first, second, or final
syllables. | [
"Split",
"/",
"iu",
"/",
"sequences",
"that",
"do",
"not",
"appear",
"in",
"the",
"first",
"second",
"or",
"final",
"syllables",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v04.py#L269-L285 | train | Split / iu sequences that do not appear in the first second or final
syllables. |
QunarOPS/qg.core | qg/core/importutils.py | import_class | def import_class(import_str):
"""Returns a class from a string including module and class."""
mod_str, _sep, class_str = import_str.rpartition('.')
try:
__import__(mod_str)
return getattr(sys.modules[mod_str], class_str)
except (ValueError, AttributeError):
raise ImportError('Cla... | python | def import_class(import_str):
"""Returns a class from a string including module and class."""
mod_str, _sep, class_str = import_str.rpartition('.')
try:
__import__(mod_str)
return getattr(sys.modules[mod_str], class_str)
except (ValueError, AttributeError):
raise ImportError('Cla... | [
"def",
"import_class",
"(",
"import_str",
")",
":",
"mod_str",
",",
"_sep",
",",
"class_str",
"=",
"import_str",
".",
"rpartition",
"(",
"'.'",
")",
"try",
":",
"__import__",
"(",
"mod_str",
")",
"return",
"getattr",
"(",
"sys",
".",
"modules",
"[",
"mod... | Returns a class from a string including module and class. | [
"Returns",
"a",
"class",
"from",
"a",
"string",
"including",
"module",
"and",
"class",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/importutils.py#L24-L33 | train | Returns a class from a string including module and class. |
QunarOPS/qg.core | qg/core/importutils.py | import_object_ns | def import_object_ns(name_space, import_str, *args, **kwargs):
"""Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
"""
im... | python | def import_object_ns(name_space, import_str, *args, **kwargs):
"""Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
"""
im... | [
"def",
"import_object_ns",
"(",
"name_space",
",",
"import_str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import_value",
"=",
"\"%s.%s\"",
"%",
"(",
"name_space",
",",
"import_str",
")",
"try",
":",
"return",
"import_class",
"(",
"import_value",... | Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace. | [
"Tries",
"to",
"import",
"object",
"from",
"default",
"namespace",
"."
] | d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3 | https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/importutils.py#L41-L52 | train | Tries to import an object from the default namespace and returns an instance of it |
pyBookshelf/bookshelf | bookshelf/api_v2/vagrant.py | install_virtualbox | def install_virtualbox(distribution, force_setup=False):
""" install virtualbox """
if 'ubuntu' in distribution:
with hide('running', 'stdout'):
sudo('DEBIAN_FRONTEND=noninteractive apt-get update')
sudo("sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o "
"D... | python | def install_virtualbox(distribution, force_setup=False):
""" install virtualbox """
if 'ubuntu' in distribution:
with hide('running', 'stdout'):
sudo('DEBIAN_FRONTEND=noninteractive apt-get update')
sudo("sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o "
"D... | [
"def",
"install_virtualbox",
"(",
"distribution",
",",
"force_setup",
"=",
"False",
")",
":",
"if",
"'ubuntu'",
"in",
"distribution",
":",
"with",
"hide",
"(",
"'running'",
",",
"'stdout'",
")",
":",
"sudo",
"(",
"'DEBIAN_FRONTEND=noninteractive apt-get update'",
... | install virtualbox | [
"install",
"virtualbox"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/vagrant.py#L13-L54 | train | installs the virtualbox if the distribution is ubuntu |
pyBookshelf/bookshelf | bookshelf/api_v2/vagrant.py | install_vagrant_plugin | def install_vagrant_plugin(plugin, use_sudo=False):
""" install vagrant plugin """
cmd = 'vagrant plugin install %s' % plugin
with settings(hide('running', 'stdout')):
if use_sudo:
if plugin not in sudo('vagrant plugin list'):
sudo(cmd)
else:
if plug... | python | def install_vagrant_plugin(plugin, use_sudo=False):
""" install vagrant plugin """
cmd = 'vagrant plugin install %s' % plugin
with settings(hide('running', 'stdout')):
if use_sudo:
if plugin not in sudo('vagrant plugin list'):
sudo(cmd)
else:
if plug... | [
"def",
"install_vagrant_plugin",
"(",
"plugin",
",",
"use_sudo",
"=",
"False",
")",
":",
"cmd",
"=",
"'vagrant plugin install %s'",
"%",
"plugin",
"with",
"settings",
"(",
"hide",
"(",
"'running'",
",",
"'stdout'",
")",
")",
":",
"if",
"use_sudo",
":",
"if",... | install vagrant plugin | [
"install",
"vagrant",
"plugin"
] | a6770678e735de95b194f6e6989223970db5f654 | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v2/vagrant.py#L66-L77 | train | install vagrant plugin |
OLC-Bioinformatics/sipprverse | MASHsippr/mashsippr.py | MashSippr.runner | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting mashsippr analysis pipeline', self.starttime)
if not self.pipeline:
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.... | python | def runner(self):
"""
Run the necessary methods in the correct order
"""
printtime('Starting mashsippr analysis pipeline', self.starttime)
if not self.pipeline:
# Create the objects to be used in the analyses
objects = Objectprep(self)
objects.... | [
"def",
"runner",
"(",
"self",
")",
":",
"printtime",
"(",
"'Starting mashsippr analysis pipeline'",
",",
"self",
".",
"starttime",
")",
"if",
"not",
"self",
".",
"pipeline",
":",
"# Create the objects to be used in the analyses",
"objects",
"=",
"Objectprep",
"(",
"... | Run the necessary methods in the correct order | [
"Run",
"the",
"necessary",
"methods",
"in",
"the",
"correct",
"order"
] | d4f10cdf8e1a39dac0953db61c21c97efc6006de | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/MASHsippr/mashsippr.py#L15-L26 | train | Run the necessary methods in the correct order for the mashsippr analysis pipeline |
benoitkugler/abstractDataLibrary | pyDLib/GUI/common.py | abstractDetails.cree_widgets | def cree_widgets(self):
"""Create widgets and store them in self.widgets"""
for t in self.FIELDS:
if type(t) is str:
attr, kwargs = t, {}
else:
attr, kwargs = t[0], t[1].copy()
self.champs.append(attr)
is_editable = kwargs.p... | python | def cree_widgets(self):
"""Create widgets and store them in self.widgets"""
for t in self.FIELDS:
if type(t) is str:
attr, kwargs = t, {}
else:
attr, kwargs = t[0], t[1].copy()
self.champs.append(attr)
is_editable = kwargs.p... | [
"def",
"cree_widgets",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"FIELDS",
":",
"if",
"type",
"(",
"t",
")",
"is",
"str",
":",
"attr",
",",
"kwargs",
"=",
"t",
",",
"{",
"}",
"else",
":",
"attr",
",",
"kwargs",
"=",
"t",
"[",
"0",... | Create widgets and store them in self.widgets | [
"Create",
"widgets",
"and",
"store",
"them",
"in",
"self",
".",
"widgets"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/common.py#L346-L369 | train | Create widgets and store them in self. widgets |
benoitkugler/abstractDataLibrary | pyDLib/GUI/common.py | abstractDetails.cree_ws_lecture | def cree_ws_lecture(self, champs_ligne):
"""Alternative to create read only widgets. They should be set after."""
for c in champs_ligne:
label = ASSOCIATION[c][0]
w = ASSOCIATION[c][3](self.acces[c], False)
w.setObjectName("champ-lecture-seule-details")
se... | python | def cree_ws_lecture(self, champs_ligne):
"""Alternative to create read only widgets. They should be set after."""
for c in champs_ligne:
label = ASSOCIATION[c][0]
w = ASSOCIATION[c][3](self.acces[c], False)
w.setObjectName("champ-lecture-seule-details")
se... | [
"def",
"cree_ws_lecture",
"(",
"self",
",",
"champs_ligne",
")",
":",
"for",
"c",
"in",
"champs_ligne",
":",
"label",
"=",
"ASSOCIATION",
"[",
"c",
"]",
"[",
"0",
"]",
"w",
"=",
"ASSOCIATION",
"[",
"c",
"]",
"[",
"3",
"]",
"(",
"self",
".",
"acces"... | Alternative to create read only widgets. They should be set after. | [
"Alternative",
"to",
"create",
"read",
"only",
"widgets",
".",
"They",
"should",
"be",
"set",
"after",
"."
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/common.py#L371-L377 | train | Alternative to create read only widgets. They should be set after. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | preservesurrogates | def preservesurrogates(s):
"""
Function for splitting a string into a list of characters, preserving surrogate pairs.
In python 2, unicode characters above 0x10000 are stored as surrogate pairs. For example, the Unicode character
u"\U0001e900" is stored as the surrogate pair u"\ud83a\udd00":
s = ... | python | def preservesurrogates(s):
"""
Function for splitting a string into a list of characters, preserving surrogate pairs.
In python 2, unicode characters above 0x10000 are stored as surrogate pairs. For example, the Unicode character
u"\U0001e900" is stored as the surrogate pair u"\ud83a\udd00":
s = ... | [
"def",
"preservesurrogates",
"(",
"s",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"raise",
"TypeError",
"(",
"u\"String to split must be of type 'unicode'!\"",
")",
"surrogates_regex_str",
"=",
"u\"[{0}-{1}][{2}-{3}]\"",
"... | Function for splitting a string into a list of characters, preserving surrogate pairs.
In python 2, unicode characters above 0x10000 are stored as surrogate pairs. For example, the Unicode character
u"\U0001e900" is stored as the surrogate pair u"\ud83a\udd00":
s = u"AB\U0001e900CD"
len(s) -> 6
l... | [
"Function",
"for",
"splitting",
"a",
"string",
"into",
"a",
"list",
"of",
"characters",
"preserving",
"surrogate",
"pairs",
"."
] | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L23-L46 | train | Function for splitting a string into a list of characters preserving surrogates. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | _unichr | def _unichr(i):
"""
Helper function for taking a Unicode scalar value and returning a Unicode character.
:param s: Unicode scalar value to convert.
:return: Unicode character
"""
if not isinstance(i, int):
raise TypeError
try:
return six.unichr(i)
except ValueError:
... | python | def _unichr(i):
"""
Helper function for taking a Unicode scalar value and returning a Unicode character.
:param s: Unicode scalar value to convert.
:return: Unicode character
"""
if not isinstance(i, int):
raise TypeError
try:
return six.unichr(i)
except ValueError:
... | [
"def",
"_unichr",
"(",
"i",
")",
":",
"if",
"not",
"isinstance",
"(",
"i",
",",
"int",
")",
":",
"raise",
"TypeError",
"try",
":",
"return",
"six",
".",
"unichr",
"(",
"i",
")",
"except",
"ValueError",
":",
"# Workaround the error \"ValueError: unichr() arg ... | Helper function for taking a Unicode scalar value and returning a Unicode character.
:param s: Unicode scalar value to convert.
:return: Unicode character | [
"Helper",
"function",
"for",
"taking",
"a",
"Unicode",
"scalar",
"value",
"and",
"returning",
"a",
"Unicode",
"character",
"."
] | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L49-L62 | train | Helper function for taking a Unicode scalar value and returning a Unicode character. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | _padded_hex | def _padded_hex(i, pad_width=4, uppercase=True):
"""
Helper function for taking an integer and returning a hex string. The string will be padded on the left with zeroes
until the string is of the specified width. For example:
_padded_hex(31, pad_width=4, uppercase=True) -> "001F"
:param i: integ... | python | def _padded_hex(i, pad_width=4, uppercase=True):
"""
Helper function for taking an integer and returning a hex string. The string will be padded on the left with zeroes
until the string is of the specified width. For example:
_padded_hex(31, pad_width=4, uppercase=True) -> "001F"
:param i: integ... | [
"def",
"_padded_hex",
"(",
"i",
",",
"pad_width",
"=",
"4",
",",
"uppercase",
"=",
"True",
")",
":",
"result",
"=",
"hex",
"(",
"i",
")",
"[",
"2",
":",
"]",
"# Remove the leading \"0x\"",
"if",
"uppercase",
":",
"result",
"=",
"result",
".",
"upper",
... | Helper function for taking an integer and returning a hex string. The string will be padded on the left with zeroes
until the string is of the specified width. For example:
_padded_hex(31, pad_width=4, uppercase=True) -> "001F"
:param i: integer to convert to a hex string
:param pad_width: (int spec... | [
"Helper",
"function",
"for",
"taking",
"an",
"integer",
"and",
"returning",
"a",
"hex",
"string",
".",
"The",
"string",
"will",
"be",
"padded",
"on",
"the",
"left",
"with",
"zeroes",
"until",
"the",
"string",
"is",
"of",
"the",
"specified",
"width",
".",
... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L75-L91 | train | Helper function for taking an integer and returning a hex string. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | _uax44lm2transform | def _uax44lm2transform(s):
"""
Helper function for taking a string (i.e. a Unicode character name) and transforming it via UAX44-LM2 loose matching
rule. For more information, see <https://www.unicode.org/reports/tr44/#UAX44-LM2>.
The rule is defined as follows:
"UAX44-LM2. Ignore case, whitespac... | python | def _uax44lm2transform(s):
"""
Helper function for taking a string (i.e. a Unicode character name) and transforming it via UAX44-LM2 loose matching
rule. For more information, see <https://www.unicode.org/reports/tr44/#UAX44-LM2>.
The rule is defined as follows:
"UAX44-LM2. Ignore case, whitespac... | [
"def",
"_uax44lm2transform",
"(",
"s",
")",
":",
"result",
"=",
"s",
"# For the regex, we are using lookaround assertions to verify that there is a word character immediately before (the",
"# lookbehind assertion (?<=\\w)) and immediately after (the lookahead assertion (?=\\w)) the hyphen, per t... | Helper function for taking a string (i.e. a Unicode character name) and transforming it via UAX44-LM2 loose matching
rule. For more information, see <https://www.unicode.org/reports/tr44/#UAX44-LM2>.
The rule is defined as follows:
"UAX44-LM2. Ignore case, whitespace, underscore ('_'), and all medial hyp... | [
"Helper",
"function",
"for",
"taking",
"a",
"string",
"(",
"i",
".",
"e",
".",
"a",
"Unicode",
"character",
"name",
")",
"and",
"transforming",
"it",
"via",
"UAX44",
"-",
"LM2",
"loose",
"matching",
"rule",
".",
"For",
"more",
"information",
"see",
"<htt... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L94-L135 | train | This function transforms a string into a UAX44 - LM2 string. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | _to_unicode_scalar_value | def _to_unicode_scalar_value(s):
"""
Helper function for converting a character or surrogate pair into a Unicode scalar value e.g.
"\ud800\udc00" -> 0x10000
The algorithm can be found in older versions of the Unicode Standard.
https://unicode.org/versions/Unicode3.0.0/ch03.pdf, Section 3.7, D28
... | python | def _to_unicode_scalar_value(s):
"""
Helper function for converting a character or surrogate pair into a Unicode scalar value e.g.
"\ud800\udc00" -> 0x10000
The algorithm can be found in older versions of the Unicode Standard.
https://unicode.org/versions/Unicode3.0.0/ch03.pdf, Section 3.7, D28
... | [
"def",
"_to_unicode_scalar_value",
"(",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"==",
"1",
":",
"return",
"ord",
"(",
"s",
")",
"elif",
"len",
"(",
"s",
")",
"==",
"2",
":",
"return",
"(",
"ord",
"(",
"s",
"[",
"0",
"]",
")",
"-",
"0xD800"... | Helper function for converting a character or surrogate pair into a Unicode scalar value e.g.
"\ud800\udc00" -> 0x10000
The algorithm can be found in older versions of the Unicode Standard.
https://unicode.org/versions/Unicode3.0.0/ch03.pdf, Section 3.7, D28
Unicode scalar value: a number N from 0 to... | [
"Helper",
"function",
"for",
"converting",
"a",
"character",
"or",
"surrogate",
"pair",
"into",
"a",
"Unicode",
"scalar",
"value",
"e",
".",
"g",
".",
"\\",
"ud800",
"\\",
"udc00",
"-",
">",
"0x10000"
] | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L138-L162 | train | Helper function to convert a Unicode scalar value from a string to a Unicode scalar value. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | _get_nr_prefix | def _get_nr_prefix(i):
"""
Helper function for looking up the derived name prefix associated with a Unicode scalar value.
:param i: Unicode scalar value.
:return: String with the derived name prefix.
"""
for lookup_range, prefix_string in _nr_prefix_strings.items():
if i in lookup_range... | python | def _get_nr_prefix(i):
"""
Helper function for looking up the derived name prefix associated with a Unicode scalar value.
:param i: Unicode scalar value.
:return: String with the derived name prefix.
"""
for lookup_range, prefix_string in _nr_prefix_strings.items():
if i in lookup_range... | [
"def",
"_get_nr_prefix",
"(",
"i",
")",
":",
"for",
"lookup_range",
",",
"prefix_string",
"in",
"_nr_prefix_strings",
".",
"items",
"(",
")",
":",
"if",
"i",
"in",
"lookup_range",
":",
"return",
"prefix_string",
"raise",
"ValueError",
"(",
"\"No prefix string as... | Helper function for looking up the derived name prefix associated with a Unicode scalar value.
:param i: Unicode scalar value.
:return: String with the derived name prefix. | [
"Helper",
"function",
"for",
"looking",
"up",
"the",
"derived",
"name",
"prefix",
"associated",
"with",
"a",
"Unicode",
"scalar",
"value",
"."
] | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L198-L208 | train | Helper function for looking up the derived name prefix associated with a Unicode scalar value. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | casefold | def casefold(s, fullcasefold=True, useturkicmapping=False):
"""
Function for performing case folding. This function will take the input
string s and return a copy of the string suitable for caseless comparisons.
The input string must be of type 'unicode', otherwise a TypeError will be
raised.
... | python | def casefold(s, fullcasefold=True, useturkicmapping=False):
"""
Function for performing case folding. This function will take the input
string s and return a copy of the string suitable for caseless comparisons.
The input string must be of type 'unicode', otherwise a TypeError will be
raised.
... | [
"def",
"casefold",
"(",
"s",
",",
"fullcasefold",
"=",
"True",
",",
"useturkicmapping",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"six",
".",
"text_type",
")",
":",
"raise",
"TypeError",
"(",
"u\"String to casefold must be of type 'unic... | Function for performing case folding. This function will take the input
string s and return a copy of the string suitable for caseless comparisons.
The input string must be of type 'unicode', otherwise a TypeError will be
raised.
For more information on case folding, see section 3.13 of the Unicode St... | [
"Function",
"for",
"performing",
"case",
"folding",
".",
"This",
"function",
"will",
"take",
"the",
"input",
"string",
"s",
"and",
"return",
"a",
"copy",
"of",
"the",
"string",
"suitable",
"for",
"caseless",
"comparisons",
".",
"The",
"input",
"string",
"mus... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L522-L560 | train | This function will perform a case folding on the input string s. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | UnicodeData._build_unicode_character_database | def _build_unicode_character_database(self):
"""
Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
filename = "Uni... | python | def _build_unicode_character_database(self):
"""
Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
filename = "Uni... | [
"def",
"_build_unicode_character_database",
"(",
"self",
")",
":",
"filename",
"=",
"\"UnicodeData.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"tag",
"=",
"re",
".",
"com... | Function for parsing the Unicode character data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/ | [
"Function",
"for",
"parsing",
"the",
"Unicode",
"character",
"data",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
".",
"For",
"more",
"info",
"on",
"the",
"UCD",
"see",
"the",
"following",
... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L228-L278 | train | Function for parsing the Unicode Character Database and generating a lookup table. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | UnicodeData.lookup_by_name | def lookup_by_name(self, name):
"""
Function for retrieving the UnicodeCharacter associated with a name. The name lookup uses the loose matching
rule UAX44-LM2 for loose matching. See the following for more info:
https://www.unicode.org/reports/tr44/#UAX44-LM2
For example:
... | python | def lookup_by_name(self, name):
"""
Function for retrieving the UnicodeCharacter associated with a name. The name lookup uses the loose matching
rule UAX44-LM2 for loose matching. See the following for more info:
https://www.unicode.org/reports/tr44/#UAX44-LM2
For example:
... | [
"def",
"lookup_by_name",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"self",
".",
"_name_database",
"[",
"_uax44lm2transform",
"(",
"name",
")",
"]",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"u\"Unknown character name: '{0}'!\"",
".",
... | Function for retrieving the UnicodeCharacter associated with a name. The name lookup uses the loose matching
rule UAX44-LM2 for loose matching. See the following for more info:
https://www.unicode.org/reports/tr44/#UAX44-LM2
For example:
ucd = UnicodeData()
ucd.lookup_by_nam... | [
"Function",
"for",
"retrieving",
"the",
"UnicodeCharacter",
"associated",
"with",
"a",
"name",
".",
"The",
"name",
"lookup",
"uses",
"the",
"loose",
"matching",
"rule",
"UAX44",
"-",
"LM2",
"for",
"loose",
"matching",
".",
"See",
"the",
"following",
"for",
"... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L339-L359 | train | Function for retrieving the UnicodeCharacter associated with a name. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | UnicodeData.lookup_by_partial_name | def lookup_by_partial_name(self, partial_name):
"""
Similar to lookup_by_name(name), this method uses loose matching rule UAX44-LM2 to attempt to find the
UnicodeCharacter associated with a name. However, it attempts to permit even looser matching by doing a
substring search instead of ... | python | def lookup_by_partial_name(self, partial_name):
"""
Similar to lookup_by_name(name), this method uses loose matching rule UAX44-LM2 to attempt to find the
UnicodeCharacter associated with a name. However, it attempts to permit even looser matching by doing a
substring search instead of ... | [
"def",
"lookup_by_partial_name",
"(",
"self",
",",
"partial_name",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_name_database",
".",
"items",
"(",
")",
":",
"if",
"_uax44lm2transform",
"(",
"partial_name",
")",
"in",
"k",
":",
"yield",
"v"
] | Similar to lookup_by_name(name), this method uses loose matching rule UAX44-LM2 to attempt to find the
UnicodeCharacter associated with a name. However, it attempts to permit even looser matching by doing a
substring search instead of a simple match. This method will return a generator that yields ins... | [
"Similar",
"to",
"lookup_by_name",
"(",
"name",
")",
"this",
"method",
"uses",
"loose",
"matching",
"rule",
"UAX44",
"-",
"LM2",
"to",
"attempt",
"to",
"find",
"the",
"UnicodeCharacter",
"associated",
"with",
"a",
"name",
".",
"However",
"it",
"attempts",
"t... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L361-L383 | train | This method returns a generator that yields UnicodeCharacter instances for the given partial name. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | UnicodeBlocks._load_unicode_block_info | def _load_unicode_block_info(self):
"""
Function for parsing the Unicode block info from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
filename = "Blocks.txt"
... | python | def _load_unicode_block_info(self):
"""
Function for parsing the Unicode block info from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
filename = "Blocks.txt"
... | [
"def",
"_load_unicode_block_info",
"(",
"self",
")",
":",
"filename",
"=",
"\"Blocks.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"with",
"codecs",
".",
"open",
"(",
"os... | Function for parsing the Unicode block info from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/ | [
"Function",
"for",
"parsing",
"the",
"Unicode",
"block",
"info",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
".",
"For",
"more",
"info",
"on",
"the",
"UCD",
"see",
"the",
"following",
"we... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L394-L409 | train | Function for parsing Unicode character set info from the Unicode CharacterSet Database and generating a lookup table. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | CaseFoldingMap._build_casefold_map | def _build_casefold_map(self):
"""
Function for parsing the case folding data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
self._casefold_map = defaultdict(d... | python | def _build_casefold_map(self):
"""
Function for parsing the case folding data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/
"""
self._casefold_map = defaultdict(d... | [
"def",
"_build_casefold_map",
"(",
"self",
")",
":",
"self",
".",
"_casefold_map",
"=",
"defaultdict",
"(",
"dict",
")",
"filename",
"=",
"\"CaseFolding.txt\"",
"current_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
... | Function for parsing the case folding data from the Unicode Character
Database (UCD) and generating a lookup table. For more info on the UCD,
see the following website: https://www.unicode.org/ucd/ | [
"Function",
"for",
"parsing",
"the",
"case",
"folding",
"data",
"from",
"the",
"Unicode",
"Character",
"Database",
"(",
"UCD",
")",
"and",
"generating",
"a",
"lookup",
"table",
".",
"For",
"more",
"info",
"on",
"the",
"UCD",
"see",
"the",
"following",
"web... | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L473-L489 | train | Function for parsing the Unicode Character
database and generating a lookup table. |
leonidessaguisagjr/unicodeutil | unicodeutil/unicodeutil.py | CaseFoldingMap.lookup | def lookup(self, c, lookup_order="CF"):
"""
Function to lookup a character in the casefold map.
The casefold map has four sub-tables, the 'C' or common table, the 'F' or
full table, the 'S' or simple table and the 'T' or the Turkic special
case table. These tables correspond to... | python | def lookup(self, c, lookup_order="CF"):
"""
Function to lookup a character in the casefold map.
The casefold map has four sub-tables, the 'C' or common table, the 'F' or
full table, the 'S' or simple table and the 'T' or the Turkic special
case table. These tables correspond to... | [
"def",
"lookup",
"(",
"self",
",",
"c",
",",
"lookup_order",
"=",
"\"CF\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"c",
",",
"six",
".",
"text_type",
")",
":",
"raise",
"TypeError",
"(",
"u\"Character to lookup must be of type 'unicode'!\"",
")",
"for",
"... | Function to lookup a character in the casefold map.
The casefold map has four sub-tables, the 'C' or common table, the 'F' or
full table, the 'S' or simple table and the 'T' or the Turkic special
case table. These tables correspond to the statuses defined in the
CaseFolding.txt file. ... | [
"Function",
"to",
"lookup",
"a",
"character",
"in",
"the",
"casefold",
"map",
"."
] | c25c882cf9cb38c123df49fad365be67e5818928 | https://github.com/leonidessaguisagjr/unicodeutil/blob/c25c882cf9cb38c123df49fad365be67e5818928/unicodeutil/unicodeutil.py#L491-L516 | train | Function to lookup a character in the casefold map. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/models.py | RegistryResponse.load_from_json | def load_from_json(data):
"""
Load a :class:`RegistryReponse` from a dictionary or a string (that
will be parsed as json).
"""
if isinstance(data, str):
data = json.loads(data)
applications = [
ApplicationResponse.load_from_json(a) for a in data['a... | python | def load_from_json(data):
"""
Load a :class:`RegistryReponse` from a dictionary or a string (that
will be parsed as json).
"""
if isinstance(data, str):
data = json.loads(data)
applications = [
ApplicationResponse.load_from_json(a) for a in data['a... | [
"def",
"load_from_json",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"applications",
"=",
"[",
"ApplicationResponse",
".",
"load_from_json",
"(",
"a",
")",
"for",
"a... | Load a :class:`RegistryReponse` from a dictionary or a string (that
will be parsed as json). | [
"Load",
"a",
":",
"class",
":",
"RegistryReponse",
"from",
"a",
"dictionary",
"or",
"a",
"string",
"(",
"that",
"will",
"be",
"parsed",
"as",
"json",
")",
"."
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/models.py#L26-L39 | train | Load a RegistryResponse from a dictionary or a string. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/models.py | ApplicationResponse.load_from_json | def load_from_json(data):
"""
Load a :class:`ApplicationResponse` from a dictionary or string (that
will be parsed as json).
"""
if isinstance(data, str):
data = json.loads(data)
items = [Item.load_from_json(a) for a in data['items']] if data['items'] is not N... | python | def load_from_json(data):
"""
Load a :class:`ApplicationResponse` from a dictionary or string (that
will be parsed as json).
"""
if isinstance(data, str):
data = json.loads(data)
items = [Item.load_from_json(a) for a in data['items']] if data['items'] is not N... | [
"def",
"load_from_json",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"items",
"=",
"[",
"Item",
".",
"load_from_json",
"(",
"a",
")",
"for",
"a",
"in",
"data",
... | Load a :class:`ApplicationResponse` from a dictionary or string (that
will be parsed as json). | [
"Load",
"a",
":",
"class",
":",
"ApplicationResponse",
"from",
"a",
"dictionary",
"or",
"string",
"(",
"that",
"will",
"be",
"parsed",
"as",
"json",
")",
"."
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/models.py#L76-L87 | train | Load a : class : ApplicationResponse from a dictionary or string. |
OnroerendErfgoed/pyramid_urireferencer | pyramid_urireferencer/models.py | Item.load_from_json | def load_from_json(data):
"""
Load a :class:`Item` from a dictionary ot string (that will be parsed
as json)
"""
if isinstance(data, str):
data = json.loads(data)
return Item(data['title'], data['uri']) | python | def load_from_json(data):
"""
Load a :class:`Item` from a dictionary ot string (that will be parsed
as json)
"""
if isinstance(data, str):
data = json.loads(data)
return Item(data['title'], data['uri']) | [
"def",
"load_from_json",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"return",
"Item",
"(",
"data",
"[",
"'title'",
"]",
",",
"data",
"[",
"'uri'",
"]",
")"
] | Load a :class:`Item` from a dictionary ot string (that will be parsed
as json) | [
"Load",
"a",
":",
"class",
":",
"Item",
"from",
"a",
"dictionary",
"ot",
"string",
"(",
"that",
"will",
"be",
"parsed",
"as",
"json",
")"
] | c6ee4ba863e32ced304b9cf00f3f5b450757a29a | https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/models.py#L114-L121 | train | Load a : class : Item from a dictionary ot string |
tsnaomi/finnsyll | finnsyll/prev/v11.py | apply_T11 | def apply_T11(word):
'''If a VVV sequence contains a /u, y/-final diphthong and the third vowel
is /i/, there is a syllable boundary between the diphthong and /i/.'''
WORD = word
offset = 0
for vvv in t11_vvv_sequences(WORD):
# i = vvv.start(1) + (1 if vvv.group(1).startswith('i') else 2) +... | python | def apply_T11(word):
'''If a VVV sequence contains a /u, y/-final diphthong and the third vowel
is /i/, there is a syllable boundary between the diphthong and /i/.'''
WORD = word
offset = 0
for vvv in t11_vvv_sequences(WORD):
# i = vvv.start(1) + (1 if vvv.group(1).startswith('i') else 2) +... | [
"def",
"apply_T11",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vvv",
"in",
"t11_vvv_sequences",
"(",
"WORD",
")",
":",
"# i = vvv.start(1) + (1 if vvv.group(1).startswith('i') else 2) + offset",
"i",
"=",
"vvv",
".",
"start",
"(",
"1... | If a VVV sequence contains a /u, y/-final diphthong and the third vowel
is /i/, there is a syllable boundary between the diphthong and /i/. | [
"If",
"a",
"VVV",
"sequence",
"contains",
"a",
"/",
"u",
"y",
"/",
"-",
"final",
"diphthong",
"and",
"the",
"third",
"vowel",
"is",
"/",
"i",
"/",
"there",
"is",
"a",
"syllable",
"boundary",
"between",
"the",
"diphthong",
"and",
"/",
"i",
"/",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v11.py#L347-L361 | train | Apply T11 to a word. |
tsnaomi/finnsyll | finnsyll/prev/v09.py | _syllabify_simplex | def _syllabify_simplex(word):
'''Syllabify the given word.'''
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
rules += T2 + T8 + T9
# T4 produc... | python | def _syllabify_simplex(word):
'''Syllabify the given word.'''
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
rules += T2 + T8 + T9
# T4 produc... | [
"def",
"_syllabify_simplex",
"(",
"word",
")",
":",
"word",
",",
"rules",
"=",
"apply_T1",
"(",
"word",
")",
"if",
"re",
".",
"search",
"(",
"r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*'",
",",
"word",
")",
":",
"word",
",",
"T2",
"=",
"apply_T2",
"(",
"word... | Syllabify the given word. | [
"Syllabify",
"the",
"given",
"word",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v09.py#L66-L95 | train | Syllabify the given word. |
tsnaomi/finnsyll | finnsyll/prev/v09.py | apply_T10 | def apply_T10(word):
'''Any /iou/ sequence contains a syllable boundary between the first and
second vowel.'''
WORD = word
offset = 0
for iou in iou_sequences(WORD):
i = iou.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T10' if word != WORD... | python | def apply_T10(word):
'''Any /iou/ sequence contains a syllable boundary between the first and
second vowel.'''
WORD = word
offset = 0
for iou in iou_sequences(WORD):
i = iou.start(1) + 1 + offset
WORD = WORD[:i] + '.' + WORD[i:]
offset += 1
RULE = ' T10' if word != WORD... | [
"def",
"apply_T10",
"(",
"word",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"iou",
"in",
"iou_sequences",
"(",
"WORD",
")",
":",
"i",
"=",
"iou",
".",
"start",
"(",
"1",
")",
"+",
"1",
"+",
"offset",
"WORD",
"=",
"WORD",
"[",
":"... | Any /iou/ sequence contains a syllable boundary between the first and
second vowel. | [
"Any",
"/",
"iou",
"/",
"sequence",
"contains",
"a",
"syllable",
"boundary",
"between",
"the",
"first",
"and",
"second",
"vowel",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v09.py#L354-L367 | train | Any iou sequence contains a syllable boundary between the first and the second vowel. |
tsnaomi/finnsyll | finnsyll/v13.py | T1 | def T1(word):
'''Insert a syllable boundary in front of every CV sequence.'''
# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
WORD = [i for i in re.split(r'([ieaouäöy]+)', word, flags=FLAGS) if i]
# keep track of which sub-rules are applying
sub_rules = set()
# a count ... | python | def T1(word):
'''Insert a syllable boundary in front of every CV sequence.'''
# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']
WORD = [i for i in re.split(r'([ieaouäöy]+)', word, flags=FLAGS) if i]
# keep track of which sub-rules are applying
sub_rules = set()
# a count ... | [
"def",
"T1",
"(",
"word",
")",
":",
"# split consonants and vowels: 'balloon' -> ['b', 'a', 'll', 'oo', 'n']",
"WORD",
"=",
"[",
"i",
"for",
"i",
"in",
"re",
".",
"split",
"(",
"r'([ieaouäöy]+)', ",
"w",
"rd, ",
"f",
"ags=F",
"L",
"AGS) ",
"i",
" i",
"",
"",
... | Insert a syllable boundary in front of every CV sequence. | [
"Insert",
"a",
"syllable",
"boundary",
"in",
"front",
"of",
"every",
"CV",
"sequence",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L80-L158 | train | T1 - > T1. |
tsnaomi/finnsyll | finnsyll/v13.py | T2 | def T2(word, rules):
'''Split any VV sequence that is not a genuine diphthong or long vowel.
E.g., [ta.e], [ko.et.taa]. This rule can apply within VVV+ sequences.'''
WORD = word
offset = 0
for vv in vv_sequences(WORD):
seq = vv.group(1)
if not phon.is_diphthong(seq) and not phon.is... | python | def T2(word, rules):
'''Split any VV sequence that is not a genuine diphthong or long vowel.
E.g., [ta.e], [ko.et.taa]. This rule can apply within VVV+ sequences.'''
WORD = word
offset = 0
for vv in vv_sequences(WORD):
seq = vv.group(1)
if not phon.is_diphthong(seq) and not phon.is... | [
"def",
"T2",
"(",
"word",
",",
"rules",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vv",
"in",
"vv_sequences",
"(",
"WORD",
")",
":",
"seq",
"=",
"vv",
".",
"group",
"(",
"1",
")",
"if",
"not",
"phon",
".",
"is_diphthong",
"(",
"... | Split any VV sequence that is not a genuine diphthong or long vowel.
E.g., [ta.e], [ko.et.taa]. This rule can apply within VVV+ sequences. | [
"Split",
"any",
"VV",
"sequence",
"that",
"is",
"not",
"a",
"genuine",
"diphthong",
"or",
"long",
"vowel",
".",
"E",
".",
"g",
".",
"[",
"ta",
".",
"e",
"]",
"[",
"ko",
".",
"et",
".",
"taa",
"]",
".",
"This",
"rule",
"can",
"apply",
"within",
... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L163-L179 | train | Split any VV sequence that is not a genuine diphthong or long vowel.
Eg., [ ta. e ko. et. taa ]. This rule can apply within VVV + sequences. |
tsnaomi/finnsyll | finnsyll/v13.py | T4 | def T4(word, rules):
'''Optionally split /u,y/-final diphthongs that do not take primary stress.
E.g., [lau.ka.us], [va.ka.ut.taa].'''
WORD = re.split(
r'([ieaouäöy]+[^ieaouäöy]+\.*[ieaoäö]{1}(?:u|y)(?:\.*[^ieaouäöy]+|$))', # noqa
word, flags=re.I | re.U)
PARTS = [[] for part in range(... | python | def T4(word, rules):
'''Optionally split /u,y/-final diphthongs that do not take primary stress.
E.g., [lau.ka.us], [va.ka.ut.taa].'''
WORD = re.split(
r'([ieaouäöy]+[^ieaouäöy]+\.*[ieaoäö]{1}(?:u|y)(?:\.*[^ieaouäöy]+|$))', # noqa
word, flags=re.I | re.U)
PARTS = [[] for part in range(... | [
"def",
"T4",
"(",
"word",
",",
"rules",
")",
":",
"WORD",
"=",
"re",
".",
"split",
"(",
"r'([ieaouäöy]+[^ieaouäöy]+\\.*[ieaoäö]{1}(?:u|y)(?:\\.*[^ieaouäöy]+|$))', # noq",
"a",
"",
"word",
",",
"flags",
"=",
"re",
".",
"I",
"|",
"re",
".",
"U",
")",
"PARTS",... | Optionally split /u,y/-final diphthongs that do not take primary stress.
E.g., [lau.ka.us], [va.ka.ut.taa]. | [
"Optionally",
"split",
"/",
"u",
"y",
"/",
"-",
"final",
"diphthongs",
"that",
"do",
"not",
"take",
"primary",
"stress",
".",
"E",
".",
"g",
".",
"[",
"lau",
".",
"ka",
".",
"us",
"]",
"[",
"va",
".",
"ka",
".",
"ut",
".",
"taa",
"]",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L190-L217 | train | T4 generator for all the rules in the current language. |
tsnaomi/finnsyll | finnsyll/v13.py | T6 | def T6(word, rules):
'''If a VVV-sequence contains a long vowel, insert a syllable boundary
between it and the third vowel. E.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
offset = 0
try:
WORD, rest = tuple(word.split('.', 1))
for vvv in long_vowel_sequences(rest):
... | python | def T6(word, rules):
'''If a VVV-sequence contains a long vowel, insert a syllable boundary
between it and the third vowel. E.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te].'''
offset = 0
try:
WORD, rest = tuple(word.split('.', 1))
for vvv in long_vowel_sequences(rest):
... | [
"def",
"T6",
"(",
"word",
",",
"rules",
")",
":",
"offset",
"=",
"0",
"try",
":",
"WORD",
",",
"rest",
"=",
"tuple",
"(",
"word",
".",
"split",
"(",
"'.'",
",",
"1",
")",
")",
"for",
"vvv",
"in",
"long_vowel_sequences",
"(",
"rest",
")",
":",
"... | If a VVV-sequence contains a long vowel, insert a syllable boundary
between it and the third vowel. E.g. [kor.ke.aa], [yh.ti.öön], [ruu.an],
[mää.yt.te]. | [
"If",
"a",
"VVV",
"-",
"sequence",
"contains",
"a",
"long",
"vowel",
"insert",
"a",
"syllable",
"boundary",
"between",
"it",
"and",
"the",
"third",
"vowel",
".",
"E",
".",
"g",
".",
"[",
"kor",
".",
"ke",
".",
"aa",
"]",
"[",
"yh",
".",
"ti",
"."... | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L222-L253 | train | T6 is a word - > a VVV - sequence contains a long vowel insert a syllable boundary
between it and the third vowel. E. g. kor. ku. ti. öön. |
tsnaomi/finnsyll | finnsyll/v13.py | T8 | def T8(word, rules):
'''Join /ie/, /uo/, or /yö/ sequences in syllables that take primary
stress.'''
WORD = word
try:
vv = tail_diphthongs(WORD)
i = vv.start(1) + 1
WORD = WORD[:i] + word[i + 1:]
except AttributeError:
pass
rules += ' T8' if word != WORD else '... | python | def T8(word, rules):
'''Join /ie/, /uo/, or /yö/ sequences in syllables that take primary
stress.'''
WORD = word
try:
vv = tail_diphthongs(WORD)
i = vv.start(1) + 1
WORD = WORD[:i] + word[i + 1:]
except AttributeError:
pass
rules += ' T8' if word != WORD else '... | [
"def",
"T8",
"(",
"word",
",",
"rules",
")",
":",
"WORD",
"=",
"word",
"try",
":",
"vv",
"=",
"tail_diphthongs",
"(",
"WORD",
")",
"i",
"=",
"vv",
".",
"start",
"(",
"1",
")",
"+",
"1",
"WORD",
"=",
"WORD",
"[",
":",
"i",
"]",
"+",
"word",
... | Join /ie/, /uo/, or /yö/ sequences in syllables that take primary
stress. | [
"Join",
"/",
"ie",
"/",
"/",
"uo",
"/",
"or",
"/",
"yö",
"/",
"sequences",
"in",
"syllables",
"that",
"take",
"primary",
"stress",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L258-L273 | train | Join IE UO or Yö or Yö sequences in syllables that take primary
stress. |
tsnaomi/finnsyll | finnsyll/v13.py | T11 | def T11(word, rules):
'''If a VVV sequence contains a /u,y/-final diphthong, insert a syllable
boundary between the diphthong and the third vowel.'''
WORD = word
offset = 0
for vvv in precedence_sequences(WORD):
i = vvv.start(1) + (1 if vvv.group(1)[-1] in 'uyUY' else 2) + offset
WO... | python | def T11(word, rules):
'''If a VVV sequence contains a /u,y/-final diphthong, insert a syllable
boundary between the diphthong and the third vowel.'''
WORD = word
offset = 0
for vvv in precedence_sequences(WORD):
i = vvv.start(1) + (1 if vvv.group(1)[-1] in 'uyUY' else 2) + offset
WO... | [
"def",
"T11",
"(",
"word",
",",
"rules",
")",
":",
"WORD",
"=",
"word",
"offset",
"=",
"0",
"for",
"vvv",
"in",
"precedence_sequences",
"(",
"WORD",
")",
":",
"i",
"=",
"vvv",
".",
"start",
"(",
"1",
")",
"+",
"(",
"1",
"if",
"vvv",
".",
"group... | If a VVV sequence contains a /u,y/-final diphthong, insert a syllable
boundary between the diphthong and the third vowel. | [
"If",
"a",
"VVV",
"sequence",
"contains",
"a",
"/",
"u",
"y",
"/",
"-",
"final",
"diphthong",
"insert",
"a",
"syllable",
"boundary",
"between",
"the",
"diphthong",
"and",
"the",
"third",
"vowel",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L278-L291 | train | T11 is a special case for the T11 word. |
tsnaomi/finnsyll | finnsyll/v13.py | pk_prom | def pk_prom(word):
'''Return the number of stressed light syllables.'''
violations = 0
stressed = []
for w in extract_words(word):
stressed += w.split('.')[2:-1:2] # odd syllables, excl. word-initial
# (CVV = light)
for syll in stressed:
if phon.is_vowel(syll[-1]):
... | python | def pk_prom(word):
'''Return the number of stressed light syllables.'''
violations = 0
stressed = []
for w in extract_words(word):
stressed += w.split('.')[2:-1:2] # odd syllables, excl. word-initial
# (CVV = light)
for syll in stressed:
if phon.is_vowel(syll[-1]):
... | [
"def",
"pk_prom",
"(",
"word",
")",
":",
"violations",
"=",
"0",
"stressed",
"=",
"[",
"]",
"for",
"w",
"in",
"extract_words",
"(",
"word",
")",
":",
"stressed",
"+=",
"w",
".",
"split",
"(",
"'.'",
")",
"[",
"2",
":",
"-",
"1",
":",
"2",
"]",
... | Return the number of stressed light syllables. | [
"Return",
"the",
"number",
"of",
"stressed",
"light",
"syllables",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L373-L392 | train | Return the number of stressed light syllables. |
tsnaomi/finnsyll | finnsyll/v13.py | rank | def rank(syllabifications):
'''Rank syllabifications.'''
# def key(s):
# word = s[0]
# w = wsp(word)
# p = pk_prom(word)
# n = nuc(word)
# t = w + p + n
# print('%s\twsp: %s\tpk: %s\tnuc: %s\ttotal: %s' % (word, w, p, n, t))
# return w + p + n
# syl... | python | def rank(syllabifications):
'''Rank syllabifications.'''
# def key(s):
# word = s[0]
# w = wsp(word)
# p = pk_prom(word)
# n = nuc(word)
# t = w + p + n
# print('%s\twsp: %s\tpk: %s\tnuc: %s\ttotal: %s' % (word, w, p, n, t))
# return w + p + n
# syl... | [
"def",
"rank",
"(",
"syllabifications",
")",
":",
"# def key(s):",
"# word = s[0]",
"# w = wsp(word)",
"# p = pk_prom(word)",
"# n = nuc(word)",
"# t = w + p + n",
"# print('%s\\twsp: %s\\tpk: %s\\tnuc: %s\\ttotal: %s' % (word, w, p, n, t))",
"# return w + p + n... | Rank syllabifications. | [
"Rank",
"syllabifications",
"."
] | 6a42740311688c946a636a3e2304866c7aa041b3 | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/v13.py#L400-L417 | train | Rank syllabifications. |
moralrecordings/mrcrowbar | mrcrowbar/lib/images/base.py | CodecImage.ansi_format_iter | def ansi_format_iter( self, x_start=0, y_start=0, width=None, height=None, frame=0, columns=1, downsample=1 ):
"""Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the t... | python | def ansi_format_iter( self, x_start=0, y_start=0, width=None, height=None, frame=0, columns=1, downsample=1 ):
"""Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the t... | [
"def",
"ansi_format_iter",
"(",
"self",
",",
"x_start",
"=",
"0",
",",
"y_start",
"=",
"0",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"frame",
"=",
"0",
",",
"columns",
"=",
"1",
",",
"downsample",
"=",
"1",
")",
":",
"image",
"... | Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the top of the image data to render from. Defaults to 0.
width
Width of the image data to render. Defaults... | [
"Return",
"the",
"ANSI",
"escape",
"sequence",
"to",
"render",
"the",
"image",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/lib/images/base.py#L87-L139 | train | Return an iterator over the ANSI escape sequences that can be used to render the image. |
moralrecordings/mrcrowbar | mrcrowbar/lib/images/base.py | IndexedImage.ansi_format_iter | def ansi_format_iter( self, x_start=0, y_start=0, width=None, height=None, frame=0, columns=1, downsample=1, frame_index=None, frame_flip_v=0, frame_flip_h=0 ):
"""Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to... | python | def ansi_format_iter( self, x_start=0, y_start=0, width=None, height=None, frame=0, columns=1, downsample=1, frame_index=None, frame_flip_v=0, frame_flip_h=0 ):
"""Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to... | [
"def",
"ansi_format_iter",
"(",
"self",
",",
"x_start",
"=",
"0",
",",
"y_start",
"=",
"0",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"frame",
"=",
"0",
",",
"columns",
"=",
"1",
",",
"downsample",
"=",
"1",
",",
"frame_index",
"=... | Return the ANSI escape sequence to render the image.
x_start
Offset from the left of the image data to render from. Defaults to 0.
y_start
Offset from the top of the image data to render from. Defaults to 0.
width
Width of the image data to render. Defaults... | [
"Return",
"the",
"ANSI",
"escape",
"sequence",
"to",
"render",
"the",
"image",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/lib/images/base.py#L192-L270 | train | Return an iterator over the ANSI escape sequences that can be used to render the image. |
obulpathi/cdn-fastly-python | bin/fastly_purge_url.py | main | def main():
"""
Purge a single fastly url
"""
parser = OptionParser(description=
"Purge a single url from fastly.")
parser.add_option("-k", "--key", dest="apikey",
default="", help="fastly api key")
parser.add_option("-H", "--host", dest="host",
... | python | def main():
"""
Purge a single fastly url
"""
parser = OptionParser(description=
"Purge a single url from fastly.")
parser.add_option("-k", "--key", dest="apikey",
default="", help="fastly api key")
parser.add_option("-H", "--host", dest="host",
... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
"description",
"=",
"\"Purge a single url from fastly.\"",
")",
"parser",
".",
"add_option",
"(",
"\"-k\"",
",",
"\"--key\"",
",",
"dest",
"=",
"\"apikey\"",
",",
"default",
"=",
"\"\"",
",",
... | Purge a single fastly url | [
"Purge",
"a",
"single",
"fastly",
"url"
] | db2564b047e8af4bce72c3b88d6c27d3d0291425 | https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/bin/fastly_purge_url.py#L34-L57 | train | Purges a single fastly url from fastly. |
benoitkugler/abstractDataLibrary | pyDLib/GUI/tabs.py | abstractModule.set_callbacks | def set_callbacks(self, **dic_functions):
"""Register callbacks needed by the interface object"""
for action in self.interface.CALLBACKS:
try:
f = dic_functions[action]
except KeyError:
pass
else:
setattr(self.interface.... | python | def set_callbacks(self, **dic_functions):
"""Register callbacks needed by the interface object"""
for action in self.interface.CALLBACKS:
try:
f = dic_functions[action]
except KeyError:
pass
else:
setattr(self.interface.... | [
"def",
"set_callbacks",
"(",
"self",
",",
"*",
"*",
"dic_functions",
")",
":",
"for",
"action",
"in",
"self",
".",
"interface",
".",
"CALLBACKS",
":",
"try",
":",
"f",
"=",
"dic_functions",
"[",
"action",
"]",
"except",
"KeyError",
":",
"pass",
"else",
... | Register callbacks needed by the interface object | [
"Register",
"callbacks",
"needed",
"by",
"the",
"interface",
"object"
] | 16be28e99837e40287a63803bbfdf67ac1806b7b | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/tabs.py#L37-L53 | train | Register callbacks needed by the interface object. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Configurable.populate | def populate(self, obj=None, section=None, parse_types=True):
"""Set attributes in ``obj`` with ``setattr`` from the all values in
``section``.
"""
section = self.default_section if section is None else section
obj = Settings() if obj is None else obj
is_dict = isinstanc... | python | def populate(self, obj=None, section=None, parse_types=True):
"""Set attributes in ``obj`` with ``setattr`` from the all values in
``section``.
"""
section = self.default_section if section is None else section
obj = Settings() if obj is None else obj
is_dict = isinstanc... | [
"def",
"populate",
"(",
"self",
",",
"obj",
"=",
"None",
",",
"section",
"=",
"None",
",",
"parse_types",
"=",
"True",
")",
":",
"section",
"=",
"self",
".",
"default_section",
"if",
"section",
"is",
"None",
"else",
"section",
"obj",
"=",
"Settings",
"... | Set attributes in ``obj`` with ``setattr`` from the all values in
``section``. | [
"Set",
"attributes",
"in",
"obj",
"with",
"setattr",
"from",
"the",
"all",
"values",
"in",
"section",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L49-L77 | train | Populates obj with the values from the all values in section. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Configurable._get_calling_module | def _get_calling_module(self):
"""Get the last module in the call stack that is not this module or ``None`` if
the call originated from this module.
"""
for frame in inspect.stack():
mod = inspect.getmodule(frame[0])
logger.debug(f'calling module: {mod}')
... | python | def _get_calling_module(self):
"""Get the last module in the call stack that is not this module or ``None`` if
the call originated from this module.
"""
for frame in inspect.stack():
mod = inspect.getmodule(frame[0])
logger.debug(f'calling module: {mod}')
... | [
"def",
"_get_calling_module",
"(",
"self",
")",
":",
"for",
"frame",
"in",
"inspect",
".",
"stack",
"(",
")",
":",
"mod",
"=",
"inspect",
".",
"getmodule",
"(",
"frame",
"[",
"0",
"]",
")",
"logger",
".",
"debug",
"(",
"f'calling module: {mod}'",
")",
... | Get the last module in the call stack that is not this module or ``None`` if
the call originated from this module. | [
"Get",
"the",
"last",
"module",
"in",
"the",
"call",
"stack",
"that",
"is",
"not",
"this",
"module",
"or",
"None",
"if",
"the",
"call",
"originated",
"from",
"this",
"module",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L79-L90 | train | Get the module that is calling this function. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Configurable.resource_filename | def resource_filename(self, resource_name, module_name=None):
"""Return a resource based on a file name. This uses the ``pkg_resources``
package first to find the resources. If it doesn't find it, it returns
a path on the file system.
:param: resource_name the file name of the resourc... | python | def resource_filename(self, resource_name, module_name=None):
"""Return a resource based on a file name. This uses the ``pkg_resources``
package first to find the resources. If it doesn't find it, it returns
a path on the file system.
:param: resource_name the file name of the resourc... | [
"def",
"resource_filename",
"(",
"self",
",",
"resource_name",
",",
"module_name",
"=",
"None",
")",
":",
"if",
"module_name",
"is",
"None",
":",
"mod",
"=",
"self",
".",
"_get_calling_module",
"(",
")",
"logger",
".",
"debug",
"(",
"f'calling module: {mod}'",... | Return a resource based on a file name. This uses the ``pkg_resources``
package first to find the resources. If it doesn't find it, it returns
a path on the file system.
:param: resource_name the file name of the resource to obtain (or name
if obtained from an installed module)
... | [
"Return",
"a",
"resource",
"based",
"on",
"a",
"file",
"name",
".",
"This",
"uses",
"the",
"pkg_resources",
"package",
"first",
"to",
"find",
"the",
"resources",
".",
"If",
"it",
"doesn",
"t",
"find",
"it",
"it",
"returns",
"a",
"path",
"on",
"the",
"f... | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L92-L115 | train | Return a resource based on a file name. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.parser | def parser(self):
"Load the configuration file."
if not hasattr(self, '_conf'):
cfile = self.config_file
logger.debug('loading config %s' % cfile)
if os.path.isfile(cfile):
conf = self._create_config_parser()
conf.read(os.path.expanduse... | python | def parser(self):
"Load the configuration file."
if not hasattr(self, '_conf'):
cfile = self.config_file
logger.debug('loading config %s' % cfile)
if os.path.isfile(cfile):
conf = self._create_config_parser()
conf.read(os.path.expanduse... | [
"def",
"parser",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_conf'",
")",
":",
"cfile",
"=",
"self",
".",
"config_file",
"logger",
".",
"debug",
"(",
"'loading config %s'",
"%",
"cfile",
")",
"if",
"os",
".",
"path",
".",
"isf... | Load the configuration file. | [
"Load",
"the",
"configuration",
"file",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L144-L159 | train | Load the configuration file. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_options | def get_options(self, section='default', opt_keys=None, vars=None):
"""
Get all options for a section. If ``opt_keys`` is given return
only options with those keys.
"""
vars = vars if vars else self.default_vars
conf = self.parser
opts = {}
if opt_keys is... | python | def get_options(self, section='default', opt_keys=None, vars=None):
"""
Get all options for a section. If ``opt_keys`` is given return
only options with those keys.
"""
vars = vars if vars else self.default_vars
conf = self.parser
opts = {}
if opt_keys is... | [
"def",
"get_options",
"(",
"self",
",",
"section",
"=",
"'default'",
",",
"opt_keys",
"=",
"None",
",",
"vars",
"=",
"None",
")",
":",
"vars",
"=",
"vars",
"if",
"vars",
"else",
"self",
".",
"default_vars",
"conf",
"=",
"self",
".",
"parser",
"opts",
... | Get all options for a section. If ``opt_keys`` is given return
only options with those keys. | [
"Get",
"all",
"options",
"for",
"a",
"section",
".",
"If",
"opt_keys",
"is",
"given",
"return",
"only",
"options",
"with",
"those",
"keys",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L165-L188 | train | Get all options for a section. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option | def get_option(self, name, section=None, vars=None, expect=None):
"""Return an option from ``section`` with ``name``.
:param section: section in the ini file to fetch the value; defaults to
constructor's ``default_section``
"""
vars = vars if vars else self.default_vars
... | python | def get_option(self, name, section=None, vars=None, expect=None):
"""Return an option from ``section`` with ``name``.
:param section: section in the ini file to fetch the value; defaults to
constructor's ``default_section``
"""
vars = vars if vars else self.default_vars
... | [
"def",
"get_option",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
")",
":",
"vars",
"=",
"vars",
"if",
"vars",
"else",
"self",
".",
"default_vars",
"if",
"section",
"is",
"None",
":",
... | Return an option from ``section`` with ``name``.
:param section: section in the ini file to fetch the value; defaults to
constructor's ``default_section`` | [
"Return",
"an",
"option",
"from",
"section",
"with",
"name",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L190-L206 | train | Return an option from section with name. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option_list | def get_option_list(self, name, section=None, vars=None,
expect=None, separator=','):
"""Just like ``get_option`` but parse as a list using ``split``.
"""
val = self.get_option(name, section, vars, expect)
return val.split(separator) if val else [] | python | def get_option_list(self, name, section=None, vars=None,
expect=None, separator=','):
"""Just like ``get_option`` but parse as a list using ``split``.
"""
val = self.get_option(name, section, vars, expect)
return val.split(separator) if val else [] | [
"def",
"get_option_list",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
",",
"separator",
"=",
"','",
")",
":",
"val",
"=",
"self",
".",
"get_option",
"(",
"name",
",",
"section",
",",
... | Just like ``get_option`` but parse as a list using ``split``. | [
"Just",
"like",
"get_option",
"but",
"parse",
"as",
"a",
"list",
"using",
"split",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L208-L214 | train | Return a list of values from the option named name in section. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option_boolean | def get_option_boolean(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a boolean (any case `true`).
"""
val = self.get_option(name, section, vars, expect)
val = val.lower() if val else 'false'
return val == 'true' | python | def get_option_boolean(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a boolean (any case `true`).
"""
val = self.get_option(name, section, vars, expect)
val = val.lower() if val else 'false'
return val == 'true' | [
"def",
"get_option_boolean",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get_option",
"(",
"name",
",",
"section",
",",
"vars",
",",
"expect",
")",
... | Just like ``get_option`` but parse as a boolean (any case `true`). | [
"Just",
"like",
"get_option",
"but",
"parse",
"as",
"a",
"boolean",
"(",
"any",
"case",
"true",
")",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L216-L222 | train | Get option as a boolean. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option_int | def get_option_int(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as an integer."""
val = self.get_option(name, section, vars, expect)
if val:
return int(val) | python | def get_option_int(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as an integer."""
val = self.get_option(name, section, vars, expect)
if val:
return int(val) | [
"def",
"get_option_int",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get_option",
"(",
"name",
",",
"section",
",",
"vars",
",",
"expect",
")",
"if... | Just like ``get_option`` but parse as an integer. | [
"Just",
"like",
"get_option",
"but",
"parse",
"as",
"an",
"integer",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L224-L228 | train | Just like get_option but parse as an integer. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option_float | def get_option_float(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a float."""
val = self.get_option(name, section, vars, expect)
if val:
return float(val) | python | def get_option_float(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but parse as a float."""
val = self.get_option(name, section, vars, expect)
if val:
return float(val) | [
"def",
"get_option_float",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get_option",
"(",
"name",
",",
"section",
",",
"vars",
",",
"expect",
")",
"... | Just like ``get_option`` but parse as a float. | [
"Just",
"like",
"get_option",
"but",
"parse",
"as",
"a",
"float",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L230-L234 | train | Just like get_option but parse as a float. |
plandes/actioncli | src/python/zensols/actioncli/config.py | Config.get_option_path | def get_option_path(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but return a ``pathlib.Path`` object of
the string.
"""
val = self.get_option(name, section, vars, expect)
return Path(val) | python | def get_option_path(self, name, section=None, vars=None, expect=None):
"""Just like ``get_option`` but return a ``pathlib.Path`` object of
the string.
"""
val = self.get_option(name, section, vars, expect)
return Path(val) | [
"def",
"get_option_path",
"(",
"self",
",",
"name",
",",
"section",
"=",
"None",
",",
"vars",
"=",
"None",
",",
"expect",
"=",
"None",
")",
":",
"val",
"=",
"self",
".",
"get_option",
"(",
"name",
",",
"section",
",",
"vars",
",",
"expect",
")",
"r... | Just like ``get_option`` but return a ``pathlib.Path`` object of
the string. | [
"Just",
"like",
"get_option",
"but",
"return",
"a",
"pathlib",
".",
"Path",
"object",
"of",
"the",
"string",
"."
] | d1c4ea27e6f3394b30a1652ddd4b916160662773 | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L236-L242 | train | Like get_option but return a Path object of
the string. |
moralrecordings/mrcrowbar | mrcrowbar/refs.py | property_get | def property_get( prop, instance, **kwargs ):
"""Wrapper for property reads which auto-dereferences Refs if required.
prop
A Ref (which gets dereferenced and returned) or any other value (which gets returned).
instance
The context object used to dereference the Ref.
"""
if isinstan... | python | def property_get( prop, instance, **kwargs ):
"""Wrapper for property reads which auto-dereferences Refs if required.
prop
A Ref (which gets dereferenced and returned) or any other value (which gets returned).
instance
The context object used to dereference the Ref.
"""
if isinstan... | [
"def",
"property_get",
"(",
"prop",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"prop",
",",
"Ref",
")",
":",
"return",
"prop",
".",
"get",
"(",
"instance",
",",
"*",
"*",
"kwargs",
")",
"return",
"prop"
] | Wrapper for property reads which auto-dereferences Refs if required.
prop
A Ref (which gets dereferenced and returned) or any other value (which gets returned).
instance
The context object used to dereference the Ref. | [
"Wrapper",
"for",
"property",
"reads",
"which",
"auto",
"-",
"dereferences",
"Refs",
"if",
"required",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/refs.py#L101-L112 | train | Wrapper for property reads which auto - dereferences Refs if required. |
moralrecordings/mrcrowbar | mrcrowbar/refs.py | property_set | def property_set( prop, instance, value, **kwargs ):
"""Wrapper for property writes which auto-deferences Refs.
prop
A Ref (which gets dereferenced and the target value set).
instance
The context object used to dereference the Ref.
value
The value to set the property to.
... | python | def property_set( prop, instance, value, **kwargs ):
"""Wrapper for property writes which auto-deferences Refs.
prop
A Ref (which gets dereferenced and the target value set).
instance
The context object used to dereference the Ref.
value
The value to set the property to.
... | [
"def",
"property_set",
"(",
"prop",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"prop",
",",
"Ref",
")",
":",
"return",
"prop",
".",
"set",
"(",
"instance",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
... | Wrapper for property writes which auto-deferences Refs.
prop
A Ref (which gets dereferenced and the target value set).
instance
The context object used to dereference the Ref.
value
The value to set the property to.
Throws AttributeError if prop is not a Ref. | [
"Wrapper",
"for",
"property",
"writes",
"which",
"auto",
"-",
"deferences",
"Refs",
"."
] | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/refs.py#L115-L132 | train | Wrapper for property. set |
moralrecordings/mrcrowbar | mrcrowbar/refs.py | view_property | def view_property( prop ):
"""Wrapper for attributes of a View class which auto-dereferences Refs.
Equivalent to setting a property on the class with the getter wrapped
with property_get(), and the setter wrapped with property_set().
prop
A string containing the name of the class attribute... | python | def view_property( prop ):
"""Wrapper for attributes of a View class which auto-dereferences Refs.
Equivalent to setting a property on the class with the getter wrapped
with property_get(), and the setter wrapped with property_set().
prop
A string containing the name of the class attribute... | [
"def",
"view_property",
"(",
"prop",
")",
":",
"def",
"getter",
"(",
"self",
")",
":",
"return",
"property_get",
"(",
"getattr",
"(",
"self",
",",
"prop",
")",
",",
"self",
".",
"parent",
")",
"def",
"setter",
"(",
"self",
",",
"value",
")",
":",
"... | Wrapper for attributes of a View class which auto-dereferences Refs.
Equivalent to setting a property on the class with the getter wrapped
with property_get(), and the setter wrapped with property_set().
prop
A string containing the name of the class attribute to wrap. | [
"Wrapper",
"for",
"attributes",
"of",
"a",
"View",
"class",
"which",
"auto",
"-",
"dereferences",
"Refs",
".",
"Equivalent",
"to",
"setting",
"a",
"property",
"on",
"the",
"class",
"with",
"the",
"getter",
"wrapped",
"with",
"property_get",
"()",
"and",
"the... | b1ed882c4555552e7656b2d84aca543184577fa3 | https://github.com/moralrecordings/mrcrowbar/blob/b1ed882c4555552e7656b2d84aca543184577fa3/mrcrowbar/refs.py#L135-L150 | train | A property decorator for attributes of a View class which auto - dereferences Refs. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.