repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
DataONEorg/d1_python | lib_common/src/d1_common/utils/progress_logger.py | ProgressLogger.event | def event(self, event_name):
"""Register an event that occurred during processing of a task of the given
type.
Args: event_name: str A name for a type of events. Events of the
same type are displayed as a single entry and a total count of
occurences.
... | python | def event(self, event_name):
"""Register an event that occurred during processing of a task of the given
type.
Args: event_name: str A name for a type of events. Events of the
same type are displayed as a single entry and a total count of
occurences.
... | [
"def",
"event",
"(",
"self",
",",
"event_name",
")",
":",
"self",
".",
"_event_dict",
".",
"setdefault",
"(",
"event_name",
",",
"0",
")",
"self",
".",
"_event_dict",
"[",
"event_name",
"]",
"+=",
"1",
"self",
".",
"_log_progress_if_interval_elapsed",
"(",
... | Register an event that occurred during processing of a task of the given
type.
Args: event_name: str A name for a type of events. Events of the
same type are displayed as a single entry and a total count of
occurences. | [
"Register",
"an",
"event",
"that",
"occurred",
"during",
"processing",
"of",
"a",
"task",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/utils/progress_logger.py#L195-L206 |
wilson-eft/wilson | wilson/run/wet/rge.py | get_permissible_wcs | def get_permissible_wcs(classname, f):
r"""For some classes (in particular $\Delta F=1$), only a subset of Wilson
coefficients exist in WET-3 and WET-4. Therefore, depending on the number
of flavours `f`, the dimensionality of the ADM has to be reduced."""
# these are the problematic sectors
classes... | python | def get_permissible_wcs(classname, f):
r"""For some classes (in particular $\Delta F=1$), only a subset of Wilson
coefficients exist in WET-3 and WET-4. Therefore, depending on the number
of flavours `f`, the dimensionality of the ADM has to be reduced."""
# these are the problematic sectors
classes... | [
"def",
"get_permissible_wcs",
"(",
"classname",
",",
"f",
")",
":",
"# these are the problematic sectors",
"classes",
"=",
"[",
"'cu'",
",",
"'db'",
",",
"'sb'",
",",
"'sd'",
",",
"'mue'",
",",
"'mutau'",
",",
"'taue'",
",",
"'dF0'",
"]",
"if",
"classname",
... | r"""For some classes (in particular $\Delta F=1$), only a subset of Wilson
coefficients exist in WET-3 and WET-4. Therefore, depending on the number
of flavours `f`, the dimensionality of the ADM has to be reduced. | [
"r",
"For",
"some",
"classes",
"(",
"in",
"particular",
"$",
"\\",
"Delta",
"F",
"=",
"1$",
")",
"only",
"a",
"subset",
"of",
"Wilson",
"coefficients",
"exist",
"in",
"WET",
"-",
"3",
"and",
"WET",
"-",
"4",
".",
"Therefore",
"depending",
"on",
"the"... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/rge.py#L14-L33 |
wilson-eft/wilson | wilson/run/wet/rge.py | admeig | def admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Compute the eigenvalues and eigenvectors for a QCD anomalous dimension
matrix that is defined in `adm.adm_s_X` where X is the name of the sector.
Supports memoization. Output analogous to `np.linalg.eig`."""
args = f, m_u, m_d, m_s... | python | def admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Compute the eigenvalues and eigenvectors for a QCD anomalous dimension
matrix that is defined in `adm.adm_s_X` where X is the name of the sector.
Supports memoization. Output analogous to `np.linalg.eig`."""
args = f, m_u, m_d, m_s... | [
"def",
"admeig",
"(",
"classname",
",",
"f",
",",
"m_u",
",",
"m_d",
",",
"m_s",
",",
"m_c",
",",
"m_b",
",",
"m_e",
",",
"m_mu",
",",
"m_tau",
")",
":",
"args",
"=",
"f",
",",
"m_u",
",",
"m_d",
",",
"m_s",
",",
"m_c",
",",
"m_b",
",",
"m_... | Compute the eigenvalues and eigenvectors for a QCD anomalous dimension
matrix that is defined in `adm.adm_s_X` where X is the name of the sector.
Supports memoization. Output analogous to `np.linalg.eig`. | [
"Compute",
"the",
"eigenvalues",
"and",
"eigenvectors",
"for",
"a",
"QCD",
"anomalous",
"dimension",
"matrix",
"that",
"is",
"defined",
"in",
"adm",
".",
"adm_s_X",
"where",
"X",
"is",
"the",
"name",
"of",
"the",
"sector",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/rge.py#L38-L50 |
wilson-eft/wilson | wilson/run/wet/rge.py | getUs | def getUs(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
w, v = admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau)
b0s = 11 - 2 * f / 3
a = w / (2 * b0s)
return v @ np.diag(eta_s**a) @ np.linalg.inv(v) | python | def getUs(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
w, v = admeig(classname, f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau)
b0s = 11 - 2 * f / 3
a = w / (2 * b0s)
return v @ np.diag(eta_s**a) @ np.linalg.inv(v) | [
"def",
"getUs",
"(",
"classname",
",",
"eta_s",
",",
"f",
",",
"alpha_s",
",",
"alpha_e",
",",
"m_u",
",",
"m_d",
",",
"m_s",
",",
"m_c",
",",
"m_b",
",",
"m_e",
",",
"m_mu",
",",
"m_tau",
")",
":",
"w",
",",
"v",
"=",
"admeig",
"(",
"classname... | Get the QCD evolution matrix. | [
"Get",
"the",
"QCD",
"evolution",
"matrix",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/rge.py#L54-L59 |
wilson-eft/wilson | wilson/run/wet/rge.py | getUe | def getUe(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
args = f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau
A = getattr(adm, 'adm_e_' + classname)(*args)
perm_keys = get_permissible_wcs(classname, f)
if perm_keys != 'all':
... | python | def getUe(classname, eta_s, f, alpha_s, alpha_e, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau):
"""Get the QCD evolution matrix."""
args = f, m_u, m_d, m_s, m_c, m_b, m_e, m_mu, m_tau
A = getattr(adm, 'adm_e_' + classname)(*args)
perm_keys = get_permissible_wcs(classname, f)
if perm_keys != 'all':
... | [
"def",
"getUe",
"(",
"classname",
",",
"eta_s",
",",
"f",
",",
"alpha_s",
",",
"alpha_e",
",",
"m_u",
",",
"m_d",
",",
"m_s",
",",
"m_c",
",",
"m_b",
",",
"m_e",
",",
"m_mu",
",",
"m_tau",
")",
":",
"args",
"=",
"f",
",",
"m_u",
",",
"m_d",
"... | Get the QCD evolution matrix. | [
"Get",
"the",
"QCD",
"evolution",
"matrix",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/rge.py#L63-L81 |
wilson-eft/wilson | wilson/run/wet/rge.py | run_sector | def run_sector(sector, C_in, eta_s, f, p_in, p_out, qed_order=1, qcd_order=1):
r"""Solve the WET RGE for a specific sector.
Parameters:
- sector: sector of interest
- C_in: dictionary of Wilson coefficients
- eta_s: ratio of $\alpha_s$ at input and output scale
- f: number of active quark flav... | python | def run_sector(sector, C_in, eta_s, f, p_in, p_out, qed_order=1, qcd_order=1):
r"""Solve the WET RGE for a specific sector.
Parameters:
- sector: sector of interest
- C_in: dictionary of Wilson coefficients
- eta_s: ratio of $\alpha_s$ at input and output scale
- f: number of active quark flav... | [
"def",
"run_sector",
"(",
"sector",
",",
"C_in",
",",
"eta_s",
",",
"f",
",",
"p_in",
",",
"p_out",
",",
"qed_order",
"=",
"1",
",",
"qcd_order",
"=",
"1",
")",
":",
"Cdictout",
"=",
"OrderedDict",
"(",
")",
"classname",
"=",
"sectors",
"[",
"sector"... | r"""Solve the WET RGE for a specific sector.
Parameters:
- sector: sector of interest
- C_in: dictionary of Wilson coefficients
- eta_s: ratio of $\alpha_s$ at input and output scale
- f: number of active quark flavours
- p_in: running parameters at the input scale
- p_out: running paramet... | [
"r",
"Solve",
"the",
"WET",
"RGE",
"for",
"a",
"specific",
"sector",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/run/wet/rge.py#L119-L162 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/resolver/region.py | Resolver._merge_region_trees | def _merge_region_trees(self, dst_tree, src_tree, pid):
"""Merge conflicts occur if a folder in one tree is a file in the other.
As the files are PIDs, this can only happen if a PID matches one of the
geographical areas that the dataset covers and should be very rare. In such
conflicts,... | python | def _merge_region_trees(self, dst_tree, src_tree, pid):
"""Merge conflicts occur if a folder in one tree is a file in the other.
As the files are PIDs, this can only happen if a PID matches one of the
geographical areas that the dataset covers and should be very rare. In such
conflicts,... | [
"def",
"_merge_region_trees",
"(",
"self",
",",
"dst_tree",
",",
"src_tree",
",",
"pid",
")",
":",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"src_tree",
".",
"items",
"(",
")",
")",
":",
"# Prepend an underscore to the administrative area names, to make them",
"#... | Merge conflicts occur if a folder in one tree is a file in the other.
As the files are PIDs, this can only happen if a PID matches one of the
geographical areas that the dataset covers and should be very rare. In such
conflicts, the destination wins. | [
"Merge",
"conflicts",
"occur",
"if",
"a",
"folder",
"in",
"one",
"tree",
"is",
"a",
"file",
"in",
"the",
"other",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/region.py#L219-L235 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/resolver/region.py | Resolver._get_region_tree_item_and_unconsumed_path | def _get_region_tree_item_and_unconsumed_path(
self, region_tree, path, parent_key=''
):
"""Return the region_tree item specified by path. An item can be a a folder
(represented by a dictionary) or a PID (represented by None).
This function is also used for determining which section... | python | def _get_region_tree_item_and_unconsumed_path(
self, region_tree, path, parent_key=''
):
"""Return the region_tree item specified by path. An item can be a a folder
(represented by a dictionary) or a PID (represented by None).
This function is also used for determining which section... | [
"def",
"_get_region_tree_item_and_unconsumed_path",
"(",
"self",
",",
"region_tree",
",",
"path",
",",
"parent_key",
"=",
"''",
")",
":",
"# Handle valid item within region tree.",
"if",
"not",
"path",
":",
"if",
"region_tree",
"is",
"None",
":",
"return",
"parent_k... | Return the region_tree item specified by path. An item can be a a folder
(represented by a dictionary) or a PID (represented by None).
This function is also used for determining which section of a path is within
the region tree and which section should be passed to the next resolver. To
... | [
"Return",
"the",
"region_tree",
"item",
"specified",
"by",
"path",
".",
"An",
"item",
"can",
"be",
"a",
"a",
"folder",
"(",
"represented",
"by",
"a",
"dictionary",
")",
"or",
"a",
"PID",
"(",
"represented",
"by",
"None",
")",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/resolver/region.py#L237-L277 |
genialis/resolwe | resolwe/flow/serializers/base.py | ResolweBaseSerializer.save | def save(self, **kwargs):
"""Override save method to catch handled errors and repackage them as 400 errors."""
try:
return super().save(**kwargs)
except SlugError as error:
raise ParseError(error) | python | def save(self, **kwargs):
"""Override save method to catch handled errors and repackage them as 400 errors."""
try:
return super().save(**kwargs)
except SlugError as error:
raise ParseError(error) | [
"def",
"save",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"super",
"(",
")",
".",
"save",
"(",
"*",
"*",
"kwargs",
")",
"except",
"SlugError",
"as",
"error",
":",
"raise",
"ParseError",
"(",
"error",
")"
] | Override save method to catch handled errors and repackage them as 400 errors. | [
"Override",
"save",
"method",
"to",
"catch",
"handled",
"errors",
"and",
"repackage",
"them",
"as",
"400",
"errors",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/serializers/base.py#L63-L68 |
DataONEorg/d1_python | lib_client/src/d1_client/d1client.py | get_api_major_by_base_url | def get_api_major_by_base_url(base_url, *client_arg_list, **client_arg_dict):
"""Read the Node document from a node and return an int containing the latest D1 API
version supported by the node.
The Node document can always be reached through the v1 API and will list services
for v1 and any later APIs v... | python | def get_api_major_by_base_url(base_url, *client_arg_list, **client_arg_dict):
"""Read the Node document from a node and return an int containing the latest D1 API
version supported by the node.
The Node document can always be reached through the v1 API and will list services
for v1 and any later APIs v... | [
"def",
"get_api_major_by_base_url",
"(",
"base_url",
",",
"*",
"client_arg_list",
",",
"*",
"*",
"client_arg_dict",
")",
":",
"api_major",
"=",
"0",
"client",
"=",
"d1_client",
".",
"mnclient",
".",
"MemberNodeClient",
"(",
"base_url",
",",
"*",
"client_arg_list... | Read the Node document from a node and return an int containing the latest D1 API
version supported by the node.
The Node document can always be reached through the v1 API and will list services
for v1 and any later APIs versions supported by the node. | [
"Read",
"the",
"Node",
"document",
"from",
"a",
"node",
"and",
"return",
"an",
"int",
"containing",
"the",
"latest",
"D1",
"API",
"version",
"supported",
"by",
"the",
"node",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/d1client.py#L39-L55 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/model_util.py | delete_unused_subjects | def delete_unused_subjects():
"""Delete any unused subjects from the database.
This is not strictly required as any unused subjects will automatically be reused if
needed in the future.
"""
# This causes Django to create a single join (check with query.query)
query = d1_gmn.app.models.Subject.... | python | def delete_unused_subjects():
"""Delete any unused subjects from the database.
This is not strictly required as any unused subjects will automatically be reused if
needed in the future.
"""
# This causes Django to create a single join (check with query.query)
query = d1_gmn.app.models.Subject.... | [
"def",
"delete_unused_subjects",
"(",
")",
":",
"# This causes Django to create a single join (check with query.query)",
"query",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Subject",
".",
"objects",
".",
"all",
"(",
")",
"query",
"=",
"query",
".",
"filter",
... | Delete any unused subjects from the database.
This is not strictly required as any unused subjects will automatically be reused if
needed in the future. | [
"Delete",
"any",
"unused",
"subjects",
"from",
"the",
"database",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/model_util.py#L46-L65 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | extract_subject_from_dn | def extract_subject_from_dn(cert_obj):
"""Serialize a DN to a DataONE subject string.
Args:
cert_obj: cryptography.Certificate
Returns:
str:
Primary subject extracted from the certificate DN.
The certificate DN (DistinguishedName) is a sequence of RDNs
(RelativeDistinguishedNa... | python | def extract_subject_from_dn(cert_obj):
"""Serialize a DN to a DataONE subject string.
Args:
cert_obj: cryptography.Certificate
Returns:
str:
Primary subject extracted from the certificate DN.
The certificate DN (DistinguishedName) is a sequence of RDNs
(RelativeDistinguishedNa... | [
"def",
"extract_subject_from_dn",
"(",
"cert_obj",
")",
":",
"return",
"\",\"",
".",
"join",
"(",
"\"{}={}\"",
".",
"format",
"(",
"OID_TO_SHORT_NAME_DICT",
".",
"get",
"(",
"v",
".",
"oid",
".",
"dotted_string",
",",
"v",
".",
"oid",
".",
"dotted_string",
... | Serialize a DN to a DataONE subject string.
Args:
cert_obj: cryptography.Certificate
Returns:
str:
Primary subject extracted from the certificate DN.
The certificate DN (DistinguishedName) is a sequence of RDNs
(RelativeDistinguishedName). Each RDN is a set of AVAs (AttributeValue... | [
"Serialize",
"a",
"DN",
"to",
"a",
"DataONE",
"subject",
"string",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L107-L140 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | create_d1_dn_subject | def create_d1_dn_subject(common_name_str):
"""Create the DN Subject for certificate that will be used in a DataONE environment.
The DN is formatted into a DataONE subject, which is used in authentication,
authorization and event tracking.
Args:
common_name_str: str
DataONE uses sim... | python | def create_d1_dn_subject(common_name_str):
"""Create the DN Subject for certificate that will be used in a DataONE environment.
The DN is formatted into a DataONE subject, which is used in authentication,
authorization and event tracking.
Args:
common_name_str: str
DataONE uses sim... | [
"def",
"create_d1_dn_subject",
"(",
"common_name_str",
")",
":",
"return",
"cryptography",
".",
"x509",
".",
"Name",
"(",
"[",
"cryptography",
".",
"x509",
".",
"NameAttribute",
"(",
"cryptography",
".",
"x509",
".",
"oid",
".",
"NameOID",
".",
"COUNTRY_NAME",... | Create the DN Subject for certificate that will be used in a DataONE environment.
The DN is formatted into a DataONE subject, which is used in authentication,
authorization and event tracking.
Args:
common_name_str: str
DataONE uses simple DNs without physical location information, so ... | [
"Create",
"the",
"DN",
"Subject",
"for",
"certificate",
"that",
"will",
"be",
"used",
"in",
"a",
"DataONE",
"environment",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L143-L181 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | generate_csr | def generate_csr(private_key_bytes, subject_name, fqdn_list):
"""Generate a Certificate Signing Request (CSR).
Args:
private_key_bytes: bytes
Private key with which the CSR will be signed.
subject_name: str
Certificate Subject Name
fqdn_list:
List o... | python | def generate_csr(private_key_bytes, subject_name, fqdn_list):
"""Generate a Certificate Signing Request (CSR).
Args:
private_key_bytes: bytes
Private key with which the CSR will be signed.
subject_name: str
Certificate Subject Name
fqdn_list:
List o... | [
"def",
"generate_csr",
"(",
"private_key_bytes",
",",
"subject_name",
",",
"fqdn_list",
")",
":",
"return",
"(",
"cryptography",
".",
"x509",
".",
"CertificateSigningRequestBuilder",
"(",
")",
".",
"subject_name",
"(",
"subject_name",
")",
".",
"add_extension",
"(... | Generate a Certificate Signing Request (CSR).
Args:
private_key_bytes: bytes
Private key with which the CSR will be signed.
subject_name: str
Certificate Subject Name
fqdn_list:
List of Fully Qualified Domain Names (FQDN) and/or IP addresses for which
... | [
"Generate",
"a",
"Certificate",
"Signing",
"Request",
"(",
"CSR",
")",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L232-L262 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | deserialize_pem | def deserialize_pem(cert_pem):
"""Deserialize PEM (Base64) encoded X.509 v3 certificate.
Args:
cert_pem: str or bytes
PEM (Base64) encoded X.509 v3 certificate
Returns:
cert_obj: cryptography.Certificate
"""
if isinstance(cert_pem, str):
cert_pem = cert_pem.encode("utf... | python | def deserialize_pem(cert_pem):
"""Deserialize PEM (Base64) encoded X.509 v3 certificate.
Args:
cert_pem: str or bytes
PEM (Base64) encoded X.509 v3 certificate
Returns:
cert_obj: cryptography.Certificate
"""
if isinstance(cert_pem, str):
cert_pem = cert_pem.encode("utf... | [
"def",
"deserialize_pem",
"(",
"cert_pem",
")",
":",
"if",
"isinstance",
"(",
"cert_pem",
",",
"str",
")",
":",
"cert_pem",
"=",
"cert_pem",
".",
"encode",
"(",
"\"utf-8\"",
")",
"return",
"cryptography",
".",
"x509",
".",
"load_pem_x509_certificate",
"(",
"... | Deserialize PEM (Base64) encoded X.509 v3 certificate.
Args:
cert_pem: str or bytes
PEM (Base64) encoded X.509 v3 certificate
Returns:
cert_obj: cryptography.Certificate | [
"Deserialize",
"PEM",
"(",
"Base64",
")",
"encoded",
"X",
".",
"509",
"v3",
"certificate",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L268-L283 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | serialize_cert_to_pem | def serialize_cert_to_pem(cert_obj):
"""Serialize certificate to PEM.
The certificate can be also be a Certificate Signing Request (CSR).
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded certificate
"""
return cert_obj.public_bytes(
encoding=cryptograp... | python | def serialize_cert_to_pem(cert_obj):
"""Serialize certificate to PEM.
The certificate can be also be a Certificate Signing Request (CSR).
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded certificate
"""
return cert_obj.public_bytes(
encoding=cryptograp... | [
"def",
"serialize_cert_to_pem",
"(",
"cert_obj",
")",
":",
"return",
"cert_obj",
".",
"public_bytes",
"(",
"encoding",
"=",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"serialization",
".",
"Encoding",
".",
"PEM",
")"
] | Serialize certificate to PEM.
The certificate can be also be a Certificate Signing Request (CSR).
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded certificate | [
"Serialize",
"certificate",
"to",
"PEM",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L301-L315 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | extract_subject_info_extension | def extract_subject_info_extension(cert_obj):
"""Extract DataONE SubjectInfo XML doc from certificate.
Certificates issued by DataONE may include an embedded XML doc containing
additional information about the subject specified in the certificate DN. If
present, the doc is stored as an extension with a... | python | def extract_subject_info_extension(cert_obj):
"""Extract DataONE SubjectInfo XML doc from certificate.
Certificates issued by DataONE may include an embedded XML doc containing
additional information about the subject specified in the certificate DN. If
present, the doc is stored as an extension with a... | [
"def",
"extract_subject_info_extension",
"(",
"cert_obj",
")",
":",
"try",
":",
"subject_info_der",
"=",
"cert_obj",
".",
"extensions",
".",
"get_extension_for_oid",
"(",
"cryptography",
".",
"x509",
".",
"oid",
".",
"ObjectIdentifier",
"(",
"DATAONE_SUBJECT_INFO_OID"... | Extract DataONE SubjectInfo XML doc from certificate.
Certificates issued by DataONE may include an embedded XML doc containing
additional information about the subject specified in the certificate DN. If
present, the doc is stored as an extension with an OID specified by DataONE and
formatted as speci... | [
"Extract",
"DataONE",
"SubjectInfo",
"XML",
"doc",
"from",
"certificate",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L321-L342 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | download_as_der | def download_as_der(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as DER encoded ``bytes``.
If the certificate is being downloaded in order to troubleshoot validation issues,
the download its... | python | def download_as_der(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as DER encoded ``bytes``.
If the certificate is being downloaded in order to troubleshoot validation issues,
the download its... | [
"def",
"download_as_der",
"(",
"base_url",
"=",
"d1_common",
".",
"const",
".",
"URL_DATAONE_ROOT",
",",
"timeout_sec",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_HTTP_TIMEOUT",
",",
")",
":",
"# TODO: It is unclear which SSL and TLS protocols are supported by the method... | Download public certificate from a TLS/SSL web server as DER encoded ``bytes``.
If the certificate is being downloaded in order to troubleshoot validation issues,
the download itself may fail due to the validation issue that is being investigated.
To work around such chicken-and-egg problems, temporarily w... | [
"Download",
"public",
"certificate",
"from",
"a",
"TLS",
"/",
"SSL",
"web",
"server",
"as",
"DER",
"encoded",
"bytes",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L348-L378 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | download_as_pem | def download_as_pem(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as PEM encoded string.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... | python | def download_as_pem(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as PEM encoded string.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... | [
"def",
"download_as_pem",
"(",
"base_url",
"=",
"d1_common",
".",
"const",
".",
"URL_DATAONE_ROOT",
",",
"timeout_sec",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_HTTP_TIMEOUT",
",",
")",
":",
"return",
"ssl",
".",
"DER_cert_to_PEM_cert",
"(",
"download_as_der"... | Download public certificate from a TLS/SSL web server as PEM encoded string.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service endpoint or a server hostname
timeout_sec : int or float
Timeout for the SSL socket operations
Returns:
s... | [
"Download",
"public",
"certificate",
"from",
"a",
"TLS",
"/",
"SSL",
"web",
"server",
"as",
"PEM",
"encoded",
"string",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L412-L430 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | download_as_obj | def download_as_obj(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as Certificate object.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... | python | def download_as_obj(
base_url=d1_common.const.URL_DATAONE_ROOT,
timeout_sec=d1_common.const.DEFAULT_HTTP_TIMEOUT,
):
"""Download public certificate from a TLS/SSL web server as Certificate object.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service en... | [
"def",
"download_as_obj",
"(",
"base_url",
"=",
"d1_common",
".",
"const",
".",
"URL_DATAONE_ROOT",
",",
"timeout_sec",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_HTTP_TIMEOUT",
",",
")",
":",
"return",
"decode_der",
"(",
"download_as_der",
"(",
"base_url",
"... | Download public certificate from a TLS/SSL web server as Certificate object.
Also see download_as_der().
Args:
base_url : str
A full URL to a DataONE service endpoint or a server hostname
timeout_sec : int or float
Timeout for the SSL socket operations
Returns:
c... | [
"Download",
"public",
"certificate",
"from",
"a",
"TLS",
"/",
"SSL",
"web",
"server",
"as",
"Certificate",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L433-L451 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | decode_der | def decode_der(cert_der):
"""Decode cert DER string to Certificate object.
Args:
cert_der : Certificate as a DER encoded string
Returns:
cryptography.Certificate()
"""
return cryptography.x509.load_der_x509_certificate(
data=cert_der, backend=cryptography.hazmat.backends.defau... | python | def decode_der(cert_der):
"""Decode cert DER string to Certificate object.
Args:
cert_der : Certificate as a DER encoded string
Returns:
cryptography.Certificate()
"""
return cryptography.x509.load_der_x509_certificate(
data=cert_der, backend=cryptography.hazmat.backends.defau... | [
"def",
"decode_der",
"(",
"cert_der",
")",
":",
"return",
"cryptography",
".",
"x509",
".",
"load_der_x509_certificate",
"(",
"data",
"=",
"cert_der",
",",
"backend",
"=",
"cryptography",
".",
"hazmat",
".",
"backends",
".",
"default_backend",
"(",
")",
")"
] | Decode cert DER string to Certificate object.
Args:
cert_der : Certificate as a DER encoded string
Returns:
cryptography.Certificate() | [
"Decode",
"cert",
"DER",
"string",
"to",
"Certificate",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L454-L466 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | disable_cert_validation | def disable_cert_validation():
"""Context manager to temporarily disable certificate validation in the standard SSL
library.
Note: This should not be used in production code but is sometimes useful for
troubleshooting certificate validation issues.
By design, the standard SSL library does not prov... | python | def disable_cert_validation():
"""Context manager to temporarily disable certificate validation in the standard SSL
library.
Note: This should not be used in production code but is sometimes useful for
troubleshooting certificate validation issues.
By design, the standard SSL library does not prov... | [
"def",
"disable_cert_validation",
"(",
")",
":",
"current_context",
"=",
"ssl",
".",
"_create_default_https_context",
"ssl",
".",
"_create_default_https_context",
"=",
"ssl",
".",
"_create_unverified_context",
"try",
":",
"yield",
"finally",
":",
"ssl",
".",
"_create_... | Context manager to temporarily disable certificate validation in the standard SSL
library.
Note: This should not be used in production code but is sometimes useful for
troubleshooting certificate validation issues.
By design, the standard SSL library does not provide a way to disable verification
... | [
"Context",
"manager",
"to",
"temporarily",
"disable",
"certificate",
"validation",
"in",
"the",
"standard",
"SSL",
"library",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L471-L489 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | extract_issuer_ca_cert_url | def extract_issuer_ca_cert_url(cert_obj):
"""Extract issuer CA certificate URL from certificate.
Certificates may include a URL where the root certificate for the CA which was used
for signing the certificate can be downloaded. This function returns the URL if
present.
The primary use for this is ... | python | def extract_issuer_ca_cert_url(cert_obj):
"""Extract issuer CA certificate URL from certificate.
Certificates may include a URL where the root certificate for the CA which was used
for signing the certificate can be downloaded. This function returns the URL if
present.
The primary use for this is ... | [
"def",
"extract_issuer_ca_cert_url",
"(",
"cert_obj",
")",
":",
"for",
"extension",
"in",
"cert_obj",
".",
"extensions",
":",
"if",
"extension",
".",
"oid",
".",
"dotted_string",
"==",
"AUTHORITY_INFO_ACCESS_OID",
":",
"authority_info_access",
"=",
"extension",
".",... | Extract issuer CA certificate URL from certificate.
Certificates may include a URL where the root certificate for the CA which was used
for signing the certificate can be downloaded. This function returns the URL if
present.
The primary use for this is to fix validation failure due to non-trusted issu... | [
"Extract",
"issuer",
"CA",
"certificate",
"URL",
"from",
"certificate",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L492-L515 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | serialize_private_key_to_pem | def serialize_private_key_to_pem(private_key, passphrase_bytes=None):
"""Serialize private key to PEM.
Args:
private_key:
passphrase_bytes:
Returns:
bytes: PEM encoded private key
"""
return private_key.private_bytes(
encoding=cryptography.hazmat.primitives.serialization... | python | def serialize_private_key_to_pem(private_key, passphrase_bytes=None):
"""Serialize private key to PEM.
Args:
private_key:
passphrase_bytes:
Returns:
bytes: PEM encoded private key
"""
return private_key.private_bytes(
encoding=cryptography.hazmat.primitives.serialization... | [
"def",
"serialize_private_key_to_pem",
"(",
"private_key",
",",
"passphrase_bytes",
"=",
"None",
")",
":",
"return",
"private_key",
".",
"private_bytes",
"(",
"encoding",
"=",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"serialization",
".",
"Encoding",
... | Serialize private key to PEM.
Args:
private_key:
passphrase_bytes:
Returns:
bytes: PEM encoded private key | [
"Serialize",
"private",
"key",
"to",
"PEM",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L521-L540 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | generate_private_key | def generate_private_key(key_size=2048):
"""Generate a private key"""
return cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key(
public_exponent=65537,
key_size=key_size,
backend=cryptography.hazmat.backends.default_backend(),
) | python | def generate_private_key(key_size=2048):
"""Generate a private key"""
return cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key(
public_exponent=65537,
key_size=key_size,
backend=cryptography.hazmat.backends.default_backend(),
) | [
"def",
"generate_private_key",
"(",
"key_size",
"=",
"2048",
")",
":",
"return",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"asymmetric",
".",
"rsa",
".",
"generate_private_key",
"(",
"public_exponent",
"=",
"65537",
",",
"key_size",
"=",
"key_size",... | Generate a private key | [
"Generate",
"a",
"private",
"key"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L543-L549 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | get_public_key_pem | def get_public_key_pem(cert_obj):
"""Extract public key from certificate as PEM encoded PKCS#1.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded PKCS#1 public key.
"""
return cert_obj.public_key().public_bytes(
encoding=cryptography.hazmat.primitives.serial... | python | def get_public_key_pem(cert_obj):
"""Extract public key from certificate as PEM encoded PKCS#1.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded PKCS#1 public key.
"""
return cert_obj.public_key().public_bytes(
encoding=cryptography.hazmat.primitives.serial... | [
"def",
"get_public_key_pem",
"(",
"cert_obj",
")",
":",
"return",
"cert_obj",
".",
"public_key",
"(",
")",
".",
"public_bytes",
"(",
"encoding",
"=",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"serialization",
".",
"Encoding",
".",
"PEM",
",",
"f... | Extract public key from certificate as PEM encoded PKCS#1.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: PEM encoded PKCS#1 public key. | [
"Extract",
"public",
"key",
"from",
"certificate",
"as",
"PEM",
"encoded",
"PKCS#1",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L555-L568 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | load_csr | def load_csr(pem_path):
"""Load CSR from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.x509.load_pem_x509_csr(
data=f.read(), backend=cryptography.hazmat.backends.default_backend()
) | python | def load_csr(pem_path):
"""Load CSR from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.x509.load_pem_x509_csr(
data=f.read(), backend=cryptography.hazmat.backends.default_backend()
) | [
"def",
"load_csr",
"(",
"pem_path",
")",
":",
"with",
"open",
"(",
"pem_path",
",",
"\"rb\"",
")",
"as",
"f",
":",
"return",
"cryptography",
".",
"x509",
".",
"load_pem_x509_csr",
"(",
"data",
"=",
"f",
".",
"read",
"(",
")",
",",
"backend",
"=",
"cr... | Load CSR from PEM encoded file | [
"Load",
"CSR",
"from",
"PEM",
"encoded",
"file"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L580-L585 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | load_private_key | def load_private_key(pem_path, passphrase_bytes=None):
"""Load private key from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.hazmat.primitives.serialization.load_pem_private_key(
data=f.read(),
password=passphrase_bytes,
backend=cryptography... | python | def load_private_key(pem_path, passphrase_bytes=None):
"""Load private key from PEM encoded file"""
with open(pem_path, "rb") as f:
return cryptography.hazmat.primitives.serialization.load_pem_private_key(
data=f.read(),
password=passphrase_bytes,
backend=cryptography... | [
"def",
"load_private_key",
"(",
"pem_path",
",",
"passphrase_bytes",
"=",
"None",
")",
":",
"with",
"open",
"(",
"pem_path",
",",
"\"rb\"",
")",
"as",
"f",
":",
"return",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"serialization",
".",
"load_pem_... | Load private key from PEM encoded file | [
"Load",
"private",
"key",
"from",
"PEM",
"encoded",
"file"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L588-L595 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | serialize_cert_to_der | def serialize_cert_to_der(cert_obj):
"""Serialize certificate to DER.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: DER encoded certificate
"""
return cert_obj.public_bytes(
cryptography.hazmat.primitives.serialization.Encoding.DER
) | python | def serialize_cert_to_der(cert_obj):
"""Serialize certificate to DER.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: DER encoded certificate
"""
return cert_obj.public_bytes(
cryptography.hazmat.primitives.serialization.Encoding.DER
) | [
"def",
"serialize_cert_to_der",
"(",
"cert_obj",
")",
":",
"return",
"cert_obj",
".",
"public_bytes",
"(",
"cryptography",
".",
"hazmat",
".",
"primitives",
".",
"serialization",
".",
"Encoding",
".",
"DER",
")"
] | Serialize certificate to DER.
Args:
cert_obj: cryptography.Certificate
Returns:
bytes: DER encoded certificate | [
"Serialize",
"certificate",
"to",
"DER",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L631-L643 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | log_cert_info | def log_cert_info(logger, msg_str, cert_obj):
"""Dump basic certificate values to the log.
Args:
logger: Logger
Logger to which to write the certificate values.
msg_str: str
A message to write to the log before the certificate values.
cert_obj: cryptography.Certificate
... | python | def log_cert_info(logger, msg_str, cert_obj):
"""Dump basic certificate values to the log.
Args:
logger: Logger
Logger to which to write the certificate values.
msg_str: str
A message to write to the log before the certificate values.
cert_obj: cryptography.Certificate
... | [
"def",
"log_cert_info",
"(",
"logger",
",",
"msg_str",
",",
"cert_obj",
")",
":",
"list",
"(",
"map",
"(",
"logger",
",",
"[",
"\"{}:\"",
".",
"format",
"(",
"msg_str",
")",
"]",
"+",
"[",
"\" {}\"",
".",
"format",
"(",
"v",
")",
"for",
"v",
"in",... | Dump basic certificate values to the log.
Args:
logger: Logger
Logger to which to write the certificate values.
msg_str: str
A message to write to the log before the certificate values.
cert_obj: cryptography.Certificate
Certificate containing values to log.
Returns... | [
"Dump",
"basic",
"certificate",
"values",
"to",
"the",
"log",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L774-L826 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | get_extension_by_name | def get_extension_by_name(cert_obj, extension_name):
"""Get a standard certificate extension by attribute name.
Args:
cert_obj: cryptography.Certificate
Certificate containing a standard extension.
extension_name : str
Extension name. E.g., 'SUBJECT_DIRECTORY_ATTRIBUTES'.
Retu... | python | def get_extension_by_name(cert_obj, extension_name):
"""Get a standard certificate extension by attribute name.
Args:
cert_obj: cryptography.Certificate
Certificate containing a standard extension.
extension_name : str
Extension name. E.g., 'SUBJECT_DIRECTORY_ATTRIBUTES'.
Retu... | [
"def",
"get_extension_by_name",
"(",
"cert_obj",
",",
"extension_name",
")",
":",
"try",
":",
"return",
"cert_obj",
".",
"extensions",
".",
"get_extension_for_oid",
"(",
"getattr",
"(",
"cryptography",
".",
"x509",
".",
"oid",
".",
"ExtensionOID",
",",
"extensio... | Get a standard certificate extension by attribute name.
Args:
cert_obj: cryptography.Certificate
Certificate containing a standard extension.
extension_name : str
Extension name. E.g., 'SUBJECT_DIRECTORY_ATTRIBUTES'.
Returns:
Cryptography.Extension | [
"Get",
"a",
"standard",
"certificate",
"extension",
"by",
"attribute",
"name",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L829-L848 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | _get_val_list | def _get_val_list(obj, path_list, reverse=False):
"""Extract values from nested objects by attribute names.
Objects contain attributes which are named references to objects. This will descend
down a tree of nested objects, starting at the given object, following the given
path.
Args:
obj: ob... | python | def _get_val_list(obj, path_list, reverse=False):
"""Extract values from nested objects by attribute names.
Objects contain attributes which are named references to objects. This will descend
down a tree of nested objects, starting at the given object, following the given
path.
Args:
obj: ob... | [
"def",
"_get_val_list",
"(",
"obj",
",",
"path_list",
",",
"reverse",
"=",
"False",
")",
":",
"try",
":",
"y",
"=",
"getattr",
"(",
"obj",
",",
"path_list",
"[",
"0",
"]",
")",
"except",
"AttributeError",
":",
"return",
"[",
"]",
"if",
"len",
"(",
... | Extract values from nested objects by attribute names.
Objects contain attributes which are named references to objects. This will descend
down a tree of nested objects, starting at the given object, following the given
path.
Args:
obj: object
Any type of object
path_list: list
... | [
"Extract",
"values",
"from",
"nested",
"objects",
"by",
"attribute",
"names",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L854-L885 |
DataONEorg/d1_python | lib_common/src/d1_common/cert/x509.py | _get_val_str | def _get_val_str(obj, path_list=None, reverse=False):
"""Extract values from nested objects by attribute names and concatenate their
string representations.
Args:
obj: object
Any type of object
path_list: list
Attribute names
reverse: bool
Reverse the list of val... | python | def _get_val_str(obj, path_list=None, reverse=False):
"""Extract values from nested objects by attribute names and concatenate their
string representations.
Args:
obj: object
Any type of object
path_list: list
Attribute names
reverse: bool
Reverse the list of val... | [
"def",
"_get_val_str",
"(",
"obj",
",",
"path_list",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"val_list",
"=",
"_get_val_list",
"(",
"obj",
",",
"path_list",
"or",
"[",
"]",
",",
"reverse",
")",
"return",
"\"<not found>\"",
"if",
"obj",
"is",... | Extract values from nested objects by attribute names and concatenate their
string representations.
Args:
obj: object
Any type of object
path_list: list
Attribute names
reverse: bool
Reverse the list of values before concatenation.
Returns:
str: Concatenat... | [
"Extract",
"values",
"from",
"nested",
"objects",
"by",
"attribute",
"names",
"and",
"concatenate",
"their",
"string",
"representations",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/x509.py#L888-L907 |
wilson-eft/wilson | wilson/translate/wet.py | _JMS_to_Bern_I | def _JMS_to_Bern_I(C, qq):
"""From JMS to BernI basis (= traditional SUSY basis in this case)
for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = tuple(dflav[q] for q in qq)
elif qq == 'cu':
dd = 'uu'
ij =... | python | def _JMS_to_Bern_I(C, qq):
"""From JMS to BernI basis (= traditional SUSY basis in this case)
for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = tuple(dflav[q] for q in qq)
elif qq == 'cu':
dd = 'uu'
ij =... | [
"def",
"_JMS_to_Bern_I",
"(",
"C",
",",
"qq",
")",
":",
"if",
"qq",
"in",
"[",
"'sb'",
",",
"'db'",
",",
"'ds'",
"]",
":",
"dd",
"=",
"'dd'",
"ij",
"=",
"tuple",
"(",
"dflav",
"[",
"q",
"]",
"for",
"q",
"in",
"qq",
")",
"elif",
"qq",
"==",
... | From JMS to BernI basis (= traditional SUSY basis in this case)
for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu | [
"From",
"JMS",
"to",
"BernI",
"basis",
"(",
"=",
"traditional",
"SUSY",
"basis",
"in",
"this",
"case",
")",
"for",
"$",
"\\",
"Delta",
"F",
"=",
"2$",
"operators",
".",
"qq",
"should",
"be",
"sb",
"db",
"ds",
"or",
"cu"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L29-L55 |
wilson-eft/wilson | wilson/translate/wet.py | _Bern_to_JMS_I | def _Bern_to_JMS_I(C, qq):
"""From Bern to JMS basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = '{}{}'.format(dflav[qq[0]] + 1, dflav[qq[1]] + 1)
elif qq == 'cu':
dd = 'uu'
ij = '{}{}'.format(uflav[qq... | python | def _Bern_to_JMS_I(C, qq):
"""From Bern to JMS basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu'"""
if qq in ['sb', 'db', 'ds']:
dd = 'dd'
ij = '{}{}'.format(dflav[qq[0]] + 1, dflav[qq[1]] + 1)
elif qq == 'cu':
dd = 'uu'
ij = '{}{}'.format(uflav[qq... | [
"def",
"_Bern_to_JMS_I",
"(",
"C",
",",
"qq",
")",
":",
"if",
"qq",
"in",
"[",
"'sb'",
",",
"'db'",
",",
"'ds'",
"]",
":",
"dd",
"=",
"'dd'",
"ij",
"=",
"'{}{}'",
".",
"format",
"(",
"dflav",
"[",
"qq",
"[",
"0",
"]",
"]",
"+",
"1",
",",
"d... | From Bern to JMS basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'cu | [
"From",
"Bern",
"to",
"JMS",
"basis",
"for",
"$",
"\\",
"Delta",
"F",
"=",
"2$",
"operators",
".",
"qq",
"should",
"be",
"sb",
"db",
"ds",
"or",
"cu"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L58-L83 |
wilson-eft/wilson | wilson/translate/wet.py | _BernI_to_Flavio_I | def _BernI_to_Flavio_I(C, qq):
"""From BernI to FlavioI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds', 'cu']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'CSLL_'... | python | def _BernI_to_Flavio_I(C, qq):
"""From BernI to FlavioI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds', 'cu']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'CSLL_'... | [
"def",
"_BernI_to_Flavio_I",
"(",
"C",
",",
"qq",
")",
":",
"qqf",
"=",
"qq",
"[",
":",
":",
"-",
"1",
"]",
"# flavio uses \"bs\" instead of \"sb\" etc.",
"if",
"qq",
"in",
"[",
"'sb'",
",",
"'db'",
",",
"'ds'",
",",
"'cu'",
"]",
":",
"return",
"{",
... | From BernI to FlavioI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc | [
"From",
"BernI",
"to",
"FlavioI",
"basis",
"for",
"$",
"\\",
"Delta",
"F",
"=",
"2$",
"operators",
".",
"qq",
"should",
"be",
"sb",
"db",
"ds",
"or",
"uc"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L86-L102 |
wilson-eft/wilson | wilson/translate/wet.py | _FlavioI_to_Bern_I | def _FlavioI_to_Bern_I(C, qq):
"""From FlavioI to BernI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqb = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['bs', 'bd', 'sd', 'uc']:
return {
'1' + 2*qqb: C["CVLL_" + 2*qq],
'2' + 2... | python | def _FlavioI_to_Bern_I(C, qq):
"""From FlavioI to BernI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqb = qq[::-1] # flavio uses "bs" instead of "sb" etc.
if qq in ['bs', 'bd', 'sd', 'uc']:
return {
'1' + 2*qqb: C["CVLL_" + 2*qq],
'2' + 2... | [
"def",
"_FlavioI_to_Bern_I",
"(",
"C",
",",
"qq",
")",
":",
"qqb",
"=",
"qq",
"[",
":",
":",
"-",
"1",
"]",
"# flavio uses \"bs\" instead of \"sb\" etc.",
"if",
"qq",
"in",
"[",
"'bs'",
",",
"'bd'",
",",
"'sd'",
",",
"'uc'",
"]",
":",
"return",
"{",
... | From FlavioI to BernI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc | [
"From",
"FlavioI",
"to",
"BernI",
"basis",
"for",
"$",
"\\",
"Delta",
"F",
"=",
"2$",
"operators",
".",
"qq",
"should",
"be",
"sb",
"db",
"ds",
"or",
"uc"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L105-L121 |
wilson-eft/wilson | wilson/translate/wet.py | _BernI_to_FormFlavor_I | def _BernI_to_FormFlavor_I(C, qq):
"""From BernI to FormFlavorI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # FormFlavour uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'... | python | def _BernI_to_FormFlavor_I(C, qq):
"""From BernI to FormFlavorI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc'"""
qqf = qq[::-1] # FormFlavour uses "bs" instead of "sb" etc.
if qq in ['sb', 'db', 'ds']:
return {
'CVLL_' + 2*qqf: C["1" + 2*qq],
'... | [
"def",
"_BernI_to_FormFlavor_I",
"(",
"C",
",",
"qq",
")",
":",
"qqf",
"=",
"qq",
"[",
":",
":",
"-",
"1",
"]",
"# FormFlavour uses \"bs\" instead of \"sb\" etc.",
"if",
"qq",
"in",
"[",
"'sb'",
",",
"'db'",
",",
"'ds'",
"]",
":",
"return",
"{",
"'CVLL_'... | From BernI to FormFlavorI basis for $\Delta F=2$ operators.
`qq` should be 'sb', 'db', 'ds' or 'uc | [
"From",
"BernI",
"to",
"FormFlavorI",
"basis",
"for",
"$",
"\\",
"Delta",
"F",
"=",
"2$",
"operators",
".",
"qq",
"should",
"be",
"sb",
"db",
"ds",
"or",
"uc"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L124-L151 |
wilson-eft/wilson | wilson/translate/wet.py | _JMS_to_Bern_II | def _JMS_to_Bern_II(C, udlnu):
"""From JMS to BernII basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... | python | def _JMS_to_Bern_II(C, udlnu):
"""From JMS to BernII basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... | [
"def",
"_JMS_to_Bern_II",
"(",
"C",
",",
"udlnu",
")",
":",
"u",
"=",
"uflav",
"[",
"udlnu",
"[",
"0",
"]",
"]",
"d",
"=",
"dflav",
"[",
"udlnu",
"[",
"1",
"]",
"]",
"l",
"=",
"lflav",
"[",
"udlnu",
"[",
"4",
":",
"udlnu",
".",
"find",
"(",
... | From JMS to BernII basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc. | [
"From",
"JMS",
"to",
"BernII",
"basis",
"for",
"charged",
"current",
"process",
"semileptonic",
"operators",
".",
"udlnu",
"should",
"be",
"of",
"the",
"form",
"udl_enu_tau",
"cbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L156-L171 |
wilson-eft/wilson | wilson/translate/wet.py | _Bern_to_JMS_II | def _Bern_to_JMS_II(C, udlnu):
"""From BernII to JMS basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... | python | def _Bern_to_JMS_II(C, udlnu):
"""From BernII to JMS basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
lp = lflav[udlnu[udlnu.find('_',5)+1:len(ud... | [
"def",
"_Bern_to_JMS_II",
"(",
"C",
",",
"udlnu",
")",
":",
"u",
"=",
"uflav",
"[",
"udlnu",
"[",
"0",
"]",
"]",
"d",
"=",
"dflav",
"[",
"udlnu",
"[",
"1",
"]",
"]",
"l",
"=",
"lflav",
"[",
"udlnu",
"[",
"4",
":",
"udlnu",
".",
"find",
"(",
... | From BernII to JMS basis for charged current process semileptonic
operators. `udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc. | [
"From",
"BernII",
"to",
"JMS",
"basis",
"for",
"charged",
"current",
"process",
"semileptonic",
"operators",
".",
"udlnu",
"should",
"be",
"of",
"the",
"form",
"udl_enu_tau",
"cbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L174-L189 |
wilson-eft/wilson | wilson/translate/wet.py | _BernII_to_Flavio_II | def _BernII_to_Flavio_II(C, udlnu, parameters):
"""From BernII to FlavioII basis
for charged current process semileptonic operators.
`udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
p = parameters
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
... | python | def _BernII_to_Flavio_II(C, udlnu, parameters):
"""From BernII to FlavioII basis
for charged current process semileptonic operators.
`udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc."""
p = parameters
u = uflav[udlnu[0]]
d = dflav[udlnu[1]]
l = lflav[udlnu[4:udlnu.find('n')]]
... | [
"def",
"_BernII_to_Flavio_II",
"(",
"C",
",",
"udlnu",
",",
"parameters",
")",
":",
"p",
"=",
"parameters",
"u",
"=",
"uflav",
"[",
"udlnu",
"[",
"0",
"]",
"]",
"d",
"=",
"dflav",
"[",
"udlnu",
"[",
"1",
"]",
"]",
"l",
"=",
"lflav",
"[",
"udlnu",... | From BernII to FlavioII basis
for charged current process semileptonic operators.
`udlnu` should be of the form 'udl_enu_tau', 'cbl_munu_e' etc. | [
"From",
"BernII",
"to",
"FlavioII",
"basis",
"for",
"charged",
"current",
"process",
"semileptonic",
"operators",
".",
"udlnu",
"should",
"be",
"of",
"the",
"form",
"udl_enu_tau",
"cbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L192-L214 |
wilson-eft/wilson | wilson/translate/wet.py | _Fierz_to_JMS_III_IV_V | def _Fierz_to_JMS_III_IV_V(Fqqqq, qqqq):
"""From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
F = Fqqqq.copy()
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc'... | python | def _Fierz_to_JMS_III_IV_V(Fqqqq, qqqq):
"""From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
F = Fqqqq.copy()
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc'... | [
"def",
"_Fierz_to_JMS_III_IV_V",
"(",
"Fqqqq",
",",
"qqqq",
")",
":",
"F",
"=",
"Fqqqq",
".",
"copy",
"(",
")",
"#case dduu",
"classIII",
"=",
"[",
"'sbuc'",
",",
"'sbcu'",
",",
"'dbuc'",
",",
"'dbcu'",
",",
"'dsuc'",
",",
"'dscu'",
"]",
"classVdduu",
... | From 4-quark Fierz to JMS basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc. | [
"From",
"4",
"-",
"quark",
"Fierz",
"to",
"JMS",
"basis",
"for",
"Classes",
"III",
"IV",
"and",
"V",
".",
"qqqq",
"should",
"be",
"of",
"the",
"form",
"sbuc",
"sdcc",
"ucuu",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L269-L415 |
wilson-eft/wilson | wilson/translate/wet.py | _JMS_to_Fierz_III_IV_V | def _JMS_to_Fierz_III_IV_V(C, qqqq):
"""From JMS to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc' , 'dbcc', 'dscc']
if... | python | def _JMS_to_Fierz_III_IV_V(C, qqqq):
"""From JMS to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
#case dduu
classIII = ['sbuc', 'sbcu', 'dbuc', 'dbcu', 'dsuc', 'dscu']
classVdduu = ['sbuu' , 'dbuu', 'dsuu', 'sbcc' , 'dbcc', 'dscc']
if... | [
"def",
"_JMS_to_Fierz_III_IV_V",
"(",
"C",
",",
"qqqq",
")",
":",
"#case dduu",
"classIII",
"=",
"[",
"'sbuc'",
",",
"'sbcu'",
",",
"'dbuc'",
",",
"'dbcu'",
",",
"'dsuc'",
",",
"'dscu'",
"]",
"classVdduu",
"=",
"[",
"'sbuu'",
",",
"'dbuu'",
",",
"'dsuu'"... | From JMS to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc. | [
"From",
"JMS",
"to",
"4",
"-",
"quark",
"Fierz",
"basis",
"for",
"Classes",
"III",
"IV",
"and",
"V",
".",
"qqqq",
"should",
"be",
"of",
"the",
"form",
"sbuc",
"sdcc",
"ucuu",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L417-L599 |
wilson-eft/wilson | wilson/translate/wet.py | _Fierz_to_Bern_III_IV_V | def _Fierz_to_Bern_III_IV_V(Fqqqq, qqqq):
"""From Fierz to 4-quark Bern basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'1' + qqqq : -Fqq... | python | def _Fierz_to_Bern_III_IV_V(Fqqqq, qqqq):
"""From Fierz to 4-quark Bern basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'1' + qqqq : -Fqq... | [
"def",
"_Fierz_to_Bern_III_IV_V",
"(",
"Fqqqq",
",",
"qqqq",
")",
":",
"# 2nd != 4th, color-octet redundant",
"if",
"qqqq",
"in",
"[",
"'sbss'",
",",
"'dbdd'",
",",
"'dbds'",
",",
"'sbsd'",
",",
"'bsbd'",
",",
"'dsdd'",
"]",
":",
"return",
"{",
"'1'",
"+",
... | From Fierz to 4-quark Bern basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc. | [
"From",
"Fierz",
"to",
"4",
"-",
"quark",
"Bern",
"basis",
"for",
"Classes",
"III",
"IV",
"and",
"V",
".",
"qqqq",
"should",
"be",
"of",
"the",
"form",
"sbuc",
"sdcc",
"ucuu",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L602-L714 |
wilson-eft/wilson | wilson/translate/wet.py | _Bern_to_Fierz_III_IV_V | def _Bern_to_Fierz_III_IV_V(C, qqqq):
"""From Bern to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'F' + qqqq + ... | python | def _Bern_to_Fierz_III_IV_V(C, qqqq):
"""From Bern to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc."""
# 2nd != 4th, color-octet redundant
if qqqq in ['sbss', 'dbdd', 'dbds', 'sbsd', 'bsbd', 'dsdd']:
return {
'F' + qqqq + ... | [
"def",
"_Bern_to_Fierz_III_IV_V",
"(",
"C",
",",
"qqqq",
")",
":",
"# 2nd != 4th, color-octet redundant",
"if",
"qqqq",
"in",
"[",
"'sbss'",
",",
"'dbdd'",
",",
"'dbds'",
",",
"'sbsd'",
",",
"'bsbd'",
",",
"'dsdd'",
"]",
":",
"return",
"{",
"'F'",
"+",
"qq... | From Bern to 4-quark Fierz basis for Classes III, IV and V.
`qqqq` should be of the form 'sbuc', 'sdcc', 'ucuu' etc. | [
"From",
"Bern",
"to",
"4",
"-",
"quark",
"Fierz",
"basis",
"for",
"Classes",
"III",
"IV",
"and",
"V",
".",
"qqqq",
"should",
"be",
"of",
"the",
"form",
"sbuc",
"sdcc",
"ucuu",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L716-L772 |
wilson-eft/wilson | wilson/translate/wet.py | _Fierz_to_EOS_V | def _Fierz_to_EOS_V(Fsbuu,Fsbdd,Fsbcc,Fsbss,Fsbbb,parameters):
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
Vtb = V[2,2]
Vts = V[2,1]
"""From Fierz to the EOS basis for b -> s transitions.
The arguments are dictionaries of the corresponding Fierz bases """
... | python | def _Fierz_to_EOS_V(Fsbuu,Fsbdd,Fsbcc,Fsbss,Fsbbb,parameters):
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
Vtb = V[2,2]
Vts = V[2,1]
"""From Fierz to the EOS basis for b -> s transitions.
The arguments are dictionaries of the corresponding Fierz bases """
... | [
"def",
"_Fierz_to_EOS_V",
"(",
"Fsbuu",
",",
"Fsbdd",
",",
"Fsbcc",
",",
"Fsbss",
",",
"Fsbbb",
",",
"parameters",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"... | From Fierz to the EOS basis for b -> s transitions.
The arguments are dictionaries of the corresponding Fierz bases | [
"From",
"Fierz",
"to",
"the",
"EOS",
"basis",
"for",
"b",
"-",
">",
"s",
"transitions",
".",
"The",
"arguments",
"are",
"dictionaries",
"of",
"the",
"corresponding",
"Fierz",
"bases"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L884-L930 |
wilson-eft/wilson | wilson/translate/wet.py | JMS_to_Fierz_lep | def JMS_to_Fierz_lep(C, ddll):
"""From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
if ddll[:2] == 'uc':
s = uflav[ddll[0]]
b = uflav[ddll[1]]
q = 'u'
else:
s = dflav[ddll[0]]
b = dflav[ddll[1]]
... | python | def JMS_to_Fierz_lep(C, ddll):
"""From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
if ddll[:2] == 'uc':
s = uflav[ddll[0]]
b = uflav[ddll[1]]
q = 'u'
else:
s = dflav[ddll[0]]
b = dflav[ddll[1]]
... | [
"def",
"JMS_to_Fierz_lep",
"(",
"C",
",",
"ddll",
")",
":",
"if",
"ddll",
"[",
":",
"2",
"]",
"==",
"'uc'",
":",
"s",
"=",
"uflav",
"[",
"ddll",
"[",
"0",
"]",
"]",
"b",
"=",
"uflav",
"[",
"ddll",
"[",
"1",
"]",
"]",
"q",
"=",
"'u'",
"else"... | From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"JMS",
"to",
"semileptonic",
"Fierz",
"basis",
"for",
"Class",
"V",
".",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L936-L971 |
wilson-eft/wilson | wilson/translate/wet.py | JMS_to_Fierz_nunu | def JMS_to_Fierz_nunu(C, ddll):
"""From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
s = dflav[ddll[0]]
b = dflav[ddll[1]]
l = lflav[ddll[4:ddll.find('n')]]
lp = lflav[ddll[ddll.find('_',5)+1:len(ddll)]]
ind = ddll.replace('l_'... | python | def JMS_to_Fierz_nunu(C, ddll):
"""From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
s = dflav[ddll[0]]
b = dflav[ddll[1]]
l = lflav[ddll[4:ddll.find('n')]]
lp = lflav[ddll[ddll.find('_',5)+1:len(ddll)]]
ind = ddll.replace('l_'... | [
"def",
"JMS_to_Fierz_nunu",
"(",
"C",
",",
"ddll",
")",
":",
"s",
"=",
"dflav",
"[",
"ddll",
"[",
"0",
"]",
"]",
"b",
"=",
"dflav",
"[",
"ddll",
"[",
"1",
"]",
"]",
"l",
"=",
"lflav",
"[",
"ddll",
"[",
"4",
":",
"ddll",
".",
"find",
"(",
"'... | From JMS to semileptonic Fierz basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"JMS",
"to",
"semileptonic",
"Fierz",
"basis",
"for",
"Class",
"V",
".",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L973-L984 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_JMS_lep | def Fierz_to_JMS_lep(C, ddll):
"""From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
if ddll[:2] == 'uc':
s = str(uflav[ddll[0]] + 1)
b = str(uflav[ddll[1]] + 1)
q = 'u'
else:
s = str(dflav[ddll[0]] + 1)
... | python | def Fierz_to_JMS_lep(C, ddll):
"""From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
if ddll[:2] == 'uc':
s = str(uflav[ddll[0]] + 1)
b = str(uflav[ddll[1]] + 1)
q = 'u'
else:
s = str(dflav[ddll[0]] + 1)
... | [
"def",
"Fierz_to_JMS_lep",
"(",
"C",
",",
"ddll",
")",
":",
"if",
"ddll",
"[",
":",
"2",
"]",
"==",
"'uc'",
":",
"s",
"=",
"str",
"(",
"uflav",
"[",
"ddll",
"[",
"0",
"]",
"]",
"+",
"1",
")",
"b",
"=",
"str",
"(",
"uflav",
"[",
"ddll",
"[",... | From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"Fierz",
"to",
"semileptonic",
"JMS",
"basis",
"for",
"Class",
"V",
".",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L987-L1013 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_JMS_nunu | def Fierz_to_JMS_nunu(C, ddll):
"""From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
s = str(dflav[ddll[0]] + 1)
b = str(dflav[ddll[1]] + 1)
l = str(lflav[ddll[4:ddll.find('n')]] + 1)
lp = str(lflav[ddll[ddll.find('_',5)+1:len(ddll... | python | def Fierz_to_JMS_nunu(C, ddll):
"""From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
s = str(dflav[ddll[0]] + 1)
b = str(dflav[ddll[1]] + 1)
l = str(lflav[ddll[4:ddll.find('n')]] + 1)
lp = str(lflav[ddll[ddll.find('_',5)+1:len(ddll... | [
"def",
"Fierz_to_JMS_nunu",
"(",
"C",
",",
"ddll",
")",
":",
"s",
"=",
"str",
"(",
"dflav",
"[",
"ddll",
"[",
"0",
"]",
"]",
"+",
"1",
")",
"b",
"=",
"str",
"(",
"dflav",
"[",
"ddll",
"[",
"1",
"]",
"]",
"+",
"1",
")",
"l",
"=",
"str",
"(... | From Fierz to semileptonic JMS basis for Class V.
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"Fierz",
"to",
"semileptonic",
"JMS",
"basis",
"for",
"Class",
"V",
".",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1015-L1027 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_Bern_lep | def Fierz_to_Bern_lep(C, ddll):
"""From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
dic = {
'1' + ind : 5... | python | def Fierz_to_Bern_lep(C, ddll):
"""From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
dic = {
'1' + ind : 5... | [
"def",
"Fierz_to_Bern_lep",
"(",
"C",
",",
"ddll",
")",
":",
"ind",
"=",
"ddll",
".",
"replace",
"(",
"'l_'",
",",
"''",
")",
".",
"replace",
"(",
"'nu_'",
",",
"''",
")",
"dic",
"=",
"{",
"'1'",
"+",
"ind",
":",
"5",
"*",
"C",
"[",
"'F'",
"+... | From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Fierz",
"basis",
"to",
"Bern",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1030-L1049 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_Bern_nunu | def Fierz_to_Bern_nunu(C, ddll):
"""From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
dic = {
'nu1' + ind... | python | def Fierz_to_Bern_nunu(C, ddll):
"""From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
dic = {
'nu1' + ind... | [
"def",
"Fierz_to_Bern_nunu",
"(",
"C",
",",
"ddll",
")",
":",
"ind",
"=",
"ddll",
".",
"replace",
"(",
"'l_'",
",",
"''",
")",
".",
"replace",
"(",
"'nu_'",
",",
"''",
")",
"dic",
"=",
"{",
"'nu1'",
"+",
"ind",
":",
"C",
"[",
"'F'",
"+",
"ind",... | From semileptonic Fierz basis to Bern semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Fierz",
"basis",
"to",
"Bern",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1051-L1061 |
wilson-eft/wilson | wilson/translate/wet.py | Bern_to_Fierz_lep | def Bern_to_Fierz_lep(C,ddll):
"""From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
return {'F' + ind + '9': C['1'... | python | def Bern_to_Fierz_lep(C,ddll):
"""From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
return {'F' + ind + '9': C['1'... | [
"def",
"Bern_to_Fierz_lep",
"(",
"C",
",",
"ddll",
")",
":",
"ind",
"=",
"ddll",
".",
"replace",
"(",
"'l_'",
",",
"''",
")",
".",
"replace",
"(",
"'nu_'",
",",
"''",
")",
"return",
"{",
"'F'",
"+",
"ind",
"+",
"'9'",
":",
"C",
"[",
"'1'",
"+",... | From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Bern",
"basis",
"to",
"Fierz",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1064-L1079 |
wilson-eft/wilson | wilson/translate/wet.py | Bern_to_Fierz_nunu | def Bern_to_Fierz_nunu(C,ddll):
"""From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
return {
'F' + in... | python | def Bern_to_Fierz_nunu(C,ddll):
"""From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
ind = ddll.replace('l_','').replace('nu_','')
return {
'F' + in... | [
"def",
"Bern_to_Fierz_nunu",
"(",
"C",
",",
"ddll",
")",
":",
"ind",
"=",
"ddll",
".",
"replace",
"(",
"'l_'",
",",
"''",
")",
".",
"replace",
"(",
"'nu_'",
",",
"''",
")",
"return",
"{",
"'F'",
"+",
"ind",
"+",
"'nu'",
":",
"C",
"[",
"'nu1'",
... | From semileptonic Bern basis to Fierz semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Bern",
"basis",
"to",
"Fierz",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1082-L1090 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_Flavio_lep | def Fierz_to_Flavio_lep(C, ddll, parameters, norm_gf=True):
"""From semileptonic Fierz basis to Flavio semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vu... | python | def Fierz_to_Flavio_lep(C, ddll, parameters, norm_gf=True):
"""From semileptonic Fierz basis to Flavio semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vu... | [
"def",
"Fierz_to_Flavio_lep",
"(",
"C",
",",
"ddll",
",",
"parameters",
",",
"norm_gf",
"=",
"True",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
"... | From semileptonic Fierz basis to Flavio semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Fierz",
"basis",
"to",
"Flavio",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1093-L1138 |
wilson-eft/wilson | wilson/translate/wet.py | Flavio_to_Fierz_nunu | def Flavio_to_Fierz_nunu(C, ddll, parameters, norm_gf=True):
"""From Flavio semileptonic basis to semileptonic Fierz basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["... | python | def Flavio_to_Fierz_nunu(C, ddll, parameters, norm_gf=True):
"""From Flavio semileptonic basis to semileptonic Fierz basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["... | [
"def",
"Flavio_to_Fierz_nunu",
"(",
"C",
",",
"ddll",
",",
"parameters",
",",
"norm_gf",
"=",
"True",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
... | From Flavio semileptonic basis to semileptonic Fierz basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"Flavio",
"semileptonic",
"basis",
"to",
"semileptonic",
"Fierz",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1224-L1253 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_EOS_lep | def Fierz_to_EOS_lep(C, ddll, parameters):
"""From semileptonic Fierz basis to EOS semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vc... | python | def Fierz_to_EOS_lep(C, ddll, parameters):
"""From semileptonic Fierz basis to EOS semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vc... | [
"def",
"Fierz_to_EOS_lep",
"(",
"C",
",",
"ddll",
",",
"parameters",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
",",
"p",
"[",
"\"Vcb\"",
"]",
... | From semileptonic Fierz basis to EOS semileptonic basis for Class V.
C should be the corresponding leptonic Fierz basis and
`ddll` should be of the form 'sbl_enu_tau', 'dbl_munu_e' etc. | [
"From",
"semileptonic",
"Fierz",
"basis",
"to",
"EOS",
"semileptonic",
"basis",
"for",
"Class",
"V",
".",
"C",
"should",
"be",
"the",
"corresponding",
"leptonic",
"Fierz",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_enu_tau",
"dbl_munu_e"... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1256-L1280 |
wilson-eft/wilson | wilson/translate/wet.py | JMS_to_FormFlavor_lep | def JMS_to_FormFlavor_lep(C, dd):
"""From JMS to semileptonic Fierz basis for Classes V.
C should be the JMS basis and `ddll` should be of the
form 'sbl_eni_tau', 'dbl_munu_e' etc."""
b = dflav[dd[0]]
s = dflav[dd[1]]
return {
'CVLL_' + dd + 'mm' : C["VedLL"][1, 1, s, b],
'CVRR_'... | python | def JMS_to_FormFlavor_lep(C, dd):
"""From JMS to semileptonic Fierz basis for Classes V.
C should be the JMS basis and `ddll` should be of the
form 'sbl_eni_tau', 'dbl_munu_e' etc."""
b = dflav[dd[0]]
s = dflav[dd[1]]
return {
'CVLL_' + dd + 'mm' : C["VedLL"][1, 1, s, b],
'CVRR_'... | [
"def",
"JMS_to_FormFlavor_lep",
"(",
"C",
",",
"dd",
")",
":",
"b",
"=",
"dflav",
"[",
"dd",
"[",
"0",
"]",
"]",
"s",
"=",
"dflav",
"[",
"dd",
"[",
"1",
"]",
"]",
"return",
"{",
"'CVLL_'",
"+",
"dd",
"+",
"'mm'",
":",
"C",
"[",
"\"VedLL\"",
"... | From JMS to semileptonic Fierz basis for Classes V.
C should be the JMS basis and `ddll` should be of the
form 'sbl_eni_tau', 'dbl_munu_e' etc. | [
"From",
"JMS",
"to",
"semileptonic",
"Fierz",
"basis",
"for",
"Classes",
"V",
".",
"C",
"should",
"be",
"the",
"JMS",
"basis",
"and",
"ddll",
"should",
"be",
"of",
"the",
"form",
"sbl_eni_tau",
"dbl_munu_e",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1282-L1305 |
wilson-eft/wilson | wilson/translate/wet.py | JMS_to_Fierz_chrom | def JMS_to_Fierz_chrom(C, qq):
"""From JMS to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'ds' etc."""
if qq[0] in dflav:
s = dflav[qq[0]]
b = dflav[qq[1]]
return {
'F7gamma' + qq : C['dgamma'][s, b],
'F8g' + qq : C['dG'][s, ... | python | def JMS_to_Fierz_chrom(C, qq):
"""From JMS to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'ds' etc."""
if qq[0] in dflav:
s = dflav[qq[0]]
b = dflav[qq[1]]
return {
'F7gamma' + qq : C['dgamma'][s, b],
'F8g' + qq : C['dG'][s, ... | [
"def",
"JMS_to_Fierz_chrom",
"(",
"C",
",",
"qq",
")",
":",
"if",
"qq",
"[",
"0",
"]",
"in",
"dflav",
":",
"s",
"=",
"dflav",
"[",
"qq",
"[",
"0",
"]",
"]",
"b",
"=",
"dflav",
"[",
"qq",
"[",
"1",
"]",
"]",
"return",
"{",
"'F7gamma'",
"+",
... | From JMS to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'ds' etc. | [
"From",
"JMS",
"to",
"chromomagnetic",
"Fierz",
"basis",
"for",
"Class",
"V",
".",
"qq",
"should",
"be",
"of",
"the",
"form",
"sb",
"ds",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1308-L1328 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_JMS_chrom | def Fierz_to_JMS_chrom(C, qq):
"""From chromomagnetic Fierz to JMS basis for Class V.
qq should be of the form 'sb', 'ds' etc."""
if qq[0] in dflav:
s = dflav[qq[0]] + 1
b = dflav[qq[1]] + 1
return {'dgamma_{}{}'.format(s, b): C['F7gamma' + qq],
'dG_{}{}'.format(s, b)... | python | def Fierz_to_JMS_chrom(C, qq):
"""From chromomagnetic Fierz to JMS basis for Class V.
qq should be of the form 'sb', 'ds' etc."""
if qq[0] in dflav:
s = dflav[qq[0]] + 1
b = dflav[qq[1]] + 1
return {'dgamma_{}{}'.format(s, b): C['F7gamma' + qq],
'dG_{}{}'.format(s, b)... | [
"def",
"Fierz_to_JMS_chrom",
"(",
"C",
",",
"qq",
")",
":",
"if",
"qq",
"[",
"0",
"]",
"in",
"dflav",
":",
"s",
"=",
"dflav",
"[",
"qq",
"[",
"0",
"]",
"]",
"+",
"1",
"b",
"=",
"dflav",
"[",
"qq",
"[",
"1",
"]",
"]",
"+",
"1",
"return",
"... | From chromomagnetic Fierz to JMS basis for Class V.
qq should be of the form 'sb', 'ds' etc. | [
"From",
"chromomagnetic",
"Fierz",
"to",
"JMS",
"basis",
"for",
"Class",
"V",
".",
"qq",
"should",
"be",
"of",
"the",
"form",
"sb",
"ds",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1331-L1349 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_Bern_chrom | def Fierz_to_Bern_chrom(C, dd, parameters):
"""From Fierz to chromomagnetic Bern basis for Class V.
dd should be of the form 'sb', 'ds' etc."""
e = sqrt(4 * pi * parameters['alpha_e'])
gs = sqrt(4 * pi * parameters['alpha_s'])
if dd == 'sb' or dd == 'db':
mq = parameters['m_b']
elif dd =... | python | def Fierz_to_Bern_chrom(C, dd, parameters):
"""From Fierz to chromomagnetic Bern basis for Class V.
dd should be of the form 'sb', 'ds' etc."""
e = sqrt(4 * pi * parameters['alpha_e'])
gs = sqrt(4 * pi * parameters['alpha_s'])
if dd == 'sb' or dd == 'db':
mq = parameters['m_b']
elif dd =... | [
"def",
"Fierz_to_Bern_chrom",
"(",
"C",
",",
"dd",
",",
"parameters",
")",
":",
"e",
"=",
"sqrt",
"(",
"4",
"*",
"pi",
"*",
"parameters",
"[",
"'alpha_e'",
"]",
")",
"gs",
"=",
"sqrt",
"(",
"4",
"*",
"pi",
"*",
"parameters",
"[",
"'alpha_s'",
"]",
... | From Fierz to chromomagnetic Bern basis for Class V.
dd should be of the form 'sb', 'ds' etc. | [
"From",
"Fierz",
"to",
"chromomagnetic",
"Bern",
"basis",
"for",
"Class",
"V",
".",
"dd",
"should",
"be",
"of",
"the",
"form",
"sb",
"ds",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1352-L1368 |
wilson-eft/wilson | wilson/translate/wet.py | Flavio_to_Fierz_chrom | def Flavio_to_Fierz_chrom(C, qq, parameters):
"""From Flavio to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'db' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
if qq == 'sb':
xi = V[2, 2] * V[2, 1].conj()
elif qq == 'd... | python | def Flavio_to_Fierz_chrom(C, qq, parameters):
"""From Flavio to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'db' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
if qq == 'sb':
xi = V[2, 2] * V[2, 1].conj()
elif qq == 'd... | [
"def",
"Flavio_to_Fierz_chrom",
"(",
"C",
",",
"qq",
",",
"parameters",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
",",
"p",
"[",
"\"Vcb\"",
"]",... | From Flavio to chromomagnetic Fierz basis for Class V.
qq should be of the form 'sb', 'db' etc. | [
"From",
"Flavio",
"to",
"chromomagnetic",
"Fierz",
"basis",
"for",
"Class",
"V",
".",
"qq",
"should",
"be",
"of",
"the",
"form",
"sb",
"db",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1426-L1459 |
wilson-eft/wilson | wilson/translate/wet.py | Fierz_to_EOS_chrom | def Fierz_to_EOS_chrom(C, dd, parameters):
"""From Fierz to chromomagnetic EOS basis for Class V.
dd should be of the form 'sb', 'ds' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
Vtb = V[2,2]
Vts = V[2,1]
e = sqrt(4 * pi * parameters['alpha_e'])
... | python | def Fierz_to_EOS_chrom(C, dd, parameters):
"""From Fierz to chromomagnetic EOS basis for Class V.
dd should be of the form 'sb', 'ds' etc."""
p = parameters
V = ckmutil.ckm.ckm_tree(p["Vus"], p["Vub"], p["Vcb"], p["delta"])
Vtb = V[2,2]
Vts = V[2,1]
e = sqrt(4 * pi * parameters['alpha_e'])
... | [
"def",
"Fierz_to_EOS_chrom",
"(",
"C",
",",
"dd",
",",
"parameters",
")",
":",
"p",
"=",
"parameters",
"V",
"=",
"ckmutil",
".",
"ckm",
".",
"ckm_tree",
"(",
"p",
"[",
"\"Vus\"",
"]",
",",
"p",
"[",
"\"Vub\"",
"]",
",",
"p",
"[",
"\"Vcb\"",
"]",
... | From Fierz to chromomagnetic EOS basis for Class V.
dd should be of the form 'sb', 'ds' etc. | [
"From",
"Fierz",
"to",
"chromomagnetic",
"EOS",
"basis",
"for",
"Class",
"V",
".",
"dd",
"should",
"be",
"of",
"the",
"form",
"sb",
"ds",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1462-L1478 |
wilson-eft/wilson | wilson/translate/wet.py | JMS_to_FormFlavor_chrom | def JMS_to_FormFlavor_chrom(C, qq, parameters):
"""From JMS to chromomagnetic FormFlavor basis for Class V.
qq should be of the form 'sb', 'ds', 'uu', mt (mu tau), em (e mu) etc."""
e = sqrt(4 * pi * parameters['alpha_e'])
gs = sqrt(4 * pi * parameters['alpha_s'])
if qq[0] in dflav.keys():
s... | python | def JMS_to_FormFlavor_chrom(C, qq, parameters):
"""From JMS to chromomagnetic FormFlavor basis for Class V.
qq should be of the form 'sb', 'ds', 'uu', mt (mu tau), em (e mu) etc."""
e = sqrt(4 * pi * parameters['alpha_e'])
gs = sqrt(4 * pi * parameters['alpha_s'])
if qq[0] in dflav.keys():
s... | [
"def",
"JMS_to_FormFlavor_chrom",
"(",
"C",
",",
"qq",
",",
"parameters",
")",
":",
"e",
"=",
"sqrt",
"(",
"4",
"*",
"pi",
"*",
"parameters",
"[",
"'alpha_e'",
"]",
")",
"gs",
"=",
"sqrt",
"(",
"4",
"*",
"pi",
"*",
"parameters",
"[",
"'alpha_s'",
"... | From JMS to chromomagnetic FormFlavor basis for Class V.
qq should be of the form 'sb', 'ds', 'uu', mt (mu tau), em (e mu) etc. | [
"From",
"JMS",
"to",
"chromomagnetic",
"FormFlavor",
"basis",
"for",
"Class",
"V",
".",
"qq",
"should",
"be",
"of",
"the",
"form",
"sb",
"ds",
"uu",
"mt",
"(",
"mu",
"tau",
")",
"em",
"(",
"e",
"mu",
")",
"etc",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1481-L1512 |
wilson-eft/wilson | wilson/translate/wet.py | _JMS_to_Flavio_VII | def _JMS_to_Flavio_VII(C, parameters):
"""From JMS to flavio basis for class VII, i.e. flavour blind operators."""
d = {}
dtrans = json.loads(pkgutil.get_data('wilson', 'data/flavio_jms_vii.json').decode('utf8'))
for cj, cf in dtrans.items():
d[cf] = C.get(cj, 0)
gs = sqrt(4 * pi * parameter... | python | def _JMS_to_Flavio_VII(C, parameters):
"""From JMS to flavio basis for class VII, i.e. flavour blind operators."""
d = {}
dtrans = json.loads(pkgutil.get_data('wilson', 'data/flavio_jms_vii.json').decode('utf8'))
for cj, cf in dtrans.items():
d[cf] = C.get(cj, 0)
gs = sqrt(4 * pi * parameter... | [
"def",
"_JMS_to_Flavio_VII",
"(",
"C",
",",
"parameters",
")",
":",
"d",
"=",
"{",
"}",
"dtrans",
"=",
"json",
".",
"loads",
"(",
"pkgutil",
".",
"get_data",
"(",
"'wilson'",
",",
"'data/flavio_jms_vii.json'",
")",
".",
"decode",
"(",
"'utf8'",
")",
")",... | From JMS to flavio basis for class VII, i.e. flavour blind operators. | [
"From",
"JMS",
"to",
"flavio",
"basis",
"for",
"class",
"VII",
"i",
".",
"e",
".",
"flavour",
"blind",
"operators",
"."
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1515-L1539 |
wilson-eft/wilson | wilson/translate/wet.py | get_parameters | def get_parameters(scale, f=5, input_parameters=None):
"""Get parameters (masses, coupling constants, ...) at the scale
`scale` in QCD with `f` dynamical quark flavours. Optionally takes a
dictionary of inputs (otherwise, defaults are used)."""
p = default_parameters.copy()
if input_parameters is no... | python | def get_parameters(scale, f=5, input_parameters=None):
"""Get parameters (masses, coupling constants, ...) at the scale
`scale` in QCD with `f` dynamical quark flavours. Optionally takes a
dictionary of inputs (otherwise, defaults are used)."""
p = default_parameters.copy()
if input_parameters is no... | [
"def",
"get_parameters",
"(",
"scale",
",",
"f",
"=",
"5",
",",
"input_parameters",
"=",
"None",
")",
":",
"p",
"=",
"default_parameters",
".",
"copy",
"(",
")",
"if",
"input_parameters",
"is",
"not",
"None",
":",
"# if parameters are passed in, overwrite the de... | Get parameters (masses, coupling constants, ...) at the scale
`scale` in QCD with `f` dynamical quark flavours. Optionally takes a
dictionary of inputs (otherwise, defaults are used). | [
"Get",
"parameters",
"(",
"masses",
"coupling",
"constants",
"...",
")",
"at",
"the",
"scale",
"scale",
"in",
"QCD",
"with",
"f",
"dynamical",
"quark",
"flavours",
".",
"Optionally",
"takes",
"a",
"dictionary",
"of",
"inputs",
"(",
"otherwise",
"defaults",
"... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/translate/wet.py#L1569-L1591 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | cut_from_chain | def cut_from_chain(sciobj_model):
"""Remove an object from a revision chain.
The object can be at any location in the chain, including the head or tail.
Preconditions:
- The object with the pid is verified to exist and to be a member of an
revision chain. E.g., with:
d1_gmn.app.views.asserts.... | python | def cut_from_chain(sciobj_model):
"""Remove an object from a revision chain.
The object can be at any location in the chain, including the head or tail.
Preconditions:
- The object with the pid is verified to exist and to be a member of an
revision chain. E.g., with:
d1_gmn.app.views.asserts.... | [
"def",
"cut_from_chain",
"(",
"sciobj_model",
")",
":",
"if",
"_is_head",
"(",
"sciobj_model",
")",
":",
"old_pid",
"=",
"sciobj_model",
".",
"obsoletes",
".",
"did",
"_cut_head_from_chain",
"(",
"sciobj_model",
")",
"elif",
"_is_tail",
"(",
"sciobj_model",
")",... | Remove an object from a revision chain.
The object can be at any location in the chain, including the head or tail.
Preconditions:
- The object with the pid is verified to exist and to be a member of an
revision chain. E.g., with:
d1_gmn.app.views.asserts.is_existing_object(pid)
d1_gmn.app.vi... | [
"Remove",
"an",
"object",
"from",
"a",
"revision",
"chain",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L51-L81 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | resolve_sid | def resolve_sid(sid):
"""Get the PID to which the ``sid`` currently maps.
Preconditions:
- ``sid`` is verified to exist. E.g., with d1_gmn.app.views.asserts.is_sid().
"""
return d1_gmn.app.models.Chain.objects.get(sid__did=sid).head_pid.did | python | def resolve_sid(sid):
"""Get the PID to which the ``sid`` currently maps.
Preconditions:
- ``sid`` is verified to exist. E.g., with d1_gmn.app.views.asserts.is_sid().
"""
return d1_gmn.app.models.Chain.objects.get(sid__did=sid).head_pid.did | [
"def",
"resolve_sid",
"(",
"sid",
")",
":",
"return",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Chain",
".",
"objects",
".",
"get",
"(",
"sid__did",
"=",
"sid",
")",
".",
"head_pid",
".",
"did"
] | Get the PID to which the ``sid`` currently maps.
Preconditions:
- ``sid`` is verified to exist. E.g., with d1_gmn.app.views.asserts.is_sid(). | [
"Get",
"the",
"PID",
"to",
"which",
"the",
"sid",
"currently",
"maps",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L94-L101 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | is_obsoletes_pid | def is_obsoletes_pid(pid):
"""Return True if ``pid`` is referenced in the obsoletes field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain.
"""
return d1_gmn.app.models.Sc... | python | def is_obsoletes_pid(pid):
"""Return True if ``pid`` is referenced in the obsoletes field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain.
"""
return d1_gmn.app.models.Sc... | [
"def",
"is_obsoletes_pid",
"(",
"pid",
")",
":",
"return",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ScienceObject",
".",
"objects",
".",
"filter",
"(",
"obsoletes__did",
"=",
"pid",
")",
".",
"exists",
"(",
")"
] | Return True if ``pid`` is referenced in the obsoletes field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain. | [
"Return",
"True",
"if",
"pid",
"is",
"referenced",
"in",
"the",
"obsoletes",
"field",
"of",
"any",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L132-L139 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | is_obsoleted_by_pid | def is_obsoleted_by_pid(pid):
"""Return True if ``pid`` is referenced in the obsoletedBy field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain.
"""
return d1_gmn.app.mode... | python | def is_obsoleted_by_pid(pid):
"""Return True if ``pid`` is referenced in the obsoletedBy field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain.
"""
return d1_gmn.app.mode... | [
"def",
"is_obsoleted_by_pid",
"(",
"pid",
")",
":",
"return",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ScienceObject",
".",
"objects",
".",
"filter",
"(",
"obsoleted_by__did",
"=",
"pid",
")",
".",
"exists",
"(",
")"
] | Return True if ``pid`` is referenced in the obsoletedBy field of any object.
This will return True even if the PID is in the obsoletes field of an object that
does not exist on the local MN, such as replica that is in an incomplete chain. | [
"Return",
"True",
"if",
"pid",
"is",
"referenced",
"in",
"the",
"obsoletedBy",
"field",
"of",
"any",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L142-L151 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _merge_chains | def _merge_chains(chain_model_a, chain_model_b):
"""Merge two chains.
For use when it becomes known that two chains that were created separately
actually are separate sections of the same chain
E.g.:
- A obsoleted by X is created. A has no SID. X does not exist yet. A chain is
created for A... | python | def _merge_chains(chain_model_a, chain_model_b):
"""Merge two chains.
For use when it becomes known that two chains that were created separately
actually are separate sections of the same chain
E.g.:
- A obsoleted by X is created. A has no SID. X does not exist yet. A chain is
created for A... | [
"def",
"_merge_chains",
"(",
"chain_model_a",
",",
"chain_model_b",
")",
":",
"_set_chain_sid",
"(",
"chain_model_a",
",",
"d1_gmn",
".",
"app",
".",
"did",
".",
"get_did_by_foreign_key",
"(",
"chain_model_b",
".",
"sid",
")",
")",
"for",
"member_model",
"in",
... | Merge two chains.
For use when it becomes known that two chains that were created separately
actually are separate sections of the same chain
E.g.:
- A obsoleted by X is created. A has no SID. X does not exist yet. A chain is
created for A.
- B obsoleting Y is created. B has SID. Y does not... | [
"Merge",
"two",
"chains",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L196-L220 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _set_chain_sid | def _set_chain_sid(chain_model, sid):
"""Set or update SID for chain.
If the chain already has a SID, ``sid`` must either be None or match the existing
SID.
"""
if not sid:
return
if chain_model.sid and chain_model.sid.did != sid:
raise d1_common.types.exceptions.ServiceFailure... | python | def _set_chain_sid(chain_model, sid):
"""Set or update SID for chain.
If the chain already has a SID, ``sid`` must either be None or match the existing
SID.
"""
if not sid:
return
if chain_model.sid and chain_model.sid.did != sid:
raise d1_common.types.exceptions.ServiceFailure... | [
"def",
"_set_chain_sid",
"(",
"chain_model",
",",
"sid",
")",
":",
"if",
"not",
"sid",
":",
"return",
"if",
"chain_model",
".",
"sid",
"and",
"chain_model",
".",
"sid",
".",
"did",
"!=",
"sid",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
... | Set or update SID for chain.
If the chain already has a SID, ``sid`` must either be None or match the existing
SID. | [
"Set",
"or",
"update",
"SID",
"for",
"chain",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L230-L246 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _get_chain_by_pid | def _get_chain_by_pid(pid):
"""Find chain by pid.
Return None if not found.
"""
try:
return d1_gmn.app.models.ChainMember.objects.get(pid__did=pid).chain
except d1_gmn.app.models.ChainMember.DoesNotExist:
pass | python | def _get_chain_by_pid(pid):
"""Find chain by pid.
Return None if not found.
"""
try:
return d1_gmn.app.models.ChainMember.objects.get(pid__did=pid).chain
except d1_gmn.app.models.ChainMember.DoesNotExist:
pass | [
"def",
"_get_chain_by_pid",
"(",
"pid",
")",
":",
"try",
":",
"return",
"d1_gmn",
".",
"app",
".",
"models",
".",
"ChainMember",
".",
"objects",
".",
"get",
"(",
"pid__did",
"=",
"pid",
")",
".",
"chain",
"except",
"d1_gmn",
".",
"app",
".",
"models",
... | Find chain by pid.
Return None if not found. | [
"Find",
"chain",
"by",
"pid",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L281-L290 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _get_chain_by_sid | def _get_chain_by_sid(sid):
"""Return None if not found."""
try:
return d1_gmn.app.models.Chain.objects.get(sid__did=sid)
except d1_gmn.app.models.Chain.DoesNotExist:
pass | python | def _get_chain_by_sid(sid):
"""Return None if not found."""
try:
return d1_gmn.app.models.Chain.objects.get(sid__did=sid)
except d1_gmn.app.models.Chain.DoesNotExist:
pass | [
"def",
"_get_chain_by_sid",
"(",
"sid",
")",
":",
"try",
":",
"return",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Chain",
".",
"objects",
".",
"get",
"(",
"sid__did",
"=",
"sid",
")",
"except",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Chain",
".",... | Return None if not found. | [
"Return",
"None",
"if",
"not",
"found",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L293-L298 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _update_sid_to_last_existing_pid_map | def _update_sid_to_last_existing_pid_map(pid):
"""Set chain head PID to the last existing object in the chain to which ``pid``
belongs. If SID has been set for chain, it resolves to chain head PID.
Intended to be called in MNStorage.delete() and other chain manipulation.
Preconditions:
- ``pid`` m... | python | def _update_sid_to_last_existing_pid_map(pid):
"""Set chain head PID to the last existing object in the chain to which ``pid``
belongs. If SID has been set for chain, it resolves to chain head PID.
Intended to be called in MNStorage.delete() and other chain manipulation.
Preconditions:
- ``pid`` m... | [
"def",
"_update_sid_to_last_existing_pid_map",
"(",
"pid",
")",
":",
"last_pid",
"=",
"_find_head_or_latest_connected",
"(",
"pid",
")",
"chain_model",
"=",
"_get_chain_by_pid",
"(",
"last_pid",
")",
"if",
"not",
"chain_model",
":",
"return",
"chain_model",
".",
"he... | Set chain head PID to the last existing object in the chain to which ``pid``
belongs. If SID has been set for chain, it resolves to chain head PID.
Intended to be called in MNStorage.delete() and other chain manipulation.
Preconditions:
- ``pid`` must exist and be verified to be a PID.
d1_gmn.ap... | [
"Set",
"chain",
"head",
"PID",
"to",
"the",
"last",
"existing",
"object",
"in",
"the",
"chain",
"to",
"which",
"pid",
"belongs",
".",
"If",
"SID",
"has",
"been",
"set",
"for",
"chain",
"it",
"resolves",
"to",
"chain",
"head",
"PID",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L301-L317 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | _create_chain | def _create_chain(pid, sid):
"""Create the initial chain structure for a new standalone object. Intended to be
called in MNStorage.create().
Preconditions:
- ``sid`` must be verified to be available to be assigned to a new standalone
object. E.g., with is_valid_sid_for_new_standalone().
"""
... | python | def _create_chain(pid, sid):
"""Create the initial chain structure for a new standalone object. Intended to be
called in MNStorage.create().
Preconditions:
- ``sid`` must be verified to be available to be assigned to a new standalone
object. E.g., with is_valid_sid_for_new_standalone().
"""
... | [
"def",
"_create_chain",
"(",
"pid",
",",
"sid",
")",
":",
"chain_model",
"=",
"d1_gmn",
".",
"app",
".",
"models",
".",
"Chain",
"(",
"# sid=d1_gmn.app.models.did(sid) if sid else None,",
"head_pid",
"=",
"d1_gmn",
".",
"app",
".",
"did",
".",
"get_or_create_did... | Create the initial chain structure for a new standalone object. Intended to be
called in MNStorage.create().
Preconditions:
- ``sid`` must be verified to be available to be assigned to a new standalone
object. E.g., with is_valid_sid_for_new_standalone(). | [
"Create",
"the",
"initial",
"chain",
"structure",
"for",
"a",
"new",
"standalone",
"object",
".",
"Intended",
"to",
"be",
"called",
"in",
"MNStorage",
".",
"create",
"()",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L320-L336 |
genialis/resolwe | resolwe/flow/migrations/0025_entity_type.py | populate_entity_type | def populate_entity_type(apps, schema_editor):
"""Populate entity type from attached descriptor schema."""
Entity = apps.get_model('flow', 'Entity')
for entity in Entity.objects.all():
if entity.descriptor_schema is not None:
entity.type = entity.descriptor_schema.slug
entit... | python | def populate_entity_type(apps, schema_editor):
"""Populate entity type from attached descriptor schema."""
Entity = apps.get_model('flow', 'Entity')
for entity in Entity.objects.all():
if entity.descriptor_schema is not None:
entity.type = entity.descriptor_schema.slug
entit... | [
"def",
"populate_entity_type",
"(",
"apps",
",",
"schema_editor",
")",
":",
"Entity",
"=",
"apps",
".",
"get_model",
"(",
"'flow'",
",",
"'Entity'",
")",
"for",
"entity",
"in",
"Entity",
".",
"objects",
".",
"all",
"(",
")",
":",
"if",
"entity",
".",
"... | Populate entity type from attached descriptor schema. | [
"Populate",
"entity",
"type",
"from",
"attached",
"descriptor",
"schema",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0025_entity_type.py#L8-L15 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | deserialize | def deserialize(doc_xml, pyxb_binding=None):
"""Deserialize DataONE XML types to PyXB.
Args:
doc_xml: UTF-8 encoded ``bytes``
pyxb_binding: PyXB binding object. If not specified, the correct one should be
selected automatically.
Returns:
PyXB object
See Also:
``deserial... | python | def deserialize(doc_xml, pyxb_binding=None):
"""Deserialize DataONE XML types to PyXB.
Args:
doc_xml: UTF-8 encoded ``bytes``
pyxb_binding: PyXB binding object. If not specified, the correct one should be
selected automatically.
Returns:
PyXB object
See Also:
``deserial... | [
"def",
"deserialize",
"(",
"doc_xml",
",",
"pyxb_binding",
"=",
"None",
")",
":",
"pyxb_binding",
"=",
"pyxb_binding",
"or",
"d1_common",
".",
"types",
".",
"dataoneTypes",
"try",
":",
"return",
"pyxb_binding",
".",
"CreateFromDocument",
"(",
"doc_xml",
")",
"... | Deserialize DataONE XML types to PyXB.
Args:
doc_xml: UTF-8 encoded ``bytes``
pyxb_binding: PyXB binding object. If not specified, the correct one should be
selected automatically.
Returns:
PyXB object
See Also:
``deserialize_d1_exception()`` for deserializing DataONE Excep... | [
"Deserialize",
"DataONE",
"XML",
"types",
"to",
"PyXB",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L36-L66 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | serialize_gen | def serialize_gen(
obj_pyxb, encoding='utf-8', pretty=False, strip_prolog=False, xslt_url=None
):
"""Serialize PyXB object to XML.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
encoding: str
Encoding to use for XML doc bytes
pretty: bool
True: Use pretty ... | python | def serialize_gen(
obj_pyxb, encoding='utf-8', pretty=False, strip_prolog=False, xslt_url=None
):
"""Serialize PyXB object to XML.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
encoding: str
Encoding to use for XML doc bytes
pretty: bool
True: Use pretty ... | [
"def",
"serialize_gen",
"(",
"obj_pyxb",
",",
"encoding",
"=",
"'utf-8'",
",",
"pretty",
"=",
"False",
",",
"strip_prolog",
"=",
"False",
",",
"xslt_url",
"=",
"None",
")",
":",
"assert",
"d1_common",
".",
"type_conversions",
".",
"is_pyxb",
"(",
"obj_pyxb",... | Serialize PyXB object to XML.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
encoding: str
Encoding to use for XML doc bytes
pretty: bool
True: Use pretty print formatting for human readability.
strip_prolog:
True: remove any XML prolog (e.g., ``<?x... | [
"Serialize",
"PyXB",
"object",
"to",
"XML",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L79-L139 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | serialize_for_transport | def serialize_for_transport(obj_pyxb, pretty=False, strip_prolog=False, xslt_url=None):
"""Serialize PyXB object to XML ``bytes`` with UTF-8 encoding for transport over the
network, filesystem storage and other machine usage.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty... | python | def serialize_for_transport(obj_pyxb, pretty=False, strip_prolog=False, xslt_url=None):
"""Serialize PyXB object to XML ``bytes`` with UTF-8 encoding for transport over the
network, filesystem storage and other machine usage.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty... | [
"def",
"serialize_for_transport",
"(",
"obj_pyxb",
",",
"pretty",
"=",
"False",
",",
"strip_prolog",
"=",
"False",
",",
"xslt_url",
"=",
"None",
")",
":",
"return",
"serialize_gen",
"(",
"obj_pyxb",
",",
"'utf-8'",
",",
"pretty",
",",
"strip_prolog",
",",
"x... | Serialize PyXB object to XML ``bytes`` with UTF-8 encoding for transport over the
network, filesystem storage and other machine usage.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty: bool
True: Use pretty print formatting for human readability.
strip_prolog:
... | [
"Serialize",
"PyXB",
"object",
"to",
"XML",
"bytes",
"with",
"UTF",
"-",
"8",
"encoding",
"for",
"transport",
"over",
"the",
"network",
"filesystem",
"storage",
"and",
"other",
"machine",
"usage",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L142-L168 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | serialize_to_xml_str | def serialize_to_xml_str(obj_pyxb, pretty=True, strip_prolog=False, xslt_url=None):
"""Serialize PyXB object to pretty printed XML ``str`` for display.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty: bool
False: Disable pretty print formatting. XML will not have line ... | python | def serialize_to_xml_str(obj_pyxb, pretty=True, strip_prolog=False, xslt_url=None):
"""Serialize PyXB object to pretty printed XML ``str`` for display.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty: bool
False: Disable pretty print formatting. XML will not have line ... | [
"def",
"serialize_to_xml_str",
"(",
"obj_pyxb",
",",
"pretty",
"=",
"True",
",",
"strip_prolog",
"=",
"False",
",",
"xslt_url",
"=",
"None",
")",
":",
"return",
"serialize_gen",
"(",
"obj_pyxb",
",",
"None",
",",
"pretty",
",",
"strip_prolog",
",",
"xslt_url... | Serialize PyXB object to pretty printed XML ``str`` for display.
Args:
obj_pyxb: PyXB object
PyXB object to serialize.
pretty: bool
False: Disable pretty print formatting. XML will not have line breaks.
strip_prolog:
True: remove any XML prolog (e.g., ``<?xml version="1.... | [
"Serialize",
"PyXB",
"object",
"to",
"pretty",
"printed",
"XML",
"str",
"for",
"display",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L172-L194 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | reformat_to_pretty_xml | def reformat_to_pretty_xml(doc_xml):
"""Pretty print XML doc.
Args:
doc_xml : str
Well formed XML doc
Returns:
str: Pretty printed XML doc
"""
assert isinstance(doc_xml, str)
dom_obj = xml.dom.minidom.parseString(doc_xml)
pretty_xml = dom_obj.toprettyxml(indent=' ')
... | python | def reformat_to_pretty_xml(doc_xml):
"""Pretty print XML doc.
Args:
doc_xml : str
Well formed XML doc
Returns:
str: Pretty printed XML doc
"""
assert isinstance(doc_xml, str)
dom_obj = xml.dom.minidom.parseString(doc_xml)
pretty_xml = dom_obj.toprettyxml(indent=' ')
... | [
"def",
"reformat_to_pretty_xml",
"(",
"doc_xml",
")",
":",
"assert",
"isinstance",
"(",
"doc_xml",
",",
"str",
")",
"dom_obj",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"parseString",
"(",
"doc_xml",
")",
"pretty_xml",
"=",
"dom_obj",
".",
"toprettyxml",
... | Pretty print XML doc.
Args:
doc_xml : str
Well formed XML doc
Returns:
str: Pretty printed XML doc | [
"Pretty",
"print",
"XML",
"doc",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L197-L212 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | are_equivalent | def are_equivalent(a_xml, b_xml, encoding=None):
"""Return True if two XML docs are semantically equivalent, else False.
- TODO: Include test for tails. Skipped for now because tails are not used in any
D1 types.
"""
assert isinstance(a_xml, str)
assert isinstance(b_xml, str)
a_tree = st... | python | def are_equivalent(a_xml, b_xml, encoding=None):
"""Return True if two XML docs are semantically equivalent, else False.
- TODO: Include test for tails. Skipped for now because tails are not used in any
D1 types.
"""
assert isinstance(a_xml, str)
assert isinstance(b_xml, str)
a_tree = st... | [
"def",
"are_equivalent",
"(",
"a_xml",
",",
"b_xml",
",",
"encoding",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"a_xml",
",",
"str",
")",
"assert",
"isinstance",
"(",
"b_xml",
",",
"str",
")",
"a_tree",
"=",
"str_to_etree",
"(",
"a_xml",
",",
... | Return True if two XML docs are semantically equivalent, else False.
- TODO: Include test for tails. Skipped for now because tails are not used in any
D1 types. | [
"Return",
"True",
"if",
"two",
"XML",
"docs",
"are",
"semantically",
"equivalent",
"else",
"False",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L222-L235 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | are_equal_or_superset | def are_equal_or_superset(superset_tree, base_tree):
"""Return True if ``superset_tree`` is equal to or a superset of ``base_tree``
- Checks that all elements and attributes in ``superset_tree`` are present and
contain the same values as in ``base_tree``. For elements, also checks that the
order is... | python | def are_equal_or_superset(superset_tree, base_tree):
"""Return True if ``superset_tree`` is equal to or a superset of ``base_tree``
- Checks that all elements and attributes in ``superset_tree`` are present and
contain the same values as in ``base_tree``. For elements, also checks that the
order is... | [
"def",
"are_equal_or_superset",
"(",
"superset_tree",
",",
"base_tree",
")",
":",
"try",
":",
"_compare_attr",
"(",
"superset_tree",
",",
"base_tree",
")",
"_compare_text",
"(",
"superset_tree",
",",
"base_tree",
")",
"except",
"CompareError",
"as",
"e",
":",
"l... | Return True if ``superset_tree`` is equal to or a superset of ``base_tree``
- Checks that all elements and attributes in ``superset_tree`` are present and
contain the same values as in ``base_tree``. For elements, also checks that the
order is the same.
- Can be used for checking if one XML documen... | [
"Return",
"True",
"if",
"superset_tree",
"is",
"equal",
"to",
"or",
"a",
"superset",
"of",
"base_tree"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L238-L255 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | are_equal_xml | def are_equal_xml(a_xml, b_xml):
"""Normalize and compare XML documents for equality. The document may or may not be
a DataONE type.
Args:
a_xml: str
b_xml: str
XML documents to compare for equality.
Returns:
bool: ``True`` if the XML documents are semantically equivalent.
... | python | def are_equal_xml(a_xml, b_xml):
"""Normalize and compare XML documents for equality. The document may or may not be
a DataONE type.
Args:
a_xml: str
b_xml: str
XML documents to compare for equality.
Returns:
bool: ``True`` if the XML documents are semantically equivalent.
... | [
"def",
"are_equal_xml",
"(",
"a_xml",
",",
"b_xml",
")",
":",
"a_dom",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"parseString",
"(",
"a_xml",
")",
"b_dom",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"parseString",
"(",
"b_xml",
")",
"return",
"a... | Normalize and compare XML documents for equality. The document may or may not be
a DataONE type.
Args:
a_xml: str
b_xml: str
XML documents to compare for equality.
Returns:
bool: ``True`` if the XML documents are semantically equivalent. | [
"Normalize",
"and",
"compare",
"XML",
"documents",
"for",
"equality",
".",
"The",
"document",
"may",
"or",
"may",
"not",
"be",
"a",
"DataONE",
"type",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L337-L352 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | are_equal_elements | def are_equal_elements(a_el, b_el):
"""Normalize and compare ElementTrees for equality.
Args:
a_el: ElementTree
b_el: ElementTree
ElementTrees to compare for equality.
Returns:
bool: ``True`` if the ElementTrees are semantically equivalent.
"""
if a_el.tagName != b_el.ta... | python | def are_equal_elements(a_el, b_el):
"""Normalize and compare ElementTrees for equality.
Args:
a_el: ElementTree
b_el: ElementTree
ElementTrees to compare for equality.
Returns:
bool: ``True`` if the ElementTrees are semantically equivalent.
"""
if a_el.tagName != b_el.ta... | [
"def",
"are_equal_elements",
"(",
"a_el",
",",
"b_el",
")",
":",
"if",
"a_el",
".",
"tagName",
"!=",
"b_el",
".",
"tagName",
":",
"return",
"False",
"if",
"sorted",
"(",
"a_el",
".",
"attributes",
".",
"items",
"(",
")",
")",
"!=",
"sorted",
"(",
"b_... | Normalize and compare ElementTrees for equality.
Args:
a_el: ElementTree
b_el: ElementTree
ElementTrees to compare for equality.
Returns:
bool: ``True`` if the ElementTrees are semantically equivalent. | [
"Normalize",
"and",
"compare",
"ElementTrees",
"for",
"equality",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L370-L400 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | sort_elements_by_child_values | def sort_elements_by_child_values(obj_pyxb, child_name_list):
"""In-place sort simple or complex elements in a PyXB object by values they contain
in child elements.
Args:
obj_pyxb: PyXB object
child_name_list: list of str
List of element names that are direct children of the PyXB objec... | python | def sort_elements_by_child_values(obj_pyxb, child_name_list):
"""In-place sort simple or complex elements in a PyXB object by values they contain
in child elements.
Args:
obj_pyxb: PyXB object
child_name_list: list of str
List of element names that are direct children of the PyXB objec... | [
"def",
"sort_elements_by_child_values",
"(",
"obj_pyxb",
",",
"child_name_list",
")",
":",
"obj_pyxb",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"[",
"get_auto",
"(",
"getattr",
"(",
"x",
",",
"n",
")",
")",
"for",
"n",
"in",
"child_name_list",
"... | In-place sort simple or complex elements in a PyXB object by values they contain
in child elements.
Args:
obj_pyxb: PyXB object
child_name_list: list of str
List of element names that are direct children of the PyXB object. | [
"In",
"-",
"place",
"sort",
"simple",
"or",
"complex",
"elements",
"in",
"a",
"PyXB",
"object",
"by",
"values",
"they",
"contain",
"in",
"child",
"elements",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L412-L423 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | format_diff_pyxb | def format_diff_pyxb(a_pyxb, b_pyxb):
"""Create a diff between two PyXB objects.
Args:
a_pyxb: PyXB object
b_pyxb: PyXB object
Returns:
str : `Differ`-style delta
"""
return '\n'.join(
difflib.ndiff(
serialize_to_xml_str(a_pyxb).splitlines(),
seri... | python | def format_diff_pyxb(a_pyxb, b_pyxb):
"""Create a diff between two PyXB objects.
Args:
a_pyxb: PyXB object
b_pyxb: PyXB object
Returns:
str : `Differ`-style delta
"""
return '\n'.join(
difflib.ndiff(
serialize_to_xml_str(a_pyxb).splitlines(),
seri... | [
"def",
"format_diff_pyxb",
"(",
"a_pyxb",
",",
"b_pyxb",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"difflib",
".",
"ndiff",
"(",
"serialize_to_xml_str",
"(",
"a_pyxb",
")",
".",
"splitlines",
"(",
")",
",",
"serialize_to_xml_str",
"(",
"b_pyxb",
")",
... | Create a diff between two PyXB objects.
Args:
a_pyxb: PyXB object
b_pyxb: PyXB object
Returns:
str : `Differ`-style delta | [
"Create",
"a",
"diff",
"between",
"two",
"PyXB",
"objects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L426-L442 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | format_diff_xml | def format_diff_xml(a_xml, b_xml):
"""Create a diff between two XML documents.
Args:
a_xml: str
b_xml: str
Returns:
str : `Differ`-style delta
"""
return '\n'.join(
difflib.ndiff(
reformat_to_pretty_xml(a_xml).splitlines(),
reformat_to_pretty_xml(... | python | def format_diff_xml(a_xml, b_xml):
"""Create a diff between two XML documents.
Args:
a_xml: str
b_xml: str
Returns:
str : `Differ`-style delta
"""
return '\n'.join(
difflib.ndiff(
reformat_to_pretty_xml(a_xml).splitlines(),
reformat_to_pretty_xml(... | [
"def",
"format_diff_xml",
"(",
"a_xml",
",",
"b_xml",
")",
":",
"return",
"'\\n'",
".",
"join",
"(",
"difflib",
".",
"ndiff",
"(",
"reformat_to_pretty_xml",
"(",
"a_xml",
")",
".",
"splitlines",
"(",
")",
",",
"reformat_to_pretty_xml",
"(",
"b_xml",
")",
"... | Create a diff between two XML documents.
Args:
a_xml: str
b_xml: str
Returns:
str : `Differ`-style delta | [
"Create",
"a",
"diff",
"between",
"two",
"XML",
"documents",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L445-L461 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | get_opt_attr | def get_opt_attr(obj_pyxb, attr_str, default_val=None):
"""Get an optional attribute value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missing.
... | python | def get_opt_attr(obj_pyxb, attr_str, default_val=None):
"""Get an optional attribute value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missing.
... | [
"def",
"get_opt_attr",
"(",
"obj_pyxb",
",",
"attr_str",
",",
"default_val",
"=",
"None",
")",
":",
"v",
"=",
"getattr",
"(",
"obj_pyxb",
",",
"attr_str",
",",
"default_val",
")",
"return",
"v",
"if",
"v",
"is",
"not",
"None",
"else",
"default_val"
] | Get an optional attribute value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missing.
Args:
obj_pyxb: PyXB object
attr_str: str
... | [
"Get",
"an",
"optional",
"attribute",
"value",
"from",
"a",
"PyXB",
"element",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L508-L529 |
DataONEorg/d1_python | lib_common/src/d1_common/xml.py | get_opt_val | def get_opt_val(obj_pyxb, attr_str, default_val=None):
"""Get an optional Simple Content value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missi... | python | def get_opt_val(obj_pyxb, attr_str, default_val=None):
"""Get an optional Simple Content value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missi... | [
"def",
"get_opt_val",
"(",
"obj_pyxb",
",",
"attr_str",
",",
"default_val",
"=",
"None",
")",
":",
"try",
":",
"return",
"get_req_val",
"(",
"getattr",
"(",
"obj_pyxb",
",",
"attr_str",
")",
")",
"except",
"(",
"ValueError",
",",
"AttributeError",
")",
":"... | Get an optional Simple Content value from a PyXB element.
The attributes for elements that are optional according to the schema and
not set in the PyXB object are present and set to None.
PyXB validation will fail if required elements are missing.
Args:
obj_pyxb: PyXB object
attr_str: st... | [
"Get",
"an",
"optional",
"Simple",
"Content",
"value",
"from",
"a",
"PyXB",
"element",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/xml.py#L532-L556 |
genialis/resolwe | resolwe/flow/utils/exceptions.py | resolwe_exception_handler | def resolwe_exception_handler(exc, context):
"""Handle exceptions raised in API and make them nicer.
To enable this, you have to add it to the settings:
.. code:: python
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'resolwe.flow.utils.exceptions.resolwe_exception_handler',
... | python | def resolwe_exception_handler(exc, context):
"""Handle exceptions raised in API and make them nicer.
To enable this, you have to add it to the settings:
.. code:: python
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'resolwe.flow.utils.exceptions.resolwe_exception_handler',
... | [
"def",
"resolwe_exception_handler",
"(",
"exc",
",",
"context",
")",
":",
"response",
"=",
"exception_handler",
"(",
"exc",
",",
"context",
")",
"if",
"isinstance",
"(",
"exc",
",",
"ValidationError",
")",
":",
"if",
"response",
"is",
"None",
":",
"response"... | Handle exceptions raised in API and make them nicer.
To enable this, you have to add it to the settings:
.. code:: python
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'resolwe.flow.utils.exceptions.resolwe_exception_handler',
} | [
"Handle",
"exceptions",
"raised",
"in",
"API",
"and",
"make",
"them",
"nicer",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/exceptions.py#L16-L36 |
DataONEorg/d1_python | utilities/src/d1_util/jwt_token_tasks.py | validate_and_decode | def validate_and_decode(jwt_bu64, cert_obj):
"""Example for validating the signature of a JWT using only the cryptography
library.
Note that this does NOT validate the claims in the claim set.
"""
public_key = cert_obj.public_key()
message = '.'.join(d1_common.cert.jwt.get_bu64_tup(jwt_bu64)[:... | python | def validate_and_decode(jwt_bu64, cert_obj):
"""Example for validating the signature of a JWT using only the cryptography
library.
Note that this does NOT validate the claims in the claim set.
"""
public_key = cert_obj.public_key()
message = '.'.join(d1_common.cert.jwt.get_bu64_tup(jwt_bu64)[:... | [
"def",
"validate_and_decode",
"(",
"jwt_bu64",
",",
"cert_obj",
")",
":",
"public_key",
"=",
"cert_obj",
".",
"public_key",
"(",
")",
"message",
"=",
"'.'",
".",
"join",
"(",
"d1_common",
".",
"cert",
".",
"jwt",
".",
"get_bu64_tup",
"(",
"jwt_bu64",
")",
... | Example for validating the signature of a JWT using only the cryptography
library.
Note that this does NOT validate the claims in the claim set. | [
"Example",
"for",
"validating",
"the",
"signature",
"of",
"a",
"JWT",
"using",
"only",
"the",
"cryptography",
"library",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/jwt_token_tasks.py#L82-L101 |
DataONEorg/d1_python | utilities/src/d1_util/jwt_token_tasks.py | find_valid_combinations | def find_valid_combinations(cert_file_name_list, jwt_file_name_list):
"""Given a list of cert and JWT file names, print a list showing each combination
along with indicators for combinations where the JWT signature was successfully
validated with the cert."""
for cert_file_name in cert_file_name_list:
... | python | def find_valid_combinations(cert_file_name_list, jwt_file_name_list):
"""Given a list of cert and JWT file names, print a list showing each combination
along with indicators for combinations where the JWT signature was successfully
validated with the cert."""
for cert_file_name in cert_file_name_list:
... | [
"def",
"find_valid_combinations",
"(",
"cert_file_name_list",
",",
"jwt_file_name_list",
")",
":",
"for",
"cert_file_name",
"in",
"cert_file_name_list",
":",
"cert_pem",
"=",
"''",
"# self.test_files.load_utf8_to_str(cert_file_name)",
"cert_obj",
"=",
"d1_common",
".",
"cer... | Given a list of cert and JWT file names, print a list showing each combination
along with indicators for combinations where the JWT signature was successfully
validated with the cert. | [
"Given",
"a",
"list",
"of",
"cert",
"and",
"JWT",
"file",
"names",
"print",
"a",
"list",
"showing",
"each",
"combination",
"along",
"with",
"indicators",
"for",
"combinations",
"where",
"the",
"JWT",
"signature",
"was",
"successfully",
"validated",
"with",
"th... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/jwt_token_tasks.py#L104-L126 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | parseUrl | def parseUrl(url):
"""Return a dict containing scheme, netloc, url, params, query, fragment keys.
query is a dict where the values are always lists. If the query key appears only
once in the URL, the list will have a single value.
"""
scheme, netloc, url, params, query, fragment = urllib.parse.url... | python | def parseUrl(url):
"""Return a dict containing scheme, netloc, url, params, query, fragment keys.
query is a dict where the values are always lists. If the query key appears only
once in the URL, the list will have a single value.
"""
scheme, netloc, url, params, query, fragment = urllib.parse.url... | [
"def",
"parseUrl",
"(",
"url",
")",
":",
"scheme",
",",
"netloc",
",",
"url",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
")",
"query_dict",
"=",
"{",
"k",
":",
"sorted",
"(",
"v",
")",
... | Return a dict containing scheme, netloc, url, params, query, fragment keys.
query is a dict where the values are always lists. If the query key appears only
once in the URL, the list will have a single value. | [
"Return",
"a",
"dict",
"containing",
"scheme",
"netloc",
"url",
"params",
"query",
"fragment",
"keys",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L28-L47 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | encodePathElement | def encodePathElement(element):
"""Encode a URL path element according to RFC3986."""
return urllib.parse.quote(
(
element.encode('utf-8')
if isinstance(element, str)
else str(element)
if isinstance(element, int)
else element
),
... | python | def encodePathElement(element):
"""Encode a URL path element according to RFC3986."""
return urllib.parse.quote(
(
element.encode('utf-8')
if isinstance(element, str)
else str(element)
if isinstance(element, int)
else element
),
... | [
"def",
"encodePathElement",
"(",
"element",
")",
":",
"return",
"urllib",
".",
"parse",
".",
"quote",
"(",
"(",
"element",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"isinstance",
"(",
"element",
",",
"str",
")",
"else",
"str",
"(",
"element",
")",
"if"... | Encode a URL path element according to RFC3986. | [
"Encode",
"a",
"URL",
"path",
"element",
"according",
"to",
"RFC3986",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L59-L70 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | encodeQueryElement | def encodeQueryElement(element):
"""Encode a URL query element according to RFC3986."""
return urllib.parse.quote(
(
element.encode('utf-8')
if isinstance(element, str)
else str(element)
if isinstance(element, int)
else element
),
... | python | def encodeQueryElement(element):
"""Encode a URL query element according to RFC3986."""
return urllib.parse.quote(
(
element.encode('utf-8')
if isinstance(element, str)
else str(element)
if isinstance(element, int)
else element
),
... | [
"def",
"encodeQueryElement",
"(",
"element",
")",
":",
"return",
"urllib",
".",
"parse",
".",
"quote",
"(",
"(",
"element",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"isinstance",
"(",
"element",
",",
"str",
")",
"else",
"str",
"(",
"element",
")",
"if... | Encode a URL query element according to RFC3986. | [
"Encode",
"a",
"URL",
"query",
"element",
"according",
"to",
"RFC3986",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L78-L89 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | urlencode | def urlencode(query, doseq=0):
"""Modified version of the standard urllib.urlencode that is conforms to RFC3986.
The urllib version encodes spaces as '+' which can lead to inconsistency. This
version will always encode spaces as '%20'.
Encode a sequence of two-element tuples or dictionary into a URL qu... | python | def urlencode(query, doseq=0):
"""Modified version of the standard urllib.urlencode that is conforms to RFC3986.
The urllib version encodes spaces as '+' which can lead to inconsistency. This
version will always encode spaces as '%20'.
Encode a sequence of two-element tuples or dictionary into a URL qu... | [
"def",
"urlencode",
"(",
"query",
",",
"doseq",
"=",
"0",
")",
":",
"if",
"hasattr",
"(",
"query",
",",
"\"items\"",
")",
":",
"# Remove None parameters from query. Dictionaries are mutable, so we can",
"# remove the the items directly. dict.keys() creates a copy of the",
"# ... | Modified version of the standard urllib.urlencode that is conforms to RFC3986.
The urllib version encodes spaces as '+' which can lead to inconsistency. This
version will always encode spaces as '%20'.
Encode a sequence of two-element tuples or dictionary into a URL query string.
If any values in the ... | [
"Modified",
"version",
"of",
"the",
"standard",
"urllib",
".",
"urlencode",
"that",
"is",
"conforms",
"to",
"RFC3986",
".",
"The",
"urllib",
"version",
"encodes",
"spaces",
"as",
"+",
"which",
"can",
"lead",
"to",
"inconsistency",
".",
"This",
"version",
"wi... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L129-L207 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | makeCNBaseURL | def makeCNBaseURL(url):
"""Attempt to create a valid CN BaseURL when one or more sections of the URL are
missing."""
o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_CN_PROTOCOL)
if o.netloc and o.path:
netloc = o.netloc
path = o.path
elif o.netloc:
netloc = o.ne... | python | def makeCNBaseURL(url):
"""Attempt to create a valid CN BaseURL when one or more sections of the URL are
missing."""
o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_CN_PROTOCOL)
if o.netloc and o.path:
netloc = o.netloc
path = o.path
elif o.netloc:
netloc = o.ne... | [
"def",
"makeCNBaseURL",
"(",
"url",
")",
":",
"o",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
",",
"scheme",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_CN_PROTOCOL",
")",
"if",
"o",
".",
"netloc",
"and",
"o",
".",
"path",
":",
"netl... | Attempt to create a valid CN BaseURL when one or more sections of the URL are
missing. | [
"Attempt",
"to",
"create",
"a",
"valid",
"CN",
"BaseURL",
"when",
"one",
"or",
"more",
"sections",
"of",
"the",
"URL",
"are",
"missing",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L210-L232 |
DataONEorg/d1_python | lib_common/src/d1_common/url.py | makeMNBaseURL | def makeMNBaseURL(url):
"""Attempt to create a valid MN BaseURL when one or more sections of the URL are
missing."""
o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_MN_PROTOCOL)
if o.netloc and o.path:
netloc = o.netloc
path = o.path
elif o.netloc:
netloc = o.ne... | python | def makeMNBaseURL(url):
"""Attempt to create a valid MN BaseURL when one or more sections of the URL are
missing."""
o = urllib.parse.urlparse(url, scheme=d1_common.const.DEFAULT_MN_PROTOCOL)
if o.netloc and o.path:
netloc = o.netloc
path = o.path
elif o.netloc:
netloc = o.ne... | [
"def",
"makeMNBaseURL",
"(",
"url",
")",
":",
"o",
"=",
"urllib",
".",
"parse",
".",
"urlparse",
"(",
"url",
",",
"scheme",
"=",
"d1_common",
".",
"const",
".",
"DEFAULT_MN_PROTOCOL",
")",
"if",
"o",
".",
"netloc",
"and",
"o",
".",
"path",
":",
"netl... | Attempt to create a valid MN BaseURL when one or more sections of the URL are
missing. | [
"Attempt",
"to",
"create",
"a",
"valid",
"MN",
"BaseURL",
"when",
"one",
"or",
"more",
"sections",
"of",
"the",
"URL",
"are",
"missing",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/url.py#L235-L257 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.