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 |
|---|---|---|---|---|---|---|---|---|---|---|
skulumani/kinematics | kinematics/attitude.py | hat_map | def hat_map(vec):
"""Return that hat map of a vector
Inputs:
vec - 3 element vector
Outputs:
skew - 3,3 skew symmetric matrix
"""
vec = np.squeeze(vec)
skew = np.array([
[0, -vec[2], vec[1]],
[vec[2], 0, -vec[0]],
... | python | def hat_map(vec):
"""Return that hat map of a vector
Inputs:
vec - 3 element vector
Outputs:
skew - 3,3 skew symmetric matrix
"""
vec = np.squeeze(vec)
skew = np.array([
[0, -vec[2], vec[1]],
[vec[2], 0, -vec[0]],
... | [
"def",
"hat_map",
"(",
"vec",
")",
":",
"vec",
"=",
"np",
".",
"squeeze",
"(",
"vec",
")",
"skew",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"0",
",",
"-",
"vec",
"[",
"2",
"]",
",",
"vec",
"[",
"1",
"]",
"]",
",",
"[",
"vec",
"[",
"2",
"... | Return that hat map of a vector
Inputs:
vec - 3 element vector
Outputs:
skew - 3,3 skew symmetric matrix | [
"Return",
"that",
"hat",
"map",
"of",
"a",
"vector",
"Inputs",
":",
"vec",
"-",
"3",
"element",
"vector"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L244-L260 |
skulumani/kinematics | kinematics/attitude.py | vee_map | def vee_map(skew):
"""Return the vee map of a vector
"""
vec = 1/2 * np.array([skew[2,1] - skew[1,2],
skew[0,2] - skew[2,0],
skew[1,0] - skew[0,1]])
return vec | python | def vee_map(skew):
"""Return the vee map of a vector
"""
vec = 1/2 * np.array([skew[2,1] - skew[1,2],
skew[0,2] - skew[2,0],
skew[1,0] - skew[0,1]])
return vec | [
"def",
"vee_map",
"(",
"skew",
")",
":",
"vec",
"=",
"1",
"/",
"2",
"*",
"np",
".",
"array",
"(",
"[",
"skew",
"[",
"2",
",",
"1",
"]",
"-",
"skew",
"[",
"1",
",",
"2",
"]",
",",
"skew",
"[",
"0",
",",
"2",
"]",
"-",
"skew",
"[",
"2",
... | Return the vee map of a vector | [
"Return",
"the",
"vee",
"map",
"of",
"a",
"vector"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L262-L271 |
skulumani/kinematics | kinematics/attitude.py | dcmtoquat | def dcmtoquat(dcm):
"""Convert DCM to quaternion
This function will convert a rotation matrix, also called a direction
cosine matrix into the equivalent quaternion.
Parameters:
----------
dcm - (3,3) numpy array
Numpy rotation matrix which defines a rotation from the b to a frame
... | python | def dcmtoquat(dcm):
"""Convert DCM to quaternion
This function will convert a rotation matrix, also called a direction
cosine matrix into the equivalent quaternion.
Parameters:
----------
dcm - (3,3) numpy array
Numpy rotation matrix which defines a rotation from the b to a frame
... | [
"def",
"dcmtoquat",
"(",
"dcm",
")",
":",
"quat",
"=",
"np",
".",
"zeros",
"(",
"4",
")",
"quat",
"[",
"-",
"1",
"]",
"=",
"1",
"/",
"2",
"*",
"np",
".",
"sqrt",
"(",
"np",
".",
"trace",
"(",
"dcm",
")",
"+",
"1",
")",
"quat",
"[",
"0",
... | Convert DCM to quaternion
This function will convert a rotation matrix, also called a direction
cosine matrix into the equivalent quaternion.
Parameters:
----------
dcm - (3,3) numpy array
Numpy rotation matrix which defines a rotation from the b to a frame
Returns:
--------
... | [
"Convert",
"DCM",
"to",
"quaternion",
"This",
"function",
"will",
"convert",
"a",
"rotation",
"matrix",
"also",
"called",
"a",
"direction",
"cosine",
"matrix",
"into",
"the",
"equivalent",
"quaternion",
"."
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L273-L295 |
skulumani/kinematics | kinematics/attitude.py | quattodcm | def quattodcm(quat):
"""Convert quaternion to DCM
This function will convert a quaternion to the equivalent rotation matrix,
or direction cosine matrix.
Parameters:
----------
quat - (4,) numpy array
Array defining a quaterion where the quaternion is defined in terms of
a vecto... | python | def quattodcm(quat):
"""Convert quaternion to DCM
This function will convert a quaternion to the equivalent rotation matrix,
or direction cosine matrix.
Parameters:
----------
quat - (4,) numpy array
Array defining a quaterion where the quaternion is defined in terms of
a vecto... | [
"def",
"quattodcm",
"(",
"quat",
")",
":",
"dcm",
"=",
"(",
"quat",
"[",
"-",
"1",
"]",
"**",
"2",
"-",
"np",
".",
"inner",
"(",
"quat",
"[",
"0",
":",
"3",
"]",
",",
"quat",
"[",
"0",
":",
"3",
"]",
")",
")",
"*",
"np",
".",
"eye",
"("... | Convert quaternion to DCM
This function will convert a quaternion to the equivalent rotation matrix,
or direction cosine matrix.
Parameters:
----------
quat - (4,) numpy array
Array defining a quaterion where the quaternion is defined in terms of
a vector and a scalar part. The ve... | [
"Convert",
"quaternion",
"to",
"DCM"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L297-L318 |
skulumani/kinematics | kinematics/attitude.py | dcmdottoang_vel | def dcmdottoang_vel(R,Rdot):
"""Convert a rotation matrix to angular velocity
w - angular velocity in inertial frame
Omega - angular velocity in body frame
"""
w = vee_map(Rdot.dot(R.T))
Omega = vee_map(R.T.dot(Rdot))
return (w, Omega) | python | def dcmdottoang_vel(R,Rdot):
"""Convert a rotation matrix to angular velocity
w - angular velocity in inertial frame
Omega - angular velocity in body frame
"""
w = vee_map(Rdot.dot(R.T))
Omega = vee_map(R.T.dot(Rdot))
return (w, Omega) | [
"def",
"dcmdottoang_vel",
"(",
"R",
",",
"Rdot",
")",
":",
"w",
"=",
"vee_map",
"(",
"Rdot",
".",
"dot",
"(",
"R",
".",
"T",
")",
")",
"Omega",
"=",
"vee_map",
"(",
"R",
".",
"T",
".",
"dot",
"(",
"Rdot",
")",
")",
"return",
"(",
"w",
",",
... | Convert a rotation matrix to angular velocity
w - angular velocity in inertial frame
Omega - angular velocity in body frame | [
"Convert",
"a",
"rotation",
"matrix",
"to",
"angular",
"velocity",
"w",
"-",
"angular",
"velocity",
"in",
"inertial",
"frame",
"Omega",
"-",
"angular",
"velocity",
"in",
"body",
"frame"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L349-L358 |
skulumani/kinematics | kinematics/attitude.py | ang_veltoaxisangledot | def ang_veltoaxisangledot(angle, axis, Omega):
"""Compute kinematics for axis angle representation
"""
angle_dot = axis.dot(Omega)
axis_dot = 1/2*(hat_map(axis) - 1/np.tan(angle/2) * hat_map(axis).dot(hat_map(axis))).dot(Omega)
return angle_dot, axis_dot | python | def ang_veltoaxisangledot(angle, axis, Omega):
"""Compute kinematics for axis angle representation
"""
angle_dot = axis.dot(Omega)
axis_dot = 1/2*(hat_map(axis) - 1/np.tan(angle/2) * hat_map(axis).dot(hat_map(axis))).dot(Omega)
return angle_dot, axis_dot | [
"def",
"ang_veltoaxisangledot",
"(",
"angle",
",",
"axis",
",",
"Omega",
")",
":",
"angle_dot",
"=",
"axis",
".",
"dot",
"(",
"Omega",
")",
"axis_dot",
"=",
"1",
"/",
"2",
"*",
"(",
"hat_map",
"(",
"axis",
")",
"-",
"1",
"/",
"np",
".",
"tan",
"(... | Compute kinematics for axis angle representation | [
"Compute",
"kinematics",
"for",
"axis",
"angle",
"representation"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L368-L374 |
skulumani/kinematics | kinematics/attitude.py | axisangledottoang_vel | def axisangledottoang_vel(angle,axis, angle_dot,axis_dot):
"""Convert axis angle represetnation to angular velocity in body frame
"""
Omega = angle_dot*axis + np.sin(angle)*axis_dot - (1-np.cos(angle))*hat_map(axis).dot(axis_dot)
return Omega | python | def axisangledottoang_vel(angle,axis, angle_dot,axis_dot):
"""Convert axis angle represetnation to angular velocity in body frame
"""
Omega = angle_dot*axis + np.sin(angle)*axis_dot - (1-np.cos(angle))*hat_map(axis).dot(axis_dot)
return Omega | [
"def",
"axisangledottoang_vel",
"(",
"angle",
",",
"axis",
",",
"angle_dot",
",",
"axis_dot",
")",
":",
"Omega",
"=",
"angle_dot",
"*",
"axis",
"+",
"np",
".",
"sin",
"(",
"angle",
")",
"*",
"axis_dot",
"-",
"(",
"1",
"-",
"np",
".",
"cos",
"(",
"a... | Convert axis angle represetnation to angular velocity in body frame | [
"Convert",
"axis",
"angle",
"represetnation",
"to",
"angular",
"velocity",
"in",
"body",
"frame"
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L376-L382 |
skulumani/kinematics | kinematics/attitude.py | normalize | def normalize(num_in, lower=0, upper=360, b=False):
"""Normalize number to range [lower, upper) or [lower, upper].
Parameters
----------
num : float
The number to be normalized.
lower : int
Lower limit of range. Default is 0.
upper : int
Upper limit of range. Default is ... | python | def normalize(num_in, lower=0, upper=360, b=False):
"""Normalize number to range [lower, upper) or [lower, upper].
Parameters
----------
num : float
The number to be normalized.
lower : int
Lower limit of range. Default is 0.
upper : int
Upper limit of range. Default is ... | [
"def",
"normalize",
"(",
"num_in",
",",
"lower",
"=",
"0",
",",
"upper",
"=",
"360",
",",
"b",
"=",
"False",
")",
":",
"if",
"lower",
">=",
"upper",
":",
"ValueError",
"(",
"\"lower must be lesser than upper\"",
")",
"if",
"not",
"b",
":",
"if",
"not",... | Normalize number to range [lower, upper) or [lower, upper].
Parameters
----------
num : float
The number to be normalized.
lower : int
Lower limit of range. Default is 0.
upper : int
Upper limit of range. Default is 360.
b : bool
Type of normalization. Default is... | [
"Normalize",
"number",
"to",
"range",
"[",
"lower",
"upper",
")",
"or",
"[",
"lower",
"upper",
"]",
"."
] | train | https://github.com/skulumani/kinematics/blob/e8cb45efb40539982025ed0f85d6561f9f10fef0/kinematics/attitude.py#L388-L509 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/repos.py | list_repos | def list_repos(owner=None, **kwargs):
"""List repositories in a namespace."""
client = get_repos_api()
api_kwargs = {}
api_kwargs.update(utils.get_page_kwargs(**kwargs))
# pylint: disable=fixme
# FIXME: Compatibility code until we work out how to conflate
# the overlapping repos_list metho... | python | def list_repos(owner=None, **kwargs):
"""List repositories in a namespace."""
client = get_repos_api()
api_kwargs = {}
api_kwargs.update(utils.get_page_kwargs(**kwargs))
# pylint: disable=fixme
# FIXME: Compatibility code until we work out how to conflate
# the overlapping repos_list metho... | [
"def",
"list_repos",
"(",
"owner",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"get_repos_api",
"(",
")",
"api_kwargs",
"=",
"{",
"}",
"api_kwargs",
".",
"update",
"(",
"utils",
".",
"get_page_kwargs",
"(",
"*",
"*",
"kwargs",
")",
... | List repositories in a namespace. | [
"List",
"repositories",
"in",
"a",
"namespace",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/repos.py#L18-L45 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/copy.py | copy | def copy(
ctx,
opts,
owner_repo_package,
destination,
skip_errors,
wait_interval,
no_wait_for_sync,
sync_attempts,
):
"""
Copy a package to another repository.
This requires appropriate permissions for both the source
repository/package and the destination repository.
... | python | def copy(
ctx,
opts,
owner_repo_package,
destination,
skip_errors,
wait_interval,
no_wait_for_sync,
sync_attempts,
):
"""
Copy a package to another repository.
This requires appropriate permissions for both the source
repository/package and the destination repository.
... | [
"def",
"copy",
"(",
"ctx",
",",
"opts",
",",
"owner_repo_package",
",",
"destination",
",",
"skip_errors",
",",
"wait_interval",
",",
"no_wait_for_sync",
",",
"sync_attempts",
",",
")",
":",
"owner",
",",
"source",
",",
"slug",
"=",
"owner_repo_package",
"clic... | Copy a package to another repository.
This requires appropriate permissions for both the source
repository/package and the destination repository.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the
REPO name where the package is stored, and the PACKAGE name (slug) of the
pac... | [
"Copy",
"a",
"package",
"to",
"another",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/copy.py#L28-L94 |
visualfabriq/bquery | bquery/ctable.py | rm_file_or_dir | def rm_file_or_dir(path, ignore_errors=True):
"""
Helper function to clean a certain filepath
Parameters
----------
path
Returns
-------
"""
if os.path.exists(path):
if os.path.isdir(path):
if os.path.islink(path):
os.unlink(path)
el... | python | def rm_file_or_dir(path, ignore_errors=True):
"""
Helper function to clean a certain filepath
Parameters
----------
path
Returns
-------
"""
if os.path.exists(path):
if os.path.isdir(path):
if os.path.islink(path):
os.unlink(path)
el... | [
"def",
"rm_file_or_dir",
"(",
"path",
",",
"ignore_errors",
"=",
"True",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"islink"... | Helper function to clean a certain filepath
Parameters
----------
path
Returns
------- | [
"Helper",
"function",
"to",
"clean",
"a",
"certain",
"filepath"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L12-L34 |
visualfabriq/bquery | bquery/ctable.py | ctable.cache_valid | def cache_valid(self, col):
"""
Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return:
"""
cache_valid = False
if self.rootdir:
col_org_file_check = self[col].rootdir + '/__attrs__'
... | python | def cache_valid(self, col):
"""
Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return:
"""
cache_valid = False
if self.rootdir:
col_org_file_check = self[col].rootdir + '/__attrs__'
... | [
"def",
"cache_valid",
"(",
"self",
",",
"col",
")",
":",
"cache_valid",
"=",
"False",
"if",
"self",
".",
"rootdir",
":",
"col_org_file_check",
"=",
"self",
"[",
"col",
"]",
".",
"rootdir",
"+",
"'/__attrs__'",
"col_values_file_check",
"=",
"self",
"[",
"co... | Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return: | [
"Checks",
"whether",
"the",
"column",
"has",
"a",
"factorization",
"that",
"exists",
"and",
"is",
"not",
"older",
"than",
"the",
"source"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L60-L74 |
visualfabriq/bquery | bquery/ctable.py | ctable.group_cache_valid | def group_cache_valid(self, col_list):
"""
Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return:
"""
cache_valid = False
if self.rootdir:
col_values_file_check = os.path.join(self.rootdir, sel... | python | def group_cache_valid(self, col_list):
"""
Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return:
"""
cache_valid = False
if self.rootdir:
col_values_file_check = os.path.join(self.rootdir, sel... | [
"def",
"group_cache_valid",
"(",
"self",
",",
"col_list",
")",
":",
"cache_valid",
"=",
"False",
"if",
"self",
".",
"rootdir",
":",
"col_values_file_check",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"rootdir",
",",
"self",
".",
"create_group_b... | Checks whether the column has a factorization that exists and is not older than the source
:param col:
:return: | [
"Checks",
"whether",
"the",
"column",
"has",
"a",
"factorization",
"that",
"exists",
"and",
"is",
"not",
"older",
"than",
"the",
"source"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L76-L93 |
visualfabriq/bquery | bquery/ctable.py | ctable.cache_factor | def cache_factor(self, col_list, refresh=False):
"""
Existing todos here are: these should be hidden helper carrays
As in: not normal columns that you would normally see as a user
The factor (label index) carray is as long as the original carray
(and the rest of the table theref... | python | def cache_factor(self, col_list, refresh=False):
"""
Existing todos here are: these should be hidden helper carrays
As in: not normal columns that you would normally see as a user
The factor (label index) carray is as long as the original carray
(and the rest of the table theref... | [
"def",
"cache_factor",
"(",
"self",
",",
"col_list",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"rootdir",
":",
"raise",
"TypeError",
"(",
"'Only out-of-core ctables can have '",
"'factorization caching at the moment'",
")",
"if",
"not",
"is... | Existing todos here are: these should be hidden helper carrays
As in: not normal columns that you would normally see as a user
The factor (label index) carray is as long as the original carray
(and the rest of the table therefore)
But the (unique) values carray is not as long (as long a... | [
"Existing",
"todos",
"here",
"are",
":",
"these",
"should",
"be",
"hidden",
"helper",
"carrays",
"As",
"in",
":",
"not",
"normal",
"columns",
"that",
"you",
"would",
"normally",
"see",
"as",
"a",
"user"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L95-L152 |
visualfabriq/bquery | bquery/ctable.py | ctable.unique | def unique(self, col_or_col_list):
"""
Return a list of unique values of a column or a list of lists of column list
:param col_or_col_list: a column or a list of columns
:return:
"""
if isinstance(col_or_col_list, list):
col_is_list = True
col_li... | python | def unique(self, col_or_col_list):
"""
Return a list of unique values of a column or a list of lists of column list
:param col_or_col_list: a column or a list of columns
:return:
"""
if isinstance(col_or_col_list, list):
col_is_list = True
col_li... | [
"def",
"unique",
"(",
"self",
",",
"col_or_col_list",
")",
":",
"if",
"isinstance",
"(",
"col_or_col_list",
",",
"list",
")",
":",
"col_is_list",
"=",
"True",
"col_list",
"=",
"col_or_col_list",
"else",
":",
"col_is_list",
"=",
"False",
"col_list",
"=",
"[",... | Return a list of unique values of a column or a list of lists of column list
:param col_or_col_list: a column or a list of columns
:return: | [
"Return",
"a",
"list",
"of",
"unique",
"values",
"of",
"a",
"column",
"or",
"a",
"list",
"of",
"lists",
"of",
"column",
"list"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L154-L192 |
visualfabriq/bquery | bquery/ctable.py | ctable.aggregate_groups | def aggregate_groups(self, ct_agg, nr_groups, skip_key,
carray_factor, groupby_cols, agg_ops,
dtype_dict, bool_arr=None):
'''Perform aggregation and place the result in the given ctable.
Args:
ct_agg (ctable): the table to hold the aggregati... | python | def aggregate_groups(self, ct_agg, nr_groups, skip_key,
carray_factor, groupby_cols, agg_ops,
dtype_dict, bool_arr=None):
'''Perform aggregation and place the result in the given ctable.
Args:
ct_agg (ctable): the table to hold the aggregati... | [
"def",
"aggregate_groups",
"(",
"self",
",",
"ct_agg",
",",
"nr_groups",
",",
"skip_key",
",",
"carray_factor",
",",
"groupby_cols",
",",
"agg_ops",
",",
"dtype_dict",
",",
"bool_arr",
"=",
"None",
")",
":",
"# this creates the groupby columns",
"for",
"col",
"i... | Perform aggregation and place the result in the given ctable.
Args:
ct_agg (ctable): the table to hold the aggregation
nr_groups (int): the number of groups (number of rows in output table)
skip_key (int): index of the output row to remove from results (used for filtering)
... | [
"Perform",
"aggregation",
"and",
"place",
"the",
"result",
"in",
"the",
"given",
"ctable",
"."
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L194-L260 |
visualfabriq/bquery | bquery/ctable.py | ctable.factorize_groupby_cols | def factorize_groupby_cols(self, groupby_cols):
"""
factorizes all columns that are used in the groupby
it will use cache carrays if available
if not yet auto_cache is valid, it will create cache carrays
"""
# first check if the factorized arrays already exist
# ... | python | def factorize_groupby_cols(self, groupby_cols):
"""
factorizes all columns that are used in the groupby
it will use cache carrays if available
if not yet auto_cache is valid, it will create cache carrays
"""
# first check if the factorized arrays already exist
# ... | [
"def",
"factorize_groupby_cols",
"(",
"self",
",",
"groupby_cols",
")",
":",
"# first check if the factorized arrays already exist",
"# unless we need to refresh the cache",
"factor_list",
"=",
"[",
"]",
"values_list",
"=",
"[",
"]",
"# factorize the groupby columns",
"for",
... | factorizes all columns that are used in the groupby
it will use cache carrays if available
if not yet auto_cache is valid, it will create cache carrays | [
"factorizes",
"all",
"columns",
"that",
"are",
"used",
"in",
"the",
"groupby",
"it",
"will",
"use",
"cache",
"carrays",
"if",
"available",
"if",
"not",
"yet",
"auto_cache",
"is",
"valid",
"it",
"will",
"create",
"cache",
"carrays"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L318-L353 |
visualfabriq/bquery | bquery/ctable.py | ctable._int_array_hash | def _int_array_hash(input_list):
"""
A function to calculate a hash value of multiple integer values, not used at the moment
Parameters
----------
input_list
Returns
-------
"""
list_len = len(input_list)
arr_len = len(input_list[0])
... | python | def _int_array_hash(input_list):
"""
A function to calculate a hash value of multiple integer values, not used at the moment
Parameters
----------
input_list
Returns
-------
"""
list_len = len(input_list)
arr_len = len(input_list[0])
... | [
"def",
"_int_array_hash",
"(",
"input_list",
")",
":",
"list_len",
"=",
"len",
"(",
"input_list",
")",
"arr_len",
"=",
"len",
"(",
"input_list",
"[",
"0",
"]",
")",
"mult_arr",
"=",
"np",
".",
"full",
"(",
"arr_len",
",",
"1000003",
",",
"dtype",
"=",
... | A function to calculate a hash value of multiple integer values, not used at the moment
Parameters
----------
input_list
Returns
------- | [
"A",
"function",
"to",
"calculate",
"a",
"hash",
"value",
"of",
"multiple",
"integer",
"values",
"not",
"used",
"at",
"the",
"moment"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L356-L383 |
visualfabriq/bquery | bquery/ctable.py | ctable.create_group_column_factor | def create_group_column_factor(self, factor_list, groupby_cols, cache=False):
"""
Create a unique, factorized column out of several individual columns
Parameters
----------
factor_list
groupby_cols
cache
Returns
-------
"""
if no... | python | def create_group_column_factor(self, factor_list, groupby_cols, cache=False):
"""
Create a unique, factorized column out of several individual columns
Parameters
----------
factor_list
groupby_cols
cache
Returns
-------
"""
if no... | [
"def",
"create_group_column_factor",
"(",
"self",
",",
"factor_list",
",",
"groupby_cols",
",",
"cache",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"rootdir",
":",
"# in-memory scenario",
"input_rootdir",
"=",
"None",
"col_rootdir",
"=",
"None",
"col_fact... | Create a unique, factorized column out of several individual columns
Parameters
----------
factor_list
groupby_cols
cache
Returns
------- | [
"Create",
"a",
"unique",
"factorized",
"column",
"out",
"of",
"several",
"individual",
"columns"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L385-L472 |
visualfabriq/bquery | bquery/ctable.py | ctable.make_group_index | def make_group_index(self, groupby_cols, bool_arr):
'''Create unique groups for groupby loop
Args:
factor_list:
values_list:
groupby_cols:
bool_arr:
Returns:
carray: (carray_factor)
int: (nr... | python | def make_group_index(self, groupby_cols, bool_arr):
'''Create unique groups for groupby loop
Args:
factor_list:
values_list:
groupby_cols:
bool_arr:
Returns:
carray: (carray_factor)
int: (nr... | [
"def",
"make_group_index",
"(",
"self",
",",
"groupby_cols",
",",
"bool_arr",
")",
":",
"factor_list",
",",
"values_list",
"=",
"self",
".",
"factorize_groupby_cols",
"(",
"groupby_cols",
")",
"# create unique groups for groupby loop",
"if",
"len",
"(",
"factor_list",... | Create unique groups for groupby loop
Args:
factor_list:
values_list:
groupby_cols:
bool_arr:
Returns:
carray: (carray_factor)
int: (nr_groups) the number of resulting groups
int: (s... | [
"Create",
"unique",
"groups",
"for",
"groupby",
"loop"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L474-L547 |
visualfabriq/bquery | bquery/ctable.py | ctable.create_tmp_rootdir | def create_tmp_rootdir(self):
"""
create a rootdir that we can destroy later again
Returns
-------
"""
if self.rootdir:
tmp_rootdir = tempfile.mkdtemp(prefix='bcolz-')
self._dir_clean_list.append(tmp_rootdir)
else:
tmp_rootdir... | python | def create_tmp_rootdir(self):
"""
create a rootdir that we can destroy later again
Returns
-------
"""
if self.rootdir:
tmp_rootdir = tempfile.mkdtemp(prefix='bcolz-')
self._dir_clean_list.append(tmp_rootdir)
else:
tmp_rootdir... | [
"def",
"create_tmp_rootdir",
"(",
"self",
")",
":",
"if",
"self",
".",
"rootdir",
":",
"tmp_rootdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'bcolz-'",
")",
"self",
".",
"_dir_clean_list",
".",
"append",
"(",
"tmp_rootdir",
")",
"else",
":",... | create a rootdir that we can destroy later again
Returns
------- | [
"create",
"a",
"rootdir",
"that",
"we",
"can",
"destroy",
"later",
"again"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L549-L562 |
visualfabriq/bquery | bquery/ctable.py | ctable.clean_tmp_rootdir | def clean_tmp_rootdir(self):
"""
clean up all used temporary rootdirs
Returns
-------
"""
for tmp_rootdir in list(self._dir_clean_list):
rm_file_or_dir(tmp_rootdir)
self._dir_clean_list.remove(tmp_rootdir) | python | def clean_tmp_rootdir(self):
"""
clean up all used temporary rootdirs
Returns
-------
"""
for tmp_rootdir in list(self._dir_clean_list):
rm_file_or_dir(tmp_rootdir)
self._dir_clean_list.remove(tmp_rootdir) | [
"def",
"clean_tmp_rootdir",
"(",
"self",
")",
":",
"for",
"tmp_rootdir",
"in",
"list",
"(",
"self",
".",
"_dir_clean_list",
")",
":",
"rm_file_or_dir",
"(",
"tmp_rootdir",
")",
"self",
".",
"_dir_clean_list",
".",
"remove",
"(",
"tmp_rootdir",
")"
] | clean up all used temporary rootdirs
Returns
------- | [
"clean",
"up",
"all",
"used",
"temporary",
"rootdirs"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L564-L574 |
visualfabriq/bquery | bquery/ctable.py | ctable.create_agg_ctable | def create_agg_ctable(self, groupby_cols, agg_list, expectedlen, rootdir):
'''Create a container for the output table, a dictionary describing it's
columns and a list of tuples describing aggregation
operations to perform.
Args:
groupby_cols (list): a list of columns... | python | def create_agg_ctable(self, groupby_cols, agg_list, expectedlen, rootdir):
'''Create a container for the output table, a dictionary describing it's
columns and a list of tuples describing aggregation
operations to perform.
Args:
groupby_cols (list): a list of columns... | [
"def",
"create_agg_ctable",
"(",
"self",
",",
"groupby_cols",
",",
"agg_list",
",",
"expectedlen",
",",
"rootdir",
")",
":",
"dtype_dict",
"=",
"{",
"}",
"# include all the groupby columns",
"for",
"col",
"in",
"groupby_cols",
":",
"dtype_dict",
"[",
"col",
"]",... | Create a container for the output table, a dictionary describing it's
columns and a list of tuples describing aggregation
operations to perform.
Args:
groupby_cols (list): a list of columns to groupby over
agg_list (list): the aggregation operations (see groupby ... | [
"Create",
"a",
"container",
"for",
"the",
"output",
"table",
"a",
"dictionary",
"describing",
"it",
"s",
"columns",
"and",
"a",
"list",
"of",
"tuples",
"describing",
"aggregation",
"operations",
"to",
"perform",
"."
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L576-L654 |
visualfabriq/bquery | bquery/ctable.py | ctable.where_terms | def where_terms(self, term_list, cache=False):
"""
Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:param term_list:
:param outcols:
:param limi... | python | def where_terms(self, term_list, cache=False):
"""
Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:param term_list:
:param outcols:
:param limi... | [
"def",
"where_terms",
"(",
"self",
",",
"term_list",
",",
"cache",
"=",
"False",
")",
":",
"if",
"type",
"(",
"term_list",
")",
"not",
"in",
"[",
"list",
",",
"set",
",",
"tuple",
"]",
":",
"raise",
"ValueError",
"(",
"\"Only term lists are supported\"",
... | Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:param term_list:
:param outcols:
:param limit:
:param skip:
:return: :raise ValueError: | [
"Create",
"a",
"boolean",
"array",
"where",
"term_list",
"is",
"true",
".",
"A",
"terms",
"list",
"has",
"a",
"[",
"(",
"col",
"operator",
"value",
")",
"..",
"]",
"construction",
".",
"Eg",
".",
"[",
"(",
"sales",
">",
"2",
")",
"(",
"state",
"in"... | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L656-L740 |
visualfabriq/bquery | bquery/ctable.py | ctable.where_terms_factorization_check | def where_terms_factorization_check(self, term_list):
"""
check for where terms if they are applicable
Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:... | python | def where_terms_factorization_check(self, term_list):
"""
check for where terms if they are applicable
Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:... | [
"def",
"where_terms_factorization_check",
"(",
"self",
",",
"term_list",
")",
":",
"if",
"type",
"(",
"term_list",
")",
"not",
"in",
"[",
"list",
",",
"set",
",",
"tuple",
"]",
":",
"raise",
"ValueError",
"(",
"\"Only term lists are supported\"",
")",
"valid",... | check for where terms if they are applicable
Create a boolean array where `term_list` is true.
A terms list has a [(col, operator, value), ..] construction.
Eg. [('sales', '>', 2), ('state', 'in', ['IL', 'AR'])]
:param term_list:
:param outcols:
:param limit:
:pa... | [
"check",
"for",
"where",
"terms",
"if",
"they",
"are",
"applicable",
"Create",
"a",
"boolean",
"array",
"where",
"term_list",
"is",
"true",
".",
"A",
"terms",
"list",
"has",
"a",
"[",
"(",
"col",
"operator",
"value",
")",
"..",
"]",
"construction",
".",
... | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L742-L819 |
visualfabriq/bquery | bquery/ctable.py | ctable.is_in_ordered_subgroups | def is_in_ordered_subgroups(self, basket_col=None, bool_arr=None,
_max_len_subgroup=1000):
"""
Expands the filter using a specified column
Parameters
----------
basket_col
bool_arr
_max_len_subgroup
Returns
-------... | python | def is_in_ordered_subgroups(self, basket_col=None, bool_arr=None,
_max_len_subgroup=1000):
"""
Expands the filter using a specified column
Parameters
----------
basket_col
bool_arr
_max_len_subgroup
Returns
-------... | [
"def",
"is_in_ordered_subgroups",
"(",
"self",
",",
"basket_col",
"=",
"None",
",",
"bool_arr",
"=",
"None",
",",
"_max_len_subgroup",
"=",
"1000",
")",
":",
"assert",
"basket_col",
"is",
"not",
"None",
"if",
"bool_arr",
"is",
"None",
":",
"return",
"None",
... | Expands the filter using a specified column
Parameters
----------
basket_col
bool_arr
_max_len_subgroup
Returns
------- | [
"Expands",
"the",
"filter",
"using",
"a",
"specified",
"column"
] | train | https://github.com/visualfabriq/bquery/blob/3702e974696e22876944a3339affad2f29e1ee06/bquery/ctable.py#L821-L849 |
kalefranz/auxlib | auxlib/_vendor/five.py | with_metaclass | def with_metaclass(Type, skip_attrs=set(('__dict__', '__weakref__'))):
"""Class decorator to set metaclass.
Works with both Python 2 and Python 3 and it does not add
an extra class in the lookup order like ``six.with_metaclass`` does
(that is -- it copies the original class instead of using inheritance... | python | def with_metaclass(Type, skip_attrs=set(('__dict__', '__weakref__'))):
"""Class decorator to set metaclass.
Works with both Python 2 and Python 3 and it does not add
an extra class in the lookup order like ``six.with_metaclass`` does
(that is -- it copies the original class instead of using inheritance... | [
"def",
"with_metaclass",
"(",
"Type",
",",
"skip_attrs",
"=",
"set",
"(",
"(",
"'__dict__'",
",",
"'__weakref__'",
")",
")",
")",
":",
"def",
"_clone_with_metaclass",
"(",
"Class",
")",
":",
"attrs",
"=",
"dict",
"(",
"(",
"key",
",",
"value",
")",
"fo... | Class decorator to set metaclass.
Works with both Python 2 and Python 3 and it does not add
an extra class in the lookup order like ``six.with_metaclass`` does
(that is -- it copies the original class instead of using inheritance). | [
"Class",
"decorator",
"to",
"set",
"metaclass",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/five.py#L202-L216 |
marrow/schema | marrow/schema/util.py | ensure_tuple | def ensure_tuple(length, tuples):
"""Yield `length`-sized tuples from the given collection.
Will truncate longer tuples to the desired length, and pad using the leading element if shorter.
"""
for elem in tuples:
# Handle non-tuples and non-lists as a single repeated element.
if not isinstance(elem, (tuple,... | python | def ensure_tuple(length, tuples):
"""Yield `length`-sized tuples from the given collection.
Will truncate longer tuples to the desired length, and pad using the leading element if shorter.
"""
for elem in tuples:
# Handle non-tuples and non-lists as a single repeated element.
if not isinstance(elem, (tuple,... | [
"def",
"ensure_tuple",
"(",
"length",
",",
"tuples",
")",
":",
"for",
"elem",
"in",
"tuples",
":",
"# Handle non-tuples and non-lists as a single repeated element.",
"if",
"not",
"isinstance",
"(",
"elem",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"yield",
... | Yield `length`-sized tuples from the given collection.
Will truncate longer tuples to the desired length, and pad using the leading element if shorter. | [
"Yield",
"length",
"-",
"sized",
"tuples",
"from",
"the",
"given",
"collection",
".",
"Will",
"truncate",
"longer",
"tuples",
"to",
"the",
"desired",
"length",
"and",
"pad",
"using",
"the",
"leading",
"element",
"if",
"shorter",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/util.py#L24-L48 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/main.py | print_version | def print_version():
"""Print the environment versions."""
click.echo("Versions:")
click.secho(
"CLI Package Version: %(version)s"
% {"version": click.style(get_cli_version(), bold=True)}
)
click.secho(
"API Package Version: %(version)s"
% {"version": click.style(get_... | python | def print_version():
"""Print the environment versions."""
click.echo("Versions:")
click.secho(
"CLI Package Version: %(version)s"
% {"version": click.style(get_cli_version(), bold=True)}
)
click.secho(
"API Package Version: %(version)s"
% {"version": click.style(get_... | [
"def",
"print_version",
"(",
")",
":",
"click",
".",
"echo",
"(",
"\"Versions:\"",
")",
"click",
".",
"secho",
"(",
"\"CLI Package Version: %(version)s\"",
"%",
"{",
"\"version\"",
":",
"click",
".",
"style",
"(",
"get_cli_version",
"(",
")",
",",
"bold",
"=... | Print the environment versions. | [
"Print",
"the",
"environment",
"versions",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/main.py#L15-L25 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/main.py | main | def main(ctx, opts, version):
"""Handle entrypoint to CLI."""
# pylint: disable=unused-argument
if version:
print_version()
elif ctx.invoked_subcommand is None:
click.echo(ctx.get_help()) | python | def main(ctx, opts, version):
"""Handle entrypoint to CLI."""
# pylint: disable=unused-argument
if version:
print_version()
elif ctx.invoked_subcommand is None:
click.echo(ctx.get_help()) | [
"def",
"main",
"(",
"ctx",
",",
"opts",
",",
"version",
")",
":",
"# pylint: disable=unused-argument",
"if",
"version",
":",
"print_version",
"(",
")",
"elif",
"ctx",
".",
"invoked_subcommand",
"is",
"None",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"get... | Handle entrypoint to CLI. | [
"Handle",
"entrypoint",
"to",
"CLI",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/main.py#L58-L64 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | validate_upload_file | def validate_upload_file(ctx, opts, owner, repo, filepath, skip_errors):
"""Validate parameters for requesting a file upload."""
filename = click.format_filename(filepath)
basename = os.path.basename(filename)
click.echo(
"Checking %(filename)s file upload parameters ... "
% {"filename"... | python | def validate_upload_file(ctx, opts, owner, repo, filepath, skip_errors):
"""Validate parameters for requesting a file upload."""
filename = click.format_filename(filepath)
basename = os.path.basename(filename)
click.echo(
"Checking %(filename)s file upload parameters ... "
% {"filename"... | [
"def",
"validate_upload_file",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"filepath",
",",
"skip_errors",
")",
":",
"filename",
"=",
"click",
".",
"format_filename",
"(",
"filepath",
")",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
... | Validate parameters for requesting a file upload. | [
"Validate",
"parameters",
"for",
"requesting",
"a",
"file",
"upload",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L31-L53 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | upload_file | def upload_file(ctx, opts, owner, repo, filepath, skip_errors, md5_checksum):
"""Upload a package file via the API."""
filename = click.format_filename(filepath)
basename = os.path.basename(filename)
click.echo(
"Requesting file upload for %(filename)s ... "
% {"filename": click.style(b... | python | def upload_file(ctx, opts, owner, repo, filepath, skip_errors, md5_checksum):
"""Upload a package file via the API."""
filename = click.format_filename(filepath)
basename = os.path.basename(filename)
click.echo(
"Requesting file upload for %(filename)s ... "
% {"filename": click.style(b... | [
"def",
"upload_file",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"filepath",
",",
"skip_errors",
",",
"md5_checksum",
")",
":",
"filename",
"=",
"click",
".",
"format_filename",
"(",
"filepath",
")",
"basename",
"=",
"os",
".",
"path",
".",... | Upload a package file via the API. | [
"Upload",
"a",
"package",
"file",
"via",
"the",
"API",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L56-L103 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | validate_create_package | def validate_create_package(
ctx, opts, owner, repo, package_type, skip_errors, **kwargs
):
"""Check new package parameters via the API."""
click.echo(
"Checking %(package_type)s package upload parameters ... "
% {"package_type": click.style(package_type, bold=True)},
nl=False,
)... | python | def validate_create_package(
ctx, opts, owner, repo, package_type, skip_errors, **kwargs
):
"""Check new package parameters via the API."""
click.echo(
"Checking %(package_type)s package upload parameters ... "
% {"package_type": click.style(package_type, bold=True)},
nl=False,
)... | [
"def",
"validate_create_package",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"package_type",
",",
"skip_errors",
",",
"*",
"*",
"kwargs",
")",
":",
"click",
".",
"echo",
"(",
"\"Checking %(package_type)s package upload parameters ... \"",
"%",
"{",
... | Check new package parameters via the API. | [
"Check",
"new",
"package",
"parameters",
"via",
"the",
"API",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L106-L126 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | create_package | def create_package(ctx, opts, owner, repo, package_type, skip_errors, **kwargs):
"""Create a new package via the API."""
click.echo(
"Creating a new %(package_type)s package ... "
% {"package_type": click.style(package_type, bold=True)},
nl=False,
)
context_msg = "Failed to crea... | python | def create_package(ctx, opts, owner, repo, package_type, skip_errors, **kwargs):
"""Create a new package via the API."""
click.echo(
"Creating a new %(package_type)s package ... "
% {"package_type": click.style(package_type, bold=True)},
nl=False,
)
context_msg = "Failed to crea... | [
"def",
"create_package",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"package_type",
",",
"skip_errors",
",",
"*",
"*",
"kwargs",
")",
":",
"click",
".",
"echo",
"(",
"\"Creating a new %(package_type)s package ... \"",
"%",
"{",
"\"package_type\"",
... | Create a new package via the API. | [
"Create",
"a",
"new",
"package",
"via",
"the",
"API",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L129-L158 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | wait_for_package_sync | def wait_for_package_sync(
ctx, opts, owner, repo, slug, wait_interval, skip_errors, attempts=3
):
"""Wait for a package to synchronise (or fail)."""
# pylint: disable=too-many-locals
attempts -= 1
click.echo()
label = "Synchronising %(package)s:" % {"package": click.style(slug, fg="green")}
... | python | def wait_for_package_sync(
ctx, opts, owner, repo, slug, wait_interval, skip_errors, attempts=3
):
"""Wait for a package to synchronise (or fail)."""
# pylint: disable=too-many-locals
attempts -= 1
click.echo()
label = "Synchronising %(package)s:" % {"package": click.style(slug, fg="green")}
... | [
"def",
"wait_for_package_sync",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"slug",
",",
"wait_interval",
",",
"skip_errors",
",",
"attempts",
"=",
"3",
")",
":",
"# pylint: disable=too-many-locals",
"attempts",
"-=",
"1",
"click",
".",
"echo",
... | Wait for a package to synchronise (or fail). | [
"Wait",
"for",
"a",
"package",
"to",
"synchronise",
"(",
"or",
"fail",
")",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L161-L265 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | upload_files_and_create_package | def upload_files_and_create_package(
ctx,
opts,
package_type,
owner_repo,
dry_run,
no_wait_for_sync,
wait_interval,
skip_errors,
sync_attempts,
**kwargs
):
"""Upload package files and create a new package."""
# pylint: disable=unused-argument
owner, repo = owner_repo
... | python | def upload_files_and_create_package(
ctx,
opts,
package_type,
owner_repo,
dry_run,
no_wait_for_sync,
wait_interval,
skip_errors,
sync_attempts,
**kwargs
):
"""Upload package files and create a new package."""
# pylint: disable=unused-argument
owner, repo = owner_repo
... | [
"def",
"upload_files_and_create_package",
"(",
"ctx",
",",
"opts",
",",
"package_type",
",",
"owner_repo",
",",
"dry_run",
",",
"no_wait_for_sync",
",",
"wait_interval",
",",
"skip_errors",
",",
"sync_attempts",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disabl... | Upload package files and create a new package. | [
"Upload",
"package",
"files",
"and",
"create",
"a",
"new",
"package",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L268-L354 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/push.py | create_push_handlers | def create_push_handlers():
"""Create a handler for upload per package format."""
# pylint: disable=fixme
# HACK: hacky territory - Dynamically generate a handler for each of the
# package formats, until we have slightly more clever 'guess type'
# handling. :-)
handlers = create_push_handlers.ha... | python | def create_push_handlers():
"""Create a handler for upload per package format."""
# pylint: disable=fixme
# HACK: hacky territory - Dynamically generate a handler for each of the
# package formats, until we have slightly more clever 'guess type'
# handling. :-)
handlers = create_push_handlers.ha... | [
"def",
"create_push_handlers",
"(",
")",
":",
"# pylint: disable=fixme",
"# HACK: hacky territory - Dynamically generate a handler for each of the",
"# package formats, until we have slightly more clever 'guess type'",
"# handling. :-)",
"handlers",
"=",
"create_push_handlers",
".",
"handl... | Create a handler for upload per package format. | [
"Create",
"a",
"handler",
"for",
"upload",
"per",
"package",
"format",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/push.py#L357-L501 |
kalefranz/auxlib | auxlib/decorators.py | memoize | def memoize(func):
"""
Decorator to cause a function to cache it's results for each combination of
inputs and return the cached result on subsequent calls. Does not support
named arguments or arg values that are not hashable.
>>> @memoize
... def foo(x):
... print('running function wit... | python | def memoize(func):
"""
Decorator to cause a function to cache it's results for each combination of
inputs and return the cached result on subsequent calls. Does not support
named arguments or arg values that are not hashable.
>>> @memoize
... def foo(x):
... print('running function wit... | [
"def",
"memoize",
"(",
"func",
")",
":",
"func",
".",
"_result_cache",
"=",
"{",
"}",
"# pylint: disable-msg=W0212",
"@",
"wraps",
"(",
"func",
")",
"def",
"_memoized_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"(",
"args",
... | Decorator to cause a function to cache it's results for each combination of
inputs and return the cached result on subsequent calls. Does not support
named arguments or arg values that are not hashable.
>>> @memoize
... def foo(x):
... print('running function with', x)
... return x+3
... | [
"Decorator",
"to",
"cause",
"a",
"function",
"to",
"cache",
"it",
"s",
"results",
"for",
"each",
"combination",
"of",
"inputs",
"and",
"return",
"the",
"cached",
"result",
"on",
"subsequent",
"calls",
".",
"Does",
"not",
"support",
"named",
"arguments",
"or"... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/decorators.py#L10-L62 |
kalefranz/auxlib | auxlib/decorators.py | memoizemethod | def memoizemethod(method):
"""
Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... @memoizemethod
... ... | python | def memoizemethod(method):
"""
Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... @memoizemethod
... ... | [
"def",
"memoizemethod",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"_wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# NOTE: a __dict__ check is performed here rather than using the",
"# built-in hasattr function ... | Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... @memoizemethod
... def foo(self, x, y=0):
... prin... | [
"Decorator",
"to",
"cause",
"a",
"method",
"to",
"cache",
"it",
"s",
"results",
"in",
"self",
"for",
"each",
"combination",
"of",
"inputs",
"and",
"return",
"the",
"cached",
"result",
"on",
"subsequent",
"calls",
".",
"Does",
"not",
"support",
"named",
"ar... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/decorators.py#L65-L147 |
kalefranz/auxlib | auxlib/decorators.py | clear_memoized_methods | def clear_memoized_methods(obj, *method_names):
"""
Clear the memoized method or @memoizedproperty results for the given
method names from the given object.
>>> v = [0]
>>> def inc():
... v[0] += 1
... return v[0]
...
>>> class Foo(object):
... @memoizemethod
... ... | python | def clear_memoized_methods(obj, *method_names):
"""
Clear the memoized method or @memoizedproperty results for the given
method names from the given object.
>>> v = [0]
>>> def inc():
... v[0] += 1
... return v[0]
...
>>> class Foo(object):
... @memoizemethod
... ... | [
"def",
"clear_memoized_methods",
"(",
"obj",
",",
"*",
"method_names",
")",
":",
"for",
"key",
"in",
"list",
"(",
"getattr",
"(",
"obj",
",",
"'_memoized_results'",
",",
"{",
"}",
")",
".",
"keys",
"(",
")",
")",
":",
"# key[0] is the method name",
"if",
... | Clear the memoized method or @memoizedproperty results for the given
method names from the given object.
>>> v = [0]
>>> def inc():
... v[0] += 1
... return v[0]
...
>>> class Foo(object):
... @memoizemethod
... def foo(self):
... return inc()
... @me... | [
"Clear",
"the",
"memoized",
"method",
"or",
"@memoizedproperty",
"results",
"for",
"the",
"given",
"method",
"names",
"from",
"the",
"given",
"object",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/decorators.py#L187-L232 |
kalefranz/auxlib | auxlib/decorators.py | memoizedproperty | def memoizedproperty(func):
"""
Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... _x = 1
... @memoiz... | python | def memoizedproperty(func):
"""
Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... _x = 1
... @memoiz... | [
"def",
"memoizedproperty",
"(",
"func",
")",
":",
"inner_attname",
"=",
"'__%s'",
"%",
"func",
".",
"__name__",
"def",
"new_fget",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_cache_'",
")",
":",
"self",
".",
"_cache_",
"=",
"dic... | Decorator to cause a method to cache it's results in self for each
combination of inputs and return the cached result on subsequent calls.
Does not support named arguments or arg values that are not hashable.
>>> class Foo (object):
... _x = 1
... @memoizedproperty
... def foo(self):
... | [
"Decorator",
"to",
"cause",
"a",
"method",
"to",
"cache",
"it",
"s",
"results",
"in",
"self",
"for",
"each",
"combination",
"of",
"inputs",
"and",
"return",
"the",
"cached",
"result",
"on",
"subsequent",
"calls",
".",
"Does",
"not",
"support",
"named",
"ar... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/decorators.py#L235-L272 |
kalefranz/auxlib | auxlib/crypt.py | aes_encrypt | def aes_encrypt(base64_encryption_key, data):
"""Encrypt data with AES-CBC and sign it with HMAC-SHA256
Arguments:
base64_encryption_key (str): a base64-encoded string containing an AES encryption key
and HMAC signing key as generated by generate_encryption_key()
data (str): a byte ... | python | def aes_encrypt(base64_encryption_key, data):
"""Encrypt data with AES-CBC and sign it with HMAC-SHA256
Arguments:
base64_encryption_key (str): a base64-encoded string containing an AES encryption key
and HMAC signing key as generated by generate_encryption_key()
data (str): a byte ... | [
"def",
"aes_encrypt",
"(",
"base64_encryption_key",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"text_type",
")",
":",
"data",
"=",
"data",
".",
"encode",
"(",
"\"UTF-8\"",
")",
"aes_key_bytes",
",",
"hmac_key_bytes",
"=",
"_extract_keys",
"... | Encrypt data with AES-CBC and sign it with HMAC-SHA256
Arguments:
base64_encryption_key (str): a base64-encoded string containing an AES encryption key
and HMAC signing key as generated by generate_encryption_key()
data (str): a byte string containing the data to be encrypted
Retur... | [
"Encrypt",
"data",
"with",
"AES",
"-",
"CBC",
"and",
"sign",
"it",
"with",
"HMAC",
"-",
"SHA256"
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/crypt.py#L77-L97 |
kalefranz/auxlib | auxlib/crypt.py | aes_decrypt | def aes_decrypt(base64_encryption_key, base64_data):
"""Verify HMAC-SHA256 signature and decrypt data with AES-CBC
Arguments:
encryption_key (str): a base64-encoded string containing an AES encryption key and HMAC
signing key as generated by generate_encryption_key()
data (str): a b... | python | def aes_decrypt(base64_encryption_key, base64_data):
"""Verify HMAC-SHA256 signature and decrypt data with AES-CBC
Arguments:
encryption_key (str): a base64-encoded string containing an AES encryption key and HMAC
signing key as generated by generate_encryption_key()
data (str): a b... | [
"def",
"aes_decrypt",
"(",
"base64_encryption_key",
",",
"base64_data",
")",
":",
"data",
"=",
"from_base64",
"(",
"base64_data",
")",
"aes_key_bytes",
",",
"hmac_key_bytes",
"=",
"_extract_keys",
"(",
"base64_encryption_key",
")",
"data",
",",
"hmac_signature",
"="... | Verify HMAC-SHA256 signature and decrypt data with AES-CBC
Arguments:
encryption_key (str): a base64-encoded string containing an AES encryption key and HMAC
signing key as generated by generate_encryption_key()
data (str): a byte string containing the data decrypted with an HMAC signin... | [
"Verify",
"HMAC",
"-",
"SHA256",
"signature",
"and",
"decrypt",
"data",
"with",
"AES",
"-",
"CBC"
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/crypt.py#L100-L124 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/whoami.py | whoami | def whoami(ctx, opts):
"""Retrieve your current authentication status."""
click.echo("Retrieving your authentication status from the API ... ", nl=False)
context_msg = "Failed to retrieve your authentication status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with mayb... | python | def whoami(ctx, opts):
"""Retrieve your current authentication status."""
click.echo("Retrieving your authentication status from the API ... ", nl=False)
context_msg = "Failed to retrieve your authentication status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with mayb... | [
"def",
"whoami",
"(",
"ctx",
",",
"opts",
")",
":",
"click",
".",
"echo",
"(",
"\"Retrieving your authentication status from the API ... \"",
",",
"nl",
"=",
"False",
")",
"context_msg",
"=",
"\"Failed to retrieve your authentication status!\"",
"with",
"handle_api_except... | Retrieve your current authentication status. | [
"Retrieve",
"your",
"current",
"authentication",
"status",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/whoami.py#L20-L41 |
marrow/schema | marrow/schema/transform/container.py | Array._clean | def _clean(self, value):
"""Perform a standardized pipline of operations across an iterable."""
value = (str(v) for v in value)
if self.strip:
value = (v.strip() for v in value)
if not self.empty:
value = (v for v in value if v)
return value | python | def _clean(self, value):
"""Perform a standardized pipline of operations across an iterable."""
value = (str(v) for v in value)
if self.strip:
value = (v.strip() for v in value)
if not self.empty:
value = (v for v in value if v)
return value | [
"def",
"_clean",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"(",
"str",
"(",
"v",
")",
"for",
"v",
"in",
"value",
")",
"if",
"self",
".",
"strip",
":",
"value",
"=",
"(",
"v",
".",
"strip",
"(",
")",
"for",
"v",
"in",
"value",
")",
... | Perform a standardized pipline of operations across an iterable. | [
"Perform",
"a",
"standardized",
"pipline",
"of",
"operations",
"across",
"an",
"iterable",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/container.py#L21-L32 |
marrow/schema | marrow/schema/transform/container.py | Array.native | def native(self, value, context=None):
"""Convert the given string into a list of substrings."""
separator = self.separator.strip() if self.strip and hasattr(self.separator, 'strip') else self.separator
value = super().native(value, context)
if value is None:
return self.cast()
if hasattr(value, '... | python | def native(self, value, context=None):
"""Convert the given string into a list of substrings."""
separator = self.separator.strip() if self.strip and hasattr(self.separator, 'strip') else self.separator
value = super().native(value, context)
if value is None:
return self.cast()
if hasattr(value, '... | [
"def",
"native",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"separator",
"=",
"self",
".",
"separator",
".",
"strip",
"(",
")",
"if",
"self",
".",
"strip",
"and",
"hasattr",
"(",
"self",
".",
"separator",
",",
"'strip'",
")",
... | Convert the given string into a list of substrings. | [
"Convert",
"the",
"given",
"string",
"into",
"a",
"list",
"of",
"substrings",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/container.py#L34-L51 |
marrow/schema | marrow/schema/transform/container.py | Array.foreign | def foreign(self, value, context=None):
"""Construct a string-like representation for an iterable of string-like objects."""
if self.separator is None:
separator = ' '
else:
separator = self.separator.strip() if self.strip and hasattr(self.separator, 'strip') else self.separator
value = self._clean(... | python | def foreign(self, value, context=None):
"""Construct a string-like representation for an iterable of string-like objects."""
if self.separator is None:
separator = ' '
else:
separator = self.separator.strip() if self.strip and hasattr(self.separator, 'strip') else self.separator
value = self._clean(... | [
"def",
"foreign",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"if",
"self",
".",
"separator",
"is",
"None",
":",
"separator",
"=",
"' '",
"else",
":",
"separator",
"=",
"self",
".",
"separator",
".",
"strip",
"(",
")",
"if",
"... | Construct a string-like representation for an iterable of string-like objects. | [
"Construct",
"a",
"string",
"-",
"like",
"representation",
"for",
"an",
"iterable",
"of",
"string",
"-",
"like",
"objects",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/container.py#L53-L68 |
ndf-zz/asfv1 | asfv1.py | tob32 | def tob32(val):
"""Return provided 32 bit value as a string of four bytes."""
ret = bytearray(4)
ret[0] = (val>>24)&M8
ret[1] = (val>>16)&M8
ret[2] = (val>>8)&M8
ret[3] = val&M8
return ret | python | def tob32(val):
"""Return provided 32 bit value as a string of four bytes."""
ret = bytearray(4)
ret[0] = (val>>24)&M8
ret[1] = (val>>16)&M8
ret[2] = (val>>8)&M8
ret[3] = val&M8
return ret | [
"def",
"tob32",
"(",
"val",
")",
":",
"ret",
"=",
"bytearray",
"(",
"4",
")",
"ret",
"[",
"0",
"]",
"=",
"(",
"val",
">>",
"24",
")",
"&",
"M8",
"ret",
"[",
"1",
"]",
"=",
"(",
"val",
">>",
"16",
")",
"&",
"M8",
"ret",
"[",
"2",
"]",
"=... | Return provided 32 bit value as a string of four bytes. | [
"Return",
"provided",
"32",
"bit",
"value",
"as",
"a",
"string",
"of",
"four",
"bytes",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L129-L136 |
ndf-zz/asfv1 | asfv1.py | bintoihex | def bintoihex(buf, spos=0x0000):
"""Convert binary buffer to ihex and return as string."""
c = 0
olen = len(buf)
ret = ""
# 16 byte lines
while (c+0x10) <= olen:
adr = c + spos
l = ':10{0:04X}00'.format(adr)
sum = 0x10+((adr>>8)&M8)+(adr&M8)
for j in range(0,0x10)... | python | def bintoihex(buf, spos=0x0000):
"""Convert binary buffer to ihex and return as string."""
c = 0
olen = len(buf)
ret = ""
# 16 byte lines
while (c+0x10) <= olen:
adr = c + spos
l = ':10{0:04X}00'.format(adr)
sum = 0x10+((adr>>8)&M8)+(adr&M8)
for j in range(0,0x10)... | [
"def",
"bintoihex",
"(",
"buf",
",",
"spos",
"=",
"0x0000",
")",
":",
"c",
"=",
"0",
"olen",
"=",
"len",
"(",
"buf",
")",
"ret",
"=",
"\"\"",
"# 16 byte lines",
"while",
"(",
"c",
"+",
"0x10",
")",
"<=",
"olen",
":",
"adr",
"=",
"c",
"+",
"spos... | Convert binary buffer to ihex and return as string. | [
"Convert",
"binary",
"buffer",
"to",
"ihex",
"and",
"return",
"as",
"string",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L138-L169 |
ndf-zz/asfv1 | asfv1.py | op_gen | def op_gen(mcode):
"""Generate a machine instruction using the op gen table."""
gen = op_tbl[mcode[0]]
ret = gen[0] # opcode
nargs = len(gen)
i = 1
while i < nargs:
if i < len(mcode): # or assume they are same len
ret |= (mcode[i]&gen[i][0]) << gen[i][1]
i += 1
re... | python | def op_gen(mcode):
"""Generate a machine instruction using the op gen table."""
gen = op_tbl[mcode[0]]
ret = gen[0] # opcode
nargs = len(gen)
i = 1
while i < nargs:
if i < len(mcode): # or assume they are same len
ret |= (mcode[i]&gen[i][0]) << gen[i][1]
i += 1
re... | [
"def",
"op_gen",
"(",
"mcode",
")",
":",
"gen",
"=",
"op_tbl",
"[",
"mcode",
"[",
"0",
"]",
"]",
"ret",
"=",
"gen",
"[",
"0",
"]",
"# opcode",
"nargs",
"=",
"len",
"(",
"gen",
")",
"i",
"=",
"1",
"while",
"i",
"<",
"nargs",
":",
"if",
"i",
... | Generate a machine instruction using the op gen table. | [
"Generate",
"a",
"machine",
"instruction",
"using",
"the",
"op",
"gen",
"table",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L207-L217 |
ndf-zz/asfv1 | asfv1.py | fv1parse.scanerror | def scanerror(self, msg):
"""Emit scan error and abort assembly."""
error('scan error: ' + msg + ' on line {}'.format(self.sline))
sys.exit(-1) | python | def scanerror(self, msg):
"""Emit scan error and abort assembly."""
error('scan error: ' + msg + ' on line {}'.format(self.sline))
sys.exit(-1) | [
"def",
"scanerror",
"(",
"self",
",",
"msg",
")",
":",
"error",
"(",
"'scan error: '",
"+",
"msg",
"+",
"' on line {}'",
".",
"format",
"(",
"self",
".",
"sline",
")",
")",
"sys",
".",
"exit",
"(",
"-",
"1",
")"
] | Emit scan error and abort assembly. | [
"Emit",
"scan",
"error",
"and",
"abort",
"assembly",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L792-L795 |
ndf-zz/asfv1 | asfv1.py | fv1parse.parsewarn | def parsewarn(self, msg, line=None):
"""Emit parse warning."""
if line is None:
line = self.sline
self.dowarn('warning: ' + msg + ' on line {}'.format(line)) | python | def parsewarn(self, msg, line=None):
"""Emit parse warning."""
if line is None:
line = self.sline
self.dowarn('warning: ' + msg + ' on line {}'.format(line)) | [
"def",
"parsewarn",
"(",
"self",
",",
"msg",
",",
"line",
"=",
"None",
")",
":",
"if",
"line",
"is",
"None",
":",
"line",
"=",
"self",
".",
"sline",
"self",
".",
"dowarn",
"(",
"'warning: '",
"+",
"msg",
"+",
"' on line {}'",
".",
"format",
"(",
"l... | Emit parse warning. | [
"Emit",
"parse",
"warning",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L797-L801 |
ndf-zz/asfv1 | asfv1.py | fv1parse.parseerror | def parseerror(self, msg, line=None):
"""Emit parse error and abort assembly."""
if line is None:
line = self.sline
error('parse error: ' + msg + ' on line {}'.format(line))
sys.exit(-2) | python | def parseerror(self, msg, line=None):
"""Emit parse error and abort assembly."""
if line is None:
line = self.sline
error('parse error: ' + msg + ' on line {}'.format(line))
sys.exit(-2) | [
"def",
"parseerror",
"(",
"self",
",",
"msg",
",",
"line",
"=",
"None",
")",
":",
"if",
"line",
"is",
"None",
":",
"line",
"=",
"self",
".",
"sline",
"error",
"(",
"'parse error: '",
"+",
"msg",
"+",
"' on line {}'",
".",
"format",
"(",
"line",
")",
... | Emit parse error and abort assembly. | [
"Emit",
"parse",
"error",
"and",
"abort",
"assembly",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L803-L808 |
ndf-zz/asfv1 | asfv1.py | fv1parse.parse | def parse(self):
"""Parse input."""
self.__next__()
while self.sym['type'] != 'EOF':
if self.sym['type'] == 'LABEL':
self.__label__()
elif self.sym['type'] == 'MNEMONIC':
self.__instruction__()
elif self.sym['type'] == 'NAME' or... | python | def parse(self):
"""Parse input."""
self.__next__()
while self.sym['type'] != 'EOF':
if self.sym['type'] == 'LABEL':
self.__label__()
elif self.sym['type'] == 'MNEMONIC':
self.__instruction__()
elif self.sym['type'] == 'NAME' or... | [
"def",
"parse",
"(",
"self",
")",
":",
"self",
".",
"__next__",
"(",
")",
"while",
"self",
".",
"sym",
"[",
"'type'",
"]",
"!=",
"'EOF'",
":",
"if",
"self",
".",
"sym",
"[",
"'type'",
"]",
"==",
"'LABEL'",
":",
"self",
".",
"__label__",
"(",
")",... | Parse input. | [
"Parse",
"input",
"."
] | train | https://github.com/ndf-zz/asfv1/blob/c18f940d7ee86b14e6b201e6d8a4b71e3a57c34a/asfv1.py#L1114-L1155 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/resync.py | resync | def resync(
ctx,
opts,
owner_repo_package,
skip_errors,
wait_interval,
no_wait_for_sync,
sync_attempts,
):
"""
Resynchronise a package in a repository.
This requires appropriate permissions for package.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), t... | python | def resync(
ctx,
opts,
owner_repo_package,
skip_errors,
wait_interval,
no_wait_for_sync,
sync_attempts,
):
"""
Resynchronise a package in a repository.
This requires appropriate permissions for package.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), t... | [
"def",
"resync",
"(",
"ctx",
",",
"opts",
",",
"owner_repo_package",
",",
"skip_errors",
",",
"wait_interval",
",",
"no_wait_for_sync",
",",
"sync_attempts",
",",
")",
":",
"owner",
",",
"source",
",",
"slug",
"=",
"owner_repo_package",
"resync_package",
"(",
... | Resynchronise a package in a repository.
This requires appropriate permissions for package.
- OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the
REPO name where the package is stored, and the PACKAGE name (slug) of the
package itself. All separated by a slash.
Example: 'you... | [
"Resynchronise",
"a",
"package",
"in",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/resync.py#L27-L69 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/resync.py | resync_package | def resync_package(ctx, opts, owner, repo, slug, skip_errors):
"""Resynchronise a package."""
click.echo(
"Resynchonising the %(slug)s package ... "
% {"slug": click.style(slug, bold=True)},
nl=False,
)
context_msg = "Failed to resynchronise package!"
with handle_api_excepti... | python | def resync_package(ctx, opts, owner, repo, slug, skip_errors):
"""Resynchronise a package."""
click.echo(
"Resynchonising the %(slug)s package ... "
% {"slug": click.style(slug, bold=True)},
nl=False,
)
context_msg = "Failed to resynchronise package!"
with handle_api_excepti... | [
"def",
"resync_package",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"repo",
",",
"slug",
",",
"skip_errors",
")",
":",
"click",
".",
"echo",
"(",
"\"Resynchonising the %(slug)s package ... \"",
"%",
"{",
"\"slug\"",
":",
"click",
".",
"style",
"(",
"slug",
... | Resynchronise a package. | [
"Resynchronise",
"a",
"package",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/resync.py#L72-L87 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | make_create_payload | def make_create_payload(**kwargs):
"""Create payload for upload/check-upload operations."""
payload = {}
# Add non-empty arguments
for k, v in six.iteritems(kwargs):
if v is not None:
payload[k] = v
return payload | python | def make_create_payload(**kwargs):
"""Create payload for upload/check-upload operations."""
payload = {}
# Add non-empty arguments
for k, v in six.iteritems(kwargs):
if v is not None:
payload[k] = v
return payload | [
"def",
"make_create_payload",
"(",
"*",
"*",
"kwargs",
")",
":",
"payload",
"=",
"{",
"}",
"# Add non-empty arguments",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"if",
"v",
"is",
"not",
"None",
":",
"payload",
"[",
... | Create payload for upload/check-upload operations. | [
"Create",
"payload",
"for",
"upload",
"/",
"check",
"-",
"upload",
"operations",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L21-L29 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | create_package | def create_package(package_format, owner, repo, **kwargs):
"""Create a new package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
upload = getattr(client, "packages_upload_%s_with_http_info" % package_format)
data, _, headers = upload(
owner=o... | python | def create_package(package_format, owner, repo, **kwargs):
"""Create a new package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
upload = getattr(client, "packages_upload_%s_with_http_info" % package_format)
data, _, headers = upload(
owner=o... | [
"def",
"create_package",
"(",
"package_format",
",",
"owner",
",",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"upload",
"=",
"getattr",
"(",
"client",
",",
"\"... | Create a new package in a repository. | [
"Create",
"a",
"new",
"package",
"in",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L32-L44 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | validate_create_package | def validate_create_package(package_format, owner, repo, **kwargs):
"""Validate parameters for creating a package."""
client = get_packages_api()
with catch_raise_api_exception():
check = getattr(
client, "packages_validate_upload_%s_with_http_info" % package_format
)
_... | python | def validate_create_package(package_format, owner, repo, **kwargs):
"""Validate parameters for creating a package."""
client = get_packages_api()
with catch_raise_api_exception():
check = getattr(
client, "packages_validate_upload_%s_with_http_info" % package_format
)
_... | [
"def",
"validate_create_package",
"(",
"package_format",
",",
"owner",
",",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"check",
"=",
"getattr",
"(",
"client",
",... | Validate parameters for creating a package. | [
"Validate",
"parameters",
"for",
"creating",
"a",
"package",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L47-L61 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | copy_package | def copy_package(owner, repo, identifier, destination):
"""Copy a package to another repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_copy_with_http_info(
owner=owner,
repo=repo,
identifier=identifier... | python | def copy_package(owner, repo, identifier, destination):
"""Copy a package to another repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_copy_with_http_info(
owner=owner,
repo=repo,
identifier=identifier... | [
"def",
"copy_package",
"(",
"owner",
",",
"repo",
",",
"identifier",
",",
"destination",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"packa... | Copy a package to another repository. | [
"Copy",
"a",
"package",
"to",
"another",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L64-L77 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | move_package | def move_package(owner, repo, identifier, destination):
"""Move a package to another repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_move_with_http_info(
owner=owner,
repo=repo,
identifier=identifier... | python | def move_package(owner, repo, identifier, destination):
"""Move a package to another repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_move_with_http_info(
owner=owner,
repo=repo,
identifier=identifier... | [
"def",
"move_package",
"(",
"owner",
",",
"repo",
",",
"identifier",
",",
"destination",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"packa... | Move a package to another repository. | [
"Move",
"a",
"package",
"to",
"another",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L80-L93 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | delete_package | def delete_package(owner, repo, identifier):
"""Delete a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
_, _, headers = client.packages_delete_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratelimits.maybe_rate_li... | python | def delete_package(owner, repo, identifier):
"""Delete a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
_, _, headers = client.packages_delete_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratelimits.maybe_rate_li... | [
"def",
"delete_package",
"(",
"owner",
",",
"repo",
",",
"identifier",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"_",
",",
"_",
",",
"headers",
"=",
"client",
".",
"packages_delete_with_http_info... | Delete a package in a repository. | [
"Delete",
"a",
"package",
"in",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L96-L106 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | resync_package | def resync_package(owner, repo, identifier):
"""Resync a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_resync_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratelimits.maybe_rate... | python | def resync_package(owner, repo, identifier):
"""Resync a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_resync_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratelimits.maybe_rate... | [
"def",
"resync_package",
"(",
"owner",
",",
"repo",
",",
"identifier",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"packages_resync_with_http_i... | Resync a package in a repository. | [
"Resync",
"a",
"package",
"in",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L109-L119 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | get_package_status | def get_package_status(owner, repo, identifier):
"""Get the status for a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_status_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratel... | python | def get_package_status(owner, repo, identifier):
"""Get the status for a package in a repository."""
client = get_packages_api()
with catch_raise_api_exception():
data, _, headers = client.packages_status_with_http_info(
owner=owner, repo=repo, identifier=identifier
)
ratel... | [
"def",
"get_package_status",
"(",
"owner",
",",
"repo",
",",
"identifier",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"packages_status_with_ht... | Get the status for a package in a repository. | [
"Get",
"the",
"status",
"for",
"a",
"package",
"in",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L122-L142 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | list_packages | def list_packages(owner, repo, **kwargs):
"""List packages for a repository."""
client = get_packages_api()
api_kwargs = {}
api_kwargs.update(utils.get_page_kwargs(**kwargs))
api_kwargs.update(utils.get_query_kwargs(**kwargs))
with catch_raise_api_exception():
data, _, headers = client... | python | def list_packages(owner, repo, **kwargs):
"""List packages for a repository."""
client = get_packages_api()
api_kwargs = {}
api_kwargs.update(utils.get_page_kwargs(**kwargs))
api_kwargs.update(utils.get_query_kwargs(**kwargs))
with catch_raise_api_exception():
data, _, headers = client... | [
"def",
"list_packages",
"(",
"owner",
",",
"repo",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"get_packages_api",
"(",
")",
"api_kwargs",
"=",
"{",
"}",
"api_kwargs",
".",
"update",
"(",
"utils",
".",
"get_page_kwargs",
"(",
"*",
"*",
"kwargs",
... | List packages for a repository. | [
"List",
"packages",
"for",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L145-L160 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | get_package_formats | def get_package_formats():
"""Get the list of available package formats and parameters."""
# pylint: disable=fixme
# HACK: This obviously isn't great, and it is subject to change as
# the API changes, but it'll do for now as a interim method of
# introspection to get the parameters we need.
def ... | python | def get_package_formats():
"""Get the list of available package formats and parameters."""
# pylint: disable=fixme
# HACK: This obviously isn't great, and it is subject to change as
# the API changes, but it'll do for now as a interim method of
# introspection to get the parameters we need.
def ... | [
"def",
"get_package_formats",
"(",
")",
":",
"# pylint: disable=fixme",
"# HACK: This obviously isn't great, and it is subject to change as",
"# the API changes, but it'll do for now as a interim method of",
"# introspection to get the parameters we need.",
"def",
"get_parameters",
"(",
"cls... | Get the list of available package formats and parameters. | [
"Get",
"the",
"list",
"of",
"available",
"package",
"formats",
"and",
"parameters",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L163-L202 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/packages.py | get_package_format_names | def get_package_format_names(predicate=None):
"""Get names for available package formats."""
return [
k
for k, v in six.iteritems(get_package_formats())
if not predicate or predicate(k, v)
] | python | def get_package_format_names(predicate=None):
"""Get names for available package formats."""
return [
k
for k, v in six.iteritems(get_package_formats())
if not predicate or predicate(k, v)
] | [
"def",
"get_package_format_names",
"(",
"predicate",
"=",
"None",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"get_package_formats",
"(",
")",
")",
"if",
"not",
"predicate",
"or",
"predicate",
"(",
"k",
",",
... | Get names for available package formats. | [
"Get",
"names",
"for",
"available",
"package",
"formats",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/packages.py#L205-L211 |
venmo/slouch | example.py | start | def start(opts, bot, event):
"""Usage: start [--name=<name>]
Start a timer.
Without _name_, start the default timer.
To run more than one timer at once, pass _name_ to start and stop.
"""
name = opts['--name']
now = datetime.datetime.now()
bot.timers[name] = now
return bot.start... | python | def start(opts, bot, event):
"""Usage: start [--name=<name>]
Start a timer.
Without _name_, start the default timer.
To run more than one timer at once, pass _name_ to start and stop.
"""
name = opts['--name']
now = datetime.datetime.now()
bot.timers[name] = now
return bot.start... | [
"def",
"start",
"(",
"opts",
",",
"bot",
",",
"event",
")",
":",
"name",
"=",
"opts",
"[",
"'--name'",
"]",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"bot",
".",
"timers",
"[",
"name",
"]",
"=",
"now",
"return",
"bot",
".",
... | Usage: start [--name=<name>]
Start a timer.
Without _name_, start the default timer.
To run more than one timer at once, pass _name_ to start and stop. | [
"Usage",
":",
"start",
"[",
"--",
"name",
"=",
"<name",
">",
"]"
] | train | https://github.com/venmo/slouch/blob/000b03bc220a0d7aa5b06f59caf423e2b63a81d7/example.py#L40-L54 |
venmo/slouch | example.py | stop | def stop(opts, bot, event):
"""Usage: stop [--name=<name>] [--notify=<slack_username>]
Stop a timer.
_name_ works the same as for `start`.
If given _slack_username_, reply with an at-mention to the given user.
"""
name = opts['--name']
slack_username = opts['--notify']
now = datetime... | python | def stop(opts, bot, event):
"""Usage: stop [--name=<name>] [--notify=<slack_username>]
Stop a timer.
_name_ works the same as for `start`.
If given _slack_username_, reply with an at-mention to the given user.
"""
name = opts['--name']
slack_username = opts['--notify']
now = datetime... | [
"def",
"stop",
"(",
"opts",
",",
"bot",
",",
"event",
")",
":",
"name",
"=",
"opts",
"[",
"'--name'",
"]",
"slack_username",
"=",
"opts",
"[",
"'--notify'",
"]",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"delta",
"=",
"now",
"-... | Usage: stop [--name=<name>] [--notify=<slack_username>]
Stop a timer.
_name_ works the same as for `start`.
If given _slack_username_, reply with an at-mention to the given user. | [
"Usage",
":",
"stop",
"[",
"--",
"name",
"=",
"<name",
">",
"]",
"[",
"--",
"notify",
"=",
"<slack_username",
">",
"]"
] | train | https://github.com/venmo/slouch/blob/000b03bc220a0d7aa5b06f59caf423e2b63a81d7/example.py#L58-L86 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/user.py | get_user_token | def get_user_token(login, password):
"""Retrieve user token from the API (via authentication)."""
client = get_user_api()
# Never use API key for the token endpoint
config = cloudsmith_api.Configuration()
set_api_key(config, None)
with catch_raise_api_exception():
data, _, headers = cl... | python | def get_user_token(login, password):
"""Retrieve user token from the API (via authentication)."""
client = get_user_api()
# Never use API key for the token endpoint
config = cloudsmith_api.Configuration()
set_api_key(config, None)
with catch_raise_api_exception():
data, _, headers = cl... | [
"def",
"get_user_token",
"(",
"login",
",",
"password",
")",
":",
"client",
"=",
"get_user_api",
"(",
")",
"# Never use API key for the token endpoint",
"config",
"=",
"cloudsmith_api",
".",
"Configuration",
"(",
")",
"set_api_key",
"(",
"config",
",",
"None",
")"... | Retrieve user token from the API (via authentication). | [
"Retrieve",
"user",
"token",
"from",
"the",
"API",
"(",
"via",
"authentication",
")",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/user.py#L17-L31 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/user.py | get_user_brief | def get_user_brief():
"""Retrieve brief for current user (if any)."""
client = get_user_api()
with catch_raise_api_exception():
data, _, headers = client.user_self_with_http_info()
ratelimits.maybe_rate_limit(client, headers)
return data.authenticated, data.slug, data.email, data.name | python | def get_user_brief():
"""Retrieve brief for current user (if any)."""
client = get_user_api()
with catch_raise_api_exception():
data, _, headers = client.user_self_with_http_info()
ratelimits.maybe_rate_limit(client, headers)
return data.authenticated, data.slug, data.email, data.name | [
"def",
"get_user_brief",
"(",
")",
":",
"client",
"=",
"get_user_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"user_self_with_http_info",
"(",
")",
"ratelimits",
".",
"maybe_rate_limi... | Retrieve brief for current user (if any). | [
"Retrieve",
"brief",
"for",
"current",
"user",
"(",
"if",
"any",
")",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/user.py#L34-L42 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/exceptions.py | catch_raise_api_exception | def catch_raise_api_exception():
"""Context manager that translates upstream API exceptions."""
try:
yield
except _ApiException as exc:
detail = None
fields = None
if exc.body:
try:
# pylint: disable=no-member
data = json.loads(exc... | python | def catch_raise_api_exception():
"""Context manager that translates upstream API exceptions."""
try:
yield
except _ApiException as exc:
detail = None
fields = None
if exc.body:
try:
# pylint: disable=no-member
data = json.loads(exc... | [
"def",
"catch_raise_api_exception",
"(",
")",
":",
"try",
":",
"yield",
"except",
"_ApiException",
"as",
"exc",
":",
"detail",
"=",
"None",
"fields",
"=",
"None",
"if",
"exc",
".",
"body",
":",
"try",
":",
"# pylint: disable=no-member",
"data",
"=",
"json",
... | Context manager that translates upstream API exceptions. | [
"Context",
"manager",
"that",
"translates",
"upstream",
"API",
"exceptions",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/exceptions.py#L36-L57 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | ConfigReader.get_default_filepath | def get_default_filepath(cls):
"""Get the default filepath for the configuratin file."""
if not cls.config_files:
return None
if not cls.config_searchpath:
return None
filename = cls.config_files[0]
filepath = cls.config_searchpath[0]
return os.pat... | python | def get_default_filepath(cls):
"""Get the default filepath for the configuratin file."""
if not cls.config_files:
return None
if not cls.config_searchpath:
return None
filename = cls.config_files[0]
filepath = cls.config_searchpath[0]
return os.pat... | [
"def",
"get_default_filepath",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"config_files",
":",
"return",
"None",
"if",
"not",
"cls",
".",
"config_searchpath",
":",
"return",
"None",
"filename",
"=",
"cls",
".",
"config_files",
"[",
"0",
"]",
"filepath"... | Get the default filepath for the configuratin file. | [
"Get",
"the",
"default",
"filepath",
"for",
"the",
"configuratin",
"file",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L54-L62 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | ConfigReader.create_default_file | def create_default_file(cls, data=None, mode=None):
"""Create a config file and override data if specified."""
filepath = cls.get_default_filepath()
if not filepath:
return False
filename = os.path.basename(filepath)
config = read_file(get_data_path(), filename)
... | python | def create_default_file(cls, data=None, mode=None):
"""Create a config file and override data if specified."""
filepath = cls.get_default_filepath()
if not filepath:
return False
filename = os.path.basename(filepath)
config = read_file(get_data_path(), filename)
... | [
"def",
"create_default_file",
"(",
"cls",
",",
"data",
"=",
"None",
",",
"mode",
"=",
"None",
")",
":",
"filepath",
"=",
"cls",
".",
"get_default_filepath",
"(",
")",
"if",
"not",
"filepath",
":",
"return",
"False",
"filename",
"=",
"os",
".",
"path",
... | Create a config file and override data if specified. | [
"Create",
"a",
"config",
"file",
"and",
"override",
"data",
"if",
"specified",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L65-L94 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | ConfigReader.has_default_file | def has_default_file(cls):
"""Check if a configuration file exists."""
for filename in cls.config_files:
for searchpath in cls.config_searchpath:
path = os.path.join(searchpath, filename)
if os.path.exists(path):
return True
return... | python | def has_default_file(cls):
"""Check if a configuration file exists."""
for filename in cls.config_files:
for searchpath in cls.config_searchpath:
path = os.path.join(searchpath, filename)
if os.path.exists(path):
return True
return... | [
"def",
"has_default_file",
"(",
"cls",
")",
":",
"for",
"filename",
"in",
"cls",
".",
"config_files",
":",
"for",
"searchpath",
"in",
"cls",
".",
"config_searchpath",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"searchpath",
",",
"filename",
"... | Check if a configuration file exists. | [
"Check",
"if",
"a",
"configuration",
"file",
"exists",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L97-L105 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | ConfigReader.load_config | def load_config(cls, opts, path=None, profile=None):
"""Load a configuration file into an options object."""
if path and os.path.exists(path):
if os.path.isdir(path):
cls.config_searchpath.insert(0, path)
else:
cls.config_files.insert(0, path)
... | python | def load_config(cls, opts, path=None, profile=None):
"""Load a configuration file into an options object."""
if path and os.path.exists(path):
if os.path.isdir(path):
cls.config_searchpath.insert(0, path)
else:
cls.config_files.insert(0, path)
... | [
"def",
"load_config",
"(",
"cls",
",",
"opts",
",",
"path",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"if",
"path",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")... | Load a configuration file into an options object. | [
"Load",
"a",
"configuration",
"file",
"into",
"an",
"options",
"object",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L108-L124 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | Options.load_config_file | def load_config_file(self, path, profile=None):
"""Load the standard config file."""
config_cls = self.get_config_reader()
return config_cls.load_config(self, path, profile=profile) | python | def load_config_file(self, path, profile=None):
"""Load the standard config file."""
config_cls = self.get_config_reader()
return config_cls.load_config(self, path, profile=profile) | [
"def",
"load_config_file",
"(",
"self",
",",
"path",
",",
"profile",
"=",
"None",
")",
":",
"config_cls",
"=",
"self",
".",
"get_config_reader",
"(",
")",
"return",
"config_cls",
".",
"load_config",
"(",
"self",
",",
"path",
",",
"profile",
"=",
"profile",... | Load the standard config file. | [
"Load",
"the",
"standard",
"config",
"file",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L183-L186 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | Options.load_creds_file | def load_creds_file(self, path, profile=None):
"""Load the credentials config file."""
config_cls = self.get_creds_reader()
return config_cls.load_config(self, path, profile=profile) | python | def load_creds_file(self, path, profile=None):
"""Load the credentials config file."""
config_cls = self.get_creds_reader()
return config_cls.load_config(self, path, profile=profile) | [
"def",
"load_creds_file",
"(",
"self",
",",
"path",
",",
"profile",
"=",
"None",
")",
":",
"config_cls",
"=",
"self",
".",
"get_creds_reader",
"(",
")",
"return",
"config_cls",
".",
"load_config",
"(",
"self",
",",
"path",
",",
"profile",
"=",
"profile",
... | Load the credentials config file. | [
"Load",
"the",
"credentials",
"config",
"file",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L188-L191 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | Options.api_headers | def api_headers(self, value):
"""Set value for API headers."""
value = validators.validate_api_headers("api_headers", value)
self._set_option("api_headers", value) | python | def api_headers(self, value):
"""Set value for API headers."""
value = validators.validate_api_headers("api_headers", value)
self._set_option("api_headers", value) | [
"def",
"api_headers",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"validators",
".",
"validate_api_headers",
"(",
"\"api_headers\"",
",",
"value",
")",
"self",
".",
"_set_option",
"(",
"\"api_headers\"",
",",
"value",
")"
] | Set value for API headers. | [
"Set",
"value",
"for",
"API",
"headers",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L209-L212 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | Options.error_retry_codes | def error_retry_codes(self, value):
"""Set value for error_retry_codes."""
if isinstance(value, six.string_types):
value = [int(x) for x in value.split(",")]
self._set_option("error_retry_codes", value) | python | def error_retry_codes(self, value):
"""Set value for error_retry_codes."""
if isinstance(value, six.string_types):
value = [int(x) for x in value.split(",")]
self._set_option("error_retry_codes", value) | [
"def",
"error_retry_codes",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"value",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"value",
".",
"split",
"(",
"\",\"",
")",
"]",
... | Set value for error_retry_codes. | [
"Set",
"value",
"for",
"error_retry_codes",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L340-L344 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/config.py | Options._set_option | def _set_option(self, name, value, allow_clear=False):
"""Set value for an option."""
if not allow_clear:
# Prevent clears if value was set
try:
current_value = self._get_option(name)
if value is None and current_value is not None:
... | python | def _set_option(self, name, value, allow_clear=False):
"""Set value for an option."""
if not allow_clear:
# Prevent clears if value was set
try:
current_value = self._get_option(name)
if value is None and current_value is not None:
... | [
"def",
"_set_option",
"(",
"self",
",",
"name",
",",
"value",
",",
"allow_clear",
"=",
"False",
")",
":",
"if",
"not",
"allow_clear",
":",
"# Prevent clears if value was set",
"try",
":",
"current_value",
"=",
"self",
".",
"_get_option",
"(",
"name",
")",
"i... | Set value for an option. | [
"Set",
"value",
"for",
"an",
"option",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/config.py#L350-L361 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/rates.py | get_rate_limits | def get_rate_limits():
"""Retrieve status (and optionally) version from the API."""
client = get_rates_api()
with catch_raise_api_exception():
data, _, headers = client.rates_limits_list_with_http_info()
ratelimits.maybe_rate_limit(client, headers)
return {
k: RateLimitsInfo.from_... | python | def get_rate_limits():
"""Retrieve status (and optionally) version from the API."""
client = get_rates_api()
with catch_raise_api_exception():
data, _, headers = client.rates_limits_list_with_http_info()
ratelimits.maybe_rate_limit(client, headers)
return {
k: RateLimitsInfo.from_... | [
"def",
"get_rate_limits",
"(",
")",
":",
"client",
"=",
"get_rates_api",
"(",
")",
"with",
"catch_raise_api_exception",
"(",
")",
":",
"data",
",",
"_",
",",
"headers",
"=",
"client",
".",
"rates_limits_list_with_http_info",
"(",
")",
"ratelimits",
".",
"maybe... | Retrieve status (and optionally) version from the API. | [
"Retrieve",
"status",
"(",
"and",
"optionally",
")",
"version",
"from",
"the",
"API",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/rates.py#L19-L31 |
marrow/schema | marrow/schema/transform/base.py | BaseTransform.loads | def loads(self, value, context=None):
"""Attempt to load a string-based value into the native representation.
Empty strings are treated as ``None`` values.
"""
if value == '' or (hasattr(value, 'strip') and value.strip() == ''):
return None
return self.native(value) | python | def loads(self, value, context=None):
"""Attempt to load a string-based value into the native representation.
Empty strings are treated as ``None`` values.
"""
if value == '' or (hasattr(value, 'strip') and value.strip() == ''):
return None
return self.native(value) | [
"def",
"loads",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"if",
"value",
"==",
"''",
"or",
"(",
"hasattr",
"(",
"value",
",",
"'strip'",
")",
"and",
"value",
".",
"strip",
"(",
")",
"==",
"''",
")",
":",
"return",
"None",
... | Attempt to load a string-based value into the native representation.
Empty strings are treated as ``None`` values. | [
"Attempt",
"to",
"load",
"a",
"string",
"-",
"based",
"value",
"into",
"the",
"native",
"representation",
".",
"Empty",
"strings",
"are",
"treated",
"as",
"None",
"values",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/base.py#L23-L32 |
marrow/schema | marrow/schema/transform/base.py | BaseTransform.dump | def dump(self, fh, value, context=None):
"""Attempt to transform and write a string-based foreign value to the given file-like object.
Returns the length written.
"""
value = self.dumps(value)
fh.write(value)
return len(value) | python | def dump(self, fh, value, context=None):
"""Attempt to transform and write a string-based foreign value to the given file-like object.
Returns the length written.
"""
value = self.dumps(value)
fh.write(value)
return len(value) | [
"def",
"dump",
"(",
"self",
",",
"fh",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"dumps",
"(",
"value",
")",
"fh",
".",
"write",
"(",
"value",
")",
"return",
"len",
"(",
"value",
")"
] | Attempt to transform and write a string-based foreign value to the given file-like object.
Returns the length written. | [
"Attempt",
"to",
"transform",
"and",
"write",
"a",
"string",
"-",
"based",
"foreign",
"value",
"to",
"the",
"given",
"file",
"-",
"like",
"object",
".",
"Returns",
"the",
"length",
"written",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/base.py#L50-L58 |
marrow/schema | marrow/schema/transform/base.py | Transform.native | def native(self, value, context=None):
"""Convert a value from a foriegn type (i.e. web-safe) to Python-native."""
if self.strip and hasattr(value, 'strip'):
value = value.strip()
if self.none and value == '':
return None
if self.encoding and isinstance(value, bytes):
return value.decode(self.... | python | def native(self, value, context=None):
"""Convert a value from a foriegn type (i.e. web-safe) to Python-native."""
if self.strip and hasattr(value, 'strip'):
value = value.strip()
if self.none and value == '':
return None
if self.encoding and isinstance(value, bytes):
return value.decode(self.... | [
"def",
"native",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"if",
"self",
".",
"strip",
"and",
"hasattr",
"(",
"value",
",",
"'strip'",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"if",
"self",
".",
"none",
"an... | Convert a value from a foriegn type (i.e. web-safe) to Python-native. | [
"Convert",
"a",
"value",
"from",
"a",
"foriegn",
"type",
"(",
"i",
".",
"e",
".",
"web",
"-",
"safe",
")",
"to",
"Python",
"-",
"native",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/base.py#L77-L89 |
marrow/schema | marrow/schema/transform/base.py | IngressTransform.native | def native(self, value, context=None):
"""Convert a value from a foriegn type (i.e. web-safe) to Python-native."""
value = super().native(value, context)
if value is None: return
try:
return self.ingress(value)
except Exception as e:
raise Concern("Unable to transform incoming value: {0}", str(... | python | def native(self, value, context=None):
"""Convert a value from a foriegn type (i.e. web-safe) to Python-native."""
value = super().native(value, context)
if value is None: return
try:
return self.ingress(value)
except Exception as e:
raise Concern("Unable to transform incoming value: {0}", str(... | [
"def",
"native",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"value",
"=",
"super",
"(",
")",
".",
"native",
"(",
"value",
",",
"context",
")",
"if",
"value",
"is",
"None",
":",
"return",
"try",
":",
"return",
"self",
".",
"... | Convert a value from a foriegn type (i.e. web-safe) to Python-native. | [
"Convert",
"a",
"value",
"from",
"a",
"foriegn",
"type",
"(",
"i",
".",
"e",
".",
"web",
"-",
"safe",
")",
"to",
"Python",
"-",
"native",
"."
] | train | https://github.com/marrow/schema/blob/0c4c3e3b8c79d8bfeb8d7265cfa5b12a2e643152/marrow/schema/transform/base.py#L109-L119 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/check.py | rates | def rates(ctx, opts):
"""Check current API rate limits."""
click.echo("Retrieving rate limits ... ", nl=False)
context_msg = "Failed to retrieve status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with maybe_spinner(opts):
resources_limits = get_rate_limits... | python | def rates(ctx, opts):
"""Check current API rate limits."""
click.echo("Retrieving rate limits ... ", nl=False)
context_msg = "Failed to retrieve status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with maybe_spinner(opts):
resources_limits = get_rate_limits... | [
"def",
"rates",
"(",
"ctx",
",",
"opts",
")",
":",
"click",
".",
"echo",
"(",
"\"Retrieving rate limits ... \"",
",",
"nl",
"=",
"False",
")",
"context_msg",
"=",
"\"Failed to retrieve status!\"",
"with",
"handle_api_exceptions",
"(",
"ctx",
",",
"opts",
"=",
... | Check current API rate limits. | [
"Check",
"current",
"API",
"rate",
"limits",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/check.py#L34-L76 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/check.py | service | def service(ctx, opts):
"""Check the status of the Cloudsmith service."""
click.echo("Retrieving service status ... ", nl=False)
context_msg = "Failed to retrieve status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with maybe_spinner(opts):
status, version ... | python | def service(ctx, opts):
"""Check the status of the Cloudsmith service."""
click.echo("Retrieving service status ... ", nl=False)
context_msg = "Failed to retrieve status!"
with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
with maybe_spinner(opts):
status, version ... | [
"def",
"service",
"(",
"ctx",
",",
"opts",
")",
":",
"click",
".",
"echo",
"(",
"\"Retrieving service status ... \"",
",",
"nl",
"=",
"False",
")",
"context_msg",
"=",
"\"Failed to retrieve status!\"",
"with",
"handle_api_exceptions",
"(",
"ctx",
",",
"opts",
"=... | Check the status of the Cloudsmith service. | [
"Check",
"the",
"status",
"of",
"the",
"Cloudsmith",
"service",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/check.py#L84-L130 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/core/api/distros.py | list_distros | def list_distros(package_format=None):
"""List available distributions."""
client = get_distros_api()
# pylint: disable=fixme
# TODO(ls): Add package format param on the server-side to filter distros
# instead of doing it here.
with catch_raise_api_exception():
distros, _, headers = cli... | python | def list_distros(package_format=None):
"""List available distributions."""
client = get_distros_api()
# pylint: disable=fixme
# TODO(ls): Add package format param on the server-side to filter distros
# instead of doing it here.
with catch_raise_api_exception():
distros, _, headers = cli... | [
"def",
"list_distros",
"(",
"package_format",
"=",
"None",
")",
":",
"client",
"=",
"get_distros_api",
"(",
")",
"# pylint: disable=fixme",
"# TODO(ls): Add package format param on the server-side to filter distros",
"# instead of doing it here.",
"with",
"catch_raise_api_exception... | List available distributions. | [
"List",
"available",
"distributions",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/core/api/distros.py#L17-L33 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | total_seconds | def total_seconds(td):
"""For those with older versions of Python, a pure-Python
implementation of Python 2.7's :meth:`~datetime.timedelta.total_seconds`.
Args:
td (datetime.timedelta): The timedelta to convert to seconds.
Returns:
float: total number of seconds
>>> td = timedelta(... | python | def total_seconds(td):
"""For those with older versions of Python, a pure-Python
implementation of Python 2.7's :meth:`~datetime.timedelta.total_seconds`.
Args:
td (datetime.timedelta): The timedelta to convert to seconds.
Returns:
float: total number of seconds
>>> td = timedelta(... | [
"def",
"total_seconds",
"(",
"td",
")",
":",
"a_milli",
"=",
"1000000.0",
"td_ds",
"=",
"td",
".",
"seconds",
"+",
"(",
"td",
".",
"days",
"*",
"86400",
")",
"# 24 * 60 * 60",
"td_micro",
"=",
"td",
".",
"microseconds",
"+",
"(",
"td_ds",
"*",
"a_milli... | For those with older versions of Python, a pure-Python
implementation of Python 2.7's :meth:`~datetime.timedelta.total_seconds`.
Args:
td (datetime.timedelta): The timedelta to convert to seconds.
Returns:
float: total number of seconds
>>> td = timedelta(days=4, seconds=33)
>>> to... | [
"For",
"those",
"with",
"older",
"versions",
"of",
"Python",
"a",
"pure",
"-",
"Python",
"implementation",
"of",
"Python",
"2",
".",
"7",
"s",
":",
"meth",
":",
"~datetime",
".",
"timedelta",
".",
"total_seconds",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L30-L46 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | dt_to_timestamp | def dt_to_timestamp(dt):
"""Converts from a :class:`~datetime.datetime` object to an integer
timestamp, suitable interoperation with :func:`time.time` and
other `Epoch-based timestamps`.
.. _Epoch-based timestamps: https://en.wikipedia.org/wiki/Unix_time
>>> abs(round(time.time() - dt_to_timestamp... | python | def dt_to_timestamp(dt):
"""Converts from a :class:`~datetime.datetime` object to an integer
timestamp, suitable interoperation with :func:`time.time` and
other `Epoch-based timestamps`.
.. _Epoch-based timestamps: https://en.wikipedia.org/wiki/Unix_time
>>> abs(round(time.time() - dt_to_timestamp... | [
"def",
"dt_to_timestamp",
"(",
"dt",
")",
":",
"if",
"dt",
".",
"tzinfo",
":",
"td",
"=",
"dt",
"-",
"EPOCH_AWARE",
"else",
":",
"td",
"=",
"dt",
"-",
"EPOCH_NAIVE",
"return",
"total_seconds",
"(",
"td",
")"
] | Converts from a :class:`~datetime.datetime` object to an integer
timestamp, suitable interoperation with :func:`time.time` and
other `Epoch-based timestamps`.
.. _Epoch-based timestamps: https://en.wikipedia.org/wiki/Unix_time
>>> abs(round(time.time() - dt_to_timestamp(datetime.utcnow()), 2))
0.0... | [
"Converts",
"from",
"a",
":",
"class",
":",
"~datetime",
".",
"datetime",
"object",
"to",
"an",
"integer",
"timestamp",
"suitable",
"interoperation",
"with",
":",
"func",
":",
"time",
".",
"time",
"and",
"other",
"Epoch",
"-",
"based",
"timestamps",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L49-L73 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | isoparse | def isoparse(iso_str):
"""Parses the limited subset of `ISO8601-formatted time`_ strings as
returned by :meth:`datetime.datetime.isoformat`.
>>> epoch_dt = datetime.utcfromtimestamp(0)
>>> iso_str = epoch_dt.isoformat()
>>> print(iso_str)
1970-01-01T00:00:00
>>> isoparse(iso_str)
dateti... | python | def isoparse(iso_str):
"""Parses the limited subset of `ISO8601-formatted time`_ strings as
returned by :meth:`datetime.datetime.isoformat`.
>>> epoch_dt = datetime.utcfromtimestamp(0)
>>> iso_str = epoch_dt.isoformat()
>>> print(iso_str)
1970-01-01T00:00:00
>>> isoparse(iso_str)
dateti... | [
"def",
"isoparse",
"(",
"iso_str",
")",
":",
"dt_args",
"=",
"[",
"int",
"(",
"p",
")",
"for",
"p",
"in",
"_NONDIGIT_RE",
".",
"split",
"(",
"iso_str",
")",
"]",
"return",
"datetime",
"(",
"*",
"dt_args",
")"
] | Parses the limited subset of `ISO8601-formatted time`_ strings as
returned by :meth:`datetime.datetime.isoformat`.
>>> epoch_dt = datetime.utcfromtimestamp(0)
>>> iso_str = epoch_dt.isoformat()
>>> print(iso_str)
1970-01-01T00:00:00
>>> isoparse(iso_str)
datetime.datetime(1970, 1, 1, 0, 0)
... | [
"Parses",
"the",
"limited",
"subset",
"of",
"ISO8601",
"-",
"formatted",
"time",
"_",
"strings",
"as",
"returned",
"by",
":",
"meth",
":",
"datetime",
".",
"datetime",
".",
"isoformat",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L79-L103 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | parse_timedelta | def parse_timedelta(text):
"""Robustly parses a short text description of a time period into a
:class:`datetime.timedelta`. Supports weeks, days, hours, minutes,
and seconds, with or without decimal points:
Args:
text (str): Text to parse.
Returns:
datetime.timedelta
Raises:
... | python | def parse_timedelta(text):
"""Robustly parses a short text description of a time period into a
:class:`datetime.timedelta`. Supports weeks, days, hours, minutes,
and seconds, with or without decimal points:
Args:
text (str): Text to parse.
Returns:
datetime.timedelta
Raises:
... | [
"def",
"parse_timedelta",
"(",
"text",
")",
":",
"td_kwargs",
"=",
"{",
"}",
"for",
"match",
"in",
"_PARSE_TD_RE",
".",
"finditer",
"(",
"text",
")",
":",
"value",
",",
"unit",
"=",
"match",
".",
"group",
"(",
"'value'",
")",
",",
"match",
".",
"grou... | Robustly parses a short text description of a time period into a
:class:`datetime.timedelta`. Supports weeks, days, hours, minutes,
and seconds, with or without decimal points:
Args:
text (str): Text to parse.
Returns:
datetime.timedelta
Raises:
ValueError: on parse failure.... | [
"Robustly",
"parses",
"a",
"short",
"text",
"description",
"of",
"a",
"time",
"period",
"into",
"a",
":",
"class",
":",
"datetime",
".",
"timedelta",
".",
"Supports",
"weeks",
"days",
"hours",
"minutes",
"and",
"seconds",
"with",
"or",
"without",
"decimal",
... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L122-L161 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | decimal_relative_time | def decimal_relative_time(d, other=None, ndigits=0, cardinalize=True):
"""Get a tuple representing the relative time difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and now.
Args:
d (datetime): The first datetime object.
other (datetime): An... | python | def decimal_relative_time(d, other=None, ndigits=0, cardinalize=True):
"""Get a tuple representing the relative time difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and now.
Args:
d (datetime): The first datetime object.
other (datetime): An... | [
"def",
"decimal_relative_time",
"(",
"d",
",",
"other",
"=",
"None",
",",
"ndigits",
"=",
"0",
",",
"cardinalize",
"=",
"True",
")",
":",
"if",
"other",
"is",
"None",
":",
"other",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"diff",
"=",
"other",
"-",
... | Get a tuple representing the relative time difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and now.
Args:
d (datetime): The first datetime object.
other (datetime): An optional second datetime object. If
unset, defaults to the curren... | [
"Get",
"a",
"tuple",
"representing",
"the",
"relative",
"time",
"difference",
"between",
"two",
":",
"class",
":",
"~datetime",
".",
"datetime",
"objects",
"or",
"one",
":",
"class",
":",
"~datetime",
".",
"datetime",
"and",
"now",
"."
] | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L175-L218 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | relative_time | def relative_time(d, other=None, ndigits=0):
"""Get a string representation of the difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and the current time. Handles past and
future times.
Args:
d (datetime): The first datetime object.
other ... | python | def relative_time(d, other=None, ndigits=0):
"""Get a string representation of the difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and the current time. Handles past and
future times.
Args:
d (datetime): The first datetime object.
other ... | [
"def",
"relative_time",
"(",
"d",
",",
"other",
"=",
"None",
",",
"ndigits",
"=",
"0",
")",
":",
"drt",
",",
"unit",
"=",
"decimal_relative_time",
"(",
"d",
",",
"other",
",",
"ndigits",
",",
"cardinalize",
"=",
"True",
")",
"phrase",
"=",
"'ago'",
"... | Get a string representation of the difference between two
:class:`~datetime.datetime` objects or one
:class:`~datetime.datetime` and the current time. Handles past and
future times.
Args:
d (datetime): The first datetime object.
other (datetime): An optional second datetime object. If
... | [
"Get",
"a",
"string",
"representation",
"of",
"the",
"difference",
"between",
"two",
":",
"class",
":",
"~datetime",
".",
"datetime",
"objects",
"or",
"one",
":",
"class",
":",
"~datetime",
".",
"datetime",
"and",
"the",
"current",
"time",
".",
"Handles",
... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L221-L250 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | strpdate | def strpdate(string, format):
"""Parse the date string according to the format in `format`. Returns a
:class:`date` object. Internally, :meth:`datetime.strptime` is used to
parse the string and thus conversion specifiers for time fields (e.g. `%H`)
may be provided; these will be parsed but ignored.
... | python | def strpdate(string, format):
"""Parse the date string according to the format in `format`. Returns a
:class:`date` object. Internally, :meth:`datetime.strptime` is used to
parse the string and thus conversion specifiers for time fields (e.g. `%H`)
may be provided; these will be parsed but ignored.
... | [
"def",
"strpdate",
"(",
"string",
",",
"format",
")",
":",
"whence",
"=",
"datetime",
".",
"strptime",
"(",
"string",
",",
"format",
")",
"return",
"whence",
".",
"date",
"(",
")"
] | Parse the date string according to the format in `format`. Returns a
:class:`date` object. Internally, :meth:`datetime.strptime` is used to
parse the string and thus conversion specifiers for time fields (e.g. `%H`)
may be provided; these will be parsed but ignored.
Args:
string (str): The d... | [
"Parse",
"the",
"date",
"string",
"according",
"to",
"the",
"format",
"in",
"format",
".",
"Returns",
"a",
":",
"class",
":",
"date",
"object",
".",
"Internally",
":",
"meth",
":",
"datetime",
".",
"strptime",
"is",
"used",
"to",
"parse",
"the",
"string"... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L253-L277 |
kalefranz/auxlib | auxlib/_vendor/boltons/timeutils.py | daterange | def daterange(start, stop, step=1, inclusive=False):
"""In the spirit of :func:`range` and :func:`xrange`, the `daterange`
generator that yields a sequence of :class:`~datetime.date`
objects, starting at *start*, incrementing by *step*, until *stop*
is reached.
When *inclusive* is True, the final d... | python | def daterange(start, stop, step=1, inclusive=False):
"""In the spirit of :func:`range` and :func:`xrange`, the `daterange`
generator that yields a sequence of :class:`~datetime.date`
objects, starting at *start*, incrementing by *step*, until *stop*
is reached.
When *inclusive* is True, the final d... | [
"def",
"daterange",
"(",
"start",
",",
"stop",
",",
"step",
"=",
"1",
",",
"inclusive",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"start",
",",
"date",
")",
":",
"raise",
"TypeError",
"(",
"\"start expected datetime.date instance\"",
")",
"if... | In the spirit of :func:`range` and :func:`xrange`, the `daterange`
generator that yields a sequence of :class:`~datetime.date`
objects, starting at *start*, incrementing by *step*, until *stop*
is reached.
When *inclusive* is True, the final date may be *stop*, **if**
*step* falls evenly on it. By ... | [
"In",
"the",
"spirit",
"of",
":",
"func",
":",
"range",
"and",
":",
"func",
":",
"xrange",
"the",
"daterange",
"generator",
"that",
"yields",
"a",
"sequence",
"of",
":",
"class",
":",
"~datetime",
".",
"date",
"objects",
"starting",
"at",
"*",
"start",
... | train | https://github.com/kalefranz/auxlib/blob/6ff2d6b57d128d0b9ed8f01ad83572e938da064f/auxlib/_vendor/boltons/timeutils.py#L280-L364 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/list_.py | distros | def distros(ctx, opts, package_format):
"""List available distributions."""
# Use stderr for messages if the output is something else (e.g. # JSON)
use_stderr = opts.output != "pretty"
click.echo("Getting list of distributions ... ", nl=False, err=use_stderr)
context_msg = "Failed to get list of ... | python | def distros(ctx, opts, package_format):
"""List available distributions."""
# Use stderr for messages if the output is something else (e.g. # JSON)
use_stderr = opts.output != "pretty"
click.echo("Getting list of distributions ... ", nl=False, err=use_stderr)
context_msg = "Failed to get list of ... | [
"def",
"distros",
"(",
"ctx",
",",
"opts",
",",
"package_format",
")",
":",
"# Use stderr for messages if the output is something else (e.g. # JSON)",
"use_stderr",
"=",
"opts",
".",
"output",
"!=",
"\"pretty\"",
"click",
".",
"echo",
"(",
"\"Getting list of distribution... | List available distributions. | [
"List",
"available",
"distributions",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/list_.py#L47-L100 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/list_.py | packages | def packages(ctx, opts, owner_repo, page, page_size, query):
"""
List packages for a repository.
OWNER/REPO: Specify the OWNER namespace (i.e. user or org), and the
REPO name to list packages for that namespace and repository. All separated
by a slash.
You can use the search query (-q|--query)... | python | def packages(ctx, opts, owner_repo, page, page_size, query):
"""
List packages for a repository.
OWNER/REPO: Specify the OWNER namespace (i.e. user or org), and the
REPO name to list packages for that namespace and repository. All separated
by a slash.
You can use the search query (-q|--query)... | [
"def",
"packages",
"(",
"ctx",
",",
"opts",
",",
"owner_repo",
",",
"page",
",",
"page_size",
",",
"query",
")",
":",
"owner",
",",
"repo",
"=",
"owner_repo",
"# Use stderr for messages if the output is something else (e.g. # JSON)",
"use_stderr",
"=",
"opts",
".",... | List packages for a repository.
OWNER/REPO: Specify the OWNER namespace (i.e. user or org), and the
REPO name to list packages for that namespace and repository. All separated
by a slash.
You can use the search query (-q|--query) to filter packages:
- By name: 'my-package' (implicit) or 'name:m... | [
"List",
"packages",
"for",
"a",
"repository",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/list_.py#L126-L210 |
cloudsmith-io/cloudsmith-cli | cloudsmith_cli/cli/commands/list_.py | repos | def repos(ctx, opts, owner, page, page_size):
"""
List repositories for a namespace (owner).
OWNER: Specify the OWNER namespace (i.e. user or org) to list the
repositories for that namespace.
If OWNER isn't specified it'll default to the currently authenticated user
(if any). If you're unauthe... | python | def repos(ctx, opts, owner, page, page_size):
"""
List repositories for a namespace (owner).
OWNER: Specify the OWNER namespace (i.e. user or org) to list the
repositories for that namespace.
If OWNER isn't specified it'll default to the currently authenticated user
(if any). If you're unauthe... | [
"def",
"repos",
"(",
"ctx",
",",
"opts",
",",
"owner",
",",
"page",
",",
"page_size",
")",
":",
"# Use stderr for messages if the output is something else (e.g. # JSON)",
"use_stderr",
"=",
"opts",
".",
"output",
"!=",
"\"pretty\"",
"click",
".",
"echo",
"(",
"\"... | List repositories for a namespace (owner).
OWNER: Specify the OWNER namespace (i.e. user or org) to list the
repositories for that namespace.
If OWNER isn't specified it'll default to the currently authenticated user
(if any). If you're unauthenticated, no results will be returned. | [
"List",
"repositories",
"for",
"a",
"namespace",
"(",
"owner",
")",
"."
] | train | https://github.com/cloudsmith-io/cloudsmith-cli/blob/5bc245ca5d0bfa85380be48e7c206b4c86cc6c8e/cloudsmith_cli/cli/commands/list_.py#L221-L284 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.