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 |
|---|---|---|---|---|---|---|---|---|---|---|
callowayproject/Transmogrify | transmogrify/settings.py | lists_from_env | def lists_from_env(key, default=""):
"""
Splits a string in the format "a,b:c,d,e:f" into
[('a', 'b'), ('c', 'd', 'e'), ('f', )]
"""
try:
val = os.environ.get(key, default)
lists = val.split(":")
return [i.split(',') for i in lists]
except (KeyError, ValueError):
... | python | def lists_from_env(key, default=""):
"""
Splits a string in the format "a,b:c,d,e:f" into
[('a', 'b'), ('c', 'd', 'e'), ('f', )]
"""
try:
val = os.environ.get(key, default)
lists = val.split(":")
return [i.split(',') for i in lists]
except (KeyError, ValueError):
... | [
"def",
"lists_from_env",
"(",
"key",
",",
"default",
"=",
"\"\"",
")",
":",
"try",
":",
"val",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"key",
",",
"default",
")",
"lists",
"=",
"val",
".",
"split",
"(",
"\":\"",
")",
"return",
"[",
"i",
".",
... | Splits a string in the format "a,b:c,d,e:f" into
[('a', 'b'), ('c', 'd', 'e'), ('f', )] | [
"Splits",
"a",
"string",
"in",
"the",
"format",
"a",
"b",
":",
"c",
"d",
"e",
":",
"f",
"into",
"[",
"(",
"a",
"b",
")",
"(",
"c",
"d",
"e",
")",
"(",
"f",
")",
"]"
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/settings.py#L57-L67 |
slarse/clanimtk | clanimtk/cli.py | animate_cli | def animate_cli(animation_, step, event):
"""Print out the animation cycle to stdout. This function is for use with
synchronous functions and must be run in a thread.
Args:
animation_ (generator): A generator that produces strings for the
animation. Should be endless.
step (float): ... | python | def animate_cli(animation_, step, event):
"""Print out the animation cycle to stdout. This function is for use with
synchronous functions and must be run in a thread.
Args:
animation_ (generator): A generator that produces strings for the
animation. Should be endless.
step (float): ... | [
"def",
"animate_cli",
"(",
"animation_",
",",
"step",
",",
"event",
")",
":",
"while",
"True",
":",
"# run at least once, important for tests!",
"time",
".",
"sleep",
"(",
"step",
")",
"frame",
"=",
"next",
"(",
"animation_",
")",
"sys",
".",
"stdout",
".",
... | Print out the animation cycle to stdout. This function is for use with
synchronous functions and must be run in a thread.
Args:
animation_ (generator): A generator that produces strings for the
animation. Should be endless.
step (float): Seconds between each animation frame. | [
"Print",
"out",
"the",
"animation",
"cycle",
"to",
"stdout",
".",
"This",
"function",
"is",
"for",
"use",
"with",
"synchronous",
"functions",
"and",
"must",
"be",
"run",
"in",
"a",
"thread",
"."
] | train | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/cli.py#L24-L42 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | configuration_ES | def configuration_ES(t0: date, t1: Optional[date] = None,
steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]:
"""
Get the positions and velocities of the earth and sun from date t0 to t1.
Returned as a tuple q, v
q: Nx3 array of positions (x, y, z) in the J2000.0 coordinat... | python | def configuration_ES(t0: date, t1: Optional[date] = None,
steps_per_day: int = None) -> Tuple[np.ndarray, np.ndarray]:
"""
Get the positions and velocities of the earth and sun from date t0 to t1.
Returned as a tuple q, v
q: Nx3 array of positions (x, y, z) in the J2000.0 coordinat... | [
"def",
"configuration_ES",
"(",
"t0",
":",
"date",
",",
"t1",
":",
"Optional",
"[",
"date",
"]",
"=",
"None",
",",
"steps_per_day",
":",
"int",
"=",
"None",
")",
"->",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
":",
"# Defa... | Get the positions and velocities of the earth and sun from date t0 to t1.
Returned as a tuple q, v
q: Nx3 array of positions (x, y, z) in the J2000.0 coordinate frame. | [
"Get",
"the",
"positions",
"and",
"velocities",
"of",
"the",
"earth",
"and",
"sun",
"from",
"date",
"t0",
"to",
"t1",
".",
"Returned",
"as",
"a",
"tuple",
"q",
"v",
"q",
":",
"Nx3",
"array",
"of",
"positions",
"(",
"x",
"y",
"z",
")",
"in",
"the",
... | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L40-L79 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | plot_ES | def plot_ES(q: np.ndarray, sim_name: str, fname: Optional[str] = None):
"""
Plot the earth-sun orbits.
q is a Tx6 array. T indexes time points. 6 columns are sun (x, y, z) and earth (x, y, z)
"""
# Convert all distances from meters to astronomical units (AU)
# Unpack sun (x, y) in au; z not us... | python | def plot_ES(q: np.ndarray, sim_name: str, fname: Optional[str] = None):
"""
Plot the earth-sun orbits.
q is a Tx6 array. T indexes time points. 6 columns are sun (x, y, z) and earth (x, y, z)
"""
# Convert all distances from meters to astronomical units (AU)
# Unpack sun (x, y) in au; z not us... | [
"def",
"plot_ES",
"(",
"q",
":",
"np",
".",
"ndarray",
",",
"sim_name",
":",
"str",
",",
"fname",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"# Convert all distances from meters to astronomical units (AU)",
"# Unpack sun (x, y) in au; z not used in plots... | Plot the earth-sun orbits.
q is a Tx6 array. T indexes time points. 6 columns are sun (x, y, z) and earth (x, y, z) | [
"Plot",
"the",
"earth",
"-",
"sun",
"orbits",
".",
"q",
"is",
"a",
"Tx6",
"array",
".",
"T",
"indexes",
"time",
"points",
".",
"6",
"columns",
"are",
"sun",
"(",
"x",
"y",
"z",
")",
"and",
"earth",
"(",
"x",
"y",
"z",
")"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L83-L127 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | accel_ES | def accel_ES(q: np.ndarray):
"""
Compute the gravitational accelerations in the earth-sun system.
q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)
"""
# Number of celestial bodies
num_bodies: int = 2
# Number of dimensions in arrays; 3 spatial dimensions times the number of bod... | python | def accel_ES(q: np.ndarray):
"""
Compute the gravitational accelerations in the earth-sun system.
q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)
"""
# Number of celestial bodies
num_bodies: int = 2
# Number of dimensions in arrays; 3 spatial dimensions times the number of bod... | [
"def",
"accel_ES",
"(",
"q",
":",
"np",
".",
"ndarray",
")",
":",
"# Number of celestial bodies",
"num_bodies",
":",
"int",
"=",
"2",
"# Number of dimensions in arrays; 3 spatial dimensions times the number of bodies",
"dims",
"=",
"3",
"*",
"num_bodies",
"# Body 0 is the... | Compute the gravitational accelerations in the earth-sun system.
q in row vector of 6 elements: sun (x, y, z), earth (x, y, z) | [
"Compute",
"the",
"gravitational",
"accelerations",
"in",
"the",
"earth",
"-",
"sun",
"system",
".",
"q",
"in",
"row",
"vector",
"of",
"6",
"elements",
":",
"sun",
"(",
"x",
"y",
"z",
")",
"earth",
"(",
"x",
"y",
"z",
")"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L131-L170 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | energy_ES | def energy_ES(q, v):
"""Compute the kinetic and potential energy of the earth sun system"""
# Body 0 is the sun, Body 1 is the earth
m0 = mass[0]
m1 = mass[1]
# Positions of sun and earth
q0: np.ndarray = q[:, slices[0]]
q1: np.ndarray = q[:, slices[1]]
# Velocities of sun and earth
... | python | def energy_ES(q, v):
"""Compute the kinetic and potential energy of the earth sun system"""
# Body 0 is the sun, Body 1 is the earth
m0 = mass[0]
m1 = mass[1]
# Positions of sun and earth
q0: np.ndarray = q[:, slices[0]]
q1: np.ndarray = q[:, slices[1]]
# Velocities of sun and earth
... | [
"def",
"energy_ES",
"(",
"q",
",",
"v",
")",
":",
"# Body 0 is the sun, Body 1 is the earth",
"m0",
"=",
"mass",
"[",
"0",
"]",
"m1",
"=",
"mass",
"[",
"1",
"]",
"# Positions of sun and earth",
"q0",
":",
"np",
".",
"ndarray",
"=",
"q",
"[",
":",
",",
... | Compute the kinetic and potential energy of the earth sun system | [
"Compute",
"the",
"kinetic",
"and",
"potential",
"energy",
"of",
"the",
"earth",
"sun",
"system"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L174-L202 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | make_force_ES | def make_force_ES(q_vars, mass):
"""Fluxion with the potential energy of the earth-sun sytem"""
# Build the potential energy fluxion; just one pair of bodies
U = U_ij(q_vars, mass, 0, 1)
# Varname arrays for both the coordinate system and U
vn_q = np.array([q.var_name for q in q_vars])
vn_fl = ... | python | def make_force_ES(q_vars, mass):
"""Fluxion with the potential energy of the earth-sun sytem"""
# Build the potential energy fluxion; just one pair of bodies
U = U_ij(q_vars, mass, 0, 1)
# Varname arrays for both the coordinate system and U
vn_q = np.array([q.var_name for q in q_vars])
vn_fl = ... | [
"def",
"make_force_ES",
"(",
"q_vars",
",",
"mass",
")",
":",
"# Build the potential energy fluxion; just one pair of bodies",
"U",
"=",
"U_ij",
"(",
"q_vars",
",",
"mass",
",",
"0",
",",
"1",
")",
"# Varname arrays for both the coordinate system and U",
"vn_q",
"=",
... | Fluxion with the potential energy of the earth-sun sytem | [
"Fluxion",
"with",
"the",
"potential",
"energy",
"of",
"the",
"earth",
"-",
"sun",
"sytem"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L215-L228 |
CS207-Final-Project-Group-10/cs207-FinalProject | solar_system/earth_sun.py | accel_ES_fl | def accel_ES_fl(q: np.ndarray):
"""Accelaration in the earth-sun system using Fluxion potential energy"""
# Number of celestial bodies
num_bodies: int = 2
# Number of dimensions in arrays; 3 spatial dimensions times the number of bodies
dims = 3 * num_bodies
# The force given the positions q of... | python | def accel_ES_fl(q: np.ndarray):
"""Accelaration in the earth-sun system using Fluxion potential energy"""
# Number of celestial bodies
num_bodies: int = 2
# Number of dimensions in arrays; 3 spatial dimensions times the number of bodies
dims = 3 * num_bodies
# The force given the positions q of... | [
"def",
"accel_ES_fl",
"(",
"q",
":",
"np",
".",
"ndarray",
")",
":",
"# Number of celestial bodies",
"num_bodies",
":",
"int",
"=",
"2",
"# Number of dimensions in arrays; 3 spatial dimensions times the number of bodies",
"dims",
"=",
"3",
"*",
"num_bodies",
"# The force ... | Accelaration in the earth-sun system using Fluxion potential energy | [
"Accelaration",
"in",
"the",
"earth",
"-",
"sun",
"system",
"using",
"Fluxion",
"potential",
"energy"
] | train | https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L231-L246 |
delfick/aws_syncr | aws_syncr/option_spec/aws_syncr_specs.py | valid_account_id.validate | def validate(self, meta, val):
"""Validate an account_id"""
val = string_or_int_as_string_spec().normalise(meta, val)
if not regexes['amazon_account_id'].match(val):
raise BadOption("Account id must match a particular regex", got=val, should_match=regexes['amazon_account_id'].pattern... | python | def validate(self, meta, val):
"""Validate an account_id"""
val = string_or_int_as_string_spec().normalise(meta, val)
if not regexes['amazon_account_id'].match(val):
raise BadOption("Account id must match a particular regex", got=val, should_match=regexes['amazon_account_id'].pattern... | [
"def",
"validate",
"(",
"self",
",",
"meta",
",",
"val",
")",
":",
"val",
"=",
"string_or_int_as_string_spec",
"(",
")",
".",
"normalise",
"(",
"meta",
",",
"val",
")",
"if",
"not",
"regexes",
"[",
"'amazon_account_id'",
"]",
".",
"match",
"(",
"val",
... | Validate an account_id | [
"Validate",
"an",
"account_id"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/aws_syncr_specs.py#L40-L45 |
delfick/aws_syncr | aws_syncr/option_spec/aws_syncr_specs.py | AwsSyncrSpec.aws_syncr_spec | def aws_syncr_spec(self):
"""Spec for aws_syncr options"""
formatted_string = formatted(string_spec(), MergedOptionStringFormatter, expected_type=string_types)
return create_spec(AwsSyncr
, extra = defaulted(formatted_string, "")
, stage = defaulted(formatted_string, "")
... | python | def aws_syncr_spec(self):
"""Spec for aws_syncr options"""
formatted_string = formatted(string_spec(), MergedOptionStringFormatter, expected_type=string_types)
return create_spec(AwsSyncr
, extra = defaulted(formatted_string, "")
, stage = defaulted(formatted_string, "")
... | [
"def",
"aws_syncr_spec",
"(",
"self",
")",
":",
"formatted_string",
"=",
"formatted",
"(",
"string_spec",
"(",
")",
",",
"MergedOptionStringFormatter",
",",
"expected_type",
"=",
"string_types",
")",
"return",
"create_spec",
"(",
"AwsSyncr",
",",
"extra",
"=",
"... | Spec for aws_syncr options | [
"Spec",
"for",
"aws_syncr",
"options"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/aws_syncr_specs.py#L51-L63 |
delfick/aws_syncr | aws_syncr/option_spec/aws_syncr_specs.py | AwsSyncrSpec.accounts_spec | def accounts_spec(self):
"""Spec for accounts options"""
formatted_account_id = formatted(valid_account_id(), MergedOptionStringFormatter, expected_type=string_types)
return dictof(string_spec(), formatted_account_id) | python | def accounts_spec(self):
"""Spec for accounts options"""
formatted_account_id = formatted(valid_account_id(), MergedOptionStringFormatter, expected_type=string_types)
return dictof(string_spec(), formatted_account_id) | [
"def",
"accounts_spec",
"(",
"self",
")",
":",
"formatted_account_id",
"=",
"formatted",
"(",
"valid_account_id",
"(",
")",
",",
"MergedOptionStringFormatter",
",",
"expected_type",
"=",
"string_types",
")",
"return",
"dictof",
"(",
"string_spec",
"(",
")",
",",
... | Spec for accounts options | [
"Spec",
"for",
"accounts",
"options"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/aws_syncr_specs.py#L66-L69 |
sassoo/goldman | goldman/resources/s3_model.py | Resource._gen_s3_path | def _gen_s3_path(self, model, props):
""" Return the part of the S3 path based on inputs
The path will be passed to the s3_upload method &
will ultimately be merged with the standard AWS S3
URL.
An example model type of 'users' with a resource ID
of 99 & an API endpoint... | python | def _gen_s3_path(self, model, props):
""" Return the part of the S3 path based on inputs
The path will be passed to the s3_upload method &
will ultimately be merged with the standard AWS S3
URL.
An example model type of 'users' with a resource ID
of 99 & an API endpoint... | [
"def",
"_gen_s3_path",
"(",
"self",
",",
"model",
",",
"props",
")",
":",
"now",
"=",
"'%.5f'",
"%",
"time",
".",
"time",
"(",
")",
"return",
"'%s/%s/%s/%s.%s'",
"%",
"(",
"model",
".",
"rtype",
",",
"model",
".",
"rid_value",
",",
"self",
".",
"_s3_... | Return the part of the S3 path based on inputs
The path will be passed to the s3_upload method &
will ultimately be merged with the standard AWS S3
URL.
An example model type of 'users' with a resource ID
of 99 & an API endpoint ending with 'photos' will have
a path gen... | [
"Return",
"the",
"part",
"of",
"the",
"S3",
"path",
"based",
"on",
"inputs"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/resources/s3_model.py#L61-L82 |
sassoo/goldman | goldman/resources/s3_model.py | Resource.on_post | def on_post(self, req, resp, rid):
""" Deserialize the file upload & save it to S3
File uploads are associated with a model of some
kind. Ensure the associating model exists first &
foremost.
"""
signals.pre_req.send(self.model)
signals.pre_req_upload.send(self.... | python | def on_post(self, req, resp, rid):
""" Deserialize the file upload & save it to S3
File uploads are associated with a model of some
kind. Ensure the associating model exists first &
foremost.
"""
signals.pre_req.send(self.model)
signals.pre_req_upload.send(self.... | [
"def",
"on_post",
"(",
"self",
",",
"req",
",",
"resp",
",",
"rid",
")",
":",
"signals",
".",
"pre_req",
".",
"send",
"(",
"self",
".",
"model",
")",
"signals",
".",
"pre_req_upload",
".",
"send",
"(",
"self",
".",
"model",
")",
"props",
"=",
"req"... | Deserialize the file upload & save it to S3
File uploads are associated with a model of some
kind. Ensure the associating model exists first &
foremost. | [
"Deserialize",
"the",
"file",
"upload",
"&",
"save",
"it",
"to",
"S3"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/resources/s3_model.py#L84-L118 |
astex/sequential | sequential/decorators.py | before | def before(f, chain=False):
"""Runs f before the decorated function."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
if chain:
return g(f(*args, **kargs))
else:
f(*args, **kargs)
return g(*args, **kargs)
return... | python | def before(f, chain=False):
"""Runs f before the decorated function."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
if chain:
return g(f(*args, **kargs))
else:
f(*args, **kargs)
return g(*args, **kargs)
return... | [
"def",
"before",
"(",
"f",
",",
"chain",
"=",
"False",
")",
":",
"def",
"decorator",
"(",
"g",
")",
":",
"@",
"wraps",
"(",
"g",
")",
"def",
"h",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"chain",
":",
"return",
"g",
"(",
"f... | Runs f before the decorated function. | [
"Runs",
"f",
"before",
"the",
"decorated",
"function",
"."
] | train | https://github.com/astex/sequential/blob/8812d487c33a8f0f1c96336cd27ad2fa942175f6/sequential/decorators.py#L5-L16 |
astex/sequential | sequential/decorators.py | after | def after(f, chain=False):
"""Runs f with the result of the decorated function."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
if chain:
return f(g(*args, **kargs))
else:
r = g(*args, **kargs)
f(*args, **kargs)
... | python | def after(f, chain=False):
"""Runs f with the result of the decorated function."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
if chain:
return f(g(*args, **kargs))
else:
r = g(*args, **kargs)
f(*args, **kargs)
... | [
"def",
"after",
"(",
"f",
",",
"chain",
"=",
"False",
")",
":",
"def",
"decorator",
"(",
"g",
")",
":",
"@",
"wraps",
"(",
"g",
")",
"def",
"h",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"chain",
":",
"return",
"f",
"(",
"g"... | Runs f with the result of the decorated function. | [
"Runs",
"f",
"with",
"the",
"result",
"of",
"the",
"decorated",
"function",
"."
] | train | https://github.com/astex/sequential/blob/8812d487c33a8f0f1c96336cd27ad2fa942175f6/sequential/decorators.py#L19-L31 |
astex/sequential | sequential/decorators.py | during | def during(f):
"""Runs f during the decorated function's execution in a separate thread."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
tf = Thread(target=f, args=args, kwargs=kargs)
tf.start()
r = g(*args, **kargs)
tf.join()
ret... | python | def during(f):
"""Runs f during the decorated function's execution in a separate thread."""
def decorator(g):
@wraps(g)
def h(*args, **kargs):
tf = Thread(target=f, args=args, kwargs=kargs)
tf.start()
r = g(*args, **kargs)
tf.join()
ret... | [
"def",
"during",
"(",
"f",
")",
":",
"def",
"decorator",
"(",
"g",
")",
":",
"@",
"wraps",
"(",
"g",
")",
"def",
"h",
"(",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"tf",
"=",
"Thread",
"(",
"target",
"=",
"f",
",",
"args",
"=",
"args"... | Runs f during the decorated function's execution in a separate thread. | [
"Runs",
"f",
"during",
"the",
"decorated",
"function",
"s",
"execution",
"in",
"a",
"separate",
"thread",
"."
] | train | https://github.com/astex/sequential/blob/8812d487c33a8f0f1c96336cd27ad2fa942175f6/sequential/decorators.py#L34-L45 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient._delete | def _delete(self, _file_path, _method_title, _record_key):
'''
a helper method for non-blocking deletion of files
:param _file_path: string with path to file to remove
:param _method_title: string with name of method calling _delete
:param _record_key: s... | python | def _delete(self, _file_path, _method_title, _record_key):
'''
a helper method for non-blocking deletion of files
:param _file_path: string with path to file to remove
:param _method_title: string with name of method calling _delete
:param _record_key: s... | [
"def",
"_delete",
"(",
"self",
",",
"_file_path",
",",
"_method_title",
",",
"_record_key",
")",
":",
"import",
"os",
"from",
"time",
"import",
"sleep",
"current_dir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"_file_path",
")",
"[",
"0",
"]",
"count",
... | a helper method for non-blocking deletion of files
:param _file_path: string with path to file to remove
:param _method_title: string with name of method calling _delete
:param _record_key: string with name of record key to delete
:return: None | [
"a",
"helper",
"method",
"for",
"non",
"-",
"blocking",
"deletion",
"of",
"files",
":",
"param",
"_file_path",
":",
"string",
"with",
"path",
"to",
"file",
"to",
"remove",
":",
"param",
"_method_title",
":",
"string",
"with",
"name",
"of",
"method",
"calli... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L131-L164 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient._import | def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs):
'''
a helper method for other storage clients to import into appdata
:param record_key: string with key for record
:param record_data: byte data for body of record
... | python | def _import(self, record_key, record_data, overwrite=True, last_modified=0.0, **kwargs):
'''
a helper method for other storage clients to import into appdata
:param record_key: string with key for record
:param record_data: byte data for body of record
... | [
"def",
"_import",
"(",
"self",
",",
"record_key",
",",
"record_data",
",",
"overwrite",
"=",
"True",
",",
"last_modified",
"=",
"0.0",
",",
"*",
"*",
"kwargs",
")",
":",
"# construct and validate file path\r",
"file_path",
"=",
"os",
".",
"path",
".",
"join"... | a helper method for other storage clients to import into appdata
:param record_key: string with key for record
:param record_data: byte data for body of record
:param overwrite: [optional] boolean to overwrite existing records
:param last_modified: [optional] float to r... | [
"a",
"helper",
"method",
"for",
"other",
"storage",
"clients",
"to",
"import",
"into",
"appdata",
":",
"param",
"record_key",
":",
"string",
"with",
"key",
"for",
"record",
":",
"param",
"record_data",
":",
"byte",
"data",
"for",
"body",
"of",
"record",
":... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L166-L209 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.exists | def exists(self, record_key):
'''
a method to determine if a record exists in collection
:param record_key: string with key of record
:return: boolean reporting status
'''
title = '%s.exists' % self.__class__.__name__
# validate... | python | def exists(self, record_key):
'''
a method to determine if a record exists in collection
:param record_key: string with key of record
:return: boolean reporting status
'''
title = '%s.exists' % self.__class__.__name__
# validate... | [
"def",
"exists",
"(",
"self",
",",
"record_key",
")",
":",
"title",
"=",
"'%s.exists'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'record_key'",
":",
"record_key",
"}",
"for",
"key",
",",
"value",
"in",... | a method to determine if a record exists in collection
:param record_key: string with key of record
:return: boolean reporting status | [
"a",
"method",
"to",
"determine",
"if",
"a",
"record",
"exists",
"in",
"collection",
":",
"param",
"record_key",
":",
"string",
"with",
"key",
"of",
"record",
":",
"return",
":",
"boolean",
"reporting",
"status"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L211-L237 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.save | def save(self, record_key, record_data, overwrite=True, secret_key=''):
'''
a method to create a record in the collection folder
:param record_key: string with name to assign to record (see NOTES below)
:param record_data: byte data for record body
:param overwrite:... | python | def save(self, record_key, record_data, overwrite=True, secret_key=''):
'''
a method to create a record in the collection folder
:param record_key: string with name to assign to record (see NOTES below)
:param record_data: byte data for record body
:param overwrite:... | [
"def",
"save",
"(",
"self",
",",
"record_key",
",",
"record_data",
",",
"overwrite",
"=",
"True",
",",
"secret_key",
"=",
"''",
")",
":",
"title",
"=",
"'%s.save'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
... | a method to create a record in the collection folder
:param record_key: string with name to assign to record (see NOTES below)
:param record_data: byte data for record body
:param overwrite: [optional] boolean to overwrite records with same name
:param secret_key: [optional] string... | [
"a",
"method",
"to",
"create",
"a",
"record",
"in",
"the",
"collection",
"folder",
":",
"param",
"record_key",
":",
"string",
"with",
"name",
"to",
"assign",
"to",
"record",
"(",
"see",
"NOTES",
"below",
")",
":",
"param",
"record_data",
":",
"byte",
"da... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L239-L316 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.load | def load(self, record_key, secret_key=''):
'''
a method to retrieve byte data of appdata record
:param record_key: string with name of record
:param secret_key: [optional] string used to decrypt data
:return: byte data for record body
'''
title =... | python | def load(self, record_key, secret_key=''):
'''
a method to retrieve byte data of appdata record
:param record_key: string with name of record
:param secret_key: [optional] string used to decrypt data
:return: byte data for record body
'''
title =... | [
"def",
"load",
"(",
"self",
",",
"record_key",
",",
"secret_key",
"=",
"''",
")",
":",
"title",
"=",
"'%s.load'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"input_fields",
"=",
"{",
"'record_key'",
":",
"record_key",
",",
"'secre... | a method to retrieve byte data of appdata record
:param record_key: string with name of record
:param secret_key: [optional] string used to decrypt data
:return: byte data for record body | [
"a",
"method",
"to",
"retrieve",
"byte",
"data",
"of",
"appdata",
"record",
":",
"param",
"record_key",
":",
"string",
"with",
"name",
"of",
"record",
":",
"param",
"secret_key",
":",
"[",
"optional",
"]",
"string",
"used",
"to",
"decrypt",
"data",
":",
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L318-L356 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.conditional_filter | def conditional_filter(self, path_filters):
''' a method to construct a conditional filter function for class list method
:param path_filters: dictionary or list of dictionaries with query criteria
:return: filter_function object
path_filters:
[ { 0: { conditional oper... | python | def conditional_filter(self, path_filters):
''' a method to construct a conditional filter function for class list method
:param path_filters: dictionary or list of dictionaries with query criteria
:return: filter_function object
path_filters:
[ { 0: { conditional oper... | [
"def",
"conditional_filter",
"(",
"self",
",",
"path_filters",
")",
":",
"title",
"=",
"'%s.conditional_filter'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"from",
"labpack",
".",
"compilers",
".",
"filters",
"import",
"positional_filter",
"filter_function",
... | a method to construct a conditional filter function for class list method
:param path_filters: dictionary or list of dictionaries with query criteria
:return: filter_function object
path_filters:
[ { 0: { conditional operators }, 1: { conditional_operators }, ... } ]
c... | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"for",
"class",
"list",
"method",
":",
"param",
"path_filters",
":",
"dictionary",
"or",
"list",
"of",
"dictionaries",
"with",
"query",
"criteria",
":",
"return",
":",
"filter_function",... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L358-L389 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.list | def list(self, prefix='', delimiter='', filter_function=None, max_results=1, reverse_search=True, previous_key=''):
'''
a method to list keys in the collection
:param prefix: string with prefix value to filter results
:param delimiter: string with value which results must no... | python | def list(self, prefix='', delimiter='', filter_function=None, max_results=1, reverse_search=True, previous_key=''):
'''
a method to list keys in the collection
:param prefix: string with prefix value to filter results
:param delimiter: string with value which results must no... | [
"def",
"list",
"(",
"self",
",",
"prefix",
"=",
"''",
",",
"delimiter",
"=",
"''",
",",
"filter_function",
"=",
"None",
",",
"max_results",
"=",
"1",
",",
"reverse_search",
"=",
"True",
",",
"previous_key",
"=",
"''",
")",
":",
"title",
"=",
"'%s.list'... | a method to list keys in the collection
:param prefix: string with prefix value to filter results
:param delimiter: string with value which results must not contain (after prefix)
:param filter_function: (positional arguments) function used to filter results
:param max_results: int... | [
"a",
"method",
"to",
"list",
"keys",
"in",
"the",
"collection",
":",
"param",
"prefix",
":",
"string",
"with",
"prefix",
"value",
"to",
"filter",
"results",
":",
"param",
"delimiter",
":",
"string",
"with",
"value",
"which",
"results",
"must",
"not",
"cont... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L391-L494 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.delete | def delete(self, record_key):
''' a method to delete a file
:param record_key: string with name of file
:return: string reporting outcome
'''
title = '%s.delete' % self.__class__.__name__
key_arg = '%s(record_key="%s")' % (title, record_key)
# validate ... | python | def delete(self, record_key):
''' a method to delete a file
:param record_key: string with name of file
:return: string reporting outcome
'''
title = '%s.delete' % self.__class__.__name__
key_arg = '%s(record_key="%s")' % (title, record_key)
# validate ... | [
"def",
"delete",
"(",
"self",
",",
"record_key",
")",
":",
"title",
"=",
"'%s.delete'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"key_arg",
"=",
"'%s(record_key=\"%s\")'",
"%",
"(",
"title",
",",
"record_key",
")",
"# validate inputs\r",
"record_key",
"... | a method to delete a file
:param record_key: string with name of file
:return: string reporting outcome | [
"a",
"method",
"to",
"delete",
"a",
"file",
":",
"param",
"record_key",
":",
"string",
"with",
"name",
"of",
"file",
":",
"return",
":",
"string",
"reporting",
"outcome"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L496-L544 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.remove | def remove(self):
'''
a method to remove collection and all records in the collection
:return: string with confirmation of deletion
'''
_title = '%s.remove' % self.__class__.__name__
# TODO error handling is turned off to avoid system blocking
# ... | python | def remove(self):
'''
a method to remove collection and all records in the collection
:return: string with confirmation of deletion
'''
_title = '%s.remove' % self.__class__.__name__
# TODO error handling is turned off to avoid system blocking
# ... | [
"def",
"remove",
"(",
"self",
")",
":",
"_title",
"=",
"'%s.remove'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# TODO error handling is turned off to avoid system blocking\r",
"# fix potential to create artifacts in the system\r",
"# remove collection tree\r",
"try... | a method to remove collection and all records in the collection
:return: string with confirmation of deletion | [
"a",
"method",
"to",
"remove",
"collection",
"and",
"all",
"records",
"in",
"the",
"collection",
":",
"return",
":",
"string",
"with",
"confirmation",
"of",
"deletion"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L546-L567 |
collectiveacuity/labPack | labpack/storage/appdata.py | appdataClient.export | def export(self, storage_client, overwrite=True):
'''
a method to export all the records in collection to another platform
:param storage_client: class object with storage client methods
:return: string with exit message
'''
tit... | python | def export(self, storage_client, overwrite=True):
'''
a method to export all the records in collection to another platform
:param storage_client: class object with storage client methods
:return: string with exit message
'''
tit... | [
"def",
"export",
"(",
"self",
",",
"storage_client",
",",
"overwrite",
"=",
"True",
")",
":",
"title",
"=",
"'%s.export'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate storage client\r",
"method_list",
"=",
"[",
"'save'",
",",
"'load'",
",",
"... | a method to export all the records in collection to another platform
:param storage_client: class object with storage client methods
:return: string with exit message | [
"a",
"method",
"to",
"export",
"all",
"the",
"records",
"in",
"collection",
"to",
"another",
"platform",
":",
"param",
"storage_client",
":",
"class",
"object",
"with",
"storage",
"client",
"methods",
":",
"return",
":",
"string",
"with",
"exit",
"message"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/appdata.py#L569-L620 |
gsamokovarov/frames.py | frames/__init__.py | Frame.current_frame | def current_frame(raw=False):
'''
Gives the current execution frame.
:returns:
The current execution frame that is actually executing this.
'''
# `import sys` is important here, because the `sys` module is special
# and we will end up with the class frame in... | python | def current_frame(raw=False):
'''
Gives the current execution frame.
:returns:
The current execution frame that is actually executing this.
'''
# `import sys` is important here, because the `sys` module is special
# and we will end up with the class frame in... | [
"def",
"current_frame",
"(",
"raw",
"=",
"False",
")",
":",
"# `import sys` is important here, because the `sys` module is special",
"# and we will end up with the class frame instead of the `current` one.",
"if",
"NATIVE",
":",
"import",
"sys",
"frame",
"=",
"sys",
".",
"_getf... | Gives the current execution frame.
:returns:
The current execution frame that is actually executing this. | [
"Gives",
"the",
"current",
"execution",
"frame",
"."
] | train | https://github.com/gsamokovarov/frames.py/blob/ba43782d043691fb5a388a1e749e0f0edb68a3d7/frames/__init__.py#L47-L70 |
gsamokovarov/frames.py | frames/__init__.py | Frame.locate | def locate(callback, root_frame=None, include_root=False, raw=False):
'''
Locates a frame by criteria.
:param callback:
One argument function to check the frame against. The frame we are
curretly on, is given as that argument.
:param root_frame:
The r... | python | def locate(callback, root_frame=None, include_root=False, raw=False):
'''
Locates a frame by criteria.
:param callback:
One argument function to check the frame against. The frame we are
curretly on, is given as that argument.
:param root_frame:
The r... | [
"def",
"locate",
"(",
"callback",
",",
"root_frame",
"=",
"None",
",",
"include_root",
"=",
"False",
",",
"raw",
"=",
"False",
")",
":",
"def",
"get_from",
"(",
"maybe_callable",
")",
":",
"if",
"callable",
"(",
"maybe_callable",
")",
":",
"return",
"may... | Locates a frame by criteria.
:param callback:
One argument function to check the frame against. The frame we are
curretly on, is given as that argument.
:param root_frame:
The root frame to start the search from. Can be a callback taking
no arguments.
... | [
"Locates",
"a",
"frame",
"by",
"criteria",
"."
] | train | https://github.com/gsamokovarov/frames.py/blob/ba43782d043691fb5a388a1e749e0f0edb68a3d7/frames/__init__.py#L73-L119 |
toastdriven/alligator | alligator/tasks.py | Task.to_call | def to_call(self, func, *args, **kwargs):
"""
Sets the function & its arguments to be called when the task is
processed.
Ex::
task.to_call(my_function, 1, 'c', another=True)
:param func: The callable with business logic to execute
:type func: callable
... | python | def to_call(self, func, *args, **kwargs):
"""
Sets the function & its arguments to be called when the task is
processed.
Ex::
task.to_call(my_function, 1, 'c', another=True)
:param func: The callable with business logic to execute
:type func: callable
... | [
"def",
"to_call",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"func",
"=",
"func",
"self",
".",
"func_args",
"=",
"args",
"self",
".",
"func_kwargs",
"=",
"kwargs"
] | Sets the function & its arguments to be called when the task is
processed.
Ex::
task.to_call(my_function, 1, 'c', another=True)
:param func: The callable with business logic to execute
:type func: callable
:param args: Positional arguments to pass to the callable ... | [
"Sets",
"the",
"function",
"&",
"its",
"arguments",
"to",
"be",
"called",
"when",
"the",
"task",
"is",
"processed",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/tasks.py#L73-L93 |
toastdriven/alligator | alligator/tasks.py | Task.serialize | def serialize(self):
"""
Serializes the ``Task`` data for storing in the queue.
All data must be JSON-serializable in order to be stored properly.
:returns: A JSON strong of the task data.
"""
data = {
'task_id': self.task_id,
'retries': self.ret... | python | def serialize(self):
"""
Serializes the ``Task`` data for storing in the queue.
All data must be JSON-serializable in order to be stored properly.
:returns: A JSON strong of the task data.
"""
data = {
'task_id': self.task_id,
'retries': self.ret... | [
"def",
"serialize",
"(",
"self",
")",
":",
"data",
"=",
"{",
"'task_id'",
":",
"self",
".",
"task_id",
",",
"'retries'",
":",
"self",
".",
"retries",
",",
"'async'",
":",
"self",
".",
"async",
",",
"'module'",
":",
"determine_module",
"(",
"self",
".",... | Serializes the ``Task`` data for storing in the queue.
All data must be JSON-serializable in order to be stored properly.
:returns: A JSON strong of the task data. | [
"Serializes",
"the",
"Task",
"data",
"for",
"storing",
"in",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/tasks.py#L140-L177 |
toastdriven/alligator | alligator/tasks.py | Task.deserialize | def deserialize(cls, data):
"""
Given some data from the queue, deserializes it into a ``Task``
instance.
The data must be similar in format to what comes from
``Task.serialize`` (a JSON-serialized dictionary). Required keys are
``task_id``, ``retries`` & ``async``.
... | python | def deserialize(cls, data):
"""
Given some data from the queue, deserializes it into a ``Task``
instance.
The data must be similar in format to what comes from
``Task.serialize`` (a JSON-serialized dictionary). Required keys are
``task_id``, ``retries`` & ``async``.
... | [
"def",
"deserialize",
"(",
"cls",
",",
"data",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"options",
"=",
"data",
".",
"get",
"(",
"'options'",
",",
"{",
"}",
")",
"task",
"=",
"cls",
"(",
"task_id",
"=",
"data",
"[",
"'task_i... | Given some data from the queue, deserializes it into a ``Task``
instance.
The data must be similar in format to what comes from
``Task.serialize`` (a JSON-serialized dictionary). Required keys are
``task_id``, ``retries`` & ``async``.
:param data: A JSON-serialized string of th... | [
"Given",
"some",
"data",
"from",
"the",
"queue",
"deserializes",
"it",
"into",
"a",
"Task",
"instance",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/tasks.py#L180-L225 |
toastdriven/alligator | alligator/tasks.py | Task.run | def run(self):
"""
Runs the task.
This fires the ``on_start`` hook function first (if present), passing
the task itself.
Then it runs the target function supplied via ``Task.to_call`` with
its arguments & stores the result.
If the target function succeeded, the... | python | def run(self):
"""
Runs the task.
This fires the ``on_start`` hook function first (if present), passing
the task itself.
Then it runs the target function supplied via ``Task.to_call`` with
its arguments & stores the result.
If the target function succeeded, the... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"on_start",
":",
"self",
".",
"on_start",
"(",
"self",
")",
"try",
":",
"result",
"=",
"self",
".",
"func",
"(",
"*",
"self",
".",
"func_args",
",",
"*",
"*",
"self",
".",
"func_kwargs",
")"... | Runs the task.
This fires the ``on_start`` hook function first (if present), passing
the task itself.
Then it runs the target function supplied via ``Task.to_call`` with
its arguments & stores the result.
If the target function succeeded, the ``on_success`` hook function is
... | [
"Runs",
"the",
"task",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/tasks.py#L227-L264 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCcompound.py | _check_typecode_list | def _check_typecode_list(ofwhat, tcname):
'''Check a list of typecodes for compliance with Struct
requirements.'''
for o in ofwhat:
if callable(o): #skip if _Mirage
continue
if not isinstance(o, TypeCode):
raise TypeError(
tcname + ' ofwhat outside the... | python | def _check_typecode_list(ofwhat, tcname):
'''Check a list of typecodes for compliance with Struct
requirements.'''
for o in ofwhat:
if callable(o): #skip if _Mirage
continue
if not isinstance(o, TypeCode):
raise TypeError(
tcname + ' ofwhat outside the... | [
"def",
"_check_typecode_list",
"(",
"ofwhat",
",",
"tcname",
")",
":",
"for",
"o",
"in",
"ofwhat",
":",
"if",
"callable",
"(",
"o",
")",
":",
"#skip if _Mirage",
"continue",
"if",
"not",
"isinstance",
"(",
"o",
",",
"TypeCode",
")",
":",
"raise",
"TypeEr... | Check a list of typecodes for compliance with Struct
requirements. | [
"Check",
"a",
"list",
"of",
"typecodes",
"for",
"compliance",
"with",
"Struct",
"requirements",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCcompound.py#L30-L41 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCcompound.py | _get_type_or_substitute | def _get_type_or_substitute(typecode, pyobj, sw, elt):
'''return typecode or substitute type for wildcard or
derived type. For serialization only.
'''
sub = getattr(pyobj, 'typecode', typecode)
if sub is typecode or sub is None:
return typecode
# Element WildCard
if isinstance(type... | python | def _get_type_or_substitute(typecode, pyobj, sw, elt):
'''return typecode or substitute type for wildcard or
derived type. For serialization only.
'''
sub = getattr(pyobj, 'typecode', typecode)
if sub is typecode or sub is None:
return typecode
# Element WildCard
if isinstance(type... | [
"def",
"_get_type_or_substitute",
"(",
"typecode",
",",
"pyobj",
",",
"sw",
",",
"elt",
")",
":",
"sub",
"=",
"getattr",
"(",
"pyobj",
",",
"'typecode'",
",",
"typecode",
")",
"if",
"sub",
"is",
"typecode",
"or",
"sub",
"is",
"None",
":",
"return",
"ty... | return typecode or substitute type for wildcard or
derived type. For serialization only. | [
"return",
"typecode",
"or",
"substitute",
"type",
"for",
"wildcard",
"or",
"derived",
"type",
".",
"For",
"serialization",
"only",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCcompound.py#L44-L86 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCcompound.py | ComplexType.setDerivedTypeContents | def setDerivedTypeContents(self, extensions=None, restrictions=None):
"""For derived types set appropriate parameter and
"""
if extensions:
ofwhat = list(self.ofwhat)
if type(extensions) in _seqtypes:
ofwhat += list(extensions)
else:
... | python | def setDerivedTypeContents(self, extensions=None, restrictions=None):
"""For derived types set appropriate parameter and
"""
if extensions:
ofwhat = list(self.ofwhat)
if type(extensions) in _seqtypes:
ofwhat += list(extensions)
else:
... | [
"def",
"setDerivedTypeContents",
"(",
"self",
",",
"extensions",
"=",
"None",
",",
"restrictions",
"=",
"None",
")",
":",
"if",
"extensions",
":",
"ofwhat",
"=",
"list",
"(",
"self",
".",
"ofwhat",
")",
"if",
"type",
"(",
"extensions",
")",
"in",
"_seqty... | For derived types set appropriate parameter and | [
"For",
"derived",
"types",
"set",
"appropriate",
"parameter",
"and"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCcompound.py#L440-L457 |
toastdriven/alligator | alligator/backends/redis_backend.py | Client.get_connection | def get_connection(self, host, port, db):
"""
Returns a ``StrictRedis`` connection instance.
"""
return redis.StrictRedis(
host=host,
port=port,
db=db,
decode_responses=True
) | python | def get_connection(self, host, port, db):
"""
Returns a ``StrictRedis`` connection instance.
"""
return redis.StrictRedis(
host=host,
port=port,
db=db,
decode_responses=True
) | [
"def",
"get_connection",
"(",
"self",
",",
"host",
",",
"port",
",",
"db",
")",
":",
"return",
"redis",
".",
"StrictRedis",
"(",
"host",
"=",
"host",
",",
"port",
"=",
"port",
",",
"db",
"=",
"db",
",",
"decode_responses",
"=",
"True",
")"
] | Returns a ``StrictRedis`` connection instance. | [
"Returns",
"a",
"StrictRedis",
"connection",
"instance",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/redis_backend.py#L26-L35 |
toastdriven/alligator | alligator/backends/redis_backend.py | Client.drop_all | def drop_all(self, queue_name):
"""
Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
"""
task_ids = self.conn.lrange(queue_name, 0, -1)
for task_id in task_... | python | def drop_all(self, queue_name):
"""
Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
"""
task_ids = self.conn.lrange(queue_name, 0, -1)
for task_id in task_... | [
"def",
"drop_all",
"(",
"self",
",",
"queue_name",
")",
":",
"task_ids",
"=",
"self",
".",
"conn",
".",
"lrange",
"(",
"queue_name",
",",
"0",
",",
"-",
"1",
")",
"for",
"task_id",
"in",
"task_ids",
":",
"self",
".",
"conn",
".",
"delete",
"(",
"ta... | Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string | [
"Drops",
"all",
"the",
"task",
"in",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/redis_backend.py#L50-L63 |
toastdriven/alligator | alligator/backends/redis_backend.py | Client.push | def push(self, queue_name, task_id, data):
"""
Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
... | python | def push(self, queue_name, task_id, data):
"""
Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
... | [
"def",
"push",
"(",
"self",
",",
"queue_name",
",",
"task_id",
",",
"data",
")",
":",
"self",
".",
"conn",
".",
"lpush",
"(",
"queue_name",
",",
"task_id",
")",
"self",
".",
"conn",
".",
"set",
"(",
"task_id",
",",
"data",
")",
"return",
"task_id"
] | Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
:param data: The relevant data for the task.
:type ... | [
"Pushes",
"a",
"task",
"onto",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/redis_backend.py#L65-L81 |
toastdriven/alligator | alligator/backends/redis_backend.py | Client.pop | def pop(self, queue_name):
"""
Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string
"""
task_id = self.conn.lp... | python | def pop(self, queue_name):
"""
Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string
"""
task_id = self.conn.lp... | [
"def",
"pop",
"(",
"self",
",",
"queue_name",
")",
":",
"task_id",
"=",
"self",
".",
"conn",
".",
"lpop",
"(",
"queue_name",
")",
"data",
"=",
"self",
".",
"conn",
".",
"get",
"(",
"task_id",
")",
"self",
".",
"conn",
".",
"delete",
"(",
"task_id",... | Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string | [
"Pops",
"a",
"task",
"off",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/redis_backend.py#L83-L97 |
toastdriven/alligator | alligator/backends/redis_backend.py | Client.get | def get(self, queue_name, task_id):
"""
Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id:... | python | def get(self, queue_name, task_id):
"""
Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id:... | [
"def",
"get",
"(",
"self",
",",
"queue_name",
",",
"task_id",
")",
":",
"self",
".",
"conn",
".",
"lrem",
"(",
"queue_name",
",",
"1",
",",
"task_id",
")",
"data",
"=",
"self",
".",
"conn",
".",
"get",
"(",
"task_id",
")",
"if",
"data",
":",
"sel... | Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
:returns: The data for the task.
... | [
"Pops",
"a",
"specific",
"task",
"off",
"the",
"queue",
"by",
"identifier",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/redis_backend.py#L99-L118 |
evfredericksen/pynacea | pynhost/pynhost/commands.py | ActionList.contains_non_repeat_actions | def contains_non_repeat_actions(self):
'''
Because repeating repeat actions can get ugly real fast
'''
for action in self.actions:
if not isinstance(action, (int, dynamic.RepeatCommand)):
return True
return False | python | def contains_non_repeat_actions(self):
'''
Because repeating repeat actions can get ugly real fast
'''
for action in self.actions:
if not isinstance(action, (int, dynamic.RepeatCommand)):
return True
return False | [
"def",
"contains_non_repeat_actions",
"(",
"self",
")",
":",
"for",
"action",
"in",
"self",
".",
"actions",
":",
"if",
"not",
"isinstance",
"(",
"action",
",",
"(",
"int",
",",
"dynamic",
".",
"RepeatCommand",
")",
")",
":",
"return",
"True",
"return",
"... | Because repeating repeat actions can get ugly real fast | [
"Because",
"repeating",
"repeat",
"actions",
"can",
"get",
"ugly",
"real",
"fast"
] | train | https://github.com/evfredericksen/pynacea/blob/63ee0e6695209048bf2571aa2c3770f502e29b0a/pynhost/pynhost/commands.py#L67-L74 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | _all_correct_list | def _all_correct_list(array):
"""
Make sure, that all items in `array` has good type and size.
Args:
array (list): Array of python types.
Returns:
True/False
"""
if type(array) not in _ITERABLE_TYPES:
return False
for item in array:
if not type(item) in _IT... | python | def _all_correct_list(array):
"""
Make sure, that all items in `array` has good type and size.
Args:
array (list): Array of python types.
Returns:
True/False
"""
if type(array) not in _ITERABLE_TYPES:
return False
for item in array:
if not type(item) in _IT... | [
"def",
"_all_correct_list",
"(",
"array",
")",
":",
"if",
"type",
"(",
"array",
")",
"not",
"in",
"_ITERABLE_TYPES",
":",
"return",
"False",
"for",
"item",
"in",
"array",
":",
"if",
"not",
"type",
"(",
"item",
")",
"in",
"_ITERABLE_TYPES",
":",
"return",... | Make sure, that all items in `array` has good type and size.
Args:
array (list): Array of python types.
Returns:
True/False | [
"Make",
"sure",
"that",
"all",
"items",
"in",
"array",
"has",
"good",
"type",
"and",
"size",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L220-L240 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | _convert_to_dict | def _convert_to_dict(data):
"""
Convert `data` to dictionary.
Tries to get sense in multidimensional arrays.
Args:
data: List/dict/tuple of variable dimension.
Returns:
dict: If the data can be converted to dictionary.
Raises:
MetaParsingException: When the data are u... | python | def _convert_to_dict(data):
"""
Convert `data` to dictionary.
Tries to get sense in multidimensional arrays.
Args:
data: List/dict/tuple of variable dimension.
Returns:
dict: If the data can be converted to dictionary.
Raises:
MetaParsingException: When the data are u... | [
"def",
"_convert_to_dict",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"return",
"data",
"if",
"isinstance",
"(",
"data",
",",
"list",
")",
"or",
"isinstance",
"(",
"data",
",",
"tuple",
")",
":",
"if",
"_all_correct_... | Convert `data` to dictionary.
Tries to get sense in multidimensional arrays.
Args:
data: List/dict/tuple of variable dimension.
Returns:
dict: If the data can be converted to dictionary.
Raises:
MetaParsingException: When the data are unconvertible to dict. | [
"Convert",
"data",
"to",
"dictionary",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L243-L270 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | check_structure | def check_structure(data):
"""
Check whether the structure is flat dictionary. If not, try to convert it
to dictionary.
Args:
data: Whatever data you have (dict/tuple/list).
Returns:
dict: When the conversion was successful or `data` was already `good`.
Raises:
MetaPar... | python | def check_structure(data):
"""
Check whether the structure is flat dictionary. If not, try to convert it
to dictionary.
Args:
data: Whatever data you have (dict/tuple/list).
Returns:
dict: When the conversion was successful or `data` was already `good`.
Raises:
MetaPar... | [
"def",
"check_structure",
"(",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"try",
":",
"data",
"=",
"_convert_to_dict",
"(",
"data",
")",
"except",
"MetaParsingException",
":",
"raise",
"except",
":",
"raise",
"MetaPars... | Check whether the structure is flat dictionary. If not, try to convert it
to dictionary.
Args:
data: Whatever data you have (dict/tuple/list).
Returns:
dict: When the conversion was successful or `data` was already `good`.
Raises:
MetaParsingException: When the data couldn't b... | [
"Check",
"whether",
"the",
"structure",
"is",
"flat",
"dictionary",
".",
"If",
"not",
"try",
"to",
"convert",
"it",
"to",
"dictionary",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L273-L312 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | Field.check | def check(self, key, value):
"""
Check whether `key` matchs the :attr:`keyword`. If so, set the
:attr:`value` to `value`.
Args:
key (str): Key which will be matched with :attr:`keyword`.
value (str): Value which will be assigned to :attr:`value` if keys
... | python | def check(self, key, value):
"""
Check whether `key` matchs the :attr:`keyword`. If so, set the
:attr:`value` to `value`.
Args:
key (str): Key which will be matched with :attr:`keyword`.
value (str): Value which will be assigned to :attr:`value` if keys
... | [
"def",
"check",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"# try unicode conversion",
"try",
":",
"key",
"=",
"key",
".",
"decode",
"(",
"\"utf-8\"",
")",
"except",
"UnicodeEnc... | Check whether `key` matchs the :attr:`keyword`. If so, set the
:attr:`value` to `value`.
Args:
key (str): Key which will be matched with :attr:`keyword`.
value (str): Value which will be assigned to :attr:`value` if keys
matches.
Returns:
... | [
"Check",
"whether",
"key",
"matchs",
"the",
":",
"attr",
":",
"keyword",
".",
"If",
"so",
"set",
"the",
":",
"attr",
":",
"value",
"to",
"value",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L73-L100 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | Field._remove_accents | def _remove_accents(self, input_str):
"""
Convert unicode string to ASCII.
Credit: http://stackoverflow.com/a/517974
"""
nkfd_form = unicodedata.normalize('NFKD', input_str)
return u"".join([c for c in nkfd_form if not unicodedata.combining(c)]) | python | def _remove_accents(self, input_str):
"""
Convert unicode string to ASCII.
Credit: http://stackoverflow.com/a/517974
"""
nkfd_form = unicodedata.normalize('NFKD', input_str)
return u"".join([c for c in nkfd_form if not unicodedata.combining(c)]) | [
"def",
"_remove_accents",
"(",
"self",
",",
"input_str",
")",
":",
"nkfd_form",
"=",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"input_str",
")",
"return",
"u\"\"",
".",
"join",
"(",
"[",
"c",
"for",
"c",
"in",
"nkfd_form",
"if",
"not",
"unicod... | Convert unicode string to ASCII.
Credit: http://stackoverflow.com/a/517974 | [
"Convert",
"unicode",
"string",
"to",
"ASCII",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L111-L118 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | FieldParser.process | def process(self, key, val):
"""
Try to look for `key` in all required and optional fields. If found,
set the `val`.
"""
for field in self.fields:
if field.check(key, val):
return
for field in self.optional:
if field.check(key, val... | python | def process(self, key, val):
"""
Try to look for `key` in all required and optional fields. If found,
set the `val`.
"""
for field in self.fields:
if field.check(key, val):
return
for field in self.optional:
if field.check(key, val... | [
"def",
"process",
"(",
"self",
",",
"key",
",",
"val",
")",
":",
"for",
"field",
"in",
"self",
".",
"fields",
":",
"if",
"field",
".",
"check",
"(",
"key",
",",
"val",
")",
":",
"return",
"for",
"field",
"in",
"self",
".",
"optional",
":",
"if",
... | Try to look for `key` in all required and optional fields. If found,
set the `val`. | [
"Try",
"to",
"look",
"for",
"key",
"in",
"all",
"required",
"and",
"optional",
"fields",
".",
"If",
"found",
"set",
"the",
"val",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L158-L169 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/decoders/validator.py | FieldParser.get_epublication | def get_epublication(self):
"""
Returns:
EPublication: Structure when the object :meth:`is_valid`.
Raises:
MetaParsingException: When the object is not valid.
"""
if not self.is_valid():
bad_fields = filter(lambda x: not x.is_valid(), self.fie... | python | def get_epublication(self):
"""
Returns:
EPublication: Structure when the object :meth:`is_valid`.
Raises:
MetaParsingException: When the object is not valid.
"""
if not self.is_valid():
bad_fields = filter(lambda x: not x.is_valid(), self.fie... | [
"def",
"get_epublication",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_valid",
"(",
")",
":",
"bad_fields",
"=",
"filter",
"(",
"lambda",
"x",
":",
"not",
"x",
".",
"is_valid",
"(",
")",
",",
"self",
".",
"fields",
")",
"bad_fields",
"=",
... | Returns:
EPublication: Structure when the object :meth:`is_valid`.
Raises:
MetaParsingException: When the object is not valid. | [
"Returns",
":",
"EPublication",
":",
"Structure",
"when",
"the",
"object",
":",
"meth",
":",
"is_valid",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/decoders/validator.py#L182-L217 |
riccardocagnasso/useless | src/useless/common/structures.py | Structure.get_size | def get_size(cls):
"""
Total byte size of fields in this structure => total byte size of
the structure on the file
"""
return sum([getattr(cls, name).length
for name in cls.get_fields_names()]) | python | def get_size(cls):
"""
Total byte size of fields in this structure => total byte size of
the structure on the file
"""
return sum([getattr(cls, name).length
for name in cls.get_fields_names()]) | [
"def",
"get_size",
"(",
"cls",
")",
":",
"return",
"sum",
"(",
"[",
"getattr",
"(",
"cls",
",",
"name",
")",
".",
"length",
"for",
"name",
"in",
"cls",
".",
"get_fields_names",
"(",
")",
"]",
")"
] | Total byte size of fields in this structure => total byte size of
the structure on the file | [
"Total",
"byte",
"size",
"of",
"fields",
"in",
"this",
"structure",
"=",
">",
"total",
"byte",
"size",
"of",
"the",
"structure",
"on",
"the",
"file"
] | train | https://github.com/riccardocagnasso/useless/blob/5167aab82958f653148e3689c9a7e548d4fa2cba/src/useless/common/structures.py#L79-L85 |
ronaldguillen/wave | wave/compat.py | template_render | def template_render(template, context=None, request=None):
"""
Passing Context or RequestContext to Template.render is deprecated in 1.9+,
see https://github.com/django/django/pull/3883 and
https://github.com/django/django/blob/1.9rc1/django/template/backends/django.py#L82-L84
:param template: Temp... | python | def template_render(template, context=None, request=None):
"""
Passing Context or RequestContext to Template.render is deprecated in 1.9+,
see https://github.com/django/django/pull/3883 and
https://github.com/django/django/blob/1.9rc1/django/template/backends/django.py#L82-L84
:param template: Temp... | [
"def",
"template_render",
"(",
"template",
",",
"context",
"=",
"None",
",",
"request",
"=",
"None",
")",
":",
"if",
"django",
".",
"VERSION",
"<",
"(",
"1",
",",
"8",
")",
"or",
"isinstance",
"(",
"template",
",",
"Template",
")",
":",
"if",
"reques... | Passing Context or RequestContext to Template.render is deprecated in 1.9+,
see https://github.com/django/django/pull/3883 and
https://github.com/django/django/blob/1.9rc1/django/template/backends/django.py#L82-L84
:param template: Template instance
:param context: dict
:param request: Request inst... | [
"Passing",
"Context",
"or",
"RequestContext",
"to",
"Template",
".",
"render",
"is",
"deprecated",
"in",
"1",
".",
"9",
"+",
"see",
"https",
":",
"//",
"github",
".",
"com",
"/",
"django",
"/",
"django",
"/",
"pull",
"/",
"3883",
"and",
"https",
":",
... | train | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/compat.py#L213-L232 |
ronaldguillen/wave | wave/compat.py | get_all_related_many_to_many_objects | def get_all_related_many_to_many_objects(opts):
"""
Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()
:param opts: Options instance
:return: list of many-to-many relations
"""
if django.VERSION < (1, 9):
return opts.get_all_related_many_to_many_objects()
el... | python | def get_all_related_many_to_many_objects(opts):
"""
Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()
:param opts: Options instance
:return: list of many-to-many relations
"""
if django.VERSION < (1, 9):
return opts.get_all_related_many_to_many_objects()
el... | [
"def",
"get_all_related_many_to_many_objects",
"(",
"opts",
")",
":",
"if",
"django",
".",
"VERSION",
"<",
"(",
"1",
",",
"9",
")",
":",
"return",
"opts",
".",
"get_all_related_many_to_many_objects",
"(",
")",
"else",
":",
"return",
"[",
"r",
"for",
"r",
"... | Django 1.8 changed meta api, see docstr in compat.get_all_related_objects()
:param opts: Options instance
:return: list of many-to-many relations | [
"Django",
"1",
".",
"8",
"changed",
"meta",
"api",
"see",
"docstr",
"in",
"compat",
".",
"get_all_related_objects",
"()"
] | train | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/compat.py#L251-L261 |
Aperture-py/aperture-lib | aperturelib/__init__.py | format_image | def format_image(path, options):
'''Formats an image.
Args:
path (str): Path to the image file.
options (dict): Options to apply to the image.
Returns:
(list) A list of PIL images. The list will always be of length
1 unless resolutions for resizing are provided in the optio... | python | def format_image(path, options):
'''Formats an image.
Args:
path (str): Path to the image file.
options (dict): Options to apply to the image.
Returns:
(list) A list of PIL images. The list will always be of length
1 unless resolutions for resizing are provided in the optio... | [
"def",
"format_image",
"(",
"path",
",",
"options",
")",
":",
"image",
"=",
"Image",
".",
"open",
"(",
"path",
")",
"image_pipeline_results",
"=",
"__pipeline_image",
"(",
"image",
",",
"options",
")",
"return",
"image_pipeline_results"
] | Formats an image.
Args:
path (str): Path to the image file.
options (dict): Options to apply to the image.
Returns:
(list) A list of PIL images. The list will always be of length
1 unless resolutions for resizing are provided in the options. | [
"Formats",
"an",
"image",
"."
] | train | https://github.com/Aperture-py/aperture-lib/blob/5c54af216319f297ddf96181a16f088cf1ba23f3/aperturelib/__init__.py#L26-L39 |
Aperture-py/aperture-lib | aperturelib/__init__.py | __pipeline_image | def __pipeline_image(image, options):
'''Sends an image through a processing pipeline.
Applies all (relevant) provided options to a given image.
Args:
image: An instance of a PIL Image.
options: Options to apply to the image (i.e. resolutions).
Returns:
A list containing instance... | python | def __pipeline_image(image, options):
'''Sends an image through a processing pipeline.
Applies all (relevant) provided options to a given image.
Args:
image: An instance of a PIL Image.
options: Options to apply to the image (i.e. resolutions).
Returns:
A list containing instance... | [
"def",
"__pipeline_image",
"(",
"image",
",",
"options",
")",
":",
"results",
"=",
"[",
"]",
"# Begin pipline",
"# 1. Create image copies for each resolution",
"if",
"'resolutions'",
"in",
"options",
":",
"resolutions",
"=",
"options",
"[",
"'resolutions'",
"]",
"# ... | Sends an image through a processing pipeline.
Applies all (relevant) provided options to a given image.
Args:
image: An instance of a PIL Image.
options: Options to apply to the image (i.e. resolutions).
Returns:
A list containing instances of PIL Images. This list will always be len... | [
"Sends",
"an",
"image",
"through",
"a",
"processing",
"pipeline",
".",
"Applies",
"all",
"(",
"relevant",
")",
"provided",
"options",
"to",
"a",
"given",
"image",
".",
"Args",
":",
"image",
":",
"An",
"instance",
"of",
"a",
"PIL",
"Image",
".",
"options"... | train | https://github.com/Aperture-py/aperture-lib/blob/5c54af216319f297ddf96181a16f088cf1ba23f3/aperturelib/__init__.py#L60-L110 |
nefarioustim/parker | parker/redisset.py | get_instance | def get_instance(key, expire=None):
"""Return an instance of RedisSet."""
global _instances
try:
instance = _instances[key]
except KeyError:
instance = RedisSet(
key,
_redis,
expire=expire
)
_instances[key] = instance
return instan... | python | def get_instance(key, expire=None):
"""Return an instance of RedisSet."""
global _instances
try:
instance = _instances[key]
except KeyError:
instance = RedisSet(
key,
_redis,
expire=expire
)
_instances[key] = instance
return instan... | [
"def",
"get_instance",
"(",
"key",
",",
"expire",
"=",
"None",
")",
":",
"global",
"_instances",
"try",
":",
"instance",
"=",
"_instances",
"[",
"key",
"]",
"except",
"KeyError",
":",
"instance",
"=",
"RedisSet",
"(",
"key",
",",
"_redis",
",",
"expire",... | Return an instance of RedisSet. | [
"Return",
"an",
"instance",
"of",
"RedisSet",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/redisset.py#L14-L27 |
nefarioustim/parker | parker/redisset.py | RedisSet.add | def add(self, value):
"""Add value to set."""
added = self.redis.sadd(
self.key,
value
)
if self.redis.scard(self.key) < 2:
self.redis.expire(self.key, self.expire)
return added | python | def add(self, value):
"""Add value to set."""
added = self.redis.sadd(
self.key,
value
)
if self.redis.scard(self.key) < 2:
self.redis.expire(self.key, self.expire)
return added | [
"def",
"add",
"(",
"self",
",",
"value",
")",
":",
"added",
"=",
"self",
".",
"redis",
".",
"sadd",
"(",
"self",
".",
"key",
",",
"value",
")",
"if",
"self",
".",
"redis",
".",
"scard",
"(",
"self",
".",
"key",
")",
"<",
"2",
":",
"self",
"."... | Add value to set. | [
"Add",
"value",
"to",
"set",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/redisset.py#L51-L61 |
pybel/pybel-artifactory | src/pybel_artifactory/cli.py | write | def write(name, keyword, domain, citation, author, description, species, version, contact, licenses, values,
functions, output, value_prefix):
"""Build a namespace from items."""
write_namespace(
name, keyword, domain, author, citation, values,
namespace_description=description,
... | python | def write(name, keyword, domain, citation, author, description, species, version, contact, licenses, values,
functions, output, value_prefix):
"""Build a namespace from items."""
write_namespace(
name, keyword, domain, author, citation, values,
namespace_description=description,
... | [
"def",
"write",
"(",
"name",
",",
"keyword",
",",
"domain",
",",
"citation",
",",
"author",
",",
"description",
",",
"species",
",",
"version",
",",
"contact",
",",
"licenses",
",",
"values",
",",
"functions",
",",
"output",
",",
"value_prefix",
")",
":"... | Build a namespace from items. | [
"Build",
"a",
"namespace",
"from",
"items",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/cli.py#L43-L56 |
pybel/pybel-artifactory | src/pybel_artifactory/cli.py | history | def history(namespace_module):
"""Hash all versions on Artifactory."""
for path in get_namespace_history(namespace_module):
h = get_bel_resource_hash(path.as_posix())
click.echo('{}\t{}'.format(path, h)) | python | def history(namespace_module):
"""Hash all versions on Artifactory."""
for path in get_namespace_history(namespace_module):
h = get_bel_resource_hash(path.as_posix())
click.echo('{}\t{}'.format(path, h)) | [
"def",
"history",
"(",
"namespace_module",
")",
":",
"for",
"path",
"in",
"get_namespace_history",
"(",
"namespace_module",
")",
":",
"h",
"=",
"get_bel_resource_hash",
"(",
"path",
".",
"as_posix",
"(",
")",
")",
"click",
".",
"echo",
"(",
"'{}\\t{}'",
".",... | Hash all versions on Artifactory. | [
"Hash",
"all",
"versions",
"on",
"Artifactory",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/cli.py#L79-L83 |
pybel/pybel-artifactory | src/pybel_artifactory/cli.py | convert_to_annotation | def convert_to_annotation(file, output):
"""Convert a namespace file to an annotation file."""
resource = parse_bel_resource(file)
write_annotation(
keyword=resource['Namespace']['Keyword'],
values={k: '' for k in resource['Values']},
citation_name=resource['Citation']['NameString']... | python | def convert_to_annotation(file, output):
"""Convert a namespace file to an annotation file."""
resource = parse_bel_resource(file)
write_annotation(
keyword=resource['Namespace']['Keyword'],
values={k: '' for k in resource['Values']},
citation_name=resource['Citation']['NameString']... | [
"def",
"convert_to_annotation",
"(",
"file",
",",
"output",
")",
":",
"resource",
"=",
"parse_bel_resource",
"(",
"file",
")",
"write_annotation",
"(",
"keyword",
"=",
"resource",
"[",
"'Namespace'",
"]",
"[",
"'Keyword'",
"]",
",",
"values",
"=",
"{",
"k",
... | Convert a namespace file to an annotation file. | [
"Convert",
"a",
"namespace",
"file",
"to",
"an",
"annotation",
"file",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/cli.py#L90-L100 |
pybel/pybel-artifactory | src/pybel_artifactory/cli.py | history | def history(annotation_module):
"""Output the hashes for the annotation resources' versions."""
for path in get_annotation_history(annotation_module):
h = get_bel_resource_hash(path.as_posix())
click.echo('{}\t{}'.format(path, h)) | python | def history(annotation_module):
"""Output the hashes for the annotation resources' versions."""
for path in get_annotation_history(annotation_module):
h = get_bel_resource_hash(path.as_posix())
click.echo('{}\t{}'.format(path, h)) | [
"def",
"history",
"(",
"annotation_module",
")",
":",
"for",
"path",
"in",
"get_annotation_history",
"(",
"annotation_module",
")",
":",
"h",
"=",
"get_bel_resource_hash",
"(",
"path",
".",
"as_posix",
"(",
")",
")",
"click",
".",
"echo",
"(",
"'{}\\t{}'",
"... | Output the hashes for the annotation resources' versions. | [
"Output",
"the",
"hashes",
"for",
"the",
"annotation",
"resources",
"versions",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/cli.py#L110-L114 |
pybel/pybel-artifactory | src/pybel_artifactory/cli.py | convert_to_namespace | def convert_to_namespace(file, output, keyword):
"""Convert an annotation file to a namespace file."""
resource = parse_bel_resource(file)
write_namespace(
namespace_keyword=(keyword or resource['AnnotationDefinition']['Keyword']),
namespace_name=resource['AnnotationDefinition']['Keyword'],
... | python | def convert_to_namespace(file, output, keyword):
"""Convert an annotation file to a namespace file."""
resource = parse_bel_resource(file)
write_namespace(
namespace_keyword=(keyword or resource['AnnotationDefinition']['Keyword']),
namespace_name=resource['AnnotationDefinition']['Keyword'],
... | [
"def",
"convert_to_namespace",
"(",
"file",
",",
"output",
",",
"keyword",
")",
":",
"resource",
"=",
"parse_bel_resource",
"(",
"file",
")",
"write_namespace",
"(",
"namespace_keyword",
"=",
"(",
"keyword",
"or",
"resource",
"[",
"'AnnotationDefinition'",
"]",
... | Convert an annotation file to a namespace file. | [
"Convert",
"an",
"annotation",
"file",
"to",
"a",
"namespace",
"file",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/cli.py#L129-L141 |
nefarioustim/parker | parker/client.py | get_proxy | def get_proxy():
"""Return a random proxy from proxy config."""
proxies = _config['proxies']
return proxies[
random.randint(0, len(proxies) - 1)
] if len(proxies) > 0 else None | python | def get_proxy():
"""Return a random proxy from proxy config."""
proxies = _config['proxies']
return proxies[
random.randint(0, len(proxies) - 1)
] if len(proxies) > 0 else None | [
"def",
"get_proxy",
"(",
")",
":",
"proxies",
"=",
"_config",
"[",
"'proxies'",
"]",
"return",
"proxies",
"[",
"random",
".",
"randint",
"(",
"0",
",",
"len",
"(",
"proxies",
")",
"-",
"1",
")",
"]",
"if",
"len",
"(",
"proxies",
")",
">",
"0",
"e... | Return a random proxy from proxy config. | [
"Return",
"a",
"random",
"proxy",
"from",
"proxy",
"config",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L14-L20 |
nefarioustim/parker | parker/client.py | get_instance | def get_instance():
"""Return an instance of Client."""
global _instances
user_agents = _config['user-agents']
user_agent = user_agents[
random.randint(0, len(user_agents) - 1)
] if len(user_agents) > 0 else DEFAULT_UA
instance_key = user_agent
try:
instance = _instances[i... | python | def get_instance():
"""Return an instance of Client."""
global _instances
user_agents = _config['user-agents']
user_agent = user_agents[
random.randint(0, len(user_agents) - 1)
] if len(user_agents) > 0 else DEFAULT_UA
instance_key = user_agent
try:
instance = _instances[i... | [
"def",
"get_instance",
"(",
")",
":",
"global",
"_instances",
"user_agents",
"=",
"_config",
"[",
"'user-agents'",
"]",
"user_agent",
"=",
"user_agents",
"[",
"random",
".",
"randint",
"(",
"0",
",",
"len",
"(",
"user_agents",
")",
"-",
"1",
")",
"]",
"i... | Return an instance of Client. | [
"Return",
"an",
"instance",
"of",
"Client",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L23-L40 |
nefarioustim/parker | parker/client.py | Client.get | def get(self, uri, disable_proxy=False, stream=False):
"""Return Requests response to GET request."""
response = requests.get(
uri,
headers=self.headers,
allow_redirects=True,
cookies={},
stream=stream,
proxies=self.proxy if not dis... | python | def get(self, uri, disable_proxy=False, stream=False):
"""Return Requests response to GET request."""
response = requests.get(
uri,
headers=self.headers,
allow_redirects=True,
cookies={},
stream=stream,
proxies=self.proxy if not dis... | [
"def",
"get",
"(",
"self",
",",
"uri",
",",
"disable_proxy",
"=",
"False",
",",
"stream",
"=",
"False",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"uri",
",",
"headers",
"=",
"self",
".",
"headers",
",",
"allow_redirects",
"=",
"True",
"... | Return Requests response to GET request. | [
"Return",
"Requests",
"response",
"to",
"GET",
"request",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L73-L90 |
nefarioustim/parker | parker/client.py | Client.get_content | def get_content(self, uri, disable_proxy=False):
"""Return content from URI if Response status is good."""
return self.get(uri=uri, disable_proxy=disable_proxy) | python | def get_content(self, uri, disable_proxy=False):
"""Return content from URI if Response status is good."""
return self.get(uri=uri, disable_proxy=disable_proxy) | [
"def",
"get_content",
"(",
"self",
",",
"uri",
",",
"disable_proxy",
"=",
"False",
")",
":",
"return",
"self",
".",
"get",
"(",
"uri",
"=",
"uri",
",",
"disable_proxy",
"=",
"disable_proxy",
")"
] | Return content from URI if Response status is good. | [
"Return",
"content",
"from",
"URI",
"if",
"Response",
"status",
"is",
"good",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L92-L94 |
nefarioustim/parker | parker/client.py | Client.get_iter_content | def get_iter_content(self, uri, disable_proxy=False):
"""Return iterable content from URI if Response status is good."""
return self.get(uri=uri, disable_proxy=disable_proxy, stream=True) | python | def get_iter_content(self, uri, disable_proxy=False):
"""Return iterable content from URI if Response status is good."""
return self.get(uri=uri, disable_proxy=disable_proxy, stream=True) | [
"def",
"get_iter_content",
"(",
"self",
",",
"uri",
",",
"disable_proxy",
"=",
"False",
")",
":",
"return",
"self",
".",
"get",
"(",
"uri",
"=",
"uri",
",",
"disable_proxy",
"=",
"disable_proxy",
",",
"stream",
"=",
"True",
")"
] | Return iterable content from URI if Response status is good. | [
"Return",
"iterable",
"content",
"from",
"URI",
"if",
"Response",
"status",
"is",
"good",
"."
] | train | https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/client.py#L96-L98 |
Akhail/Tebless | tebless/utils/__init__.py | dict_diff | def dict_diff(first, second):
""" Return a dict of keys that differ with another config object.
If a value is not found in one fo the configs, it will be represented
by KEYNOTFOUND.
@param first: Fist dictionary to diff.
@param second: Second dicationary to diff.
@return diff: Dict of Key =... | python | def dict_diff(first, second):
""" Return a dict of keys that differ with another config object.
If a value is not found in one fo the configs, it will be represented
by KEYNOTFOUND.
@param first: Fist dictionary to diff.
@param second: Second dicationary to diff.
@return diff: Dict of Key =... | [
"def",
"dict_diff",
"(",
"first",
",",
"second",
")",
":",
"diff",
"=",
"{",
"}",
"# Check all keys in first dict",
"for",
"key",
"in",
"first",
":",
"if",
"key",
"not",
"in",
"second",
":",
"diff",
"[",
"key",
"]",
"=",
"(",
"first",
"[",
"key",
"]"... | Return a dict of keys that differ with another config object.
If a value is not found in one fo the configs, it will be represented
by KEYNOTFOUND.
@param first: Fist dictionary to diff.
@param second: Second dicationary to diff.
@return diff: Dict of Key => (first.val, second.val) | [
"Return",
"a",
"dict",
"of",
"keys",
"that",
"differ",
"with",
"another",
"config",
"object",
".",
"If",
"a",
"value",
"is",
"not",
"found",
"in",
"one",
"fo",
"the",
"configs",
"it",
"will",
"be",
"represented",
"by",
"KEYNOTFOUND",
"."
] | train | https://github.com/Akhail/Tebless/blob/369ff76f06e7a0b6d04fabc287fa6c4095e158d4/tebless/utils/__init__.py#L13-L32 |
brentpayne/phrase | phrase/word_list.py | WordList.add | def add(self, word, id=None):
"""
Adds a new word to the WordList and assigns it an id. If id is set,
:param word: The word token
:param id: (Optional) The token id can be set, but bypasses the automatic id assignment. Only specify the id
if you plan to specify it on all add ... | python | def add(self, word, id=None):
"""
Adds a new word to the WordList and assigns it an id. If id is set,
:param word: The word token
:param id: (Optional) The token id can be set, but bypasses the automatic id assignment. Only specify the id
if you plan to specify it on all add ... | [
"def",
"add",
"(",
"self",
",",
"word",
",",
"id",
"=",
"None",
")",
":",
"word_id",
"=",
"id",
"if",
"id",
"is",
"not",
"None",
"else",
"self",
".",
"get_next_id",
"(",
")",
"self",
"[",
"word",
"]",
"=",
"word_id",
"self",
".",
"id2word",
"[",
... | Adds a new word to the WordList and assigns it an id. If id is set,
:param word: The word token
:param id: (Optional) The token id can be set, but bypasses the automatic id assignment. Only specify the id
if you plan to specify it on all add calls.
:return: None | [
"Adds",
"a",
"new",
"word",
"to",
"the",
"WordList",
"and",
"assigns",
"it",
"an",
"id",
".",
"If",
"id",
"is",
"set",
":",
"param",
"word",
":",
"The",
"word",
"token",
":",
"param",
"id",
":",
"(",
"Optional",
")",
"The",
"token",
"id",
"can",
... | train | https://github.com/brentpayne/phrase/blob/2c25e202eff0f284cb724a36cec1b22a1169e7a2/phrase/word_list.py#L28-L38 |
RonenNess/Fileter | fileter/iterators/concat_files.py | ConcatFiles.process_file | def process_file(self, path, dryrun):
"""
Concat files and return filename.
"""
# special case - skip output file so we won't include it in result
if path == self._output_path:
return None
# if dryrun skip and return file
if dryrun:
return... | python | def process_file(self, path, dryrun):
"""
Concat files and return filename.
"""
# special case - skip output file so we won't include it in result
if path == self._output_path:
return None
# if dryrun skip and return file
if dryrun:
return... | [
"def",
"process_file",
"(",
"self",
",",
"path",
",",
"dryrun",
")",
":",
"# special case - skip output file so we won't include it in result",
"if",
"path",
"==",
"self",
".",
"_output_path",
":",
"return",
"None",
"# if dryrun skip and return file",
"if",
"dryrun",
":... | Concat files and return filename. | [
"Concat",
"files",
"and",
"return",
"filename",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/iterators/concat_files.py#L41-L59 |
maxfischer2781/chainlet | chainlet/primitives/chain.py | Chain._chain_forks | def _chain_forks(elements):
"""Detect whether a sequence of elements leads to a fork of streams"""
# we are only interested in the result, so unwind from the end
for element in reversed(elements):
if element.chain_fork:
return True
elif element.chain_join:... | python | def _chain_forks(elements):
"""Detect whether a sequence of elements leads to a fork of streams"""
# we are only interested in the result, so unwind from the end
for element in reversed(elements):
if element.chain_fork:
return True
elif element.chain_join:... | [
"def",
"_chain_forks",
"(",
"elements",
")",
":",
"# we are only interested in the result, so unwind from the end",
"for",
"element",
"in",
"reversed",
"(",
"elements",
")",
":",
"if",
"element",
".",
"chain_fork",
":",
"return",
"True",
"elif",
"element",
".",
"cha... | Detect whether a sequence of elements leads to a fork of streams | [
"Detect",
"whether",
"a",
"sequence",
"of",
"elements",
"leads",
"to",
"a",
"fork",
"of",
"streams"
] | train | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/primitives/chain.py#L66-L74 |
walidsa3d/videoscene | videoscene/core.py | parse | def parse(filename):
""" parse a scene release string and return a dictionary of parsed values."""
screensize = re.compile('720p|1080p', re.I)
source = re.compile(
'\.(AHDTV|MBluRay|MDVDR|CAM|TS|TELESYNC|DVDSCR|DVD9|BDSCR|DDC|R5LINE|R5|DVDRip|HDRip|BRRip|BDRip|WEBRip|WEB-?HD|HDtv|PDTV|WEBDL|BluRay)'... | python | def parse(filename):
""" parse a scene release string and return a dictionary of parsed values."""
screensize = re.compile('720p|1080p', re.I)
source = re.compile(
'\.(AHDTV|MBluRay|MDVDR|CAM|TS|TELESYNC|DVDSCR|DVD9|BDSCR|DDC|R5LINE|R5|DVDRip|HDRip|BRRip|BDRip|WEBRip|WEB-?HD|HDtv|PDTV|WEBDL|BluRay)'... | [
"def",
"parse",
"(",
"filename",
")",
":",
"screensize",
"=",
"re",
".",
"compile",
"(",
"'720p|1080p'",
",",
"re",
".",
"I",
")",
"source",
"=",
"re",
".",
"compile",
"(",
"'\\.(AHDTV|MBluRay|MDVDR|CAM|TS|TELESYNC|DVDSCR|DVD9|BDSCR|DDC|R5LINE|R5|DVDRip|HDRip|BRRip|BD... | parse a scene release string and return a dictionary of parsed values. | [
"parse",
"a",
"scene",
"release",
"string",
"and",
"return",
"a",
"dictionary",
"of",
"parsed",
"values",
"."
] | train | https://github.com/walidsa3d/videoscene/blob/3212f8cd7b746b78f76687a60326183bcf5f2e1b/videoscene/core.py#L7-L57 |
xaptum/xtt-python | xtt/certificates.py | generate_ecdsap256_server_certificate | def generate_ecdsap256_server_certificate(server_id, server_pub_key, expiry,
root_id, root_priv_key):
"""
Creates a new server certificate signed by the provided root.
:param Identity server_id: the identity for the certificate
:param ECDSAP256PublicKey server_pu... | python | def generate_ecdsap256_server_certificate(server_id, server_pub_key, expiry,
root_id, root_priv_key):
"""
Creates a new server certificate signed by the provided root.
:param Identity server_id: the identity for the certificate
:param ECDSAP256PublicKey server_pu... | [
"def",
"generate_ecdsap256_server_certificate",
"(",
"server_id",
",",
"server_pub_key",
",",
"expiry",
",",
"root_id",
",",
"root_priv_key",
")",
":",
"cert",
"=",
"ECDSAP256ServerCertificate",
"(",
")",
"rc",
"=",
"_lib",
".",
"xtt_generate_server_certificate_ecdsap25... | Creates a new server certificate signed by the provided root.
:param Identity server_id: the identity for the certificate
:param ECDSAP256PublicKey server_pub_key: the public key for the certificate
:param CertificateExpiry expiry: the expiry date for the certificate
:param CertificateRootId root_id: t... | [
"Creates",
"a",
"new",
"server",
"certificate",
"signed",
"by",
"the",
"provided",
"root",
"."
] | train | https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/xtt/certificates.py#L35-L57 |
radjkarl/fancyTools | fancytools/math/Point3D.py | Point3D.project | def project(self, win_width, win_height, fov, viewer_distance):
""" Transforms this 3D point to 2D using a perspective projection. """
factor = fov / (viewer_distance + self.z)
x = self.x * factor + win_width // 2
y = -self.y * factor + win_height // 2
return Point3D(x, y, 1) | python | def project(self, win_width, win_height, fov, viewer_distance):
""" Transforms this 3D point to 2D using a perspective projection. """
factor = fov / (viewer_distance + self.z)
x = self.x * factor + win_width // 2
y = -self.y * factor + win_height // 2
return Point3D(x, y, 1) | [
"def",
"project",
"(",
"self",
",",
"win_width",
",",
"win_height",
",",
"fov",
",",
"viewer_distance",
")",
":",
"factor",
"=",
"fov",
"/",
"(",
"viewer_distance",
"+",
"self",
".",
"z",
")",
"x",
"=",
"self",
".",
"x",
"*",
"factor",
"+",
"win_widt... | Transforms this 3D point to 2D using a perspective projection. | [
"Transforms",
"this",
"3D",
"point",
"to",
"2D",
"using",
"a",
"perspective",
"projection",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/Point3D.py#L46-L51 |
pip-services3-python/pip-services3-components-python | pip_services3_components/build/CompositeFactory.py | CompositeFactory.can_create | def can_create(self, locator):
"""
Checks if this factory is able to create component by given locator.
This method searches for all registered components and returns
a locator for component it is able to create that matches the given locator.
If the factory is not able to creat... | python | def can_create(self, locator):
"""
Checks if this factory is able to create component by given locator.
This method searches for all registered components and returns
a locator for component it is able to create that matches the given locator.
If the factory is not able to creat... | [
"def",
"can_create",
"(",
"self",
",",
"locator",
")",
":",
"if",
"locator",
"==",
"None",
":",
"raise",
"Exception",
"(",
"\"Locator cannot be null\"",
")",
"# Iterate from the latest factories",
"for",
"factory",
"in",
"reversed",
"(",
"self",
".",
"_factories",... | Checks if this factory is able to create component by given locator.
This method searches for all registered components and returns
a locator for component it is able to create that matches the given locator.
If the factory is not able to create a requested component is returns null.
:... | [
"Checks",
"if",
"this",
"factory",
"is",
"able",
"to",
"create",
"component",
"by",
"given",
"locator",
"."
] | train | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/build/CompositeFactory.py#L65-L86 |
minorg/pastpy | py/src/pastpy/gen/database/impl/dbf/objects_dbf_record.py | ObjectsDbfRecord.read | def read(cls, iprot):
'''
Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord
'''
init_kwds = {}
iprot.read_s... | python | def read(cls, iprot):
'''
Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord
'''
init_kwds = {}
iprot.read_s... | [
"def",
"read",
"(",
"cls",
",",
"iprot",
")",
":",
"init_kwds",
"=",
"{",
"}",
"iprot",
".",
"read_struct_begin",
"(",
")",
"while",
"True",
":",
"ifield_name",
",",
"ifield_type",
",",
"_ifield_id",
"=",
"iprot",
".",
"read_field_begin",
"(",
")",
"if",... | Read a new object from the given input protocol and return the object.
:type iprot: thryft.protocol._input_protocol._InputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord | [
"Read",
"a",
"new",
"object",
"from",
"the",
"given",
"input",
"protocol",
"and",
"return",
"the",
"object",
"."
] | train | https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/dbf/objects_dbf_record.py#L9800-L11148 |
minorg/pastpy | py/src/pastpy/gen/database/impl/dbf/objects_dbf_record.py | ObjectsDbfRecord.write | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord
'''
oprot.write_struct_begin('ObjectsDbfRec... | python | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord
'''
oprot.write_struct_begin('ObjectsDbfRec... | [
"def",
"write",
"(",
"self",
",",
"oprot",
")",
":",
"oprot",
".",
"write_struct_begin",
"(",
"'ObjectsDbfRecord'",
")",
"if",
"self",
".",
"accessno",
"is",
"not",
"None",
":",
"oprot",
".",
"write_field_begin",
"(",
"name",
"=",
"'accessno'",
",",
"type"... | Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.objects_dbf_record.ObjectsDbfRecord | [
"Write",
"this",
"object",
"to",
"the",
"given",
"output",
"protocol",
"and",
"return",
"self",
"."
] | train | https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/dbf/objects_dbf_record.py#L11815-L13159 |
lambdalisue/maidenhair | src/maidenhair/functions.py | load | def load(pathname, using=None, unite=False, basecolumn=0,
relative=False, baseline=None,
parser=None, loader=None,
with_filename=False, recursive=False, natsort=True, **kwargs):
"""
Load data from file matched with given glob pattern.
Return value will be a list of data unless :a... | python | def load(pathname, using=None, unite=False, basecolumn=0,
relative=False, baseline=None,
parser=None, loader=None,
with_filename=False, recursive=False, natsort=True, **kwargs):
"""
Load data from file matched with given glob pattern.
Return value will be a list of data unless :a... | [
"def",
"load",
"(",
"pathname",
",",
"using",
"=",
"None",
",",
"unite",
"=",
"False",
",",
"basecolumn",
"=",
"0",
",",
"relative",
"=",
"False",
",",
"baseline",
"=",
"None",
",",
"parser",
"=",
"None",
",",
"loader",
"=",
"None",
",",
"with_filena... | Load data from file matched with given glob pattern.
Return value will be a list of data unless :attr:`unite` is `True`.
If :attr:`unite` is `True` then all data will be united into a single data.
Parameters
----------
pathname : string or list
A glob pattern or a list of glob pattern whic... | [
"Load",
"data",
"from",
"file",
"matched",
"with",
"given",
"glob",
"pattern",
"."
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/functions.py#L24-L145 |
lambdalisue/maidenhair | src/maidenhair/functions.py | set_default_parser | def set_default_parser(parser):
"""
Set defaulr parser instance
Parameters
----------
parser : instance or string
An instance or registered name of parser class.
The specified parser instance will be used when user did not specified
:attr:`parser` in :func:`maidenhair.functi... | python | def set_default_parser(parser):
"""
Set defaulr parser instance
Parameters
----------
parser : instance or string
An instance or registered name of parser class.
The specified parser instance will be used when user did not specified
:attr:`parser` in :func:`maidenhair.functi... | [
"def",
"set_default_parser",
"(",
"parser",
")",
":",
"if",
"isinstance",
"(",
"parser",
",",
"basestring",
")",
":",
"parser",
"=",
"registry",
".",
"find",
"(",
"parser",
")",
"(",
")",
"if",
"not",
"isinstance",
"(",
"parser",
",",
"BaseParser",
")",
... | Set defaulr parser instance
Parameters
----------
parser : instance or string
An instance or registered name of parser class.
The specified parser instance will be used when user did not specified
:attr:`parser` in :func:`maidenhair.functions.load` function.
See also
------... | [
"Set",
"defaulr",
"parser",
"instance"
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/functions.py#L166-L187 |
lambdalisue/maidenhair | src/maidenhair/functions.py | set_default_loader | def set_default_loader(loader):
"""
Set defaulr loader instance
Parameters
----------
loader : instance or string
An instance or registered name of loader class.
The specified loader instance will be used when user did not specified
:attr:`loader` in :func:`maidenhair.functi... | python | def set_default_loader(loader):
"""
Set defaulr loader instance
Parameters
----------
loader : instance or string
An instance or registered name of loader class.
The specified loader instance will be used when user did not specified
:attr:`loader` in :func:`maidenhair.functi... | [
"def",
"set_default_loader",
"(",
"loader",
")",
":",
"if",
"isinstance",
"(",
"loader",
",",
"basestring",
")",
":",
"loader",
"=",
"registry",
".",
"find",
"(",
"loader",
")",
"(",
")",
"if",
"not",
"isinstance",
"(",
"loader",
",",
"BaseLoader",
")",
... | Set defaulr loader instance
Parameters
----------
loader : instance or string
An instance or registered name of loader class.
The specified loader instance will be used when user did not specified
:attr:`loader` in :func:`maidenhair.functions.load` function.
See also
------... | [
"Set",
"defaulr",
"loader",
"instance"
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/functions.py#L208-L229 |
thingful/hypercat-py | hypercat/hypercat.py | _values | def _values(metadata, rel):
"""Searches a set <metadata> to find all relations <rel>
Returns a list of the values of those relations
(A list, because a rel can occur more than once)"""
result = []
for r in metadata:
if(r[REL] == rel):
result.append(r[VAL])
return result | python | def _values(metadata, rel):
"""Searches a set <metadata> to find all relations <rel>
Returns a list of the values of those relations
(A list, because a rel can occur more than once)"""
result = []
for r in metadata:
if(r[REL] == rel):
result.append(r[VAL])
return result | [
"def",
"_values",
"(",
"metadata",
",",
"rel",
")",
":",
"result",
"=",
"[",
"]",
"for",
"r",
"in",
"metadata",
":",
"if",
"(",
"r",
"[",
"REL",
"]",
"==",
"rel",
")",
":",
"result",
".",
"append",
"(",
"r",
"[",
"VAL",
"]",
")",
"return",
"r... | Searches a set <metadata> to find all relations <rel>
Returns a list of the values of those relations
(A list, because a rel can occur more than once) | [
"Searches",
"a",
"set",
"<metadata",
">",
"to",
"find",
"all",
"relations",
"<rel",
">",
"Returns",
"a",
"list",
"of",
"the",
"values",
"of",
"those",
"relations",
"(",
"A",
"list",
"because",
"a",
"rel",
"can",
"occur",
"more",
"than",
"once",
")"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L53-L62 |
thingful/hypercat-py | hypercat/hypercat.py | loads | def loads(inputStr):
"""Takes a string and converts it into an internal hypercat object, with some checking"""
inCat = json.loads(inputStr)
assert CATALOGUE_TYPE in _values(inCat[CATALOGUE_METADATA], ISCONTENTTYPE_RELATION)
# Manually copy mandatory fields, to check that they are they, and exclude other... | python | def loads(inputStr):
"""Takes a string and converts it into an internal hypercat object, with some checking"""
inCat = json.loads(inputStr)
assert CATALOGUE_TYPE in _values(inCat[CATALOGUE_METADATA], ISCONTENTTYPE_RELATION)
# Manually copy mandatory fields, to check that they are they, and exclude other... | [
"def",
"loads",
"(",
"inputStr",
")",
":",
"inCat",
"=",
"json",
".",
"loads",
"(",
"inputStr",
")",
"assert",
"CATALOGUE_TYPE",
"in",
"_values",
"(",
"inCat",
"[",
"CATALOGUE_METADATA",
"]",
",",
"ISCONTENTTYPE_RELATION",
")",
"# Manually copy mandatory fields, t... | Takes a string and converts it into an internal hypercat object, with some checking | [
"Takes",
"a",
"string",
"and",
"converts",
"it",
"into",
"an",
"internal",
"hypercat",
"object",
"with",
"some",
"checking"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L195-L212 |
thingful/hypercat-py | hypercat/hypercat.py | Base.rels | def rels(self):
"""Returns a LIST of all the metadata relations"""
r = []
for i in self.metadata:
r = r + i[REL]
return [] | python | def rels(self):
"""Returns a LIST of all the metadata relations"""
r = []
for i in self.metadata:
r = r + i[REL]
return [] | [
"def",
"rels",
"(",
"self",
")",
":",
"r",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"metadata",
":",
"r",
"=",
"r",
"+",
"i",
"[",
"REL",
"]",
"return",
"[",
"]"
] | Returns a LIST of all the metadata relations | [
"Returns",
"a",
"LIST",
"of",
"all",
"the",
"metadata",
"relations"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L79-L84 |
thingful/hypercat-py | hypercat/hypercat.py | Base.prettyprint | def prettyprint(self):
"""Return hypercat formatted prettily"""
return json.dumps(self.asJSON(), sort_keys=True, indent=4, separators=(',', ': ')) | python | def prettyprint(self):
"""Return hypercat formatted prettily"""
return json.dumps(self.asJSON(), sort_keys=True, indent=4, separators=(',', ': ')) | [
"def",
"prettyprint",
"(",
"self",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
".",
"asJSON",
"(",
")",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
",",
"separators",
"=",
"(",
"','",
",",
"': '",
")",
")"
] | Return hypercat formatted prettily | [
"Return",
"hypercat",
"formatted",
"prettily"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L90-L92 |
thingful/hypercat-py | hypercat/hypercat.py | Hypercat.addItem | def addItem(self, child, href):
"""Add a new item (a catalogue or resource) as a child of this catalogue."""
assert isinstance(child, Base), "child must be a hypercat Catalogue or Resource"
child.setHref(href)
for item in self.items:
assert item.href != href, "All items in a ... | python | def addItem(self, child, href):
"""Add a new item (a catalogue or resource) as a child of this catalogue."""
assert isinstance(child, Base), "child must be a hypercat Catalogue or Resource"
child.setHref(href)
for item in self.items:
assert item.href != href, "All items in a ... | [
"def",
"addItem",
"(",
"self",
",",
"child",
",",
"href",
")",
":",
"assert",
"isinstance",
"(",
"child",
",",
"Base",
")",
",",
"\"child must be a hypercat Catalogue or Resource\"",
"child",
".",
"setHref",
"(",
"href",
")",
"for",
"item",
"in",
"self",
"."... | Add a new item (a catalogue or resource) as a child of this catalogue. | [
"Add",
"a",
"new",
"item",
"(",
"a",
"catalogue",
"or",
"resource",
")",
"as",
"a",
"child",
"of",
"this",
"catalogue",
"."
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L128-L135 |
thingful/hypercat-py | hypercat/hypercat.py | Hypercat.replaceItem | def replaceItem(self, child, href):
"""Replace an existing child (by matching the href). Guarantees not to change the order of items[]"""
assert isinstance(child, Base), "child item must be a hypercat Catalogue or Resource"
for i in range(len(self.items)):
if(self.items[i].href == hr... | python | def replaceItem(self, child, href):
"""Replace an existing child (by matching the href). Guarantees not to change the order of items[]"""
assert isinstance(child, Base), "child item must be a hypercat Catalogue or Resource"
for i in range(len(self.items)):
if(self.items[i].href == hr... | [
"def",
"replaceItem",
"(",
"self",
",",
"child",
",",
"href",
")",
":",
"assert",
"isinstance",
"(",
"child",
",",
"Base",
")",
",",
"\"child item must be a hypercat Catalogue or Resource\"",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"items",
... | Replace an existing child (by matching the href). Guarantees not to change the order of items[] | [
"Replace",
"an",
"existing",
"child",
"(",
"by",
"matching",
"the",
"href",
")",
".",
"Guarantees",
"not",
"to",
"change",
"the",
"order",
"of",
"items",
"[]"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L137-L144 |
thingful/hypercat-py | hypercat/hypercat.py | Hypercat.findByPath | def findByPath(self, rel, path):
"""Traverses children, building a path based on relation <rel>, until given path is found."""
if((path=="") or (path=="/")):
return(self)
(front,dummy,rest) = path.lstrip("/").partition("/")
for child in self.items:
if front in chi... | python | def findByPath(self, rel, path):
"""Traverses children, building a path based on relation <rel>, until given path is found."""
if((path=="") or (path=="/")):
return(self)
(front,dummy,rest) = path.lstrip("/").partition("/")
for child in self.items:
if front in chi... | [
"def",
"findByPath",
"(",
"self",
",",
"rel",
",",
"path",
")",
":",
"if",
"(",
"(",
"path",
"==",
"\"\"",
")",
"or",
"(",
"path",
"==",
"\"/\"",
")",
")",
":",
"return",
"(",
"self",
")",
"(",
"front",
",",
"dummy",
",",
"rest",
")",
"=",
"p... | Traverses children, building a path based on relation <rel>, until given path is found. | [
"Traverses",
"children",
"building",
"a",
"path",
"based",
"on",
"relation",
"<rel",
">",
"until",
"given",
"path",
"is",
"found",
"."
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L161-L169 |
thingful/hypercat-py | hypercat/hypercat.py | Hypercat.recurse | def recurse(self, fn, *args):
"""Calls fn on a hypercat and all its child hypercats (not resources)"""
fn(self, *args)
for i in self.items:
if isinstance(i, Hypercat):
self.recurse(i, *args) | python | def recurse(self, fn, *args):
"""Calls fn on a hypercat and all its child hypercats (not resources)"""
fn(self, *args)
for i in self.items:
if isinstance(i, Hypercat):
self.recurse(i, *args) | [
"def",
"recurse",
"(",
"self",
",",
"fn",
",",
"*",
"args",
")",
":",
"fn",
"(",
"self",
",",
"*",
"args",
")",
"for",
"i",
"in",
"self",
".",
"items",
":",
"if",
"isinstance",
"(",
"i",
",",
"Hypercat",
")",
":",
"self",
".",
"recurse",
"(",
... | Calls fn on a hypercat and all its child hypercats (not resources) | [
"Calls",
"fn",
"on",
"a",
"hypercat",
"and",
"all",
"its",
"child",
"hypercats",
"(",
"not",
"resources",
")"
] | train | https://github.com/thingful/hypercat-py/blob/db24ef66ec92d74fbea90afbeadc3a268f18f6e3/hypercat/hypercat.py#L171-L176 |
SkyLothar/shcmd | shcmd/tailf.py | tailf | def tailf(
filepath,
lastn=0,
timeout=60,
stopon=None,
encoding="utf8",
delay=0.1
):
"""provide a `tail -f` like function
:param filepath: file to tail -f, absolute path or relative path
:param lastn: lastn line will also be yield
:param timeout: (optional)
stop tail -f ... | python | def tailf(
filepath,
lastn=0,
timeout=60,
stopon=None,
encoding="utf8",
delay=0.1
):
"""provide a `tail -f` like function
:param filepath: file to tail -f, absolute path or relative path
:param lastn: lastn line will also be yield
:param timeout: (optional)
stop tail -f ... | [
"def",
"tailf",
"(",
"filepath",
",",
"lastn",
"=",
"0",
",",
"timeout",
"=",
"60",
",",
"stopon",
"=",
"None",
",",
"encoding",
"=",
"\"utf8\"",
",",
"delay",
"=",
"0.1",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filepath",
... | provide a `tail -f` like function
:param filepath: file to tail -f, absolute path or relative path
:param lastn: lastn line will also be yield
:param timeout: (optional)
stop tail -f when time's up [timeout <= 10min, default = 1min]
:param stopon: (optional) stops when the stopon(output) return... | [
"provide",
"a",
"tail",
"-",
"f",
"like",
"function"
] | train | https://github.com/SkyLothar/shcmd/blob/d8cad6311a4da7ef09f3419c86b58e30388b7ee3/shcmd/tailf.py#L20-L84 |
padfoot27/merlin | venv/lib/python2.7/site-packages/setuptools/sandbox.py | _execfile | def _execfile(filename, globals, locals=None):
"""
Python 3 implementation of execfile.
"""
mode = 'rb'
# Python 2.6 compile requires LF for newlines, so use deprecated
# Universal newlines support.
if sys.version_info < (2, 7):
mode += 'U'
with open(filename, mode) as stream:
... | python | def _execfile(filename, globals, locals=None):
"""
Python 3 implementation of execfile.
"""
mode = 'rb'
# Python 2.6 compile requires LF for newlines, so use deprecated
# Universal newlines support.
if sys.version_info < (2, 7):
mode += 'U'
with open(filename, mode) as stream:
... | [
"def",
"_execfile",
"(",
"filename",
",",
"globals",
",",
"locals",
"=",
"None",
")",
":",
"mode",
"=",
"'rb'",
"# Python 2.6 compile requires LF for newlines, so use deprecated",
"# Universal newlines support.",
"if",
"sys",
".",
"version_info",
"<",
"(",
"2",
",",
... | Python 3 implementation of execfile. | [
"Python",
"3",
"implementation",
"of",
"execfile",
"."
] | train | https://github.com/padfoot27/merlin/blob/c317505c5eca0e774fcf8b8c7f08801479a5099a/venv/lib/python2.7/site-packages/setuptools/sandbox.py#L32-L46 |
maxfischer2781/chainlet | chainlet/primitives/link.py | ChainLink.send | def send(self, value=None):
"""Send a single value to this element for processing"""
if self.chain_fork:
return self._send_fork(value)
return self._send_flat(value) | python | def send(self, value=None):
"""Send a single value to this element for processing"""
if self.chain_fork:
return self._send_fork(value)
return self._send_flat(value) | [
"def",
"send",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"self",
".",
"chain_fork",
":",
"return",
"self",
".",
"_send_fork",
"(",
"value",
")",
"return",
"self",
".",
"_send_flat",
"(",
"value",
")"
] | Send a single value to this element for processing | [
"Send",
"a",
"single",
"value",
"to",
"this",
"element",
"for",
"processing"
] | train | https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/primitives/link.py#L184-L188 |
kankiri/pabiana | pabiana/utils.py | read_interfaces | def read_interfaces(path: str) -> Interfaces:
"""Reads an Interfaces JSON file at the given path and returns it as a dictionary."""
with open(path, encoding='utf-8') as f:
return json.load(f) | python | def read_interfaces(path: str) -> Interfaces:
"""Reads an Interfaces JSON file at the given path and returns it as a dictionary."""
with open(path, encoding='utf-8') as f:
return json.load(f) | [
"def",
"read_interfaces",
"(",
"path",
":",
"str",
")",
"->",
"Interfaces",
":",
"with",
"open",
"(",
"path",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"json",
".",
"load",
"(",
"f",
")"
] | Reads an Interfaces JSON file at the given path and returns it as a dictionary. | [
"Reads",
"an",
"Interfaces",
"JSON",
"file",
"at",
"the",
"given",
"path",
"and",
"returns",
"it",
"as",
"a",
"dictionary",
"."
] | train | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/pabiana/utils.py#L7-L10 |
kankiri/pabiana | pabiana/utils.py | multiple | def multiple(layer: int, limit: int) -> Set[str]:
"""Returns a set of strings to be used as Slots with Pabianas default Clock.
Args:
layer: The layer in the hierarchy this Area is placed in.
Technically, the number specifies how many of the Clocks signals are relevant to the Area.
Between 1 and limit.
limi... | python | def multiple(layer: int, limit: int) -> Set[str]:
"""Returns a set of strings to be used as Slots with Pabianas default Clock.
Args:
layer: The layer in the hierarchy this Area is placed in.
Technically, the number specifies how many of the Clocks signals are relevant to the Area.
Between 1 and limit.
limi... | [
"def",
"multiple",
"(",
"layer",
":",
"int",
",",
"limit",
":",
"int",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"return",
"{",
"str",
"(",
"x",
")",
".",
"zfill",
"(",
"2",
")",
"for",
"x",
"in",
"[",
"2",
"**",
"x",
"for",
"x",
"in",
"range... | Returns a set of strings to be used as Slots with Pabianas default Clock.
Args:
layer: The layer in the hierarchy this Area is placed in.
Technically, the number specifies how many of the Clocks signals are relevant to the Area.
Between 1 and limit.
limit: The number of layers of the hierarchy. | [
"Returns",
"a",
"set",
"of",
"strings",
"to",
"be",
"used",
"as",
"Slots",
"with",
"Pabianas",
"default",
"Clock",
"."
] | train | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/pabiana/utils.py#L17-L26 |
delfick/aws_syncr | aws_syncr/amazon/common.py | AmazonMixin.catch_boto_400 | def catch_boto_400(self, message, heading=None, document=None, **info):
"""Turn a BotoServerError 400 into a BadAmazon"""
try:
yield
except ClientError as error:
if str(error.response["ResponseMetadata"]["HTTPStatusCode"]).startswith("4"):
if heading or do... | python | def catch_boto_400(self, message, heading=None, document=None, **info):
"""Turn a BotoServerError 400 into a BadAmazon"""
try:
yield
except ClientError as error:
if str(error.response["ResponseMetadata"]["HTTPStatusCode"]).startswith("4"):
if heading or do... | [
"def",
"catch_boto_400",
"(",
"self",
",",
"message",
",",
"heading",
"=",
"None",
",",
"document",
"=",
"None",
",",
"*",
"*",
"info",
")",
":",
"try",
":",
"yield",
"except",
"ClientError",
"as",
"error",
":",
"if",
"str",
"(",
"error",
".",
"respo... | Turn a BotoServerError 400 into a BadAmazon | [
"Turn",
"a",
"BotoServerError",
"400",
"into",
"a",
"BadAmazon"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/common.py#L9-L24 |
delfick/aws_syncr | aws_syncr/amazon/common.py | AmazonMixin.print_change | def print_change(self, symbol, typ, changes=None, document=None, **kwargs):
"""Print out a change"""
values = ", ".join("{0}={1}".format(key, val) for key, val in sorted(kwargs.items()))
print("{0} {1}({2})".format(symbol, typ, values))
if changes:
for change in changes:
... | python | def print_change(self, symbol, typ, changes=None, document=None, **kwargs):
"""Print out a change"""
values = ", ".join("{0}={1}".format(key, val) for key, val in sorted(kwargs.items()))
print("{0} {1}({2})".format(symbol, typ, values))
if changes:
for change in changes:
... | [
"def",
"print_change",
"(",
"self",
",",
"symbol",
",",
"typ",
",",
"changes",
"=",
"None",
",",
"document",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"values",
"=",
"\", \"",
".",
"join",
"(",
"\"{0}={1}\"",
".",
"format",
"(",
"key",
",",
"... | Print out a change | [
"Print",
"out",
"a",
"change"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/common.py#L48-L56 |
delfick/aws_syncr | aws_syncr/amazon/common.py | AmazonMixin.change | def change(self, symbol, typ, **kwargs):
"""Print out a change and then do the change if not doing a dry run"""
self.print_change(symbol, typ, **kwargs)
if not self.dry_run:
try:
yield
except:
raise
else:
self.am... | python | def change(self, symbol, typ, **kwargs):
"""Print out a change and then do the change if not doing a dry run"""
self.print_change(symbol, typ, **kwargs)
if not self.dry_run:
try:
yield
except:
raise
else:
self.am... | [
"def",
"change",
"(",
"self",
",",
"symbol",
",",
"typ",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"print_change",
"(",
"symbol",
",",
"typ",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"self",
".",
"dry_run",
":",
"try",
":",
"yield",
"exce... | Print out a change and then do the change if not doing a dry run | [
"Print",
"out",
"a",
"change",
"and",
"then",
"do",
"the",
"change",
"if",
"not",
"doing",
"a",
"dry",
"run"
] | train | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/amazon/common.py#L58-L67 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | urlopen | def urlopen(url, timeout=20, redirects=None):
"""A minimal urlopen replacement hack that supports timeouts for http.
Note that this supports GET only."""
scheme, host, path, params, query, frag = urlparse(url)
if not scheme in ('http', 'https'):
return urllib.urlopen(url)
if params: path... | python | def urlopen(url, timeout=20, redirects=None):
"""A minimal urlopen replacement hack that supports timeouts for http.
Note that this supports GET only."""
scheme, host, path, params, query, frag = urlparse(url)
if not scheme in ('http', 'https'):
return urllib.urlopen(url)
if params: path... | [
"def",
"urlopen",
"(",
"url",
",",
"timeout",
"=",
"20",
",",
"redirects",
"=",
"None",
")",
":",
"scheme",
",",
"host",
",",
"path",
",",
"params",
",",
"query",
",",
"frag",
"=",
"urlparse",
"(",
"url",
")",
"if",
"not",
"scheme",
"in",
"(",
"'... | A minimal urlopen replacement hack that supports timeouts for http.
Note that this supports GET only. | [
"A",
"minimal",
"urlopen",
"replacement",
"hack",
"that",
"supports",
"timeouts",
"for",
"http",
".",
"Note",
"that",
"this",
"supports",
"GET",
"only",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L147-L211 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | DOM.SOAPUriToVersion | def SOAPUriToVersion(self, uri):
"""Return the SOAP version related to an envelope uri."""
value = self._soap_uri_mapping.get(uri)
if value is not None:
return value
raise ValueError(
'Unsupported SOAP envelope uri: %s' % uri
) | python | def SOAPUriToVersion(self, uri):
"""Return the SOAP version related to an envelope uri."""
value = self._soap_uri_mapping.get(uri)
if value is not None:
return value
raise ValueError(
'Unsupported SOAP envelope uri: %s' % uri
) | [
"def",
"SOAPUriToVersion",
"(",
"self",
",",
"uri",
")",
":",
"value",
"=",
"self",
".",
"_soap_uri_mapping",
".",
"get",
"(",
"uri",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"raise",
"ValueError",
"(",
"'Unsupported SOAP envelope uri... | Return the SOAP version related to an envelope uri. | [
"Return",
"the",
"SOAP",
"version",
"related",
"to",
"an",
"envelope",
"uri",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L242-L249 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | DOM.GetSOAPEnvUri | def GetSOAPEnvUri(self, version):
"""Return the appropriate SOAP envelope uri for a given
human-friendly SOAP version string (e.g. '1.1')."""
attrname = 'NS_SOAP_ENV_%s' % join(split(version, '.'), '_')
value = getattr(self, attrname, None)
if value is not None:
re... | python | def GetSOAPEnvUri(self, version):
"""Return the appropriate SOAP envelope uri for a given
human-friendly SOAP version string (e.g. '1.1')."""
attrname = 'NS_SOAP_ENV_%s' % join(split(version, '.'), '_')
value = getattr(self, attrname, None)
if value is not None:
re... | [
"def",
"GetSOAPEnvUri",
"(",
"self",
",",
"version",
")",
":",
"attrname",
"=",
"'NS_SOAP_ENV_%s'",
"%",
"join",
"(",
"split",
"(",
"version",
",",
"'.'",
")",
",",
"'_'",
")",
"value",
"=",
"getattr",
"(",
"self",
",",
"attrname",
",",
"None",
")",
... | Return the appropriate SOAP envelope uri for a given
human-friendly SOAP version string (e.g. '1.1'). | [
"Return",
"the",
"appropriate",
"SOAP",
"envelope",
"uri",
"for",
"a",
"given",
"human",
"-",
"friendly",
"SOAP",
"version",
"string",
"(",
"e",
".",
"g",
".",
"1",
".",
"1",
")",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L251-L260 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | DOM.WSDLUriToVersion | def WSDLUriToVersion(self, uri):
"""Return the WSDL version related to a WSDL namespace uri."""
value = self._wsdl_uri_mapping.get(uri)
if value is not None:
return value
raise ValueError(
'Unsupported SOAP envelope uri: %s' % uri
) | python | def WSDLUriToVersion(self, uri):
"""Return the WSDL version related to a WSDL namespace uri."""
value = self._wsdl_uri_mapping.get(uri)
if value is not None:
return value
raise ValueError(
'Unsupported SOAP envelope uri: %s' % uri
) | [
"def",
"WSDLUriToVersion",
"(",
"self",
",",
"uri",
")",
":",
"value",
"=",
"self",
".",
"_wsdl_uri_mapping",
".",
"get",
"(",
"uri",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"raise",
"ValueError",
"(",
"'Unsupported SOAP envelope uri... | Return the WSDL version related to a WSDL namespace uri. | [
"Return",
"the",
"WSDL",
"version",
"related",
"to",
"a",
"WSDL",
"namespace",
"uri",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L350-L357 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | DOM.isElement | def isElement(self, node, name, nsuri=None):
"""Return true if the given node is an element with the given
name and optional namespace uri."""
if node.nodeType != node.ELEMENT_NODE:
return 0
return node.localName == name and \
(nsuri is None or self.nsUriMat... | python | def isElement(self, node, name, nsuri=None):
"""Return true if the given node is an element with the given
name and optional namespace uri."""
if node.nodeType != node.ELEMENT_NODE:
return 0
return node.localName == name and \
(nsuri is None or self.nsUriMat... | [
"def",
"isElement",
"(",
"self",
",",
"node",
",",
"name",
",",
"nsuri",
"=",
"None",
")",
":",
"if",
"node",
".",
"nodeType",
"!=",
"node",
".",
"ELEMENT_NODE",
":",
"return",
"0",
"return",
"node",
".",
"localName",
"==",
"name",
"and",
"(",
"nsuri... | Return true if the given node is an element with the given
name and optional namespace uri. | [
"Return",
"true",
"if",
"the",
"given",
"node",
"is",
"an",
"element",
"with",
"the",
"given",
"name",
"and",
"optional",
"namespace",
"uri",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L410-L416 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/Utility.py | DOM.getElement | def getElement(self, node, name, nsuri=None, default=join):
"""Return the first child of node with a matching name and
namespace uri, or the default if one is provided."""
nsmatch = self.nsUriMatch
ELEMENT_NODE = node.ELEMENT_NODE
for child in node.childNodes:
if c... | python | def getElement(self, node, name, nsuri=None, default=join):
"""Return the first child of node with a matching name and
namespace uri, or the default if one is provided."""
nsmatch = self.nsUriMatch
ELEMENT_NODE = node.ELEMENT_NODE
for child in node.childNodes:
if c... | [
"def",
"getElement",
"(",
"self",
",",
"node",
",",
"name",
",",
"nsuri",
"=",
"None",
",",
"default",
"=",
"join",
")",
":",
"nsmatch",
"=",
"self",
".",
"nsUriMatch",
"ELEMENT_NODE",
"=",
"node",
".",
"ELEMENT_NODE",
"for",
"child",
"in",
"node",
"."... | Return the first child of node with a matching name and
namespace uri, or the default if one is provided. | [
"Return",
"the",
"first",
"child",
"of",
"node",
"with",
"a",
"matching",
"name",
"and",
"namespace",
"uri",
"or",
"the",
"default",
"if",
"one",
"is",
"provided",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/Utility.py#L418-L431 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.