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 |
|---|---|---|---|---|---|---|---|---|---|---|
vladsaveliev/TargQC | targqc/utilz/jsontemplate/_jsontemplate.py | _ScopedContext.Lookup | def Lookup(self, name):
"""Get the value associated with a name in the current context.
The current context could be an dictionary in a list, or a dictionary
outside a list.
Args:
name: name to lookup, e.g. 'foo' or 'foo.bar.baz'
Returns:
The value, or self.undefined_str
Rais... | python | def Lookup(self, name):
"""Get the value associated with a name in the current context.
The current context could be an dictionary in a list, or a dictionary
outside a list.
Args:
name: name to lookup, e.g. 'foo' or 'foo.bar.baz'
Returns:
The value, or self.undefined_str
Rais... | [
"def",
"Lookup",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"==",
"'@'",
":",
"return",
"self",
".",
"stack",
"[",
"-",
"1",
"]",
".",
"context",
"parts",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"value",
"=",
"self",
".",
"_LookUpStack... | Get the value associated with a name in the current context.
The current context could be an dictionary in a list, or a dictionary
outside a list.
Args:
name: name to lookup, e.g. 'foo' or 'foo.bar.baz'
Returns:
The value, or self.undefined_str
Raises:
UndefinedVariable if self... | [
"Get",
"the",
"value",
"associated",
"with",
"a",
"name",
"in",
"the",
"current",
"context",
"."
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L674-L702 |
vladsaveliev/TargQC | targqc/utilz/jsontemplate/_jsontemplate.py | Template.execute | def execute(self, data_dict, callback, group=None, trace=None):
"""Low level method to expand the template piece by piece.
Args:
data_dict: The JSON data dictionary.
callback: A callback which should be called with each expanded token.
group: Dictionary of name -> Template instance (for s... | python | def execute(self, data_dict, callback, group=None, trace=None):
"""Low level method to expand the template piece by piece.
Args:
data_dict: The JSON data dictionary.
callback: A callback which should be called with each expanded token.
group: Dictionary of name -> Template instance (for s... | [
"def",
"execute",
"(",
"self",
",",
"data_dict",
",",
"callback",
",",
"group",
"=",
"None",
",",
"trace",
"=",
"None",
")",
":",
"# First try the passed in version, then the one set by _SetTemplateGroup. May",
"# be None. Only one of these should be set.",
"group",
"=",
... | Low level method to expand the template piece by piece.
Args:
data_dict: The JSON data dictionary.
callback: A callback which should be called with each expanded token.
group: Dictionary of name -> Template instance (for styles)
Example: You can pass 'f.write' as the callback to write direct... | [
"Low",
"level",
"method",
"to",
"expand",
"the",
"template",
"piece",
"by",
"piece",
"."
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L1426-L1441 |
vladsaveliev/TargQC | targqc/utilz/jsontemplate/_jsontemplate.py | Template.expand | def expand(self, *args, **kwargs):
"""Expands the template with the given data dictionary, returning a string.
This is a small wrapper around execute(), and is the most convenient
interface.
Args:
data_dict: The JSON data dictionary. Like the builtin dict() constructor,
it can tak... | python | def expand(self, *args, **kwargs):
"""Expands the template with the given data dictionary, returning a string.
This is a small wrapper around execute(), and is the most convenient
interface.
Args:
data_dict: The JSON data dictionary. Like the builtin dict() constructor,
it can tak... | [
"def",
"expand",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"data_dict",
"=",
"args",
"[",
"0",
"]",
"trace",
"=",
"kwargs",
".",
"get",
"(",
"'trace'",
... | Expands the template with the given data dictionary, returning a string.
This is a small wrapper around execute(), and is the most convenient
interface.
Args:
data_dict: The JSON data dictionary. Like the builtin dict() constructor,
it can take a single dictionary as a positional argument... | [
"Expands",
"the",
"template",
"with",
"the",
"given",
"data",
"dictionary",
"returning",
"a",
"string",
"."
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L1445-L1487 |
vladsaveliev/TargQC | targqc/utilz/jsontemplate/_jsontemplate.py | Template.tokenstream | def tokenstream(self, data_dict):
"""Yields a list of tokens resulting from expansion.
This may be useful for WSGI apps. NOTE: In the current implementation, the
entire expanded template must be stored memory.
NOTE: This is a generator, but JavaScript doesn't have generators.
"""
toke... | python | def tokenstream(self, data_dict):
"""Yields a list of tokens resulting from expansion.
This may be useful for WSGI apps. NOTE: In the current implementation, the
entire expanded template must be stored memory.
NOTE: This is a generator, but JavaScript doesn't have generators.
"""
toke... | [
"def",
"tokenstream",
"(",
"self",
",",
"data_dict",
")",
":",
"tokens",
"=",
"[",
"]",
"self",
".",
"execute",
"(",
"data_dict",
",",
"tokens",
".",
"append",
")",
"for",
"token",
"in",
"tokens",
":",
"yield",
"token"
] | Yields a list of tokens resulting from expansion.
This may be useful for WSGI apps. NOTE: In the current implementation, the
entire expanded template must be stored memory.
NOTE: This is a generator, but JavaScript doesn't have generators. | [
"Yields",
"a",
"list",
"of",
"tokens",
"resulting",
"from",
"expansion",
"."
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/jsontemplate/_jsontemplate.py#L1489-L1500 |
RI-imaging/ODTbrain | odtbrain/_preproc.py | align_unwrapped | def align_unwrapped(sino):
"""Align an unwrapped phase array to zero-phase
All operations are performed in-place.
"""
samples = []
if len(sino.shape) == 2:
# 2D
# take 1D samples at beginning and end of array
samples.append(sino[:, 0])
samples.append(sino[:, 1])
... | python | def align_unwrapped(sino):
"""Align an unwrapped phase array to zero-phase
All operations are performed in-place.
"""
samples = []
if len(sino.shape) == 2:
# 2D
# take 1D samples at beginning and end of array
samples.append(sino[:, 0])
samples.append(sino[:, 1])
... | [
"def",
"align_unwrapped",
"(",
"sino",
")",
":",
"samples",
"=",
"[",
"]",
"if",
"len",
"(",
"sino",
".",
"shape",
")",
"==",
"2",
":",
"# 2D",
"# take 1D samples at beginning and end of array",
"samples",
".",
"append",
"(",
"sino",
"[",
":",
",",
"0",
... | Align an unwrapped phase array to zero-phase
All operations are performed in-place. | [
"Align",
"an",
"unwrapped",
"phase",
"array",
"to",
"zero",
"-",
"phase"
] | train | https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_preproc.py#L7-L46 |
RI-imaging/ODTbrain | odtbrain/_preproc.py | divmod_neg | def divmod_neg(a, b):
"""Return divmod with closest result to zero"""
q, r = divmod(a, b)
# make sure r is close to zero
sr = np.sign(r)
if np.abs(r) > b/2:
q += sr
r -= b * sr
return q, r | python | def divmod_neg(a, b):
"""Return divmod with closest result to zero"""
q, r = divmod(a, b)
# make sure r is close to zero
sr = np.sign(r)
if np.abs(r) > b/2:
q += sr
r -= b * sr
return q, r | [
"def",
"divmod_neg",
"(",
"a",
",",
"b",
")",
":",
"q",
",",
"r",
"=",
"divmod",
"(",
"a",
",",
"b",
")",
"# make sure r is close to zero",
"sr",
"=",
"np",
".",
"sign",
"(",
"r",
")",
"if",
"np",
".",
"abs",
"(",
"r",
")",
">",
"b",
"/",
"2"... | Return divmod with closest result to zero | [
"Return",
"divmod",
"with",
"closest",
"result",
"to",
"zero"
] | train | https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_preproc.py#L49-L57 |
RI-imaging/ODTbrain | odtbrain/_preproc.py | sinogram_as_radon | def sinogram_as_radon(uSin, align=True):
r"""Compute the phase from a complex wave field sinogram
This step is essential when using the ray approximation before
computation of the refractive index with the inverse Radon
transform.
Parameters
----------
uSin: 2d or 3d complex ndarray
... | python | def sinogram_as_radon(uSin, align=True):
r"""Compute the phase from a complex wave field sinogram
This step is essential when using the ray approximation before
computation of the refractive index with the inverse Radon
transform.
Parameters
----------
uSin: 2d or 3d complex ndarray
... | [
"def",
"sinogram_as_radon",
"(",
"uSin",
",",
"align",
"=",
"True",
")",
":",
"ndims",
"=",
"len",
"(",
"uSin",
".",
"shape",
")",
"if",
"ndims",
"==",
"2",
":",
"# unwrapping is very important",
"phiR",
"=",
"np",
".",
"unwrap",
"(",
"np",
".",
"angle... | r"""Compute the phase from a complex wave field sinogram
This step is essential when using the ray approximation before
computation of the refractive index with the inverse Radon
transform.
Parameters
----------
uSin: 2d or 3d complex ndarray
The background-corrected sinogram of the co... | [
"r",
"Compute",
"the",
"phase",
"from",
"a",
"complex",
"wave",
"field",
"sinogram"
] | train | https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_preproc.py#L60-L102 |
RI-imaging/ODTbrain | odtbrain/_preproc.py | sinogram_as_rytov | def sinogram_as_rytov(uSin, u0=1, align=True):
r"""Convert the complex wave field sinogram to the Rytov phase
This method applies the Rytov approximation to the
recorded complex wave sinogram. To achieve this, the following
filter is applied:
.. math::
u_\mathrm{B}(\mathbf{r}) = u_\mathrm{... | python | def sinogram_as_rytov(uSin, u0=1, align=True):
r"""Convert the complex wave field sinogram to the Rytov phase
This method applies the Rytov approximation to the
recorded complex wave sinogram. To achieve this, the following
filter is applied:
.. math::
u_\mathrm{B}(\mathbf{r}) = u_\mathrm{... | [
"def",
"sinogram_as_rytov",
"(",
"uSin",
",",
"u0",
"=",
"1",
",",
"align",
"=",
"True",
")",
":",
"ndims",
"=",
"len",
"(",
"uSin",
".",
"shape",
")",
"# imaginary part of the complex Rytov phase",
"phiR",
"=",
"np",
".",
"angle",
"(",
"uSin",
"/",
"u0"... | r"""Convert the complex wave field sinogram to the Rytov phase
This method applies the Rytov approximation to the
recorded complex wave sinogram. To achieve this, the following
filter is applied:
.. math::
u_\mathrm{B}(\mathbf{r}) = u_\mathrm{0}(\mathbf{r})
\ln\!\left(
... | [
"r",
"Convert",
"the",
"complex",
"wave",
"field",
"sinogram",
"to",
"the",
"Rytov",
"phase"
] | train | https://github.com/RI-imaging/ODTbrain/blob/abbab8b790f10c0c7aea8d858d7d60f2fdd7161e/odtbrain/_preproc.py#L105-L182 |
svenkreiss/databench | databench/utils.py | json_encoder_default | def json_encoder_default(obj):
"""Handle more data types than the default JSON encoder.
Specifically, it treats a `set` and a `numpy.array` like a `list`.
Example usage: ``json.dumps(obj, default=json_encoder_default)``
"""
if np is not None and hasattr(obj, 'size') and hasattr(obj, 'dtype'):
... | python | def json_encoder_default(obj):
"""Handle more data types than the default JSON encoder.
Specifically, it treats a `set` and a `numpy.array` like a `list`.
Example usage: ``json.dumps(obj, default=json_encoder_default)``
"""
if np is not None and hasattr(obj, 'size') and hasattr(obj, 'dtype'):
... | [
"def",
"json_encoder_default",
"(",
"obj",
")",
":",
"if",
"np",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"obj",
",",
"'size'",
")",
"and",
"hasattr",
"(",
"obj",
",",
"'dtype'",
")",
":",
"if",
"obj",
".",
"size",
"==",
"1",
":",
"if",
"np",
... | Handle more data types than the default JSON encoder.
Specifically, it treats a `set` and a `numpy.array` like a `list`.
Example usage: ``json.dumps(obj, default=json_encoder_default)`` | [
"Handle",
"more",
"data",
"types",
"than",
"the",
"default",
"JSON",
"encoder",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/utils.py#L13-L36 |
svenkreiss/databench | databench/utils.py | fig_to_src | def fig_to_src(figure, image_format='png', dpi=80):
"""Convert a matplotlib figure to an inline HTML image.
:param matplotlib.figure.Figure figure: Figure to display.
:param str image_format: png (default) or svg
:param int dpi: dots-per-inch for raster graphics.
:rtype: str
"""
if image_fo... | python | def fig_to_src(figure, image_format='png', dpi=80):
"""Convert a matplotlib figure to an inline HTML image.
:param matplotlib.figure.Figure figure: Figure to display.
:param str image_format: png (default) or svg
:param int dpi: dots-per-inch for raster graphics.
:rtype: str
"""
if image_fo... | [
"def",
"fig_to_src",
"(",
"figure",
",",
"image_format",
"=",
"'png'",
",",
"dpi",
"=",
"80",
")",
":",
"if",
"image_format",
"==",
"'png'",
":",
"f",
"=",
"io",
".",
"BytesIO",
"(",
")",
"figure",
".",
"savefig",
"(",
"f",
",",
"format",
"=",
"ima... | Convert a matplotlib figure to an inline HTML image.
:param matplotlib.figure.Figure figure: Figure to display.
:param str image_format: png (default) or svg
:param int dpi: dots-per-inch for raster graphics.
:rtype: str | [
"Convert",
"a",
"matplotlib",
"figure",
"to",
"an",
"inline",
"HTML",
"image",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/utils.py#L39-L57 |
MLAB-project/pymlab | examples/I2CSPI_HBSTEP_chain.py | axis.Reset | def Reset(self):
' Reset Axis and set default parameters for H-bridge '
spi.SPI_write(self.CS, [0xC0, 0x60]) # reset
# spi.SPI_write(self.CS, [0x14, 0x14]) # Stall Treshold setup
# spi.SPI_write(self.CS, [0xFF, 0xFF])
# spi.SPI_write(self.CS, [0x13, 0x13]) # Over Cu... | python | def Reset(self):
' Reset Axis and set default parameters for H-bridge '
spi.SPI_write(self.CS, [0xC0, 0x60]) # reset
# spi.SPI_write(self.CS, [0x14, 0x14]) # Stall Treshold setup
# spi.SPI_write(self.CS, [0xFF, 0xFF])
# spi.SPI_write(self.CS, [0x13, 0x13]) # Over Cu... | [
"def",
"Reset",
"(",
"self",
")",
":",
"spi",
".",
"SPI_write",
"(",
"self",
".",
"CS",
",",
"[",
"0xC0",
",",
"0x60",
"]",
")",
"# reset",
"# spi.SPI_write(self.CS, [0x14, 0x14]) # Stall Treshold setup",
"# spi.SPI_write(self.CS, [0xFF, 0xFF]) ",
"#... | Reset Axis and set default parameters for H-bridge | [
"Reset",
"Axis",
"and",
"set",
"default",
"parameters",
"for",
"H",
"-",
"bridge"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_chain.py#L23-L47 |
MLAB-project/pymlab | examples/I2CSPI_HBSTEP_chain.py | axis.MaxSpeed | def MaxSpeed(self, speed):
' Setup of maximum speed '
spi.SPI_write(self.CS, [0x07, 0x07]) # Max Speed setup
spi.SPI_write(self.CS, [0x00, 0x00])
spi.SPI_write(self.CS, [speed, speed]) | python | def MaxSpeed(self, speed):
' Setup of maximum speed '
spi.SPI_write(self.CS, [0x07, 0x07]) # Max Speed setup
spi.SPI_write(self.CS, [0x00, 0x00])
spi.SPI_write(self.CS, [speed, speed]) | [
"def",
"MaxSpeed",
"(",
"self",
",",
"speed",
")",
":",
"spi",
".",
"SPI_write",
"(",
"self",
".",
"CS",
",",
"[",
"0x07",
",",
"0x07",
"]",
")",
"# Max Speed setup ",
"spi",
".",
"SPI_write",
"(",
"self",
".",
"CS",
",",
"[",
"0x00",
",",
"0x00",
... | Setup of maximum speed | [
"Setup",
"of",
"maximum",
"speed"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_chain.py#L49-L53 |
MLAB-project/pymlab | examples/I2CSPI_HBSTEP_chain.py | axis.ReleaseSW | def ReleaseSW(self):
' Go away from Limit Switch '
while self.ReadStatusBit(2) == 1: # is Limit Switch ON ?
spi.SPI_write(self.CS, [0x92, 0x92] | (~self.Dir & 1)) # release SW
while self.IsBusy():
pass
self.MoveWait(10) | python | def ReleaseSW(self):
' Go away from Limit Switch '
while self.ReadStatusBit(2) == 1: # is Limit Switch ON ?
spi.SPI_write(self.CS, [0x92, 0x92] | (~self.Dir & 1)) # release SW
while self.IsBusy():
pass
self.MoveWait(10) | [
"def",
"ReleaseSW",
"(",
"self",
")",
":",
"while",
"self",
".",
"ReadStatusBit",
"(",
"2",
")",
"==",
"1",
":",
"# is Limit Switch ON ?",
"spi",
".",
"SPI_write",
"(",
"self",
".",
"CS",
",",
"[",
"0x92",
",",
"0x92",
"]",
"|",
"(",
"~",
"self",
"... | Go away from Limit Switch | [
"Go",
"away",
"from",
"Limit",
"Switch"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_chain.py#L55-L61 |
MLAB-project/pymlab | examples/I2CSPI_HBSTEP_chain.py | axis.Move | def Move(self, units):
' Move some distance units from current position '
steps = units * self.SPU # translate units to steps
if steps > 0: # look for direction
spi.SPI_write(self.CS, [0x40 | (~self.Dir & 1), 0x40 | (~self.Dir & 1)])
... | python | def Move(self, units):
' Move some distance units from current position '
steps = units * self.SPU # translate units to steps
if steps > 0: # look for direction
spi.SPI_write(self.CS, [0x40 | (~self.Dir & 1), 0x40 | (~self.Dir & 1)])
... | [
"def",
"Move",
"(",
"self",
",",
"units",
")",
":",
"steps",
"=",
"units",
"*",
"self",
".",
"SPU",
"# translate units to steps ",
"if",
"steps",
">",
"0",
":",
"# look for direction",
"spi",
".",
"SPI_write",
"(",
"self",
".",
"CS",
",",
"[",
"0x40",
... | Move some distance units from current position | [
"Move",
"some",
"distance",
"units",
"from",
"current",
"position"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/examples/I2CSPI_HBSTEP_chain.py#L75-L85 |
johntruckenbrodt/spatialist | spatialist/vector.py | bbox | def bbox(coordinates, crs, outname=None, format='ESRI Shapefile', overwrite=True):
"""
create a bounding box vector object or shapefile from coordinates and coordinate reference system.
The CRS can be in either WKT, EPSG or PROJ4 format
Parameters
----------
coordinates: dict
a dict... | python | def bbox(coordinates, crs, outname=None, format='ESRI Shapefile', overwrite=True):
"""
create a bounding box vector object or shapefile from coordinates and coordinate reference system.
The CRS can be in either WKT, EPSG or PROJ4 format
Parameters
----------
coordinates: dict
a dict... | [
"def",
"bbox",
"(",
"coordinates",
",",
"crs",
",",
"outname",
"=",
"None",
",",
"format",
"=",
"'ESRI Shapefile'",
",",
"overwrite",
"=",
"True",
")",
":",
"srs",
"=",
"crsConvert",
"(",
"crs",
",",
"'osr'",
")",
"ring",
"=",
"ogr",
".",
"Geometry",
... | create a bounding box vector object or shapefile from coordinates and coordinate reference system.
The CRS can be in either WKT, EPSG or PROJ4 format
Parameters
----------
coordinates: dict
a dictionary containing numerical variables with keys `xmin`, `xmax`, `ymin` and `ymax`
crs: int,... | [
"create",
"a",
"bounding",
"box",
"vector",
"object",
"or",
"shapefile",
"from",
"coordinates",
"and",
"coordinate",
"reference",
"system",
".",
"The",
"CRS",
"can",
"be",
"in",
"either",
"WKT",
"EPSG",
"or",
"PROJ4",
"format",
"Parameters",
"----------",
"coo... | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L669-L715 |
johntruckenbrodt/spatialist | spatialist/vector.py | dissolve | def dissolve(infile, outfile, field, layername=None):
"""
dissolve the polygons of a vector file by an attribute field
Parameters
----------
infile: str
the input vector file
outfile: str
the output shapefile
field: str
the field name to merge the polygons by
laye... | python | def dissolve(infile, outfile, field, layername=None):
"""
dissolve the polygons of a vector file by an attribute field
Parameters
----------
infile: str
the input vector file
outfile: str
the output shapefile
field: str
the field name to merge the polygons by
laye... | [
"def",
"dissolve",
"(",
"infile",
",",
"outfile",
",",
"field",
",",
"layername",
"=",
"None",
")",
":",
"with",
"Vector",
"(",
"infile",
")",
"as",
"vec",
":",
"srs",
"=",
"vec",
".",
"srs",
"feat",
"=",
"vec",
".",
"layer",
"[",
"0",
"]",
"d",
... | dissolve the polygons of a vector file by an attribute field
Parameters
----------
infile: str
the input vector file
outfile: str
the output shapefile
field: str
the field name to merge the polygons by
layername: str
the name of the output vector layer;
If... | [
"dissolve",
"the",
"polygons",
"of",
"a",
"vector",
"file",
"by",
"an",
"attribute",
"field",
"Parameters",
"----------",
"infile",
":",
"str",
"the",
"input",
"vector",
"file",
"outfile",
":",
"str",
"the",
"output",
"shapefile",
"field",
":",
"str",
"the",... | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L733-L779 |
johntruckenbrodt/spatialist | spatialist/vector.py | feature2vector | def feature2vector(feature, ref, layername=None):
"""
create a Vector object from ogr features
Parameters
----------
feature: list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature`
a single feature or a list of features
ref: Vector
a reference Vector object to retrieve... | python | def feature2vector(feature, ref, layername=None):
"""
create a Vector object from ogr features
Parameters
----------
feature: list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature`
a single feature or a list of features
ref: Vector
a reference Vector object to retrieve... | [
"def",
"feature2vector",
"(",
"feature",
",",
"ref",
",",
"layername",
"=",
"None",
")",
":",
"features",
"=",
"feature",
"if",
"isinstance",
"(",
"feature",
",",
"list",
")",
"else",
"[",
"feature",
"]",
"layername",
"=",
"layername",
"if",
"layername",
... | create a Vector object from ogr features
Parameters
----------
feature: list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature`
a single feature or a list of features
ref: Vector
a reference Vector object to retrieve geo information from
layername: str or None
the n... | [
"create",
"a",
"Vector",
"object",
"from",
"ogr",
"features"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L782-L810 |
johntruckenbrodt/spatialist | spatialist/vector.py | intersect | def intersect(obj1, obj2):
"""
intersect two Vector objects
Parameters
----------
obj1: Vector
the first vector object; this object is reprojected to the CRS of obj2 if necessary
obj2: Vector
the second vector object
Returns
-------
Vector
the intersect of o... | python | def intersect(obj1, obj2):
"""
intersect two Vector objects
Parameters
----------
obj1: Vector
the first vector object; this object is reprojected to the CRS of obj2 if necessary
obj2: Vector
the second vector object
Returns
-------
Vector
the intersect of o... | [
"def",
"intersect",
"(",
"obj1",
",",
"obj2",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj1",
",",
"Vector",
")",
"or",
"not",
"isinstance",
"(",
"obj2",
",",
"Vector",
")",
":",
"raise",
"RuntimeError",
"(",
"'both objects must be of type Vector'",
")",
... | intersect two Vector objects
Parameters
----------
obj1: Vector
the first vector object; this object is reprojected to the CRS of obj2 if necessary
obj2: Vector
the second vector object
Returns
-------
Vector
the intersect of obj1 and obj2 | [
"intersect",
"two",
"Vector",
"objects"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L813-L887 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.addfeature | def addfeature(self, geometry, fields=None):
"""
add a feature to the vector object from a geometry
Parameters
----------
geometry: :osgeo:class:`ogr.Geometry`
the geometry to add as a feature
fields: dict or None
the field names and value... | python | def addfeature(self, geometry, fields=None):
"""
add a feature to the vector object from a geometry
Parameters
----------
geometry: :osgeo:class:`ogr.Geometry`
the geometry to add as a feature
fields: dict or None
the field names and value... | [
"def",
"addfeature",
"(",
"self",
",",
"geometry",
",",
"fields",
"=",
"None",
")",
":",
"feature",
"=",
"ogr",
".",
"Feature",
"(",
"self",
".",
"layerdef",
")",
"feature",
".",
"SetGeometry",
"(",
"geometry",
")",
"if",
"fields",
"is",
"not",
"None",... | add a feature to the vector object from a geometry
Parameters
----------
geometry: :osgeo:class:`ogr.Geometry`
the geometry to add as a feature
fields: dict or None
the field names and values to assign to the new feature
Returns
------- | [
"add",
"a",
"feature",
"to",
"the",
"vector",
"object",
"from",
"a",
"geometry",
"Parameters",
"----------",
"geometry",
":",
":",
"osgeo",
":",
"class",
":",
"ogr",
".",
"Geometry",
"the",
"geometry",
"to",
"add",
"as",
"a",
"feature",
"fields",
":",
"d... | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L104-L138 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.addfield | def addfield(self, name, type, width=10):
"""
add a field to the vector layer
Parameters
----------
name: str
the field name
type: int
the OGR Field Type (OFT), e.g. ogr.OFTString.
See `Module ogr <https://gdal.org/python/osgeo.ogr-mod... | python | def addfield(self, name, type, width=10):
"""
add a field to the vector layer
Parameters
----------
name: str
the field name
type: int
the OGR Field Type (OFT), e.g. ogr.OFTString.
See `Module ogr <https://gdal.org/python/osgeo.ogr-mod... | [
"def",
"addfield",
"(",
"self",
",",
"name",
",",
"type",
",",
"width",
"=",
"10",
")",
":",
"fieldDefn",
"=",
"ogr",
".",
"FieldDefn",
"(",
"name",
",",
"type",
")",
"if",
"type",
"==",
"ogr",
".",
"OFTString",
":",
"fieldDefn",
".",
"SetWidth",
"... | add a field to the vector layer
Parameters
----------
name: str
the field name
type: int
the OGR Field Type (OFT), e.g. ogr.OFTString.
See `Module ogr <https://gdal.org/python/osgeo.ogr-module.html>`_.
width: int
the width of the n... | [
"add",
"a",
"field",
"to",
"the",
"vector",
"layer"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L140-L161 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.addlayer | def addlayer(self, name, srs, geomType):
"""
add a layer to the vector layer
Parameters
----------
name: str
the layer name
srs: int, str or :osgeo:class:`osr.SpatialReference`
the spatial reference system. See :func:`spatialist.auxil.crsConvert` ... | python | def addlayer(self, name, srs, geomType):
"""
add a layer to the vector layer
Parameters
----------
name: str
the layer name
srs: int, str or :osgeo:class:`osr.SpatialReference`
the spatial reference system. See :func:`spatialist.auxil.crsConvert` ... | [
"def",
"addlayer",
"(",
"self",
",",
"name",
",",
"srs",
",",
"geomType",
")",
":",
"self",
".",
"vector",
".",
"CreateLayer",
"(",
"name",
",",
"srs",
",",
"geomType",
")",
"self",
".",
"init_layer",
"(",
")"
] | add a layer to the vector layer
Parameters
----------
name: str
the layer name
srs: int, str or :osgeo:class:`osr.SpatialReference`
the spatial reference system. See :func:`spatialist.auxil.crsConvert` for options.
geomType: int
an OGR well-kn... | [
"add",
"a",
"layer",
"to",
"the",
"vector",
"layer"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L163-L182 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.addvector | def addvector(self, vec):
"""
add a vector object to the layer of the current Vector object
Parameters
----------
vec: Vector
the vector object to add
merge: bool
merge overlapping polygons?
Returns
-------
"""
ve... | python | def addvector(self, vec):
"""
add a vector object to the layer of the current Vector object
Parameters
----------
vec: Vector
the vector object to add
merge: bool
merge overlapping polygons?
Returns
-------
"""
ve... | [
"def",
"addvector",
"(",
"self",
",",
"vec",
")",
":",
"vec",
".",
"layer",
".",
"ResetReading",
"(",
")",
"for",
"feature",
"in",
"vec",
".",
"layer",
":",
"self",
".",
"layer",
".",
"CreateFeature",
"(",
"feature",
")",
"self",
".",
"init_features",
... | add a vector object to the layer of the current Vector object
Parameters
----------
vec: Vector
the vector object to add
merge: bool
merge overlapping polygons?
Returns
------- | [
"add",
"a",
"vector",
"object",
"to",
"the",
"layer",
"of",
"the",
"current",
"Vector",
"object"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L184-L203 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.bbox | def bbox(self, outname=None, format='ESRI Shapefile', overwrite=True):
"""
create a bounding box from the extent of the Vector object
Parameters
----------
outname: str or None
the name of the vector file to be written; if None, a Vector object is returned
fo... | python | def bbox(self, outname=None, format='ESRI Shapefile', overwrite=True):
"""
create a bounding box from the extent of the Vector object
Parameters
----------
outname: str or None
the name of the vector file to be written; if None, a Vector object is returned
fo... | [
"def",
"bbox",
"(",
"self",
",",
"outname",
"=",
"None",
",",
"format",
"=",
"'ESRI Shapefile'",
",",
"overwrite",
"=",
"True",
")",
":",
"if",
"outname",
"is",
"None",
":",
"return",
"bbox",
"(",
"self",
".",
"extent",
",",
"self",
".",
"srs",
")",
... | create a bounding box from the extent of the Vector object
Parameters
----------
outname: str or None
the name of the vector file to be written; if None, a Vector object is returned
format: str
the name of the file format to write
overwrite: bool
... | [
"create",
"a",
"bounding",
"box",
"from",
"the",
"extent",
"of",
"the",
"Vector",
"object"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L205-L226 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.convert2wkt | def convert2wkt(self, set3D=True):
"""
export the geometry of each feature as a wkt string
Parameters
----------
set3D: bool
keep the third (height) dimension?
Returns
-------
"""
features = self.getfeatures()
for feature in ... | python | def convert2wkt(self, set3D=True):
"""
export the geometry of each feature as a wkt string
Parameters
----------
set3D: bool
keep the third (height) dimension?
Returns
-------
"""
features = self.getfeatures()
for feature in ... | [
"def",
"convert2wkt",
"(",
"self",
",",
"set3D",
"=",
"True",
")",
":",
"features",
"=",
"self",
".",
"getfeatures",
"(",
")",
"for",
"feature",
"in",
"features",
":",
"try",
":",
"feature",
".",
"geometry",
"(",
")",
".",
"Set3D",
"(",
"set3D",
")",... | export the geometry of each feature as a wkt string
Parameters
----------
set3D: bool
keep the third (height) dimension?
Returns
------- | [
"export",
"the",
"geometry",
"of",
"each",
"feature",
"as",
"a",
"wkt",
"string"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L244-L265 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.getFeatureByAttribute | def getFeatureByAttribute(self, fieldname, attribute):
"""
get features by field attribute
Parameters
----------
fieldname: str
the name of the queried field
attribute: int or str
the field value of interest
Returns
-------
... | python | def getFeatureByAttribute(self, fieldname, attribute):
"""
get features by field attribute
Parameters
----------
fieldname: str
the name of the queried field
attribute: int or str
the field value of interest
Returns
-------
... | [
"def",
"getFeatureByAttribute",
"(",
"self",
",",
"fieldname",
",",
"attribute",
")",
":",
"attr",
"=",
"attribute",
".",
"strip",
"(",
")",
"if",
"isinstance",
"(",
"attribute",
",",
"str",
")",
"else",
"attribute",
"if",
"fieldname",
"not",
"in",
"self",... | get features by field attribute
Parameters
----------
fieldname: str
the name of the queried field
attribute: int or str
the field value of interest
Returns
-------
list of :osgeo:class:`ogr.Feature` or :osgeo:class:`ogr.Feature`
... | [
"get",
"features",
"by",
"field",
"attribute"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L322-L354 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.getFeatureByIndex | def getFeatureByIndex(self, index):
"""
get features by numerical (positional) index
Parameters
----------
index: int
the queried index
Returns
-------
:osgeo:class:`ogr.Feature`
the requested feature
"""
feature =... | python | def getFeatureByIndex(self, index):
"""
get features by numerical (positional) index
Parameters
----------
index: int
the queried index
Returns
-------
:osgeo:class:`ogr.Feature`
the requested feature
"""
feature =... | [
"def",
"getFeatureByIndex",
"(",
"self",
",",
"index",
")",
":",
"feature",
"=",
"self",
".",
"layer",
"[",
"index",
"]",
"if",
"feature",
"is",
"None",
":",
"feature",
"=",
"self",
".",
"getfeatures",
"(",
")",
"[",
"index",
"]",
"return",
"feature"
] | get features by numerical (positional) index
Parameters
----------
index: int
the queried index
Returns
-------
:osgeo:class:`ogr.Feature`
the requested feature | [
"get",
"features",
"by",
"numerical",
"(",
"positional",
")",
"index"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L356-L373 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.init_layer | def init_layer(self):
"""
initialize a layer object
Returns
-------
"""
self.layer = self.vector.GetLayer()
self.__features = [None] * self.nfeatures | python | def init_layer(self):
"""
initialize a layer object
Returns
-------
"""
self.layer = self.vector.GetLayer()
self.__features = [None] * self.nfeatures | [
"def",
"init_layer",
"(",
"self",
")",
":",
"self",
".",
"layer",
"=",
"self",
".",
"vector",
".",
"GetLayer",
"(",
")",
"self",
".",
"__features",
"=",
"[",
"None",
"]",
"*",
"self",
".",
"nfeatures"
] | initialize a layer object
Returns
------- | [
"initialize",
"a",
"layer",
"object"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L433-L442 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.load | def load(self):
"""
load all feature into memory
Returns
-------
"""
self.layer.ResetReading()
for i in range(self.nfeatures):
if self.__features[i] is None:
self.__features[i] = self.layer[i] | python | def load(self):
"""
load all feature into memory
Returns
-------
"""
self.layer.ResetReading()
for i in range(self.nfeatures):
if self.__features[i] is None:
self.__features[i] = self.layer[i] | [
"def",
"load",
"(",
"self",
")",
":",
"self",
".",
"layer",
".",
"ResetReading",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"nfeatures",
")",
":",
"if",
"self",
".",
"__features",
"[",
"i",
"]",
"is",
"None",
":",
"self",
".",
"__feat... | load all feature into memory
Returns
------- | [
"load",
"all",
"feature",
"into",
"memory"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L466-L477 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.reproject | def reproject(self, projection):
"""
in-memory reprojection
Parameters
----------
projection: int, str or :osgeo:class:`osr.SpatialReference`
the target CRS. See :func:`spatialist.auxil.crsConvert`.
Returns
-------
"""
srs_out = crsC... | python | def reproject(self, projection):
"""
in-memory reprojection
Parameters
----------
projection: int, str or :osgeo:class:`osr.SpatialReference`
the target CRS. See :func:`spatialist.auxil.crsConvert`.
Returns
-------
"""
srs_out = crsC... | [
"def",
"reproject",
"(",
"self",
",",
"projection",
")",
":",
"srs_out",
"=",
"crsConvert",
"(",
"projection",
",",
"'osr'",
")",
"if",
"self",
".",
"srs",
".",
"IsSame",
"(",
"srs_out",
")",
"==",
"0",
":",
"# create the CoordinateTransformation",
"coordTra... | in-memory reprojection
Parameters
----------
projection: int, str or :osgeo:class:`osr.SpatialReference`
the target CRS. See :func:`spatialist.auxil.crsConvert`.
Returns
------- | [
"in",
"-",
"memory",
"reprojection"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L523-L560 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.setCRS | def setCRS(self, crs):
"""
directly reset the spatial reference system of the vector object.
This is not going to reproject the Vector object, see :meth:`reproject` instead.
Parameters
----------
crs: int, str or :osgeo:class:`osr.SpatialReference`
the input ... | python | def setCRS(self, crs):
"""
directly reset the spatial reference system of the vector object.
This is not going to reproject the Vector object, see :meth:`reproject` instead.
Parameters
----------
crs: int, str or :osgeo:class:`osr.SpatialReference`
the input ... | [
"def",
"setCRS",
"(",
"self",
",",
"crs",
")",
":",
"# try to convert the input crs to osr.SpatialReference",
"srs_out",
"=",
"crsConvert",
"(",
"crs",
",",
"'osr'",
")",
"# save all relevant info from the existing vector object",
"layername",
"=",
"self",
".",
"layername... | directly reset the spatial reference system of the vector object.
This is not going to reproject the Vector object, see :meth:`reproject` instead.
Parameters
----------
crs: int, str or :osgeo:class:`osr.SpatialReference`
the input CRS
Returns
-------
... | [
"directly",
"reset",
"the",
"spatial",
"reference",
"system",
"of",
"the",
"vector",
"object",
".",
"This",
"is",
"not",
"going",
"to",
"reproject",
"the",
"Vector",
"object",
"see",
":",
"meth",
":",
"reproject",
"instead",
"."
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L562-L601 |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.write | def write(self, outfile, format='ESRI Shapefile', overwrite=True):
"""
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite ... | python | def write(self, outfile, format='ESRI Shapefile', overwrite=True):
"""
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite ... | [
"def",
"write",
"(",
"self",
",",
"outfile",
",",
"format",
"=",
"'ESRI Shapefile'",
",",
"overwrite",
"=",
"True",
")",
":",
"(",
"outfilepath",
",",
"outfilename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"outfile",
")",
"basename",
"=",
"os",... | write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
------- | [
"write",
"the",
"Vector",
"object",
"to",
"a",
"file"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L614-L666 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.write_byte_data | def write_byte_data(self, address, register, value):
"""
SMBus Read Byte: i2c_smbus_read_byte_data()
============================================
This reads a single byte from a device, from a designated register.
The register is specified through the Comm byte.
S Addr... | python | def write_byte_data(self, address, register, value):
"""
SMBus Read Byte: i2c_smbus_read_byte_data()
============================================
This reads a single byte from a device, from a designated register.
The register is specified through the Comm byte.
S Addr... | [
"def",
"write_byte_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"write_byte_data",
"(",
"address",
",",
"register",
",",
"value",
")"
] | SMBus Read Byte: i2c_smbus_read_byte_data()
============================================
This reads a single byte from a device, from a designated register.
The register is specified through the Comm byte.
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
Functionality flag: I... | [
"SMBus",
"Read",
"Byte",
":",
"i2c_smbus_read_byte_data",
"()",
"============================================"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L105-L117 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.write_word_data | def write_word_data(self, address, register, value):
"""
SMBus Write Word: i2c_smbus_write_word_data()
==============================================
This is the opposite of the Read Word operation. 16 bits
of data is written to a device, to the designated register that is
... | python | def write_word_data(self, address, register, value):
"""
SMBus Write Word: i2c_smbus_write_word_data()
==============================================
This is the opposite of the Read Word operation. 16 bits
of data is written to a device, to the designated register that is
... | [
"def",
"write_word_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"write_word_data",
"(",
"address",
",",
"register",
",",
"value",
")"
] | SMBus Write Word: i2c_smbus_write_word_data()
==============================================
This is the opposite of the Read Word operation. 16 bits
of data is written to a device, to the designated register that is
specified through the Comm byte.
S Addr Wr [A] Comm [A] Data... | [
"SMBus",
"Write",
"Word",
":",
"i2c_smbus_write_word_data",
"()",
"=============================================="
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L133-L150 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.write_block_data | def write_block_data(self, address, register, value):
"""
SMBus Block Write: i2c_smbus_write_block_data()
================================================
The opposite of the Block Read command, this writes up to 32 bytes to
a device, to a designated register that is specified ... | python | def write_block_data(self, address, register, value):
"""
SMBus Block Write: i2c_smbus_write_block_data()
================================================
The opposite of the Block Read command, this writes up to 32 bytes to
a device, to a designated register that is specified ... | [
"def",
"write_block_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"write_block_data",
"(",
"address",
",",
"register",
",",
"value",
")"
] | SMBus Block Write: i2c_smbus_write_block_data()
================================================
The opposite of the Block Read command, this writes up to 32 bytes to
a device, to a designated register that is specified through the
Comm byte. The amount of data is specified in the Coun... | [
"SMBus",
"Block",
"Write",
":",
"i2c_smbus_write_block_data",
"()",
"================================================"
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L171-L184 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.block_process_call | def block_process_call(self, address, register, value):
"""
SMBus Block Write - Block Read Process Call
===========================================
SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.
This command selects a de... | python | def block_process_call(self, address, register, value):
"""
SMBus Block Write - Block Read Process Call
===========================================
SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.
This command selects a de... | [
"def",
"block_process_call",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"block_process_call",
"(",
"address",
",",
"register",
",",
"value",
")"
] | SMBus Block Write - Block Read Process Call
===========================================
SMBus Block Write - Block Read Process Call was introduced in
Revision 2.0 of the specification.
This command selects a device register (through the Comm byte), sends
1 to 31 bytes of data t... | [
"SMBus",
"Block",
"Write",
"-",
"Block",
"Read",
"Process",
"Call",
"==========================================="
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L202-L218 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.write_i2c_block_data | def write_i2c_block_data(self, address, register, value):
"""
I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Write: i2c_smbus_write_i2c_block_data()
==================================================... | python | def write_i2c_block_data(self, address, register, value):
"""
I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Write: i2c_smbus_write_i2c_block_data()
==================================================... | [
"def",
"write_i2c_block_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"write_i2c_block_data",
"(",
"address",
",",
"register",
",",
"value",
")"
] | I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Write: i2c_smbus_write_i2c_block_data()
==================================================
The opposite of the Block Read command, this writes bytes to
... | [
"I2C",
"block",
"transactions",
"do",
"not",
"limit",
"the",
"number",
"of",
"bytes",
"transferred",
"but",
"the",
"SMBus",
"layer",
"places",
"a",
"limit",
"of",
"32",
"bytes",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L247-L264 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | SMBusDriver.read_i2c_block_data | def read_i2c_block_data(self, address, register, length):
"""
I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Read: i2c_smbus_read_i2c_block_data()
================================================
... | python | def read_i2c_block_data(self, address, register, length):
"""
I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Read: i2c_smbus_read_i2c_block_data()
================================================
... | [
"def",
"read_i2c_block_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"length",
")",
":",
"return",
"self",
".",
"smbus",
".",
"read_i2c_block_data",
"(",
"address",
",",
"register",
",",
"length",
")"
] | I2C block transactions do not limit the number of bytes transferred
but the SMBus layer places a limit of 32 bytes.
I2C Block Read: i2c_smbus_read_i2c_block_data()
================================================
This command reads a block of bytes from a device, from a
design... | [
"I2C",
"block",
"transactions",
"do",
"not",
"limit",
"the",
"number",
"of",
"bytes",
"transferred",
"but",
"the",
"SMBus",
"layer",
"places",
"a",
"limit",
"of",
"32",
"bytes",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L266-L282 |
svenkreiss/databench | databench_py/singlethread/meta.py | Meta._init_zmq | def _init_zmq(self, port_publish, port_subscribe):
"""Initialize zmq messaging.
Listen on sub_port. This port might at
some point receive the message to start publishing on a certain
port, but until then, no publishing.
"""
log.debug('kernel {} publishing on port {}'
... | python | def _init_zmq(self, port_publish, port_subscribe):
"""Initialize zmq messaging.
Listen on sub_port. This port might at
some point receive the message to start publishing on a certain
port, but until then, no publishing.
"""
log.debug('kernel {} publishing on port {}'
... | [
"def",
"_init_zmq",
"(",
"self",
",",
"port_publish",
",",
"port_subscribe",
")",
":",
"log",
".",
"debug",
"(",
"'kernel {} publishing on port {}'",
"''",
".",
"format",
"(",
"self",
".",
"analysis",
".",
"id_",
",",
"port_publish",
")",
")",
"self",
".",
... | Initialize zmq messaging.
Listen on sub_port. This port might at
some point receive the message to start publishing on a certain
port, but until then, no publishing. | [
"Initialize",
"zmq",
"messaging",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench_py/singlethread/meta.py#L52-L78 |
svenkreiss/databench | databench_py/singlethread/meta.py | Meta.run_process | def run_process(self, analysis, action_name, message='__nomessagetoken__'):
"""Executes an process in the analysis with the given message.
It also handles the start and stop signals in case an process_id
is given.
This method is similar to the method in databench.Analysis.
"""
... | python | def run_process(self, analysis, action_name, message='__nomessagetoken__'):
"""Executes an process in the analysis with the given message.
It also handles the start and stop signals in case an process_id
is given.
This method is similar to the method in databench.Analysis.
"""
... | [
"def",
"run_process",
"(",
"self",
",",
"analysis",
",",
"action_name",
",",
"message",
"=",
"'__nomessagetoken__'",
")",
":",
"# detect process_id",
"process_id",
"=",
"None",
"if",
"isinstance",
"(",
"message",
",",
"dict",
")",
"and",
"'__process_id'",
"in",
... | Executes an process in the analysis with the given message.
It also handles the start and stop signals in case an process_id
is given.
This method is similar to the method in databench.Analysis. | [
"Executes",
"an",
"process",
"in",
"the",
"analysis",
"with",
"the",
"given",
"message",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench_py/singlethread/meta.py#L99-L164 |
svenkreiss/databench | databench_py/singlethread/meta.py | Meta.event_loop | def event_loop(self):
"""Event loop."""
try:
zmq.eventloop.ioloop.IOLoop.current().start()
except KeyboardInterrupt:
zmq.eventloop.ioloop.IOLoop.current().stop() | python | def event_loop(self):
"""Event loop."""
try:
zmq.eventloop.ioloop.IOLoop.current().start()
except KeyboardInterrupt:
zmq.eventloop.ioloop.IOLoop.current().stop() | [
"def",
"event_loop",
"(",
"self",
")",
":",
"try",
":",
"zmq",
".",
"eventloop",
".",
"ioloop",
".",
"IOLoop",
".",
"current",
"(",
")",
".",
"start",
"(",
")",
"except",
"KeyboardInterrupt",
":",
"zmq",
".",
"eventloop",
".",
"ioloop",
".",
"IOLoop",
... | Event loop. | [
"Event",
"loop",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench_py/singlethread/meta.py#L166-L171 |
svenkreiss/databench | databench_py/singlethread/meta.py | Meta.emit | def emit(self, signal, message, analysis_id):
"""Emit signal to main.
Args:
signal: Name of the signal to be emitted.
message: Message to be sent.
analysis_id: Identifies the instance of this analysis.
"""
log.debug('kernel {} zmq send ({}): {}'
... | python | def emit(self, signal, message, analysis_id):
"""Emit signal to main.
Args:
signal: Name of the signal to be emitted.
message: Message to be sent.
analysis_id: Identifies the instance of this analysis.
"""
log.debug('kernel {} zmq send ({}): {}'
... | [
"def",
"emit",
"(",
"self",
",",
"signal",
",",
"message",
",",
"analysis_id",
")",
":",
"log",
".",
"debug",
"(",
"'kernel {} zmq send ({}): {}'",
"''",
".",
"format",
"(",
"analysis_id",
",",
"signal",
",",
"message",
")",
")",
"self",
".",
"zmq_publish"... | Emit signal to main.
Args:
signal: Name of the signal to be emitted.
message: Message to be sent.
analysis_id: Identifies the instance of this analysis. | [
"Emit",
"signal",
"to",
"main",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench_py/singlethread/meta.py#L191-L206 |
MLAB-project/pymlab | src/pymlab/sensors/gpio.py | I2CIO_TCA9535.set_ports | def set_ports(self, port0 = 0x00, port1 = 0x00):
'Writes specified value to the pins defined as output by config_ports() method. Writing to input pins has no effect.'
self.bus.write_byte_data(self.address, self.OUTPUT_PORT0, port0)
self.bus.write_byte_data(self.address, self.OUTPUT_PORT1, port1)... | python | def set_ports(self, port0 = 0x00, port1 = 0x00):
'Writes specified value to the pins defined as output by config_ports() method. Writing to input pins has no effect.'
self.bus.write_byte_data(self.address, self.OUTPUT_PORT0, port0)
self.bus.write_byte_data(self.address, self.OUTPUT_PORT1, port1)... | [
"def",
"set_ports",
"(",
"self",
",",
"port0",
"=",
"0x00",
",",
"port1",
"=",
"0x00",
")",
":",
"self",
".",
"bus",
".",
"write_byte_data",
"(",
"self",
".",
"address",
",",
"self",
".",
"OUTPUT_PORT0",
",",
"port0",
")",
"self",
".",
"bus",
".",
... | Writes specified value to the pins defined as output by config_ports() method. Writing to input pins has no effect. | [
"Writes",
"specified",
"value",
"to",
"the",
"pins",
"defined",
"as",
"output",
"by",
"config_ports",
"()",
"method",
".",
"Writing",
"to",
"input",
"pins",
"has",
"no",
"effect",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/gpio.py#L160-L164 |
MLAB-project/pymlab | src/pymlab/sensors/gpio.py | I2CIO_TCA9535.get_ports | def get_ports(self):
'Reads logical values at pins.'
return (self.bus.read_byte_data(self.address, self.STATUS_PORT0), self.bus.read_byte_data(self.address, self.STATUS_PORT1)); | python | def get_ports(self):
'Reads logical values at pins.'
return (self.bus.read_byte_data(self.address, self.STATUS_PORT0), self.bus.read_byte_data(self.address, self.STATUS_PORT1)); | [
"def",
"get_ports",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"bus",
".",
"read_byte_data",
"(",
"self",
".",
"address",
",",
"self",
".",
"STATUS_PORT0",
")",
",",
"self",
".",
"bus",
".",
"read_byte_data",
"(",
"self",
".",
"address",
",",
... | Reads logical values at pins. | [
"Reads",
"logical",
"values",
"at",
"pins",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/gpio.py#L166-L168 |
MLAB-project/pymlab | src/pymlab/sensors/gpio.py | TCA6416A.get_config | def get_config(self):
'Reads logical values at pins.'
return (self.bus.read_byte_data(self.address, self.CONTROL_PORT0), self.bus.read_byte_data(self.address, self.CONTROL_PORT1)); | python | def get_config(self):
'Reads logical values at pins.'
return (self.bus.read_byte_data(self.address, self.CONTROL_PORT0), self.bus.read_byte_data(self.address, self.CONTROL_PORT1)); | [
"def",
"get_config",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"bus",
".",
"read_byte_data",
"(",
"self",
".",
"address",
",",
"self",
".",
"CONTROL_PORT0",
")",
",",
"self",
".",
"bus",
".",
"read_byte_data",
"(",
"self",
".",
"address",
",",... | Reads logical values at pins. | [
"Reads",
"logical",
"values",
"at",
"pins",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/gpio.py#L208-L210 |
MLAB-project/pymlab | src/pymlab/sensors/gpio.py | DS4520.set_pullups | def set_pullups(self, port0 = 0x00, port1 = 0x00):
'Sets INPUT (1) or OUTPUT (0) direction on pins. Inversion setting is applicable for input pins 1-inverted 0-noninverted input polarity.'
self.bus.write_byte_data(self.address, self.PULLUP_PORT0, port0)
self.bus.write_byte_data(self.address, se... | python | def set_pullups(self, port0 = 0x00, port1 = 0x00):
'Sets INPUT (1) or OUTPUT (0) direction on pins. Inversion setting is applicable for input pins 1-inverted 0-noninverted input polarity.'
self.bus.write_byte_data(self.address, self.PULLUP_PORT0, port0)
self.bus.write_byte_data(self.address, se... | [
"def",
"set_pullups",
"(",
"self",
",",
"port0",
"=",
"0x00",
",",
"port1",
"=",
"0x00",
")",
":",
"self",
".",
"bus",
".",
"write_byte_data",
"(",
"self",
".",
"address",
",",
"self",
".",
"PULLUP_PORT0",
",",
"port0",
")",
"self",
".",
"bus",
".",
... | Sets INPUT (1) or OUTPUT (0) direction on pins. Inversion setting is applicable for input pins 1-inverted 0-noninverted input polarity. | [
"Sets",
"INPUT",
"(",
"1",
")",
"or",
"OUTPUT",
"(",
"0",
")",
"direction",
"on",
"pins",
".",
"Inversion",
"setting",
"is",
"applicable",
"for",
"input",
"pins",
"1",
"-",
"inverted",
"0",
"-",
"noninverted",
"input",
"polarity",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/gpio.py#L236-L240 |
MLAB-project/pymlab | src/pymlab/sensors/gpio.py | DS4520.set_ports | def set_ports(self, port0 = 0x00, port1 = 0x00):
'Writes specified value to the pins defined as output by method. Writing to input pins has no effect.'
self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port0)
self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port1)
retu... | python | def set_ports(self, port0 = 0x00, port1 = 0x00):
'Writes specified value to the pins defined as output by method. Writing to input pins has no effect.'
self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port0)
self.bus.write_byte_data(self.address, self.CONTROL_PORT0, port1)
retu... | [
"def",
"set_ports",
"(",
"self",
",",
"port0",
"=",
"0x00",
",",
"port1",
"=",
"0x00",
")",
":",
"self",
".",
"bus",
".",
"write_byte_data",
"(",
"self",
".",
"address",
",",
"self",
".",
"CONTROL_PORT0",
",",
"port0",
")",
"self",
".",
"bus",
".",
... | Writes specified value to the pins defined as output by method. Writing to input pins has no effect. | [
"Writes",
"specified",
"value",
"to",
"the",
"pins",
"defined",
"as",
"output",
"by",
"method",
".",
"Writing",
"to",
"input",
"pins",
"has",
"no",
"effect",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/gpio.py#L242-L246 |
vladsaveliev/TargQC | targqc/utilz/gtf.py | get_gtf_db | def get_gtf_db(gtf, in_memory=False):
"""
create a gffutils DB
"""
db_file = gtf + '.db'
if gtf.endswith('.gz'):
db_file = gtf[:-3] + '.db'
if file_exists(db_file):
return gffutils.FeatureDB(db_file)
db_file = ':memory:' if in_memory else db_file
if in_memory or not file_... | python | def get_gtf_db(gtf, in_memory=False):
"""
create a gffutils DB
"""
db_file = gtf + '.db'
if gtf.endswith('.gz'):
db_file = gtf[:-3] + '.db'
if file_exists(db_file):
return gffutils.FeatureDB(db_file)
db_file = ':memory:' if in_memory else db_file
if in_memory or not file_... | [
"def",
"get_gtf_db",
"(",
"gtf",
",",
"in_memory",
"=",
"False",
")",
":",
"db_file",
"=",
"gtf",
"+",
"'.db'",
"if",
"gtf",
".",
"endswith",
"(",
"'.gz'",
")",
":",
"db_file",
"=",
"gtf",
"[",
":",
"-",
"3",
"]",
"+",
"'.db'",
"if",
"file_exists",... | create a gffutils DB | [
"create",
"a",
"gffutils",
"DB"
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/gtf.py#L36-L53 |
vladsaveliev/TargQC | targqc/utilz/gtf.py | gtf_to_bed | def gtf_to_bed(gtf, alt_out_dir=None):
"""
create a BED file of transcript-level features with attached gene name
or gene ids
"""
out_file = os.path.splitext(gtf)[0] + '.bed'
if file_exists(out_file):
return out_file
if not os.access(os.path.dirname(out_file), os.W_OK | os.X_OK):
... | python | def gtf_to_bed(gtf, alt_out_dir=None):
"""
create a BED file of transcript-level features with attached gene name
or gene ids
"""
out_file = os.path.splitext(gtf)[0] + '.bed'
if file_exists(out_file):
return out_file
if not os.access(os.path.dirname(out_file), os.W_OK | os.X_OK):
... | [
"def",
"gtf_to_bed",
"(",
"gtf",
",",
"alt_out_dir",
"=",
"None",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"gtf",
")",
"[",
"0",
"]",
"+",
"'.bed'",
"if",
"file_exists",
"(",
"out_file",
")",
":",
"return",
"out_file",
"if"... | create a BED file of transcript-level features with attached gene name
or gene ids | [
"create",
"a",
"BED",
"file",
"of",
"transcript",
"-",
"level",
"features",
"with",
"attached",
"gene",
"name",
"or",
"gene",
"ids"
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/gtf.py#L55-L81 |
vladsaveliev/TargQC | targqc/utilz/gtf.py | tx2genefile | def tx2genefile(gtf, out_file=None):
"""
write out a file of transcript->gene mappings.
use the installed tx2gene.csv if it exists, else write a new one out
"""
installed_tx2gene = os.path.join(os.path.dirname(gtf), "tx2gene.csv")
if file_exists(installed_tx2gene):
return installed_tx2ge... | python | def tx2genefile(gtf, out_file=None):
"""
write out a file of transcript->gene mappings.
use the installed tx2gene.csv if it exists, else write a new one out
"""
installed_tx2gene = os.path.join(os.path.dirname(gtf), "tx2gene.csv")
if file_exists(installed_tx2gene):
return installed_tx2ge... | [
"def",
"tx2genefile",
"(",
"gtf",
",",
"out_file",
"=",
"None",
")",
":",
"installed_tx2gene",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"gtf",
")",
",",
"\"tx2gene.csv\"",
")",
"if",
"file_exists",
"(",
"install... | write out a file of transcript->gene mappings.
use the installed tx2gene.csv if it exists, else write a new one out | [
"write",
"out",
"a",
"file",
"of",
"transcript",
"-",
">",
"gene",
"mappings",
".",
"use",
"the",
"installed",
"tx2gene",
".",
"csv",
"if",
"it",
"exists",
"else",
"write",
"a",
"new",
"one",
"out"
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/gtf.py#L183-L197 |
vladsaveliev/TargQC | targqc/utilz/gtf.py | transcript_to_gene | def transcript_to_gene(gtf):
"""
return a dictionary keyed by transcript_id of the associated gene_id
"""
gene_lookup = {}
for feature in complete_features(get_gtf_db(gtf)):
gene_id = feature.attributes.get('gene_id', [None])[0]
transcript_id = feature.attributes.get('transcript_id',... | python | def transcript_to_gene(gtf):
"""
return a dictionary keyed by transcript_id of the associated gene_id
"""
gene_lookup = {}
for feature in complete_features(get_gtf_db(gtf)):
gene_id = feature.attributes.get('gene_id', [None])[0]
transcript_id = feature.attributes.get('transcript_id',... | [
"def",
"transcript_to_gene",
"(",
"gtf",
")",
":",
"gene_lookup",
"=",
"{",
"}",
"for",
"feature",
"in",
"complete_features",
"(",
"get_gtf_db",
"(",
"gtf",
")",
")",
":",
"gene_id",
"=",
"feature",
".",
"attributes",
".",
"get",
"(",
"'gene_id'",
",",
"... | return a dictionary keyed by transcript_id of the associated gene_id | [
"return",
"a",
"dictionary",
"keyed",
"by",
"transcript_id",
"of",
"the",
"associated",
"gene_id"
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/gtf.py#L199-L208 |
MLAB-project/pymlab | src/pymlab/sensors/clkgen.py | CLKGEN01.set_freq | def set_freq(self, fout, freq):
"""
Sets new output frequency, required parameters are real current frequency at output and new required frequency.
"""
hsdiv_tuple = (4, 5, 6, 7, 9, 11) # possible dividers
n1div_tuple = (1,) + tuple(range(2,129,2)) #
fdco_min =... | python | def set_freq(self, fout, freq):
"""
Sets new output frequency, required parameters are real current frequency at output and new required frequency.
"""
hsdiv_tuple = (4, 5, 6, 7, 9, 11) # possible dividers
n1div_tuple = (1,) + tuple(range(2,129,2)) #
fdco_min =... | [
"def",
"set_freq",
"(",
"self",
",",
"fout",
",",
"freq",
")",
":",
"hsdiv_tuple",
"=",
"(",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"9",
",",
"11",
")",
"# possible dividers",
"n1div_tuple",
"=",
"(",
"1",
",",
")",
"+",
"tuple",
"(",
"range",
... | Sets new output frequency, required parameters are real current frequency at output and new required frequency. | [
"Sets",
"new",
"output",
"frequency",
"required",
"parameters",
"are",
"real",
"current",
"frequency",
"at",
"output",
"and",
"new",
"required",
"frequency",
"."
] | train | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/clkgen.py#L102-L139 |
zeldamods/sarc | sarc/sarc.py | SARCWriter._get_file_alignment_for_new_binary_file | def _get_file_alignment_for_new_binary_file(self, file: File) -> int:
"""Detects alignment requirements for binary files with new nn::util::BinaryFileHeader."""
if len(file.data) <= 0x20:
return 0
bom = file.data[0xc:0xc+2]
if bom != b'\xff\xfe' and bom != b'\xfe\xff':
... | python | def _get_file_alignment_for_new_binary_file(self, file: File) -> int:
"""Detects alignment requirements for binary files with new nn::util::BinaryFileHeader."""
if len(file.data) <= 0x20:
return 0
bom = file.data[0xc:0xc+2]
if bom != b'\xff\xfe' and bom != b'\xfe\xff':
... | [
"def",
"_get_file_alignment_for_new_binary_file",
"(",
"self",
",",
"file",
":",
"File",
")",
"->",
"int",
":",
"if",
"len",
"(",
"file",
".",
"data",
")",
"<=",
"0x20",
":",
"return",
"0",
"bom",
"=",
"file",
".",
"data",
"[",
"0xc",
":",
"0xc",
"+"... | Detects alignment requirements for binary files with new nn::util::BinaryFileHeader. | [
"Detects",
"alignment",
"requirements",
"for",
"binary",
"files",
"with",
"new",
"nn",
"::",
"util",
"::",
"BinaryFileHeader",
"."
] | train | https://github.com/zeldamods/sarc/blob/87b7d0235fb0b526f922f2b02796c71868235ae0/sarc/sarc.py#L275-L287 |
svenkreiss/databench | databench/scaffold.py | check_folders | def check_folders(name):
"""Only checks and asks questions. Nothing is written to disk."""
if os.getcwd().endswith('analyses'):
correct = input('You are in an analyses folder. This will create '
'another analyses folder inside this one. Do '
'you want to ... | python | def check_folders(name):
"""Only checks and asks questions. Nothing is written to disk."""
if os.getcwd().endswith('analyses'):
correct = input('You are in an analyses folder. This will create '
'another analyses folder inside this one. Do '
'you want to ... | [
"def",
"check_folders",
"(",
"name",
")",
":",
"if",
"os",
".",
"getcwd",
"(",
")",
".",
"endswith",
"(",
"'analyses'",
")",
":",
"correct",
"=",
"input",
"(",
"'You are in an analyses folder. This will create '",
"'another analyses folder inside this one. Do '",
"'yo... | Only checks and asks questions. Nothing is written to disk. | [
"Only",
"checks",
"and",
"asks",
"questions",
".",
"Nothing",
"is",
"written",
"to",
"disk",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/scaffold.py#L12-L34 |
svenkreiss/databench | databench/scaffold.py | create_analyses | def create_analyses(name, kernel=None):
"""Create an analysis with given name and suffix.
If it does not exist already, it creates the top level analyses folder
and it's __init__.py and index.yaml file.
"""
if not os.path.exists(os.path.join(os.getcwd(), 'analyses')):
os.system("mkdir anal... | python | def create_analyses(name, kernel=None):
"""Create an analysis with given name and suffix.
If it does not exist already, it creates the top level analyses folder
and it's __init__.py and index.yaml file.
"""
if not os.path.exists(os.path.join(os.getcwd(), 'analyses')):
os.system("mkdir anal... | [
"def",
"create_analyses",
"(",
"name",
",",
"kernel",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'analyses'",
")",
")",
":",
"os",
".",
"s... | Create an analysis with given name and suffix.
If it does not exist already, it creates the top level analyses folder
and it's __init__.py and index.yaml file. | [
"Create",
"an",
"analysis",
"with",
"given",
"name",
"and",
"suffix",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/scaffold.py#L37-L71 |
svenkreiss/databench | databench/scaffold.py | create_analysis | def create_analysis(name, kernel, src_dir, scaffold_name):
"""Create analysis files."""
# analysis folder
folder = os.path.join(os.getcwd(), 'analyses', name)
if not os.path.exists(folder):
os.makedirs(folder)
else:
log.warning('Analysis folder {} already exists.'.format(folder))
... | python | def create_analysis(name, kernel, src_dir, scaffold_name):
"""Create analysis files."""
# analysis folder
folder = os.path.join(os.getcwd(), 'analyses', name)
if not os.path.exists(folder):
os.makedirs(folder)
else:
log.warning('Analysis folder {} already exists.'.format(folder))
... | [
"def",
"create_analysis",
"(",
"name",
",",
"kernel",
",",
"src_dir",
",",
"scaffold_name",
")",
":",
"# analysis folder",
"folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'analyses'",
",",
"name",
")",
"if",
"no... | Create analysis files. | [
"Create",
"analysis",
"files",
"."
] | train | https://github.com/svenkreiss/databench/blob/99d4adad494b60a42af6b8bfba94dd0c41ba0786/databench/scaffold.py#L100-L117 |
johntruckenbrodt/spatialist | spatialist/auxil.py | crsConvert | def crsConvert(crsIn, crsOut):
"""
convert between different types of spatial references
Parameters
----------
crsIn: int, str or :osgeo:class:`osr.SpatialReference`
the input CRS
crsOut: {'wkt', 'proj4', 'epsg', 'osr', 'opengis' or 'prettyWkt'}
the output CRS type
Returns
... | python | def crsConvert(crsIn, crsOut):
"""
convert between different types of spatial references
Parameters
----------
crsIn: int, str or :osgeo:class:`osr.SpatialReference`
the input CRS
crsOut: {'wkt', 'proj4', 'epsg', 'osr', 'opengis' or 'prettyWkt'}
the output CRS type
Returns
... | [
"def",
"crsConvert",
"(",
"crsIn",
",",
"crsOut",
")",
":",
"if",
"isinstance",
"(",
"crsIn",
",",
"osr",
".",
"SpatialReference",
")",
":",
"srs",
"=",
"crsIn",
".",
"Clone",
"(",
")",
"else",
":",
"srs",
"=",
"osr",
".",
"SpatialReference",
"(",
")... | convert between different types of spatial references
Parameters
----------
crsIn: int, str or :osgeo:class:`osr.SpatialReference`
the input CRS
crsOut: {'wkt', 'proj4', 'epsg', 'osr', 'opengis' or 'prettyWkt'}
the output CRS type
Returns
-------
int, str or :osgeo:class:`o... | [
"convert",
"between",
"different",
"types",
"of",
"spatial",
"references"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L14-L82 |
johntruckenbrodt/spatialist | spatialist/auxil.py | haversine | def haversine(lat1, lon1, lat2, lon2):
"""
compute the distance in meters between two points in latlon
Parameters
----------
lat1: int or float
the latitude of point 1
lon1: int or float
the longitude of point 1
lat2: int or float
the latitude of point 2
lon2: in... | python | def haversine(lat1, lon1, lat2, lon2):
"""
compute the distance in meters between two points in latlon
Parameters
----------
lat1: int or float
the latitude of point 1
lon1: int or float
the longitude of point 1
lat2: int or float
the latitude of point 2
lon2: in... | [
"def",
"haversine",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"radius",
"=",
"6371000",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
"=",
"map",
"(",
"math",
".",
"radians",
",",
"[",
"lat1",
",",
"lon1",
",",
"lat2",
",",
... | compute the distance in meters between two points in latlon
Parameters
----------
lat1: int or float
the latitude of point 1
lon1: int or float
the longitude of point 1
lat2: int or float
the latitude of point 2
lon2: int or float
the longitude of point 2
Re... | [
"compute",
"the",
"distance",
"in",
"meters",
"between",
"two",
"points",
"in",
"latlon"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L85-L110 |
johntruckenbrodt/spatialist | spatialist/auxil.py | gdalwarp | def gdalwarp(src, dst, options):
"""
a simple wrapper for :osgeo:func:`gdal.Warp`
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data set
options: dict
additional parameters passed t... | python | def gdalwarp(src, dst, options):
"""
a simple wrapper for :osgeo:func:`gdal.Warp`
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data set
options: dict
additional parameters passed t... | [
"def",
"gdalwarp",
"(",
"src",
",",
"dst",
",",
"options",
")",
":",
"try",
":",
"out",
"=",
"gdal",
".",
"Warp",
"(",
"dst",
",",
"src",
",",
"options",
"=",
"gdal",
".",
"WarpOptions",
"(",
"*",
"*",
"options",
")",
")",
"except",
"RuntimeError",... | a simple wrapper for :osgeo:func:`gdal.Warp`
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data set
options: dict
additional parameters passed to gdal.Warp; see :osgeo:func:`gdal.WarpOption... | [
"a",
"simple",
"wrapper",
"for",
":",
"osgeo",
":",
"func",
":",
"gdal",
".",
"Warp"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L113-L134 |
johntruckenbrodt/spatialist | spatialist/auxil.py | gdalbuildvrt | def gdalbuildvrt(src, dst, options=None, void=True):
"""
a simple wrapper for :osgeo:func:`gdal.BuildVRT`
Parameters
----------
src: str, list, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set(s)
dst: str
the output data set
options: dict
... | python | def gdalbuildvrt(src, dst, options=None, void=True):
"""
a simple wrapper for :osgeo:func:`gdal.BuildVRT`
Parameters
----------
src: str, list, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set(s)
dst: str
the output data set
options: dict
... | [
"def",
"gdalbuildvrt",
"(",
"src",
",",
"dst",
",",
"options",
"=",
"None",
",",
"void",
"=",
"True",
")",
":",
"options",
"=",
"{",
"}",
"if",
"options",
"is",
"None",
"else",
"options",
"if",
"'outputBounds'",
"in",
"options",
".",
"keys",
"(",
")"... | a simple wrapper for :osgeo:func:`gdal.BuildVRT`
Parameters
----------
src: str, list, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set(s)
dst: str
the output data set
options: dict
additional parameters passed to gdal.BuildVRT; see :osgeo:func... | [
"a",
"simple",
"wrapper",
"for",
":",
"osgeo",
":",
"func",
":",
"gdal",
".",
"BuildVRT"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L137-L171 |
johntruckenbrodt/spatialist | spatialist/auxil.py | gdal_translate | def gdal_translate(src, dst, options):
"""
a simple wrapper for `gdal.Translate <https://gdal.org/python/osgeo.gdal-module.html#Translate>`_
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data s... | python | def gdal_translate(src, dst, options):
"""
a simple wrapper for `gdal.Translate <https://gdal.org/python/osgeo.gdal-module.html#Translate>`_
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data s... | [
"def",
"gdal_translate",
"(",
"src",
",",
"dst",
",",
"options",
")",
":",
"out",
"=",
"gdal",
".",
"Translate",
"(",
"dst",
",",
"src",
",",
"options",
"=",
"gdal",
".",
"TranslateOptions",
"(",
"*",
"*",
"options",
")",
")",
"out",
"=",
"None"
] | a simple wrapper for `gdal.Translate <https://gdal.org/python/osgeo.gdal-module.html#Translate>`_
Parameters
----------
src: str, :osgeo:class:`ogr.DataSource` or :osgeo:class:`gdal.Dataset`
the input data set
dst: str
the output data set
options: dict
additional parameters ... | [
"a",
"simple",
"wrapper",
"for",
"gdal",
".",
"Translate",
"<https",
":",
"//",
"gdal",
".",
"org",
"/",
"python",
"/",
"osgeo",
".",
"gdal",
"-",
"module",
".",
"html#Translate",
">",
"_"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L174-L193 |
johntruckenbrodt/spatialist | spatialist/auxil.py | ogr2ogr | def ogr2ogr(src, dst, options):
"""
a simple wrapper for gdal.VectorTranslate aka `ogr2ogr <https://www.gdal.org/ogr2ogr.html>`_
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional p... | python | def ogr2ogr(src, dst, options):
"""
a simple wrapper for gdal.VectorTranslate aka `ogr2ogr <https://www.gdal.org/ogr2ogr.html>`_
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional p... | [
"def",
"ogr2ogr",
"(",
"src",
",",
"dst",
",",
"options",
")",
":",
"out",
"=",
"gdal",
".",
"VectorTranslate",
"(",
"dst",
",",
"src",
",",
"options",
"=",
"gdal",
".",
"VectorTranslateOptions",
"(",
"*",
"*",
"options",
")",
")",
"out",
"=",
"None"... | a simple wrapper for gdal.VectorTranslate aka `ogr2ogr <https://www.gdal.org/ogr2ogr.html>`_
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional parameters passed to gdal.VectorTranslate;
... | [
"a",
"simple",
"wrapper",
"for",
"gdal",
".",
"VectorTranslate",
"aka",
"ogr2ogr",
"<https",
":",
"//",
"www",
".",
"gdal",
".",
"org",
"/",
"ogr2ogr",
".",
"html",
">",
"_"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L196-L215 |
johntruckenbrodt/spatialist | spatialist/auxil.py | gdal_rasterize | def gdal_rasterize(src, dst, options):
"""
a simple wrapper for gdal.Rasterize
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional parameters passed to gdal.Rasterize; see :osgeo:fun... | python | def gdal_rasterize(src, dst, options):
"""
a simple wrapper for gdal.Rasterize
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional parameters passed to gdal.Rasterize; see :osgeo:fun... | [
"def",
"gdal_rasterize",
"(",
"src",
",",
"dst",
",",
"options",
")",
":",
"out",
"=",
"gdal",
".",
"Rasterize",
"(",
"dst",
",",
"src",
",",
"options",
"=",
"gdal",
".",
"RasterizeOptions",
"(",
"*",
"*",
"options",
")",
")",
"out",
"=",
"None"
] | a simple wrapper for gdal.Rasterize
Parameters
----------
src: str or :osgeo:class:`ogr.DataSource`
the input data set
dst: str
the output data set
options: dict
additional parameters passed to gdal.Rasterize; see :osgeo:func:`gdal.RasterizeOptions`
Returns
------- | [
"a",
"simple",
"wrapper",
"for",
"gdal",
".",
"Rasterize"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L218-L236 |
johntruckenbrodt/spatialist | spatialist/auxil.py | coordinate_reproject | def coordinate_reproject(x, y, s_crs, t_crs):
"""
reproject a coordinate from one CRS to another
Parameters
----------
x: int or float
the X coordinate component
y: int or float
the Y coordinate component
s_crs: int, str or :osgeo:class:`osr.SpatialReference`
the... | python | def coordinate_reproject(x, y, s_crs, t_crs):
"""
reproject a coordinate from one CRS to another
Parameters
----------
x: int or float
the X coordinate component
y: int or float
the Y coordinate component
s_crs: int, str or :osgeo:class:`osr.SpatialReference`
the... | [
"def",
"coordinate_reproject",
"(",
"x",
",",
"y",
",",
"s_crs",
",",
"t_crs",
")",
":",
"source",
"=",
"crsConvert",
"(",
"s_crs",
",",
"'osr'",
")",
"target",
"=",
"crsConvert",
"(",
"t_crs",
",",
"'osr'",
")",
"transform",
"=",
"osr",
".",
"Coordina... | reproject a coordinate from one CRS to another
Parameters
----------
x: int or float
the X coordinate component
y: int or float
the Y coordinate component
s_crs: int, str or :osgeo:class:`osr.SpatialReference`
the source CRS. See :func:`~spatialist.auxil.crsConvert` for ... | [
"reproject",
"a",
"coordinate",
"from",
"one",
"CRS",
"to",
"another",
"Parameters",
"----------",
"x",
":",
"int",
"or",
"float",
"the",
"X",
"coordinate",
"component",
"y",
":",
"int",
"or",
"float",
"the",
"Y",
"coordinate",
"component",
"s_crs",
":",
"... | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/auxil.py#L239-L262 |
vladsaveliev/TargQC | targqc/utilz/proc_args.py | set_up_dirs | def set_up_dirs(proc_name, output_dir=None, work_dir=None, log_dir=None):
""" Creates output_dir, work_dir, and sets up log
"""
output_dir = safe_mkdir(adjust_path(output_dir or join(os.getcwd(), proc_name)), 'output_dir')
debug('Saving results into ' + output_dir)
work_dir = safe_mkdir(work_dir or... | python | def set_up_dirs(proc_name, output_dir=None, work_dir=None, log_dir=None):
""" Creates output_dir, work_dir, and sets up log
"""
output_dir = safe_mkdir(adjust_path(output_dir or join(os.getcwd(), proc_name)), 'output_dir')
debug('Saving results into ' + output_dir)
work_dir = safe_mkdir(work_dir or... | [
"def",
"set_up_dirs",
"(",
"proc_name",
",",
"output_dir",
"=",
"None",
",",
"work_dir",
"=",
"None",
",",
"log_dir",
"=",
"None",
")",
":",
"output_dir",
"=",
"safe_mkdir",
"(",
"adjust_path",
"(",
"output_dir",
"or",
"join",
"(",
"os",
".",
"getcwd",
"... | Creates output_dir, work_dir, and sets up log | [
"Creates",
"output_dir",
"work_dir",
"and",
"sets",
"up",
"log"
] | train | https://github.com/vladsaveliev/TargQC/blob/e887c36b2194dbd73c6ea32989b6cb84c6c0e58d/targqc/utilz/proc_args.py#L112-L123 |
python-astrodynamics/spacetrack | spacetrack/base.py | _iter_content_generator | def _iter_content_generator(response, decode_unicode):
"""Generator used to yield 100 KiB chunks for a given response."""
for chunk in response.iter_content(100 * 1024, decode_unicode=decode_unicode):
if decode_unicode:
# Replace CRLF newlines with LF, Python will handle
# platfo... | python | def _iter_content_generator(response, decode_unicode):
"""Generator used to yield 100 KiB chunks for a given response."""
for chunk in response.iter_content(100 * 1024, decode_unicode=decode_unicode):
if decode_unicode:
# Replace CRLF newlines with LF, Python will handle
# platfo... | [
"def",
"_iter_content_generator",
"(",
"response",
",",
"decode_unicode",
")",
":",
"for",
"chunk",
"in",
"response",
".",
"iter_content",
"(",
"100",
"*",
"1024",
",",
"decode_unicode",
"=",
"decode_unicode",
")",
":",
"if",
"decode_unicode",
":",
"# Replace CR... | Generator used to yield 100 KiB chunks for a given response. | [
"Generator",
"used",
"to",
"yield",
"100",
"KiB",
"chunks",
"for",
"a",
"given",
"response",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L640-L649 |
python-astrodynamics/spacetrack | spacetrack/base.py | _iter_lines_generator | def _iter_lines_generator(response, decode_unicode):
"""Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.
The function is taken from :meth:`requests.models.Response.iter_lines`, but
... | python | def _iter_lines_generator(response, decode_unicode):
"""Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.
The function is taken from :meth:`requests.models.Response.iter_lines`, but
... | [
"def",
"_iter_lines_generator",
"(",
"response",
",",
"decode_unicode",
")",
":",
"pending",
"=",
"None",
"for",
"chunk",
"in",
"_iter_content_generator",
"(",
"response",
",",
"decode_unicode",
"=",
"decode_unicode",
")",
":",
"if",
"pending",
"is",
"not",
"Non... | Iterates over the response data, one line at a time. When
stream=True is set on the request, this avoids reading the
content at once into memory for large responses.
The function is taken from :meth:`requests.models.Response.iter_lines`, but
modified to use our :func:`~spacetrack.base._iter_content_ge... | [
"Iterates",
"over",
"the",
"response",
"data",
"one",
"line",
"at",
"a",
"time",
".",
"When",
"stream",
"=",
"True",
"is",
"set",
"on",
"the",
"request",
"this",
"avoids",
"reading",
"the",
"content",
"at",
"once",
"into",
"memory",
"for",
"large",
"resp... | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L652-L683 |
python-astrodynamics/spacetrack | spacetrack/base.py | _raise_for_status | def _raise_for_status(response):
"""Raises stored :class:`HTTPError`, if one occurred.
This is the :meth:`requests.models.Response.raise_for_status` method,
modified to add the response from Space-Track, if given.
"""
http_error_msg = ''
if 400 <= response.status_code < 500:
http_erro... | python | def _raise_for_status(response):
"""Raises stored :class:`HTTPError`, if one occurred.
This is the :meth:`requests.models.Response.raise_for_status` method,
modified to add the response from Space-Track, if given.
"""
http_error_msg = ''
if 400 <= response.status_code < 500:
http_erro... | [
"def",
"_raise_for_status",
"(",
"response",
")",
":",
"http_error_msg",
"=",
"''",
"if",
"400",
"<=",
"response",
".",
"status_code",
"<",
"500",
":",
"http_error_msg",
"=",
"'%s Client Error: %s for url: %s'",
"%",
"(",
"response",
".",
"status_code",
",",
"re... | Raises stored :class:`HTTPError`, if one occurred.
This is the :meth:`requests.models.Response.raise_for_status` method,
modified to add the response from Space-Track, if given. | [
"Raises",
"stored",
":",
"class",
":",
"HTTPError",
"if",
"one",
"occurred",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L686-L719 |
python-astrodynamics/spacetrack | spacetrack/base.py | SpaceTrackClient.generic_request | def generic_request(self, class_, iter_lines=False, iter_content=False,
controller=None, parse_types=False, **kwargs):
r"""Generic Space-Track query.
The request class methods use this method internally; the public
API is as follows:
.. code-block:: python
... | python | def generic_request(self, class_, iter_lines=False, iter_content=False,
controller=None, parse_types=False, **kwargs):
r"""Generic Space-Track query.
The request class methods use this method internally; the public
API is as follows:
.. code-block:: python
... | [
"def",
"generic_request",
"(",
"self",
",",
"class_",
",",
"iter_lines",
"=",
"False",
",",
"iter_content",
"=",
"False",
",",
"controller",
"=",
"None",
",",
"parse_types",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"iter_lines",
"and",
"ite... | r"""Generic Space-Track query.
The request class methods use this method internally; the public
API is as follows:
.. code-block:: python
st.tle_publish(*args, **kw)
st.basicspacedata.tle_publish(*args, **kw)
st.file(*args, **kw)
st.fileshare.fi... | [
"r",
"Generic",
"Space",
"-",
"Track",
"query",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L245-L402 |
python-astrodynamics/spacetrack | spacetrack/base.py | SpaceTrackClient._ratelimited_get | def _ratelimited_get(self, *args, **kwargs):
"""Perform get request, handling rate limiting."""
with self._ratelimiter:
resp = self.session.get(*args, **kwargs)
# It's possible that Space-Track will return HTTP status 500 with a
# query rate limit violation. This can happen ... | python | def _ratelimited_get(self, *args, **kwargs):
"""Perform get request, handling rate limiting."""
with self._ratelimiter:
resp = self.session.get(*args, **kwargs)
# It's possible that Space-Track will return HTTP status 500 with a
# query rate limit violation. This can happen ... | [
"def",
"_ratelimited_get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"_ratelimiter",
":",
"resp",
"=",
"self",
".",
"session",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# It's possible t... | Perform get request, handling rate limiting. | [
"Perform",
"get",
"request",
"handling",
"rate",
"limiting",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L415-L441 |
python-astrodynamics/spacetrack | spacetrack/base.py | SpaceTrackClient._find_controller | def _find_controller(self, class_):
"""Find first controller that matches given request class.
Order is specified by the keys of
``SpaceTrackClient.request_controllers``
(:class:`~collections.OrderedDict`)
"""
for controller, classes in self.request_controllers.items():
... | python | def _find_controller(self, class_):
"""Find first controller that matches given request class.
Order is specified by the keys of
``SpaceTrackClient.request_controllers``
(:class:`~collections.OrderedDict`)
"""
for controller, classes in self.request_controllers.items():
... | [
"def",
"_find_controller",
"(",
"self",
",",
"class_",
")",
":",
"for",
"controller",
",",
"classes",
"in",
"self",
".",
"request_controllers",
".",
"items",
"(",
")",
":",
"if",
"class_",
"in",
"classes",
":",
"return",
"controller",
"else",
":",
"raise",... | Find first controller that matches given request class.
Order is specified by the keys of
``SpaceTrackClient.request_controllers``
(:class:`~collections.OrderedDict`) | [
"Find",
"first",
"controller",
"that",
"matches",
"given",
"request",
"class",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L479-L490 |
python-astrodynamics/spacetrack | spacetrack/base.py | SpaceTrackClient._download_predicate_data | def _download_predicate_data(self, class_, controller):
"""Get raw predicate information for given request class, and cache for
subsequent calls.
"""
self.authenticate()
url = ('{0}{1}/modeldef/class/{2}'
.format(self.base_url, controller, class_))
logger... | python | def _download_predicate_data(self, class_, controller):
"""Get raw predicate information for given request class, and cache for
subsequent calls.
"""
self.authenticate()
url = ('{0}{1}/modeldef/class/{2}'
.format(self.base_url, controller, class_))
logger... | [
"def",
"_download_predicate_data",
"(",
"self",
",",
"class_",
",",
"controller",
")",
":",
"self",
".",
"authenticate",
"(",
")",
"url",
"=",
"(",
"'{0}{1}/modeldef/class/{2}'",
".",
"format",
"(",
"self",
".",
"base_url",
",",
"controller",
",",
"class_",
... | Get raw predicate information for given request class, and cache for
subsequent calls. | [
"Get",
"raw",
"predicate",
"information",
"for",
"given",
"request",
"class",
"and",
"cache",
"for",
"subsequent",
"calls",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L492-L507 |
python-astrodynamics/spacetrack | spacetrack/base.py | SpaceTrackClient.get_predicates | def get_predicates(self, class_, controller=None):
"""Get full predicate information for given request class, and cache
for subsequent calls.
"""
if class_ not in self._predicates:
if controller is None:
controller = self._find_controller(class_)
e... | python | def get_predicates(self, class_, controller=None):
"""Get full predicate information for given request class, and cache
for subsequent calls.
"""
if class_ not in self._predicates:
if controller is None:
controller = self._find_controller(class_)
e... | [
"def",
"get_predicates",
"(",
"self",
",",
"class_",
",",
"controller",
"=",
"None",
")",
":",
"if",
"class_",
"not",
"in",
"self",
".",
"_predicates",
":",
"if",
"controller",
"is",
"None",
":",
"controller",
"=",
"self",
".",
"_find_controller",
"(",
"... | Get full predicate information for given request class, and cache
for subsequent calls. | [
"Get",
"full",
"predicate",
"information",
"for",
"given",
"request",
"class",
"and",
"cache",
"for",
"subsequent",
"calls",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L509-L529 |
python-astrodynamics/spacetrack | spacetrack/base.py | _ControllerProxy.get_predicates | def get_predicates(self, class_):
"""Proxy ``get_predicates`` to client with stored request
controller.
"""
return self.client.get_predicates(
class_=class_, controller=self.controller) | python | def get_predicates(self, class_):
"""Proxy ``get_predicates`` to client with stored request
controller.
"""
return self.client.get_predicates(
class_=class_, controller=self.controller) | [
"def",
"get_predicates",
"(",
"self",
",",
"class_",
")",
":",
"return",
"self",
".",
"client",
".",
"get_predicates",
"(",
"class_",
"=",
"class_",
",",
"controller",
"=",
"self",
".",
"controller",
")"
] | Proxy ``get_predicates`` to client with stored request
controller. | [
"Proxy",
"get_predicates",
"to",
"client",
"with",
"stored",
"request",
"controller",
"."
] | train | https://github.com/python-astrodynamics/spacetrack/blob/18f63b7de989a31b983d140a11418e01bd6fd398/spacetrack/base.py#L632-L637 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel.on_install | def on_install(self, editor):
"""
Add the folding menu to the editor, on install.
:param editor: editor instance on which the mode has been installed to.
"""
super(FoldingPanel, self).on_install(editor)
self.context_menu = QtWidgets.QMenu(_('Folding'), self.editor)
... | python | def on_install(self, editor):
"""
Add the folding menu to the editor, on install.
:param editor: editor instance on which the mode has been installed to.
"""
super(FoldingPanel, self).on_install(editor)
self.context_menu = QtWidgets.QMenu(_('Folding'), self.editor)
... | [
"def",
"on_install",
"(",
"self",
",",
"editor",
")",
":",
"super",
"(",
"FoldingPanel",
",",
"self",
")",
".",
"on_install",
"(",
"editor",
")",
"self",
".",
"context_menu",
"=",
"QtWidgets",
".",
"QMenu",
"(",
"_",
"(",
"'Folding'",
")",
",",
"self",... | Add the folding menu to the editor, on install.
:param editor: editor instance on which the mode has been installed to. | [
"Add",
"the",
"folding",
"menu",
"to",
"the",
"editor",
"on",
"install",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L180-L209 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._draw_rect | def _draw_rect(self, rect, painter):
"""
Draw the background rectangle using the current style primitive color
or foldIndicatorBackground if nativeFoldingIndicator is true.
:param rect: The fold zone rect to draw
:param painter: The widget's painter.
"""
c = sel... | python | def _draw_rect(self, rect, painter):
"""
Draw the background rectangle using the current style primitive color
or foldIndicatorBackground if nativeFoldingIndicator is true.
:param rect: The fold zone rect to draw
:param painter: The widget's painter.
"""
c = sel... | [
"def",
"_draw_rect",
"(",
"self",
",",
"rect",
",",
"painter",
")",
":",
"c",
"=",
"self",
".",
"_custom_color",
"if",
"self",
".",
"_native",
":",
"c",
"=",
"self",
".",
"get_system_bck_color",
"(",
")",
"grad",
"=",
"QtGui",
".",
"QLinearGradient",
"... | Draw the background rectangle using the current style primitive color
or foldIndicatorBackground if nativeFoldingIndicator is true.
:param rect: The fold zone rect to draw
:param painter: The widget's painter. | [
"Draw",
"the",
"background",
"rectangle",
"using",
"the",
"current",
"style",
"primitive",
"color",
"or",
"foldIndicatorBackground",
"if",
"nativeFoldingIndicator",
"is",
"true",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L284-L323 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel.get_system_bck_color | def get_system_bck_color():
"""
Gets a system color for drawing the fold scope background.
"""
def merged_colors(colorA, colorB, factor):
maxFactor = 100
colorA = QtGui.QColor(colorA)
colorB = QtGui.QColor(colorB)
tmp = colorA
t... | python | def get_system_bck_color():
"""
Gets a system color for drawing the fold scope background.
"""
def merged_colors(colorA, colorB, factor):
maxFactor = 100
colorA = QtGui.QColor(colorA)
colorB = QtGui.QColor(colorB)
tmp = colorA
t... | [
"def",
"get_system_bck_color",
"(",
")",
":",
"def",
"merged_colors",
"(",
"colorA",
",",
"colorB",
",",
"factor",
")",
":",
"maxFactor",
"=",
"100",
"colorA",
"=",
"QtGui",
".",
"QColor",
"(",
"colorA",
")",
"colorB",
"=",
"QtGui",
".",
"QColor",
"(",
... | Gets a system color for drawing the fold scope background. | [
"Gets",
"a",
"system",
"color",
"for",
"drawing",
"the",
"fold",
"scope",
"background",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L326-L346 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._draw_fold_indicator | def _draw_fold_indicator(self, top, mouse_over, collapsed, painter):
"""
Draw the fold indicator/trigger (arrow).
:param top: Top position
:param mouse_over: Whether the mouse is over the indicator
:param collapsed: Whether the trigger is collapsed or not.
:param painter... | python | def _draw_fold_indicator(self, top, mouse_over, collapsed, painter):
"""
Draw the fold indicator/trigger (arrow).
:param top: Top position
:param mouse_over: Whether the mouse is over the indicator
:param collapsed: Whether the trigger is collapsed or not.
:param painter... | [
"def",
"_draw_fold_indicator",
"(",
"self",
",",
"top",
",",
"mouse_over",
",",
"collapsed",
",",
"painter",
")",
":",
"rect",
"=",
"QtCore",
".",
"QRect",
"(",
"0",
",",
"top",
",",
"self",
".",
"sizeHint",
"(",
")",
".",
"width",
"(",
")",
",",
"... | Draw the fold indicator/trigger (arrow).
:param top: Top position
:param mouse_over: Whether the mouse is over the indicator
:param collapsed: Whether the trigger is collapsed or not.
:param painter: QPainter | [
"Draw",
"the",
"fold",
"indicator",
"/",
"trigger",
"(",
"arrow",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L348-L385 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._get_scope_highlight_color | def _get_scope_highlight_color(self):
"""
Gets the base scope highlight color (derivated from the editor
background)
"""
color = self.editor.background
if color.lightness() < 128:
color = drift_color(color, 130)
else:
color = drift_color(c... | python | def _get_scope_highlight_color(self):
"""
Gets the base scope highlight color (derivated from the editor
background)
"""
color = self.editor.background
if color.lightness() < 128:
color = drift_color(color, 130)
else:
color = drift_color(c... | [
"def",
"_get_scope_highlight_color",
"(",
"self",
")",
":",
"color",
"=",
"self",
".",
"editor",
".",
"background",
"if",
"color",
".",
"lightness",
"(",
")",
"<",
"128",
":",
"color",
"=",
"drift_color",
"(",
"color",
",",
"130",
")",
"else",
":",
"co... | Gets the base scope highlight color (derivated from the editor
background) | [
"Gets",
"the",
"base",
"scope",
"highlight",
"color",
"(",
"derivated",
"from",
"the",
"editor",
"background",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L415-L426 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._add_scope_deco | def _add_scope_deco(self, start, end, parent_start, parent_end, base_color,
factor):
"""
Adds a scope decoration that enclose the current scope
:param start: Start of the current scope
:param end: End of the current scope
:param parent_start: Start of the ... | python | def _add_scope_deco(self, start, end, parent_start, parent_end, base_color,
factor):
"""
Adds a scope decoration that enclose the current scope
:param start: Start of the current scope
:param end: End of the current scope
:param parent_start: Start of the ... | [
"def",
"_add_scope_deco",
"(",
"self",
",",
"start",
",",
"end",
",",
"parent_start",
",",
"parent_end",
",",
"base_color",
",",
"factor",
")",
":",
"color",
"=",
"drift_color",
"(",
"base_color",
",",
"factor",
"=",
"factor",
")",
"# upper part",
"if",
"s... | Adds a scope decoration that enclose the current scope
:param start: Start of the current scope
:param end: End of the current scope
:param parent_start: Start of the parent scope
:param parent_end: End of the parent scope
:param base_color: base color for scope decoration
... | [
"Adds",
"a",
"scope",
"decoration",
"that",
"enclose",
"the",
"current",
"scope",
":",
"param",
"start",
":",
"Start",
"of",
"the",
"current",
"scope",
":",
"param",
"end",
":",
"End",
"of",
"the",
"current",
"scope",
":",
"param",
"parent_start",
":",
"... | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L428-L458 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._add_scope_decorations | def _add_scope_decorations(self, block, start, end):
"""
Show a scope decoration on the editor widget
:param start: Start line
:param end: End line
"""
try:
parent = FoldScope(block).parent()
except ValueError:
parent = None
if Tex... | python | def _add_scope_decorations(self, block, start, end):
"""
Show a scope decoration on the editor widget
:param start: Start line
:param end: End line
"""
try:
parent = FoldScope(block).parent()
except ValueError:
parent = None
if Tex... | [
"def",
"_add_scope_decorations",
"(",
"self",
",",
"block",
",",
"start",
",",
"end",
")",
":",
"try",
":",
"parent",
"=",
"FoldScope",
"(",
"block",
")",
".",
"parent",
"(",
")",
"except",
"ValueError",
":",
"parent",
"=",
"None",
"if",
"TextBlockHelper... | Show a scope decoration on the editor widget
:param start: Start line
:param end: End line | [
"Show",
"a",
"scope",
"decoration",
"on",
"the",
"editor",
"widget"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L460-L497 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._highlight_surrounding_scopes | def _highlight_surrounding_scopes(self, block):
"""
Highlights the scopes surrounding the current fold scope.
:param block: Block that starts the current fold scope.
"""
scope = FoldScope(block)
if (self._current_scope is None or
self._current_scope.get_r... | python | def _highlight_surrounding_scopes(self, block):
"""
Highlights the scopes surrounding the current fold scope.
:param block: Block that starts the current fold scope.
"""
scope = FoldScope(block)
if (self._current_scope is None or
self._current_scope.get_r... | [
"def",
"_highlight_surrounding_scopes",
"(",
"self",
",",
"block",
")",
":",
"scope",
"=",
"FoldScope",
"(",
"block",
")",
"if",
"(",
"self",
".",
"_current_scope",
"is",
"None",
"or",
"self",
".",
"_current_scope",
".",
"get_range",
"(",
")",
"!=",
"scope... | Highlights the scopes surrounding the current fold scope.
:param block: Block that starts the current fold scope. | [
"Highlights",
"the",
"scopes",
"surrounding",
"the",
"current",
"fold",
"scope",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L499-L513 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel.leaveEvent | def leaveEvent(self, event):
"""
Removes scope decorations and background from the editor and the panel
if highlight_caret_scope, else simply update the scope decorations to
match the caret scope.
"""
super(FoldingPanel, self).leaveEvent(event)
QtWidgets.QApplica... | python | def leaveEvent(self, event):
"""
Removes scope decorations and background from the editor and the panel
if highlight_caret_scope, else simply update the scope decorations to
match the caret scope.
"""
super(FoldingPanel, self).leaveEvent(event)
QtWidgets.QApplica... | [
"def",
"leaveEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"FoldingPanel",
",",
"self",
")",
".",
"leaveEvent",
"(",
"event",
")",
"QtWidgets",
".",
"QApplication",
".",
"restoreOverrideCursor",
"(",
")",
"self",
".",
"_highlight_runner",
".",
... | Removes scope decorations and background from the editor and the panel
if highlight_caret_scope, else simply update the scope decorations to
match the caret scope. | [
"Removes",
"scope",
"decorations",
"and",
"background",
"from",
"the",
"editor",
"and",
"the",
"panel",
"if",
"highlight_caret_scope",
"else",
"simply",
"update",
"the",
"scope",
"decorations",
"to",
"match",
"the",
"caret",
"scope",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L553-L570 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._add_fold_decoration | def _add_fold_decoration(self, block, region):
"""
Add fold decorations (boxes arround a folded block in the editor
widget).
"""
deco = TextDecoration(block)
deco.signals.clicked.connect(self._on_fold_deco_clicked)
deco.tooltip = region.text(max_lines=25)
... | python | def _add_fold_decoration(self, block, region):
"""
Add fold decorations (boxes arround a folded block in the editor
widget).
"""
deco = TextDecoration(block)
deco.signals.clicked.connect(self._on_fold_deco_clicked)
deco.tooltip = region.text(max_lines=25)
... | [
"def",
"_add_fold_decoration",
"(",
"self",
",",
"block",
",",
"region",
")",
":",
"deco",
"=",
"TextDecoration",
"(",
"block",
")",
"deco",
".",
"signals",
".",
"clicked",
".",
"connect",
"(",
"self",
".",
"_on_fold_deco_clicked",
")",
"deco",
".",
"toolt... | Add fold decorations (boxes arround a folded block in the editor
widget). | [
"Add",
"fold",
"decorations",
"(",
"boxes",
"arround",
"a",
"folded",
"block",
"in",
"the",
"editor",
"widget",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L572-L588 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel.toggle_fold_trigger | def toggle_fold_trigger(self, block):
"""
Toggle a fold trigger block (expand or collapse it).
:param block: The QTextBlock to expand/collapse
"""
if not TextBlockHelper.is_fold_trigger(block):
return
region = FoldScope(block)
if region.collapsed:
... | python | def toggle_fold_trigger(self, block):
"""
Toggle a fold trigger block (expand or collapse it).
:param block: The QTextBlock to expand/collapse
"""
if not TextBlockHelper.is_fold_trigger(block):
return
region = FoldScope(block)
if region.collapsed:
... | [
"def",
"toggle_fold_trigger",
"(",
"self",
",",
"block",
")",
":",
"if",
"not",
"TextBlockHelper",
".",
"is_fold_trigger",
"(",
"block",
")",
":",
"return",
"region",
"=",
"FoldScope",
"(",
"block",
")",
"if",
"region",
".",
"collapsed",
":",
"region",
"."... | Toggle a fold trigger block (expand or collapse it).
:param block: The QTextBlock to expand/collapse | [
"Toggle",
"a",
"fold",
"trigger",
"block",
"(",
"expand",
"or",
"collapse",
"it",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L590-L608 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel.on_state_changed | def on_state_changed(self, state):
"""
On state changed we (dis)connect to the cursorPositionChanged signal
"""
if state:
self.editor.key_pressed.connect(self._on_key_pressed)
if self._highlight_caret:
self.editor.cursorPositionChanged.connect(
... | python | def on_state_changed(self, state):
"""
On state changed we (dis)connect to the cursorPositionChanged signal
"""
if state:
self.editor.key_pressed.connect(self._on_key_pressed)
if self._highlight_caret:
self.editor.cursorPositionChanged.connect(
... | [
"def",
"on_state_changed",
"(",
"self",
",",
"state",
")",
":",
"if",
"state",
":",
"self",
".",
"editor",
".",
"key_pressed",
".",
"connect",
"(",
"self",
".",
"_on_key_pressed",
")",
"if",
"self",
".",
"_highlight_caret",
":",
"self",
".",
"editor",
".... | On state changed we (dis)connect to the cursorPositionChanged signal | [
"On",
"state",
"changed",
"we",
"(",
"dis",
")",
"connect",
"to",
"the",
"cursorPositionChanged",
"signal"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L623-L640 |
pyQode/pyqode.core | pyqode/core/panels/folding.py | FoldingPanel._on_key_pressed | def _on_key_pressed(self, event):
"""
Override key press to select the current scope if the user wants
to deleted a folded scope (without selecting it).
"""
delete_request = event.key() in [QtCore.Qt.Key_Backspace,
QtCore.Qt.Key_Delete]
... | python | def _on_key_pressed(self, event):
"""
Override key press to select the current scope if the user wants
to deleted a folded scope (without selecting it).
"""
delete_request = event.key() in [QtCore.Qt.Key_Backspace,
QtCore.Qt.Key_Delete]
... | [
"def",
"_on_key_pressed",
"(",
"self",
",",
"event",
")",
":",
"delete_request",
"=",
"event",
".",
"key",
"(",
")",
"in",
"[",
"QtCore",
".",
"Qt",
".",
"Key_Backspace",
",",
"QtCore",
".",
"Qt",
".",
"Key_Delete",
"]",
"if",
"event",
".",
"text",
"... | Override key press to select the current scope if the user wants
to deleted a folded scope (without selecting it). | [
"Override",
"key",
"press",
"to",
"select",
"the",
"current",
"scope",
"if",
"the",
"user",
"wants",
"to",
"deleted",
"a",
"folded",
"scope",
"(",
"without",
"selecting",
"it",
")",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/folding.py#L642-L674 |
pyQode/pyqode.core | pyqode/core/modes/autoindent.py | AutoIndentMode._on_key_pressed | def _on_key_pressed(self, event):
"""
Auto indent if the released key is the return key.
:param event: the key event
"""
if not event.isAccepted():
if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
cursor = self.editor.textCursor()
... | python | def _on_key_pressed(self, event):
"""
Auto indent if the released key is the return key.
:param event: the key event
"""
if not event.isAccepted():
if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
cursor = self.editor.textCursor()
... | [
"def",
"_on_key_pressed",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"event",
".",
"isAccepted",
"(",
")",
":",
"if",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_Return",
"or",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_... | Auto indent if the released key is the return key.
:param event: the key event | [
"Auto",
"indent",
"if",
"the",
"released",
"key",
"is",
"the",
"return",
"key",
".",
":",
"param",
"event",
":",
"the",
"key",
"event"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/autoindent.py#L35-L55 |
bmwcarit/zubbi | zubbi/views.py | WebhookView.verify_signature | def verify_signature(self, payload, headers):
"""Verify that the payload was sent from our GitHub instance."""
github_signature = headers.get("x-hub-signature")
if not github_signature:
json_abort(401, "X-Hub-Signature header missing.")
gh_webhook_secret = current_app.config... | python | def verify_signature(self, payload, headers):
"""Verify that the payload was sent from our GitHub instance."""
github_signature = headers.get("x-hub-signature")
if not github_signature:
json_abort(401, "X-Hub-Signature header missing.")
gh_webhook_secret = current_app.config... | [
"def",
"verify_signature",
"(",
"self",
",",
"payload",
",",
"headers",
")",
":",
"github_signature",
"=",
"headers",
".",
"get",
"(",
"\"x-hub-signature\"",
")",
"if",
"not",
"github_signature",
":",
"json_abort",
"(",
"401",
",",
"\"X-Hub-Signature header missin... | Verify that the payload was sent from our GitHub instance. | [
"Verify",
"that",
"the",
"payload",
"was",
"sent",
"from",
"our",
"GitHub",
"instance",
"."
] | train | https://github.com/bmwcarit/zubbi/blob/b99dfd6113c0351f13876f4172648c2eb63468ba/zubbi/views.py#L293-L307 |
psphere-project/psphere | psphere/scripting.py | BaseScript.get_options | def get_options(self):
"""Get the options that have been set.
Called after the user has added all their own options
and is ready to use the variables.
"""
(options, args) = self.parser.parse_args()
# Set values from .visdkrc, but only if they haven't already been set
... | python | def get_options(self):
"""Get the options that have been set.
Called after the user has added all their own options
and is ready to use the variables.
"""
(options, args) = self.parser.parse_args()
# Set values from .visdkrc, but only if they haven't already been set
... | [
"def",
"get_options",
"(",
"self",
")",
":",
"(",
"options",
",",
"args",
")",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
")",
"# Set values from .visdkrc, but only if they haven't already been set",
"visdkrc_opts",
"=",
"self",
".",
"read_visdkrc",
"(",
... | Get the options that have been set.
Called after the user has added all their own options
and is ready to use the variables. | [
"Get",
"the",
"options",
"that",
"have",
"been",
"set",
"."
] | train | https://github.com/psphere-project/psphere/blob/83a252e037c3d6e4f18bcd37380998bc9535e591/psphere/scripting.py#L49-L72 |
bmwcarit/zubbi | zubbi/scraper/repo_parser.py | RepoParser.parse_job_files | def parse_job_files(self):
"""Check for job definitions in known zuul files."""
repo_jobs = []
for rel_job_file_path, job_info in self.job_files.items():
LOGGER.debug("Checking for job definitions in %s", rel_job_file_path)
jobs = self.parse_job_definitions(rel_job_file_p... | python | def parse_job_files(self):
"""Check for job definitions in known zuul files."""
repo_jobs = []
for rel_job_file_path, job_info in self.job_files.items():
LOGGER.debug("Checking for job definitions in %s", rel_job_file_path)
jobs = self.parse_job_definitions(rel_job_file_p... | [
"def",
"parse_job_files",
"(",
"self",
")",
":",
"repo_jobs",
"=",
"[",
"]",
"for",
"rel_job_file_path",
",",
"job_info",
"in",
"self",
".",
"job_files",
".",
"items",
"(",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Checking for job definitions in %s\"",
",",
... | Check for job definitions in known zuul files. | [
"Check",
"for",
"job",
"definitions",
"in",
"known",
"zuul",
"files",
"."
] | train | https://github.com/bmwcarit/zubbi/blob/b99dfd6113c0351f13876f4172648c2eb63468ba/zubbi/scraper/repo_parser.py#L45-L60 |
pyQode/pyqode.core | pyqode/core/widgets/terminal.py | Terminal.change_directory | def change_directory(self, directory):
"""
Changes the current directory.
Change is made by running a "cd" command followed by a "clear" command.
:param directory:
:return:
"""
self._process.write(('cd %s\n' % directory).encode())
if sys.platform == 'win3... | python | def change_directory(self, directory):
"""
Changes the current directory.
Change is made by running a "cd" command followed by a "clear" command.
:param directory:
:return:
"""
self._process.write(('cd %s\n' % directory).encode())
if sys.platform == 'win3... | [
"def",
"change_directory",
"(",
"self",
",",
"directory",
")",
":",
"self",
".",
"_process",
".",
"write",
"(",
"(",
"'cd %s\\n'",
"%",
"directory",
")",
".",
"encode",
"(",
")",
")",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"self",
".",
"... | Changes the current directory.
Change is made by running a "cd" command followed by a "clear" command.
:param directory:
:return: | [
"Changes",
"the",
"current",
"directory",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/terminal.py#L49-L62 |
pyQode/pyqode.core | pyqode/core/panels/marker.py | Marker.icon | def icon(self):
"""
Gets the icon file name. Read-only.
"""
if isinstance(self._icon, str):
if QtGui.QIcon.hasThemeIcon(self._icon):
return QtGui.QIcon.fromTheme(self._icon)
else:
return QtGui.QIcon(self._icon)
elif isinstan... | python | def icon(self):
"""
Gets the icon file name. Read-only.
"""
if isinstance(self._icon, str):
if QtGui.QIcon.hasThemeIcon(self._icon):
return QtGui.QIcon.fromTheme(self._icon)
else:
return QtGui.QIcon(self._icon)
elif isinstan... | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_icon",
",",
"str",
")",
":",
"if",
"QtGui",
".",
"QIcon",
".",
"hasThemeIcon",
"(",
"self",
".",
"_icon",
")",
":",
"return",
"QtGui",
".",
"QIcon",
".",
"fromTheme",
"("... | Gets the icon file name. Read-only. | [
"Gets",
"the",
"icon",
"file",
"name",
".",
"Read",
"-",
"only",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L36-L50 |
pyQode/pyqode.core | pyqode/core/panels/marker.py | MarkerPanel.add_marker | def add_marker(self, marker):
"""
Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker
"""
self._markers.append(marker)
doc = self.editor.document()
assert isinstance(doc, QtGui.QTextDocument)
block = d... | python | def add_marker(self, marker):
"""
Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker
"""
self._markers.append(marker)
doc = self.editor.document()
assert isinstance(doc, QtGui.QTextDocument)
block = d... | [
"def",
"add_marker",
"(",
"self",
",",
"marker",
")",
":",
"self",
".",
"_markers",
".",
"append",
"(",
"marker",
")",
"doc",
"=",
"self",
".",
"editor",
".",
"document",
"(",
")",
"assert",
"isinstance",
"(",
"doc",
",",
"QtGui",
".",
"QTextDocument",... | Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker | [
"Adds",
"the",
"marker",
"to",
"the",
"panel",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L128-L146 |
pyQode/pyqode.core | pyqode/core/panels/marker.py | MarkerPanel.remove_marker | def remove_marker(self, marker):
"""
Removes a marker from the panel
:param marker: Marker to remove
:type marker: pyqode.core.Marker
"""
self._markers.remove(marker)
self._to_remove.append(marker)
if hasattr(marker, 'decoration'):
self.editor... | python | def remove_marker(self, marker):
"""
Removes a marker from the panel
:param marker: Marker to remove
:type marker: pyqode.core.Marker
"""
self._markers.remove(marker)
self._to_remove.append(marker)
if hasattr(marker, 'decoration'):
self.editor... | [
"def",
"remove_marker",
"(",
"self",
",",
"marker",
")",
":",
"self",
".",
"_markers",
".",
"remove",
"(",
"marker",
")",
"self",
".",
"_to_remove",
".",
"append",
"(",
"marker",
")",
"if",
"hasattr",
"(",
"marker",
",",
"'decoration'",
")",
":",
"self... | Removes a marker from the panel
:param marker: Marker to remove
:type marker: pyqode.core.Marker | [
"Removes",
"a",
"marker",
"from",
"the",
"panel"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L148-L159 |
pyQode/pyqode.core | pyqode/core/panels/marker.py | MarkerPanel.marker_for_line | def marker_for_line(self, line):
"""
Returns the marker that is displayed at the specified line number if
any.
:param line: The marker line.
:return: Marker of None
:rtype: pyqode.core.Marker
"""
markers = []
for marker in self._markers:
... | python | def marker_for_line(self, line):
"""
Returns the marker that is displayed at the specified line number if
any.
:param line: The marker line.
:return: Marker of None
:rtype: pyqode.core.Marker
"""
markers = []
for marker in self._markers:
... | [
"def",
"marker_for_line",
"(",
"self",
",",
"line",
")",
":",
"markers",
"=",
"[",
"]",
"for",
"marker",
"in",
"self",
".",
"_markers",
":",
"if",
"line",
"==",
"marker",
".",
"position",
":",
"markers",
".",
"append",
"(",
"marker",
")",
"return",
"... | Returns the marker that is displayed at the specified line number if
any.
:param line: The marker line.
:return: Marker of None
:rtype: pyqode.core.Marker | [
"Returns",
"the",
"marker",
"that",
"is",
"displayed",
"at",
"the",
"specified",
"line",
"number",
"if",
"any",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L166-L180 |
pyQode/pyqode.core | pyqode/core/panels/marker.py | MarkerPanel._display_tooltip | def _display_tooltip(self, tooltip, top):
"""
Display tooltip at the specified top position.
"""
QtWidgets.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(
self.sizeHint().width(), top)), tooltip, self) | python | def _display_tooltip(self, tooltip, top):
"""
Display tooltip at the specified top position.
"""
QtWidgets.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(
self.sizeHint().width(), top)), tooltip, self) | [
"def",
"_display_tooltip",
"(",
"self",
",",
"tooltip",
",",
"top",
")",
":",
"QtWidgets",
".",
"QToolTip",
".",
"showText",
"(",
"self",
".",
"mapToGlobal",
"(",
"QtCore",
".",
"QPoint",
"(",
"self",
".",
"sizeHint",
"(",
")",
".",
"width",
"(",
")",
... | Display tooltip at the specified top position. | [
"Display",
"tooltip",
"at",
"the",
"specified",
"top",
"position",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L244-L249 |
pyQode/pyqode.core | pyqode/core/backend/workers.py | finditer_noregex | def finditer_noregex(string, sub, whole_word):
"""
Search occurrences using str.find instead of regular expressions.
:param string: string to parse
:param sub: search string
:param whole_word: True to select whole words only
"""
start = 0
while True:
start = string.find(sub, sta... | python | def finditer_noregex(string, sub, whole_word):
"""
Search occurrences using str.find instead of regular expressions.
:param string: string to parse
:param sub: search string
:param whole_word: True to select whole words only
"""
start = 0
while True:
start = string.find(sub, sta... | [
"def",
"finditer_noregex",
"(",
"string",
",",
"sub",
",",
"whole_word",
")",
":",
"start",
"=",
"0",
"while",
"True",
":",
"start",
"=",
"string",
".",
"find",
"(",
"sub",
",",
"start",
")",
"if",
"start",
"==",
"-",
"1",
":",
"return",
"if",
"who... | Search occurrences using str.find instead of regular expressions.
:param string: string to parse
:param sub: search string
:param whole_word: True to select whole words only | [
"Search",
"occurrences",
"using",
"str",
".",
"find",
"instead",
"of",
"regular",
"expressions",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L171-L199 |
pyQode/pyqode.core | pyqode/core/backend/workers.py | findalliter | def findalliter(string, sub, regex=False, case_sensitive=False,
whole_word=False):
"""
Generator that finds all occurrences of ``sub`` in ``string``
:param string: string to parse
:param sub: string to search
:param regex: True to search using regex
:param case_sensitive: True t... | python | def findalliter(string, sub, regex=False, case_sensitive=False,
whole_word=False):
"""
Generator that finds all occurrences of ``sub`` in ``string``
:param string: string to parse
:param sub: string to search
:param regex: True to search using regex
:param case_sensitive: True t... | [
"def",
"findalliter",
"(",
"string",
",",
"sub",
",",
"regex",
"=",
"False",
",",
"case_sensitive",
"=",
"False",
",",
"whole_word",
"=",
"False",
")",
":",
"if",
"not",
"sub",
":",
"return",
"if",
"regex",
":",
"flags",
"=",
"re",
".",
"MULTILINE",
... | Generator that finds all occurrences of ``sub`` in ``string``
:param string: string to parse
:param sub: string to search
:param regex: True to search using regex
:param case_sensitive: True to match case, False to ignore case
:param whole_word: True to returns only whole words
:return: | [
"Generator",
"that",
"finds",
"all",
"occurrences",
"of",
"sub",
"in",
"string",
":",
"param",
"string",
":",
"string",
"to",
"parse",
":",
"param",
"sub",
":",
"string",
"to",
"search",
":",
"param",
"regex",
":",
"True",
"to",
"search",
"using",
"regex... | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L202-L226 |
pyQode/pyqode.core | pyqode/core/backend/workers.py | findall | def findall(data):
"""
Worker that finds all occurrences of a given string (or regex)
in a given text.
:param data: Request data dict::
{
'string': string to search in text
'sub': input text
'regex': True to consider string as a regular expression
... | python | def findall(data):
"""
Worker that finds all occurrences of a given string (or regex)
in a given text.
:param data: Request data dict::
{
'string': string to search in text
'sub': input text
'regex': True to consider string as a regular expression
... | [
"def",
"findall",
"(",
"data",
")",
":",
"return",
"list",
"(",
"findalliter",
"(",
"data",
"[",
"'string'",
"]",
",",
"data",
"[",
"'sub'",
"]",
",",
"regex",
"=",
"data",
"[",
"'regex'",
"]",
",",
"whole_word",
"=",
"data",
"[",
"'whole_word'",
"]"... | Worker that finds all occurrences of a given string (or regex)
in a given text.
:param data: Request data dict::
{
'string': string to search in text
'sub': input text
'regex': True to consider string as a regular expression
'whole_word': True to match wh... | [
"Worker",
"that",
"finds",
"all",
"occurrences",
"of",
"a",
"given",
"string",
"(",
"or",
"regex",
")",
"in",
"a",
"given",
"text",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L229-L246 |
pyQode/pyqode.core | pyqode/core/backend/workers.py | DocumentWordsProvider.split | def split(txt, seps):
"""
Splits a text in a meaningful list of words based on a list of word
separators (define in pyqode.core.settings)
:param txt: Text to split
:param seps: List of words separators
:return: A **set** of words found in the document (excluding
... | python | def split(txt, seps):
"""
Splits a text in a meaningful list of words based on a list of word
separators (define in pyqode.core.settings)
:param txt: Text to split
:param seps: List of words separators
:return: A **set** of words found in the document (excluding
... | [
"def",
"split",
"(",
"txt",
",",
"seps",
")",
":",
"# replace all possible separators with a default sep",
"default_sep",
"=",
"seps",
"[",
"0",
"]",
"for",
"sep",
"in",
"seps",
"[",
"1",
":",
"]",
":",
"if",
"sep",
":",
"txt",
"=",
"txt",
".",
"replace"... | Splits a text in a meaningful list of words based on a list of word
separators (define in pyqode.core.settings)
:param txt: Text to split
:param seps: List of words separators
:return: A **set** of words found in the document (excluding
punctuations, numbers, ...) | [
"Splits",
"a",
"text",
"in",
"a",
"meaningful",
"list",
"of",
"words",
"based",
"on",
"a",
"list",
"of",
"word",
"separators",
"(",
"define",
"in",
"pyqode",
".",
"core",
".",
"settings",
")"
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/backend/workers.py#L134-L156 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.