repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
creare-com/pydem
pydem/utils.py
parse_fn
def parse_fn(fn): """ This parses the file name and returns the coordinates of the tile Parameters ----------- fn : str Filename of a GEOTIFF Returns -------- coords = [LLC.lat, LLC.lon, URC.lat, URC.lon] """ try: parts = os.path.splitext(os.path.split(fn)[-1])[0].r...
python
def parse_fn(fn): """ This parses the file name and returns the coordinates of the tile Parameters ----------- fn : str Filename of a GEOTIFF Returns -------- coords = [LLC.lat, LLC.lon, URC.lat, URC.lon] """ try: parts = os.path.splitext(os.path.split(fn)[-1])[0].r...
[ "def", "parse_fn", "(", "fn", ")", ":", "try", ":", "parts", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "split", "(", "fn", ")", "[", "-", "1", "]", ")", "[", "0", "]", ".", "replace", "(", "'o'", ",", "'.'", ")",...
This parses the file name and returns the coordinates of the tile Parameters ----------- fn : str Filename of a GEOTIFF Returns -------- coords = [LLC.lat, LLC.lon, URC.lat, URC.lon]
[ "This", "parses", "the", "file", "name", "and", "returns", "the", "coordinates", "of", "the", "tile" ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L77-L96
train
This function parses the file name and returns the coordinates of the tile WorkItem.
creare-com/pydem
pydem/utils.py
get_fn
def get_fn(elev, name=None): """ Determines the standard filename for a given GeoTIFF Layer. Parameters ----------- elev : GdalReader.raster_layer A raster layer from the GdalReader object. name : str (optional) An optional suffix to the filename. Returns ------- fn ...
python
def get_fn(elev, name=None): """ Determines the standard filename for a given GeoTIFF Layer. Parameters ----------- elev : GdalReader.raster_layer A raster layer from the GdalReader object. name : str (optional) An optional suffix to the filename. Returns ------- fn ...
[ "def", "get_fn", "(", "elev", ",", "name", "=", "None", ")", ":", "gcs", "=", "elev", ".", "grid_coordinates", "coords", "=", "[", "gcs", ".", "LLC", ".", "lat", ",", "gcs", ".", "LLC", ".", "lon", ",", "gcs", ".", "URC", ".", "lat", ",", "gcs"...
Determines the standard filename for a given GeoTIFF Layer. Parameters ----------- elev : GdalReader.raster_layer A raster layer from the GdalReader object. name : str (optional) An optional suffix to the filename. Returns ------- fn : str The standard <filename>_<na...
[ "Determines", "the", "standard", "filename", "for", "a", "given", "GeoTIFF", "Layer", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L99-L116
train
Determines the standard filename for a given GeoTIFF Layer.
creare-com/pydem
pydem/utils.py
get_fn_from_coords
def get_fn_from_coords(coords, name=None): """ Given a set of coordinates, returns the standard filename. Parameters ----------- coords : list [LLC.lat, LLC.lon, URC.lat, URC.lon] name : str (optional) An optional suffix to the filename. Returns ------- fn : str ...
python
def get_fn_from_coords(coords, name=None): """ Given a set of coordinates, returns the standard filename. Parameters ----------- coords : list [LLC.lat, LLC.lon, URC.lat, URC.lon] name : str (optional) An optional suffix to the filename. Returns ------- fn : str ...
[ "def", "get_fn_from_coords", "(", "coords", ",", "name", "=", "None", ")", ":", "NS1", "=", "[", "\"S\"", ",", "\"N\"", "]", "[", "coords", "[", "0", "]", ">", "0", "]", "EW1", "=", "[", "\"W\"", ",", "\"E\"", "]", "[", "coords", "[", "1", "]",...
Given a set of coordinates, returns the standard filename. Parameters ----------- coords : list [LLC.lat, LLC.lon, URC.lat, URC.lon] name : str (optional) An optional suffix to the filename. Returns ------- fn : str The standard <filename>_<name>.tif with suffix (if...
[ "Given", "a", "set", "of", "coordinates", "returns", "the", "standard", "filename", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L119-L142
train
Given a set of coordinates returns the standard filename.
creare-com/pydem
pydem/utils.py
mk_dx_dy_from_geotif_layer
def mk_dx_dy_from_geotif_layer(geotif): """ Extracts the change in x and y coordinates from the geotiff file. Presently only supports WGS-84 files. """ ELLIPSOID_MAP = {'WGS84': 'WGS-84'} ellipsoid = ELLIPSOID_MAP[geotif.grid_coordinates.wkt] d = distance(ellipsoid=ellipsoid) dx = geotif...
python
def mk_dx_dy_from_geotif_layer(geotif): """ Extracts the change in x and y coordinates from the geotiff file. Presently only supports WGS-84 files. """ ELLIPSOID_MAP = {'WGS84': 'WGS-84'} ellipsoid = ELLIPSOID_MAP[geotif.grid_coordinates.wkt] d = distance(ellipsoid=ellipsoid) dx = geotif...
[ "def", "mk_dx_dy_from_geotif_layer", "(", "geotif", ")", ":", "ELLIPSOID_MAP", "=", "{", "'WGS84'", ":", "'WGS-84'", "}", "ellipsoid", "=", "ELLIPSOID_MAP", "[", "geotif", ".", "grid_coordinates", ".", "wkt", "]", "d", "=", "distance", "(", "ellipsoid", "=", ...
Extracts the change in x and y coordinates from the geotiff file. Presently only supports WGS-84 files.
[ "Extracts", "the", "change", "in", "x", "and", "y", "coordinates", "from", "the", "geotiff", "file", ".", "Presently", "only", "supports", "WGS", "-", "84", "files", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L145-L161
train
Extracts the change in x and y coordinates from the geotiff layer. Presently only supports WGS - 84 files.
creare-com/pydem
pydem/utils.py
mk_geotiff_obj
def mk_geotiff_obj(raster, fn, bands=1, gdal_data_type=gdal.GDT_Float32, lat=[46, 45], lon=[-73, -72]): """ Creates a new geotiff file objects using the WGS84 coordinate system, saves it to disk, and returns a handle to the python file object and driver Parameters ------------ ...
python
def mk_geotiff_obj(raster, fn, bands=1, gdal_data_type=gdal.GDT_Float32, lat=[46, 45], lon=[-73, -72]): """ Creates a new geotiff file objects using the WGS84 coordinate system, saves it to disk, and returns a handle to the python file object and driver Parameters ------------ ...
[ "def", "mk_geotiff_obj", "(", "raster", ",", "fn", ",", "bands", "=", "1", ",", "gdal_data_type", "=", "gdal", ".", "GDT_Float32", ",", "lat", "=", "[", "46", ",", "45", "]", ",", "lon", "=", "[", "-", "73", ",", "-", "72", "]", ")", ":", "NNi"...
Creates a new geotiff file objects using the WGS84 coordinate system, saves it to disk, and returns a handle to the python file object and driver Parameters ------------ raster : array Numpy array of the raster data to be added to the object fn : str Name of the geotiff file ban...
[ "Creates", "a", "new", "geotiff", "file", "objects", "using", "the", "WGS84", "coordinate", "system", "saves", "it", "to", "disk", "and", "returns", "a", "handle", "to", "the", "python", "file", "object", "and", "driver" ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L164-L195
train
Create a new geotiff file object and return a handle to it and driver
creare-com/pydem
pydem/utils.py
sortrows
def sortrows(a, i=0, index_out=False, recurse=True): """ Sorts array "a" by columns i Parameters ------------ a : np.ndarray array to be sorted i : int (optional) column to be sorted by, taken as 0 by default index_out : bool (optional) return the index I such that a(I) ...
python
def sortrows(a, i=0, index_out=False, recurse=True): """ Sorts array "a" by columns i Parameters ------------ a : np.ndarray array to be sorted i : int (optional) column to be sorted by, taken as 0 by default index_out : bool (optional) return the index I such that a(I) ...
[ "def", "sortrows", "(", "a", ",", "i", "=", "0", ",", "index_out", "=", "False", ",", "recurse", "=", "True", ")", ":", "I", "=", "np", ".", "argsort", "(", "a", "[", ":", ",", "i", "]", ")", "a", "=", "a", "[", "I", ",", ":", "]", "# We ...
Sorts array "a" by columns i Parameters ------------ a : np.ndarray array to be sorted i : int (optional) column to be sorted by, taken as 0 by default index_out : bool (optional) return the index I such that a(I) = sortrows(a,i). Default = False recurse : bool (optional...
[ "Sorts", "array", "a", "by", "columns", "i" ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L198-L258
train
Sorts array a in descending order by column i.
creare-com/pydem
pydem/utils.py
get_adjacent_index
def get_adjacent_index(I, shape, size): """ Find indices 2d-adjacent to those in I. Helper function for get_border*. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region shape : tuple(int, int) region shape size : int region size (technical...
python
def get_adjacent_index(I, shape, size): """ Find indices 2d-adjacent to those in I. Helper function for get_border*. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region shape : tuple(int, int) region shape size : int region size (technical...
[ "def", "get_adjacent_index", "(", "I", ",", "shape", ",", "size", ")", ":", "m", ",", "n", "=", "shape", "In", "=", "I", "%", "n", "bL", "=", "In", "!=", "0", "bR", "=", "In", "!=", "n", "-", "1", "J", "=", "np", ".", "concatenate", "(", "[...
Find indices 2d-adjacent to those in I. Helper function for get_border*. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region shape : tuple(int, int) region shape size : int region size (technically computable from shape) Returns ------- ...
[ "Find", "indices", "2d", "-", "adjacent", "to", "those", "in", "I", ".", "Helper", "function", "for", "get_border", "*", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L260-L301
train
Returns indices of 2d adjacent to those in I. Helper function for get_border.
creare-com/pydem
pydem/utils.py
get_border_index
def get_border_index(I, shape, size): """ Get flattened indices for the border of the region I. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region. size : int region size (technically computable from shape argument) shape : tuple(int, int) ...
python
def get_border_index(I, shape, size): """ Get flattened indices for the border of the region I. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region. size : int region size (technically computable from shape argument) shape : tuple(int, int) ...
[ "def", "get_border_index", "(", "I", ",", "shape", ",", "size", ")", ":", "J", "=", "get_adjacent_index", "(", "I", ",", "shape", ",", "size", ")", "# instead of setdiff?", "# border = np.zeros(size)", "# border[J] = 1", "# border[I] = 0", "# J, = np.where(border)", ...
Get flattened indices for the border of the region I. Parameters ---------- I : np.ndarray(dtype=int) indices in the flattened region. size : int region size (technically computable from shape argument) shape : tuple(int, int) region shape Returns ------- J : np...
[ "Get", "flattened", "indices", "for", "the", "border", "of", "the", "region", "I", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L303-L330
train
Returns the indices of the border of the region I.
creare-com/pydem
pydem/utils.py
get_border_mask
def get_border_mask(region): """ Get border of the region as a boolean array mask. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region Returns ------- border : np.ndarray(shape=(m, n), dtype=bool) mask of the region border (not includi...
python
def get_border_mask(region): """ Get border of the region as a boolean array mask. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region Returns ------- border : np.ndarray(shape=(m, n), dtype=bool) mask of the region border (not includi...
[ "def", "get_border_mask", "(", "region", ")", ":", "# common special case (for efficiency)", "internal", "=", "region", "[", "1", ":", "-", "1", ",", "1", ":", "-", "1", "]", "if", "internal", ".", "all", "(", ")", "and", "internal", ".", "any", "(", "...
Get border of the region as a boolean array mask. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region Returns ------- border : np.ndarray(shape=(m, n), dtype=bool) mask of the region border (not including region)
[ "Get", "border", "of", "the", "region", "as", "a", "boolean", "array", "mask", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L332-L360
train
Returns a boolean array mask of the border of the region.
creare-com/pydem
pydem/utils.py
get_distance
def get_distance(region, src): """ Compute within-region distances from the src pixels. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region src : np.ndarray(shape=(m, n), dtype=bool) mask of the source pixels to compute distances from. Ret...
python
def get_distance(region, src): """ Compute within-region distances from the src pixels. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region src : np.ndarray(shape=(m, n), dtype=bool) mask of the source pixels to compute distances from. Ret...
[ "def", "get_distance", "(", "region", ",", "src", ")", ":", "dmax", "=", "float", "(", "region", ".", "size", ")", "d", "=", "np", ".", "full", "(", "region", ".", "shape", ",", "dmax", ")", "d", "[", "src", "]", "=", "0", "for", "n", "in", "...
Compute within-region distances from the src pixels. Parameters ---------- region : np.ndarray(shape=(m, n), dtype=bool) mask of the region src : np.ndarray(shape=(m, n), dtype=bool) mask of the source pixels to compute distances from. Returns ------- d : np.ndarray(shape=(...
[ "Compute", "within", "-", "region", "distances", "from", "the", "src", "pixels", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L364-L392
train
Compute within - region distances from the nearest src pixel.
creare-com/pydem
pydem/utils.py
grow_slice
def grow_slice(slc, size): """ Grow a slice object by 1 in each direction without overreaching the list. Parameters ---------- slc: slice slice object to grow size: int list length Returns ------- slc: slice extended slice """ return slice(max(0, s...
python
def grow_slice(slc, size): """ Grow a slice object by 1 in each direction without overreaching the list. Parameters ---------- slc: slice slice object to grow size: int list length Returns ------- slc: slice extended slice """ return slice(max(0, s...
[ "def", "grow_slice", "(", "slc", ",", "size", ")", ":", "return", "slice", "(", "max", "(", "0", ",", "slc", ".", "start", "-", "1", ")", ",", "min", "(", "size", ",", "slc", ".", "stop", "+", "1", ")", ")" ]
Grow a slice object by 1 in each direction without overreaching the list. Parameters ---------- slc: slice slice object to grow size: int list length Returns ------- slc: slice extended slice
[ "Grow", "a", "slice", "object", "by", "1", "in", "each", "direction", "without", "overreaching", "the", "list", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L400-L418
train
Grow a slice object by 1 in each direction without overreaching the list.
creare-com/pydem
pydem/utils.py
is_edge
def is_edge(obj, shape): """ Check if a 2d object is on the edge of the array. Parameters ---------- obj : tuple(slice, slice) Pair of slices (e.g. from scipy.ndimage.measurements.find_objects) shape : tuple(int, int) Array shape. Returns ------- b : boolean ...
python
def is_edge(obj, shape): """ Check if a 2d object is on the edge of the array. Parameters ---------- obj : tuple(slice, slice) Pair of slices (e.g. from scipy.ndimage.measurements.find_objects) shape : tuple(int, int) Array shape. Returns ------- b : boolean ...
[ "def", "is_edge", "(", "obj", ",", "shape", ")", ":", "if", "obj", "[", "0", "]", ".", "start", "==", "0", ":", "return", "True", "if", "obj", "[", "1", "]", ".", "start", "==", "0", ":", "return", "True", "if", "obj", "[", "0", "]", ".", "...
Check if a 2d object is on the edge of the array. Parameters ---------- obj : tuple(slice, slice) Pair of slices (e.g. from scipy.ndimage.measurements.find_objects) shape : tuple(int, int) Array shape. Returns ------- b : boolean True if the object touches any edge ...
[ "Check", "if", "a", "2d", "object", "is", "on", "the", "edge", "of", "the", "array", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L439-L460
train
Check if a 2d object is on the edge of the array.
creare-com/pydem
pydem/utils.py
find_centroid
def find_centroid(region): """ Finds an approximate centroid for a region that is within the region. Parameters ---------- region : np.ndarray(shape=(m, n), dtype='bool') mask of the region. Returns ------- i, j : tuple(int, int) 2d index within the region nearest t...
python
def find_centroid(region): """ Finds an approximate centroid for a region that is within the region. Parameters ---------- region : np.ndarray(shape=(m, n), dtype='bool') mask of the region. Returns ------- i, j : tuple(int, int) 2d index within the region nearest t...
[ "def", "find_centroid", "(", "region", ")", ":", "x", ",", "y", "=", "center_of_mass", "(", "region", ")", "w", "=", "np", ".", "argwhere", "(", "region", ")", "i", ",", "j", "=", "w", "[", "np", ".", "argmin", "(", "np", ".", "linalg", ".", "n...
Finds an approximate centroid for a region that is within the region. Parameters ---------- region : np.ndarray(shape=(m, n), dtype='bool') mask of the region. Returns ------- i, j : tuple(int, int) 2d index within the region nearest the center of mass.
[ "Finds", "an", "approximate", "centroid", "for", "a", "region", "that", "is", "within", "the", "region", ".", "Parameters", "----------", "region", ":", "np", ".", "ndarray", "(", "shape", "=", "(", "m", "n", ")", "dtype", "=", "bool", ")", "mask", "of...
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/utils.py#L462-L480
train
Finds an approximate centroid for a region that is within the region.
thefab/tornadis
tornadis/write_buffer.py
WriteBuffer.clear
def clear(self): """Resets the object at its initial (empty) state.""" self._deque.clear() self._total_length = 0 self._has_view = False
python
def clear(self): """Resets the object at its initial (empty) state.""" self._deque.clear() self._total_length = 0 self._has_view = False
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_deque", ".", "clear", "(", ")", "self", ".", "_total_length", "=", "0", "self", ".", "_has_view", "=", "False" ]
Resets the object at its initial (empty) state.
[ "Resets", "the", "object", "at", "its", "initial", "(", "empty", ")", "state", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L39-L43
train
Resets the object at its initial state.
thefab/tornadis
tornadis/write_buffer.py
WriteBuffer._tobytes
def _tobytes(self): """Serializes the write buffer into a single string (bytes). Returns: a string (bytes) object. """ if not self._has_view: # fast path optimization if len(self._deque) == 0: return b"" elif len(self._dequ...
python
def _tobytes(self): """Serializes the write buffer into a single string (bytes). Returns: a string (bytes) object. """ if not self._has_view: # fast path optimization if len(self._deque) == 0: return b"" elif len(self._dequ...
[ "def", "_tobytes", "(", "self", ")", ":", "if", "not", "self", ".", "_has_view", ":", "# fast path optimization", "if", "len", "(", "self", ".", "_deque", ")", "==", "0", ":", "return", "b\"\"", "elif", "len", "(", "self", ".", "_deque", ")", "==", "...
Serializes the write buffer into a single string (bytes). Returns: a string (bytes) object.
[ "Serializes", "the", "write", "buffer", "into", "a", "single", "string", "(", "bytes", ")", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L54-L72
train
Serializes the write buffer into a single string ( bytes.
thefab/tornadis
tornadis/write_buffer.py
WriteBuffer.pop_chunk
def pop_chunk(self, chunk_max_size): """Pops a chunk of the given max size. Optimized to avoid too much string copies. Args: chunk_max_size (int): max size of the returned chunk. Returns: string (bytes) with a size <= chunk_max_size. """ if self...
python
def pop_chunk(self, chunk_max_size): """Pops a chunk of the given max size. Optimized to avoid too much string copies. Args: chunk_max_size (int): max size of the returned chunk. Returns: string (bytes) with a size <= chunk_max_size. """ if self...
[ "def", "pop_chunk", "(", "self", ",", "chunk_max_size", ")", ":", "if", "self", ".", "_total_length", "<", "chunk_max_size", ":", "# fastpath (the whole queue fit in a single chunk)", "res", "=", "self", ".", "_tobytes", "(", ")", "self", ".", "clear", "(", ")",...
Pops a chunk of the given max size. Optimized to avoid too much string copies. Args: chunk_max_size (int): max size of the returned chunk. Returns: string (bytes) with a size <= chunk_max_size.
[ "Pops", "a", "chunk", "of", "the", "given", "max", "size", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/write_buffer.py#L134-L190
train
Pops a chunk of the given max size.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
PurePath.with_name
def with_name(self, name): """Return a new path with the file name changed.""" if not self.name: raise ValueError("%r has an empty name" % (self,)) return self._from_parsed_parts(self._drv, self._root, self._parts[:-1] + [name])
python
def with_name(self, name): """Return a new path with the file name changed.""" if not self.name: raise ValueError("%r has an empty name" % (self,)) return self._from_parsed_parts(self._drv, self._root, self._parts[:-1] + [name])
[ "def", "with_name", "(", "self", ",", "name", ")", ":", "if", "not", "self", ".", "name", ":", "raise", "ValueError", "(", "\"%r has an empty name\"", "%", "(", "self", ",", ")", ")", "return", "self", ".", "_from_parsed_parts", "(", "self", ".", "_drv",...
Return a new path with the file name changed.
[ "Return", "a", "new", "path", "with", "the", "file", "name", "changed", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L773-L778
train
Return a new path with the file name changed.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
PurePath.with_suffix
def with_suffix(self, suffix): """Return a new path with the file suffix changed (or added, if none).""" # XXX if suffix is None, should the current suffix be removed? drv, root, parts = self._flavour.parse_parts((suffix,)) if drv or root or len(parts) != 1: raise ValueError(...
python
def with_suffix(self, suffix): """Return a new path with the file suffix changed (or added, if none).""" # XXX if suffix is None, should the current suffix be removed? drv, root, parts = self._flavour.parse_parts((suffix,)) if drv or root or len(parts) != 1: raise ValueError(...
[ "def", "with_suffix", "(", "self", ",", "suffix", ")", ":", "# XXX if suffix is None, should the current suffix be removed?", "drv", ",", "root", ",", "parts", "=", "self", ".", "_flavour", ".", "parse_parts", "(", "(", "suffix", ",", ")", ")", "if", "drv", "o...
Return a new path with the file suffix changed (or added, if none).
[ "Return", "a", "new", "path", "with", "the", "file", "suffix", "changed", "(", "or", "added", "if", "none", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L780-L798
train
Return a new path with the file suffix changed or added.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path._raw_open
def _raw_open(self, flags, mode=0o777): """ Open the file pointed by this path and return a file descriptor, as os.open() does. """ return self._accessor.open(self, flags, mode)
python
def _raw_open(self, flags, mode=0o777): """ Open the file pointed by this path and return a file descriptor, as os.open() does. """ return self._accessor.open(self, flags, mode)
[ "def", "_raw_open", "(", "self", ",", "flags", ",", "mode", "=", "0o777", ")", ":", "return", "self", ".", "_accessor", ".", "open", "(", "self", ",", "flags", ",", "mode", ")" ]
Open the file pointed by this path and return a file descriptor, as os.open() does.
[ "Open", "the", "file", "pointed", "by", "this", "path", "and", "return", "a", "file", "descriptor", "as", "os", ".", "open", "()", "does", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L962-L967
train
Open the file pointed by this path and return a file descriptor.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.iterdir
def iterdir(self): """Iterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. """ for name in self._accessor.listdir(self): if name in ('.', '..'): # Yielding a path object for these makes little sense ...
python
def iterdir(self): """Iterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. """ for name in self._accessor.listdir(self): if name in ('.', '..'): # Yielding a path object for these makes little sense ...
[ "def", "iterdir", "(", "self", ")", ":", "for", "name", "in", "self", ".", "_accessor", ".", "listdir", "(", "self", ")", ":", "if", "name", "in", "(", "'.'", ",", "'..'", ")", ":", "# Yielding a path object for these makes little sense", "continue", "yield"...
Iterate over the files in this directory. Does not yield any result for the special paths '.' and '..'.
[ "Iterate", "over", "the", "files", "in", "this", "directory", ".", "Does", "not", "yield", "any", "result", "for", "the", "special", "paths", ".", "and", "..", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L978-L986
train
Iterate over the files in this directory. Does not yield any result for the special paths....
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.absolute
def absolute(self): """Return an absolute version of this path. This function works even if the path doesn't point to anything. No normalization is done, i.e. all '.' and '..' will be kept along. Use resolve() to get the canonical path to a file. """ # XXX untested yet!...
python
def absolute(self): """Return an absolute version of this path. This function works even if the path doesn't point to anything. No normalization is done, i.e. all '.' and '..' will be kept along. Use resolve() to get the canonical path to a file. """ # XXX untested yet!...
[ "def", "absolute", "(", "self", ")", ":", "# XXX untested yet!", "if", "self", ".", "is_absolute", "(", ")", ":", "return", "self", "# FIXME this must defer to the specific flavour (and, under Windows,", "# use nt._getfullpathname())", "obj", "=", "self", ".", "_from_part...
Return an absolute version of this path. This function works even if the path doesn't point to anything. No normalization is done, i.e. all '.' and '..' will be kept along. Use resolve() to get the canonical path to a file.
[ "Return", "an", "absolute", "version", "of", "this", "path", ".", "This", "function", "works", "even", "if", "the", "path", "doesn", "t", "point", "to", "anything", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1012-L1026
train
Return an absolute version of this path.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.resolve
def resolve(self): """ Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). """ s = self._flavour.resolve(self) if s is None: # No symlink resolution => for cons...
python
def resolve(self): """ Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). """ s = self._flavour.resolve(self) if s is None: # No symlink resolution => for cons...
[ "def", "resolve", "(", "self", ")", ":", "s", "=", "self", ".", "_flavour", ".", "resolve", "(", "self", ")", "if", "s", "is", "None", ":", "# No symlink resolution => for consistency, raise an error if", "# the path doesn't exist or is forbidden", "self", ".", "sta...
Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).
[ "Make", "the", "path", "absolute", "resolving", "all", "symlinks", "on", "the", "way", "and", "also", "normalizing", "it", "(", "for", "example", "turning", "slashes", "into", "backslashes", "under", "Windows", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1028-L1044
train
Resolve the path and return a new object.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.open
def open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None): """ Open the file pointed by this path and return a file object, as the built-in open() function does. """ if sys.version_info >= (3, 3): return io.open(str(self), mode, buf...
python
def open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None): """ Open the file pointed by this path and return a file object, as the built-in open() function does. """ if sys.version_info >= (3, 3): return io.open(str(self), mode, buf...
[ "def", "open", "(", "self", ",", "mode", "=", "'r'", ",", "buffering", "=", "-", "1", ",", "encoding", "=", "None", ",", "errors", "=", "None", ",", "newline", "=", "None", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "3", "...
Open the file pointed by this path and return a file object, as the built-in open() function does.
[ "Open", "the", "file", "pointed", "by", "this", "path", "and", "return", "a", "file", "object", "as", "the", "built", "-", "in", "open", "()", "function", "does", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1067-L1077
train
Open the file pointed by this path and return a file object.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.replace
def replace(self, target): """ Rename this path to the given path, clobbering the existing destination if it exists. """ if sys.version_info < (3, 3): raise NotImplementedError("replace() is only available " "with Python 3.3 and l...
python
def replace(self, target): """ Rename this path to the given path, clobbering the existing destination if it exists. """ if sys.version_info < (3, 3): raise NotImplementedError("replace() is only available " "with Python 3.3 and l...
[ "def", "replace", "(", "self", ",", "target", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "3", ")", ":", "raise", "NotImplementedError", "(", "\"replace() is only available \"", "\"with Python 3.3 and later\"", ")", "self", ".", "_accessor", ...
Rename this path to the given path, clobbering the existing destination if it exists.
[ "Rename", "this", "path", "to", "the", "given", "path", "clobbering", "the", "existing", "destination", "if", "it", "exists", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1152-L1160
train
Rename this path to the given path clobbering the existing one.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.symlink_to
def symlink_to(self, target, target_is_directory=False): """ Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's. """ self._accessor.symlink(target, self, target_is_directory)
python
def symlink_to(self, target, target_is_directory=False): """ Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's. """ self._accessor.symlink(target, self, target_is_directory)
[ "def", "symlink_to", "(", "self", ",", "target", ",", "target_is_directory", "=", "False", ")", ":", "self", ".", "_accessor", ".", "symlink", "(", "target", ",", "self", ",", "target_is_directory", ")" ]
Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's.
[ "Make", "this", "path", "a", "symlink", "pointing", "to", "the", "given", "path", ".", "Note", "the", "order", "of", "arguments", "(", "self", "target", ")", "is", "the", "reverse", "of", "os", ".", "symlink", "s", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1162-L1167
train
Make this path a symlink pointing to the given path.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.is_symlink
def is_symlink(self): """ Whether this path is a symbolic link. """ try: return S_ISLNK(self.lstat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist return False
python
def is_symlink(self): """ Whether this path is a symbolic link. """ try: return S_ISLNK(self.lstat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist return False
[ "def", "is_symlink", "(", "self", ")", ":", "try", ":", "return", "S_ISLNK", "(", "self", ".", "lstat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "!=", "ENOENT", ":", "raise", "# Path doesn't exist", ...
Whether this path is a symbolic link.
[ "Whether", "this", "path", "is", "a", "symbolic", "link", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1210-L1220
train
Returns True if this path is a symbolic link.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.is_block_device
def is_block_device(self): """ Whether this path is a block device. """ try: return S_ISBLK(self.stat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist or is a broken symlink # (see htt...
python
def is_block_device(self): """ Whether this path is a block device. """ try: return S_ISBLK(self.stat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist or is a broken symlink # (see htt...
[ "def", "is_block_device", "(", "self", ")", ":", "try", ":", "return", "S_ISBLK", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "!=", "ENOENT", ":", "raise", "# Path doesn't exist...
Whether this path is a block device.
[ "Whether", "this", "path", "is", "a", "block", "device", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1222-L1233
train
Returns True if this path is a block device.
click-contrib/click-configfile
tasks/_vendor/pathlib.py
Path.is_char_device
def is_char_device(self): """ Whether this path is a character device. """ try: return S_ISCHR(self.stat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist or is a broken symlink # (see ...
python
def is_char_device(self): """ Whether this path is a character device. """ try: return S_ISCHR(self.stat().st_mode) except OSError as e: if e.errno != ENOENT: raise # Path doesn't exist or is a broken symlink # (see ...
[ "def", "is_char_device", "(", "self", ")", ":", "try", ":", "return", "S_ISCHR", "(", "self", ".", "stat", "(", ")", ".", "st_mode", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "!=", "ENOENT", ":", "raise", "# Path doesn't exist ...
Whether this path is a character device.
[ "Whether", "this", "path", "is", "a", "character", "device", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/pathlib.py#L1235-L1246
train
Return True if this path is a character device.
creare-com/pydem
pydem/reader/my_types.py
grid_coords_from_corners
def grid_coords_from_corners(upper_left_corner, lower_right_corner, size): ''' Points are the outer edges of the UL and LR pixels. Size is rows, columns. GC projection type is taken from Points. ''' assert upper_left_corner.wkt == lower_right_corner.wkt geotransform = np.array([upper_left_corner.lon, -(...
python
def grid_coords_from_corners(upper_left_corner, lower_right_corner, size): ''' Points are the outer edges of the UL and LR pixels. Size is rows, columns. GC projection type is taken from Points. ''' assert upper_left_corner.wkt == lower_right_corner.wkt geotransform = np.array([upper_left_corner.lon, -(...
[ "def", "grid_coords_from_corners", "(", "upper_left_corner", ",", "lower_right_corner", ",", "size", ")", ":", "assert", "upper_left_corner", ".", "wkt", "==", "lower_right_corner", ".", "wkt", "geotransform", "=", "np", ".", "array", "(", "[", "upper_left_corner", ...
Points are the outer edges of the UL and LR pixels. Size is rows, columns. GC projection type is taken from Points.
[ "Points", "are", "the", "outer", "edges", "of", "the", "UL", "and", "LR", "pixels", ".", "Size", "is", "rows", "columns", ".", "GC", "projection", "type", "is", "taken", "from", "Points", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L150-L159
train
Returns a GridCoordinates object for the given upper left corner and lower right corner.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates.intersects
def intersects(self, other_grid_coordinates): """ returns True if the GC's overlap. """ ogc = other_grid_coordinates # alias # for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other # Note the flipped y-coord in this coord system. ...
python
def intersects(self, other_grid_coordinates): """ returns True if the GC's overlap. """ ogc = other_grid_coordinates # alias # for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other # Note the flipped y-coord in this coord system. ...
[ "def", "intersects", "(", "self", ",", "other_grid_coordinates", ")", ":", "ogc", "=", "other_grid_coordinates", "# alias", "# for explanation: http://stackoverflow.com/questions/306316/determine-if-two-rectangles-overlap-each-other", "# Note the flipped y-coord in this coord system.", "...
returns True if the GC's overlap.
[ "returns", "True", "if", "the", "GC", "s", "overlap", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L191-L201
train
returns True if the GC s overlap.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates.unique_str
def unique_str(self): """ A string that (ideally) uniquely represents this GC object. This helps with naming files for caching. 'Unique' is defined as 'If GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely, 'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'. ...
python
def unique_str(self): """ A string that (ideally) uniquely represents this GC object. This helps with naming files for caching. 'Unique' is defined as 'If GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely, 'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'. ...
[ "def", "unique_str", "(", "self", ")", ":", "unique_str", "=", "\"_\"", ".", "join", "(", "[", "\"%.3f\"", "%", "f", "for", "f", "in", "self", ".", "geotransform", "]", "+", "[", "\"%d\"", "%", "d", "for", "d", "in", "self", ".", "x_size", ",", "...
A string that (ideally) uniquely represents this GC object. This helps with naming files for caching. 'Unique' is defined as 'If GC1 != GC2, then GC1.unique_str() != GC2.unique_str()'; conversely, 'If GC1 == GC2, then GC1.unique_str() == GC2.unique_str()'. The string should be filename-...
[ "A", "string", "that", "(", "ideally", ")", "uniquely", "represents", "this", "GC", "object", ".", "This", "helps", "with", "naming", "files", "for", "caching", ".", "Unique", "is", "defined", "as", "If", "GC1", "!", "=", "GC2", "then", "GC1", ".", "un...
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L205-L227
train
A string that uniquely represents this object.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates._get_x_axis
def _get_x_axis(self): """See http://www.gdal.org/gdal_datamodel.html for details.""" # 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5). x_centers = np.linspace(.5, self.x_size - .5, self.x_size) y_centers = x_centers * 0 return (self.geotransform[0...
python
def _get_x_axis(self): """See http://www.gdal.org/gdal_datamodel.html for details.""" # 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5). x_centers = np.linspace(.5, self.x_size - .5, self.x_size) y_centers = x_centers * 0 return (self.geotransform[0...
[ "def", "_get_x_axis", "(", "self", ")", ":", "# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).", "x_centers", "=", "np", ".", "linspace", "(", ".5", ",", "self", ".", "x_size", "-", ".5", ",", "self", ".", "x_size", ")", "y_centers",...
See http://www.gdal.org/gdal_datamodel.html for details.
[ "See", "http", ":", "//", "www", ".", "gdal", ".", "org", "/", "gdal_datamodel", ".", "html", "for", "details", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L244-L251
train
Get the x axis of the image.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates._get_y_axis
def _get_y_axis(self): """See http://www.gdal.org/gdal_datamodel.html for details.""" # 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5). y_centers = np.linspace(.5, self.y_size - .5, self.y_size) x_centers = y_centers * 0 return (self.geotransform[3...
python
def _get_y_axis(self): """See http://www.gdal.org/gdal_datamodel.html for details.""" # 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5). y_centers = np.linspace(.5, self.y_size - .5, self.y_size) x_centers = y_centers * 0 return (self.geotransform[3...
[ "def", "_get_y_axis", "(", "self", ")", ":", "# 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).", "y_centers", "=", "np", ".", "linspace", "(", ".5", ",", "self", ".", "y_size", "-", ".5", ",", "self", ".", "y_size", ")", "x_centers",...
See http://www.gdal.org/gdal_datamodel.html for details.
[ "See", "http", ":", "//", "www", ".", "gdal", ".", "org", "/", "gdal_datamodel", ".", "html", "for", "details", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L254-L261
train
Get the y axis of the logarithmic data.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates.raster_to_projection_coords
def raster_to_projection_coords(self, pixel_x, pixel_y): """ Use pixel centers when appropriate. See documentation for the GDAL function GetGeoTransform for details. """ h_px_py = np.array([1, pixel_x, pixel_y]) gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]) ...
python
def raster_to_projection_coords(self, pixel_x, pixel_y): """ Use pixel centers when appropriate. See documentation for the GDAL function GetGeoTransform for details. """ h_px_py = np.array([1, pixel_x, pixel_y]) gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]) ...
[ "def", "raster_to_projection_coords", "(", "self", ",", "pixel_x", ",", "pixel_y", ")", ":", "h_px_py", "=", "np", ".", "array", "(", "[", "1", ",", "pixel_x", ",", "pixel_y", "]", ")", "gt", "=", "np", ".", "array", "(", "[", "[", "1", ",", "0", ...
Use pixel centers when appropriate. See documentation for the GDAL function GetGeoTransform for details.
[ "Use", "pixel", "centers", "when", "appropriate", ".", "See", "documentation", "for", "the", "GDAL", "function", "GetGeoTransform", "for", "details", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L265-L271
train
Convert pixel coordinates to projection coordinates.
creare-com/pydem
pydem/reader/my_types.py
GridCoordinates.projection_to_raster_coords
def projection_to_raster_coords(self, lat, lon): """ Returns pixel centers. See documentation for the GDAL function GetGeoTransform for details. """ r_px_py = np.array([1, lon, lat]) tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])) return np.inner(t...
python
def projection_to_raster_coords(self, lat, lon): """ Returns pixel centers. See documentation for the GDAL function GetGeoTransform for details. """ r_px_py = np.array([1, lon, lat]) tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])) return np.inner(t...
[ "def", "projection_to_raster_coords", "(", "self", ",", "lat", ",", "lon", ")", ":", "r_px_py", "=", "np", ".", "array", "(", "[", "1", ",", "lon", ",", "lat", "]", ")", "tg", "=", "inv", "(", "np", ".", "array", "(", "[", "[", "1", ",", "0", ...
Returns pixel centers. See documentation for the GDAL function GetGeoTransform for details.
[ "Returns", "pixel", "centers", ".", "See", "documentation", "for", "the", "GDAL", "function", "GetGeoTransform", "for", "details", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L273-L278
train
Returns pixel centers.
creare-com/pydem
pydem/reader/my_types.py
AbstractDataLayer.reproject_to_grid_coordinates
def reproject_to_grid_coordinates(self, grid_coordinates, interp=gdalconst.GRA_NearestNeighbour): """ Reprojects data in this layer to match that in the GridCoordinates object. """ source_dataset = self.grid_coordinates._as_gdal_dataset() dest_dataset = grid_coordinates._as_gdal_dataset(...
python
def reproject_to_grid_coordinates(self, grid_coordinates, interp=gdalconst.GRA_NearestNeighbour): """ Reprojects data in this layer to match that in the GridCoordinates object. """ source_dataset = self.grid_coordinates._as_gdal_dataset() dest_dataset = grid_coordinates._as_gdal_dataset(...
[ "def", "reproject_to_grid_coordinates", "(", "self", ",", "grid_coordinates", ",", "interp", "=", "gdalconst", ".", "GRA_NearestNeighbour", ")", ":", "source_dataset", "=", "self", ".", "grid_coordinates", ".", "_as_gdal_dataset", "(", ")", "dest_dataset", "=", "gri...
Reprojects data in this layer to match that in the GridCoordinates object.
[ "Reprojects", "data", "in", "this", "layer", "to", "match", "that", "in", "the", "GridCoordinates", "object", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L351-L368
train
Reprojects data in this layer to match that in the GridCoordinates object.
creare-com/pydem
pydem/reader/my_types.py
AbstractDataLayer.inpaint
def inpaint(self): """ Replace masked-out elements in an array using an iterative image inpainting algorithm. """ import inpaint filled = inpaint.replace_nans(np.ma.filled(self.raster_data, np.NAN).astype(np.float32), 3, 0.01, 2) self.raster_data = np.ma.masked_invalid(filled)
python
def inpaint(self): """ Replace masked-out elements in an array using an iterative image inpainting algorithm. """ import inpaint filled = inpaint.replace_nans(np.ma.filled(self.raster_data, np.NAN).astype(np.float32), 3, 0.01, 2) self.raster_data = np.ma.masked_invalid(filled)
[ "def", "inpaint", "(", "self", ")", ":", "import", "inpaint", "filled", "=", "inpaint", ".", "replace_nans", "(", "np", ".", "ma", ".", "filled", "(", "self", ".", "raster_data", ",", "np", ".", "NAN", ")", ".", "astype", "(", "np", ".", "float32", ...
Replace masked-out elements in an array using an iterative image inpainting algorithm.
[ "Replace", "masked", "-", "out", "elements", "in", "an", "array", "using", "an", "iterative", "image", "inpainting", "algorithm", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L379-L384
train
Replace masked - out elements in an array using an iterative image inpainting algorithm.
creare-com/pydem
pydem/reader/my_types.py
AbstractRasterDataLayer.interp_value
def interp_value(self, lat, lon, indexed=False): """ Lookup a pixel value in the raster data, performing linear interpolation if necessary. Indexed ==> nearest neighbor (*fast*). """ (px, py) = self.grid_coordinates.projection_to_raster_coords(lat, lon) if indexed: return sel...
python
def interp_value(self, lat, lon, indexed=False): """ Lookup a pixel value in the raster data, performing linear interpolation if necessary. Indexed ==> nearest neighbor (*fast*). """ (px, py) = self.grid_coordinates.projection_to_raster_coords(lat, lon) if indexed: return sel...
[ "def", "interp_value", "(", "self", ",", "lat", ",", "lon", ",", "indexed", "=", "False", ")", ":", "(", "px", ",", "py", ")", "=", "self", ".", "grid_coordinates", ".", "projection_to_raster_coords", "(", "lat", ",", "lon", ")", "if", "indexed", ":", ...
Lookup a pixel value in the raster data, performing linear interpolation if necessary. Indexed ==> nearest neighbor (*fast*).
[ "Lookup", "a", "pixel", "value", "in", "the", "raster", "data", "performing", "linear", "interpolation", "if", "necessary", ".", "Indexed", "==", ">", "nearest", "neighbor", "(", "*", "fast", "*", ")", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/my_types.py#L445-L457
train
Interpolate the pixel value in the raster data.
thefab/tornadis
tornadis/pool.py
ClientPool.get_connected_client
def get_connected_client(self): """Gets a connected Client object. If max_size is reached, this method will block until a new client object is available. Returns: A Future object with connected Client instance as a result (or ClientError if there was a conne...
python
def get_connected_client(self): """Gets a connected Client object. If max_size is reached, this method will block until a new client object is available. Returns: A Future object with connected Client instance as a result (or ClientError if there was a conne...
[ "def", "get_connected_client", "(", "self", ")", ":", "if", "self", ".", "__sem", "is", "not", "None", ":", "yield", "self", ".", "__sem", ".", "acquire", "(", ")", "client", "=", "None", "newly_created", ",", "client", "=", "self", ".", "_get_client_fro...
Gets a connected Client object. If max_size is reached, this method will block until a new client object is available. Returns: A Future object with connected Client instance as a result (or ClientError if there was a connection problem)
[ "Gets", "a", "connected", "Client", "object", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L75-L95
train
Gets a connected Client object.
thefab/tornadis
tornadis/pool.py
ClientPool.get_client_nowait
def get_client_nowait(self): """Gets a Client object (not necessary connected). If max_size is reached, this method will return None (and won't block). Returns: A Client instance (not necessary connected) as result (or None). """ if self.__sem is not None: ...
python
def get_client_nowait(self): """Gets a Client object (not necessary connected). If max_size is reached, this method will return None (and won't block). Returns: A Client instance (not necessary connected) as result (or None). """ if self.__sem is not None: ...
[ "def", "get_client_nowait", "(", "self", ")", ":", "if", "self", ".", "__sem", "is", "not", "None", ":", "if", "self", ".", "__sem", ".", "_value", "==", "0", ":", "return", "None", "self", ".", "__sem", ".", "acquire", "(", ")", "_", ",", "client"...
Gets a Client object (not necessary connected). If max_size is reached, this method will return None (and won't block). Returns: A Client instance (not necessary connected) as result (or None).
[ "Gets", "a", "Client", "object", "(", "not", "necessary", "connected", ")", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L97-L110
train
Gets a Client object that is not yet available.
thefab/tornadis
tornadis/pool.py
ClientPool.connected_client
def connected_client(self): """Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance ...
python
def connected_client(self): """Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance ...
[ "def", "connected_client", "(", "self", ")", ":", "future", "=", "self", ".", "get_connected_client", "(", ")", "cb", "=", "functools", ".", "partial", "(", "self", ".", "_connected_client_release_cb", ",", "future", ")", "return", "ContextManagerFuture", "(", ...
Returns a ContextManagerFuture to be yielded in a with statement. Returns: A ContextManagerFuture object. Examples: >>> with (yield pool.connected_client()) as client: # client is a connected tornadis.Client instance # it will be automati...
[ "Returns", "a", "ContextManagerFuture", "to", "be", "yielded", "in", "a", "with", "statement", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L132-L147
train
Returns a ContextManagerFuture that is yielded in a with statement.
thefab/tornadis
tornadis/pool.py
ClientPool.release_client
def release_client(self, client): """Releases a client object to the pool. Args: client: Client object. """ if isinstance(client, Client): if not self._is_expired_client(client): LOG.debug('Client is not expired. Adding back to pool') ...
python
def release_client(self, client): """Releases a client object to the pool. Args: client: Client object. """ if isinstance(client, Client): if not self._is_expired_client(client): LOG.debug('Client is not expired. Adding back to pool') ...
[ "def", "release_client", "(", "self", ",", "client", ")", ":", "if", "isinstance", "(", "client", ",", "Client", ")", ":", "if", "not", "self", ".", "_is_expired_client", "(", "client", ")", ":", "LOG", ".", "debug", "(", "'Client is not expired. Adding back...
Releases a client object to the pool. Args: client: Client object.
[ "Releases", "a", "client", "object", "to", "the", "pool", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L153-L167
train
Releases a client object to the pool.
thefab/tornadis
tornadis/pool.py
ClientPool.destroy
def destroy(self): """Disconnects all pooled client objects.""" while True: try: client = self.__pool.popleft() if isinstance(client, Client): client.disconnect() except IndexError: break
python
def destroy(self): """Disconnects all pooled client objects.""" while True: try: client = self.__pool.popleft() if isinstance(client, Client): client.disconnect() except IndexError: break
[ "def", "destroy", "(", "self", ")", ":", "while", "True", ":", "try", ":", "client", "=", "self", ".", "__pool", ".", "popleft", "(", ")", "if", "isinstance", "(", "client", ",", "Client", ")", ":", "client", ".", "disconnect", "(", ")", "except", ...
Disconnects all pooled client objects.
[ "Disconnects", "all", "pooled", "client", "objects", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L169-L177
train
Disconnects all pooled client objects.
thefab/tornadis
tornadis/pool.py
ClientPool.preconnect
def preconnect(self, size=-1): """(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_si...
python
def preconnect(self, size=-1): """(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_si...
[ "def", "preconnect", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "size", "==", "-", "1", "and", "self", ".", "max_size", "==", "-", "1", ":", "raise", "ClientError", "(", "\"size=-1 not allowed with pool max_size=-1\"", ")", "limit", "=", "m...
(pre)Connects some or all redis clients inside the pool. Args: size (int): number of redis clients to build and to connect (-1 means all clients if pool max_size > -1) Raises: ClientError: when size == -1 and pool max_size == -1
[ "(", "pre", ")", "Connects", "some", "or", "all", "redis", "clients", "inside", "the", "pool", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pool.py#L180-L195
train
Connects some or all redis clients inside the pool.
click-contrib/click-configfile
tasks/_setup.py
setup_path
def setup_path(invoke_minversion=None): """Setup python search and add ``TASKS_VENDOR_DIR`` (if available).""" # print("INVOKE.tasks: setup_path") if not os.path.isdir(TASKS_VENDOR_DIR): print("SKIP: TASKS_VENDOR_DIR=%s is missing" % TASKS_VENDOR_DIR) return elif os.path.abspath(TASKS_VE...
python
def setup_path(invoke_minversion=None): """Setup python search and add ``TASKS_VENDOR_DIR`` (if available).""" # print("INVOKE.tasks: setup_path") if not os.path.isdir(TASKS_VENDOR_DIR): print("SKIP: TASKS_VENDOR_DIR=%s is missing" % TASKS_VENDOR_DIR) return elif os.path.abspath(TASKS_VE...
[ "def", "setup_path", "(", "invoke_minversion", "=", "None", ")", ":", "# print(\"INVOKE.tasks: setup_path\")", "if", "not", "os", ".", "path", ".", "isdir", "(", "TASKS_VENDOR_DIR", ")", ":", "print", "(", "\"SKIP: TASKS_VENDOR_DIR=%s is missing\"", "%", "TASKS_VENDOR...
Setup python search and add ``TASKS_VENDOR_DIR`` (if available).
[ "Setup", "python", "search", "and", "add", "TASKS_VENDOR_DIR", "(", "if", "available", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_setup.py#L30-L58
train
Setup python search and add TASKS_VENDOR_DIR if available.
click-contrib/click-configfile
tasks/_setup.py
require_invoke_minversion
def require_invoke_minversion(min_version, verbose=False): """Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirem...
python
def require_invoke_minversion(min_version, verbose=False): """Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirem...
[ "def", "require_invoke_minversion", "(", "min_version", ",", "verbose", "=", "False", ")", ":", "# -- REQUIRES: sys.path is setup and contains invoke", "try", ":", "import", "invoke", "invoke_version", "=", "invoke", ".", "__version__", "except", "ImportError", ":", "in...
Ensures that :mod:`invoke` has at the least the :param:`min_version`. Otherwise, :param min_version: Minimal acceptable invoke version (as string). :param verbose: Indicates if invoke.version should be shown. :raises: VersionRequirementError=SystemExit if requirement fails.
[ "Ensures", "that", ":", "mod", ":", "invoke", "has", "at", "the", "least", "the", ":", "param", ":", "min_version", ".", "Otherwise" ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_setup.py#L61-L85
train
Ensures that the current version of invoke is less than min_version.
click-contrib/click-configfile
click_configfile.py
matches_section
def matches_section(section_name): """Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass ...
python
def matches_section(section_name): """Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass ...
[ "def", "matches_section", "(", "section_name", ")", ":", "section_names", "=", "section_name", "if", "isinstance", "(", "section_name", ",", "six", ".", "string_types", ")", ":", "section_names", "=", "[", "section_name", "]", "elif", "not", "isinstance", "(", ...
Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name(s). .. sourcecode:: @matches_section("foo") class FooSchema(SectionSchema): pass @matches_section(["bar", "baz.*"]) ...
[ "Decorator", "for", "SectionSchema", "classes", "to", "define", "the", "mapping", "between", "a", "config", "section", "schema", "class", "and", "one", "or", "more", "config", "sections", "with", "matching", "name", "(", "s", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L30-L78
train
Decorator for SectionSchema classes to define the mapping between a config section schema class and one or more config sections with matching name.
click-contrib/click-configfile
click_configfile.py
assign_param_names
def assign_param_names(cls=None, param_class=None): """Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigS...
python
def assign_param_names(cls=None, param_class=None): """Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigS...
[ "def", "assign_param_names", "(", "cls", "=", "None", ",", "param_class", "=", "None", ")", ":", "if", "param_class", "is", "None", ":", "param_class", "=", "Param", "def", "decorate_class", "(", "cls", ")", ":", "for", "name", ",", "value", "in", "selec...
Class decorator to assign parameter name to instances of :class:`Param`. .. sourcecode:: @assign_param_names class ConfigSectionSchema(object): alice = Param(type=str) bob = Param(type=str) assert ConfigSectionSchema.alice.name == "alice" assert ConfigSec...
[ "Class", "decorator", "to", "assign", "parameter", "name", "to", "instances", "of", ":", "class", ":", "Param", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L81-L126
train
Class decorator to assign parameter names to instances of Param.
click-contrib/click-configfile
click_configfile.py
select_params_from_section_schema
def select_params_from_section_schema(section_schema, param_class=Param, deep=False): """Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params """ # pylint: disable=inva...
python
def select_params_from_section_schema(section_schema, param_class=Param, deep=False): """Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params """ # pylint: disable=inva...
[ "def", "select_params_from_section_schema", "(", "section_schema", ",", "param_class", "=", "Param", ",", "deep", "=", "False", ")", ":", "# pylint: disable=invalid-name", "for", "name", ",", "value", "in", "inspect", ".", "getmembers", "(", "section_schema", ")", ...
Selects the parameters of a config section schema. :param section_schema: Configuration file section schema to use. :return: Generator of params
[ "Selects", "the", "parameters", "of", "a", "config", "section", "schema", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L203-L222
train
Selects the parameters of a config file section schema.
click-contrib/click-configfile
click_configfile.py
parse_config_section
def parse_config_section(config_section, section_schema): """Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_...
python
def parse_config_section(config_section, section_schema): """Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_...
[ "def", "parse_config_section", "(", "config_section", ",", "section_schema", ")", ":", "storage", "=", "{", "}", "for", "name", ",", "param", "in", "select_params_from_section_schema", "(", "section_schema", ")", ":", "value", "=", "config_section", ".", "get", ...
Parse a config file section (INI file) by using its schema/description. .. sourcecode:: import configparser # -- NOTE: Use backport for Python2 import click from click_configfile import SectionSchema, Param, parse_config_section class ConfigSectionSchema(object): c...
[ "Parse", "a", "config", "file", "section", "(", "INI", "file", ")", "by", "using", "its", "schema", "/", "description", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L225-L274
train
Parse a config file section by using its schema and description.
click-contrib/click-configfile
click_configfile.py
generate_configfile_names
def generate_configfile_names(config_files, config_searchpath=None): """Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): ...
python
def generate_configfile_names(config_files, config_searchpath=None): """Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): ...
[ "def", "generate_configfile_names", "(", "config_files", ",", "config_searchpath", "=", "None", ")", ":", "if", "config_searchpath", "is", "None", ":", "config_searchpath", "=", "[", "\".\"", "]", "for", "config_path", "in", "reversed", "(", "config_searchpath", "...
Generates all configuration file name combinations to read. .. sourcecode:: # -- ALGORITHM: # First basenames/directories are prefered and override other files. for config_path in reversed(config_searchpath): for config_basename in reversed(config_files): con...
[ "Generates", "all", "configuration", "file", "name", "combinations", "to", "read", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L280-L305
train
Generates all available configuration file names.
click-contrib/click-configfile
click_configfile.py
select_config_sections
def select_config_sections(configfile_sections, desired_section_patterns): """Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as stri...
python
def select_config_sections(configfile_sections, desired_section_patterns): """Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as stri...
[ "def", "select_config_sections", "(", "configfile_sections", ",", "desired_section_patterns", ")", ":", "for", "section_name", "in", "configfile_sections", ":", "for", "desired_section_pattern", "in", "desired_section_patterns", ":", "if", "fnmatch", "(", "section_name", ...
Select a subset of the sections in a configuration file by using a list of section names of list of section name patters (supporting :mod:`fnmatch` wildcards). :param configfile_sections: List of config section names (as strings). :param desired_section_patterns: :return: List of selected section n...
[ "Select", "a", "subset", "of", "the", "sections", "in", "a", "configuration", "file", "by", "using", "a", "list", "of", "section", "names", "of", "list", "of", "section", "name", "patters", "(", "supporting", ":", "mod", ":", "fnmatch", "wildcards", ")", ...
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L308-L320
train
Select a subset of the sections in a configuration file by using a list of section names of list of section name patters
click-contrib/click-configfile
click_configfile.py
SectionSchema.matches_section
def matches_section(cls, section_name, supported_section_names=None): """Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. ...
python
def matches_section(cls, section_name, supported_section_names=None): """Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. ...
[ "def", "matches_section", "(", "cls", ",", "section_name", ",", "supported_section_names", "=", "None", ")", ":", "if", "supported_section_names", "is", "None", ":", "supported_section_names", "=", "getattr", "(", "cls", ",", "\"section_names\"", ",", "None", ")",...
Indicates if this schema can be used for a config section by using the section name. :param section_name: Config section name to check. :return: True, if this schema can be applied to the config section. :return: Fals, if this schema does not match the config section.
[ "Indicates", "if", "this", "schema", "can", "be", "used", "for", "a", "config", "section", "by", "using", "the", "section", "name", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L137-L153
train
Indicates if this schema can be applied to a config section.
click-contrib/click-configfile
click_configfile.py
ConfigFileReader.collect_config_sections_from_schemas
def collect_config_sections_from_schemas(cls, config_section_schemas=None): # pylint: disable=invalid-name """Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the...
python
def collect_config_sections_from_schemas(cls, config_section_schemas=None): # pylint: disable=invalid-name """Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the...
[ "def", "collect_config_sections_from_schemas", "(", "cls", ",", "config_section_schemas", "=", "None", ")", ":", "# pylint: disable=invalid-name", "if", "config_section_schemas", "is", "None", ":", "config_section_schemas", "=", "cls", ".", "config_section_schemas", "collec...
Derive support config section names from config section schemas. If no :param:`config_section_schemas` are provided, the schemas from this class are used (normally defined in the DerivedClass). :param config_section_schemas: List of config section schema classes. :return: List of confi...
[ "Derive", "support", "config", "section", "names", "from", "config", "section", "schemas", ".", "If", "no", ":", "param", ":", "config_section_schemas", "are", "provided", "the", "schemas", "from", "this", "class", "are", "used", "(", "normally", "defined", "i...
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L405-L424
train
Derive support config section names from config section schemas.
click-contrib/click-configfile
click_configfile.py
ConfigFileReader.process_config_section
def process_config_section(cls, config_section, storage): """Process the config section and store the extracted data in the param:`storage` (as outgoing param). """ # -- CONCEPT: # if not storage: # # -- INIT DATA: With default parts. # storage.update(dict...
python
def process_config_section(cls, config_section, storage): """Process the config section and store the extracted data in the param:`storage` (as outgoing param). """ # -- CONCEPT: # if not storage: # # -- INIT DATA: With default parts. # storage.update(dict...
[ "def", "process_config_section", "(", "cls", ",", "config_section", ",", "storage", ")", ":", "# -- CONCEPT:", "# if not storage:", "# # -- INIT DATA: With default parts.", "# storage.update(dict(_PERSONS={}))", "schema", "=", "cls", ".", "select_config_schema_for", "("...
Process the config section and store the extracted data in the param:`storage` (as outgoing param).
[ "Process", "the", "config", "section", "and", "store", "the", "extracted", "data", "in", "the", "param", ":", "storage", "(", "as", "outgoing", "param", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L429-L446
train
Process the config section and store the extracted data in the param storage.
click-contrib/click-configfile
click_configfile.py
ConfigFileReader.select_config_schema_for
def select_config_schema_for(cls, section_name): """Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema). """ # pylint: disable=cell-var-from-...
python
def select_config_schema_for(cls, section_name): """Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema). """ # pylint: disable=cell-var-from-...
[ "def", "select_config_schema_for", "(", "cls", ",", "section_name", ")", ":", "# pylint: disable=cell-var-from-loop, redefined-outer-name", "for", "section_schema", "in", "cls", ".", "config_section_schemas", ":", "schema_matches", "=", "getattr", "(", "section_schema", ","...
Select the config schema that matches the config section (by name). :param section_name: Config section name (as key). :return: Config section schmema to use (subclass of: SectionSchema).
[ "Select", "the", "config", "schema", "that", "matches", "the", "config", "section", "(", "by", "name", ")", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L449-L465
train
Select the config schema that matches the config section.
click-contrib/click-configfile
click_configfile.py
ConfigFileReader.select_storage_for
def select_storage_for(cls, section_name, storage): """Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: ...
python
def select_storage_for(cls, section_name, storage): """Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: ...
[ "def", "select_storage_for", "(", "cls", ",", "section_name", ",", "storage", ")", ":", "section_storage", "=", "storage", "storage_name", "=", "cls", ".", "get_storage_name_for", "(", "section_name", ")", "if", "storage_name", ":", "section_storage", "=", "storag...
Selects the data storage for a config section within the :param:`storage`. The primary config section is normally merged into the :param:`storage`. :param section_name: Config section (name) to process. :param storage: Data storage to use. :return: :param:`storage` or...
[ "Selects", "the", "data", "storage", "for", "a", "config", "section", "within", "the", ":", "param", ":", "storage", ".", "The", "primary", "config", "section", "is", "normally", "merged", "into", "the", ":", "param", ":", "storage", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/click_configfile.py#L484-L499
train
Selects the data storage for a config section within the given storage.
click-contrib/click-configfile
tasks/clean.py
clean
def clean(ctx, dry_run=False): """Cleanup temporary dirs/files to regain a clean state.""" # -- VARIATION-POINT 1: Allow user to override in configuration-file directories = ctx.clean.directories files = ctx.clean.files # -- VARIATION-POINT 2: Allow user to add more files/dirs to be removed. ex...
python
def clean(ctx, dry_run=False): """Cleanup temporary dirs/files to regain a clean state.""" # -- VARIATION-POINT 1: Allow user to override in configuration-file directories = ctx.clean.directories files = ctx.clean.files # -- VARIATION-POINT 2: Allow user to add more files/dirs to be removed. ex...
[ "def", "clean", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "# -- VARIATION-POINT 1: Allow user to override in configuration-file", "directories", "=", "ctx", ".", "clean", ".", "directories", "files", "=", "ctx", ".", "clean", ".", "files", "# -- VARIATION-...
Cleanup temporary dirs/files to regain a clean state.
[ "Cleanup", "temporary", "dirs", "/", "files", "to", "regain", "a", "clean", "state", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L65-L82
train
Cleanup temporary dirs and files to regain a clean state.
click-contrib/click-configfile
tasks/clean.py
clean_all
def clean_all(ctx, dry_run=False): """Clean up everything, even the precious stuff. NOTE: clean task is executed first. """ cleanup_dirs(ctx.clean_all.directories or [], dry_run=dry_run) cleanup_dirs(ctx.clean_all.extra_directories or [], dry_run=dry_run) cleanup_files(ctx.clean_all.files or [],...
python
def clean_all(ctx, dry_run=False): """Clean up everything, even the precious stuff. NOTE: clean task is executed first. """ cleanup_dirs(ctx.clean_all.directories or [], dry_run=dry_run) cleanup_dirs(ctx.clean_all.extra_directories or [], dry_run=dry_run) cleanup_files(ctx.clean_all.files or [],...
[ "def", "clean_all", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "cleanup_dirs", "(", "ctx", ".", "clean_all", ".", "directories", "or", "[", "]", ",", "dry_run", "=", "dry_run", ")", "cleanup_dirs", "(", "ctx", ".", "clean_all", ".", "extra_direc...
Clean up everything, even the precious stuff. NOTE: clean task is executed first.
[ "Clean", "up", "everything", "even", "the", "precious", "stuff", ".", "NOTE", ":", "clean", "task", "is", "executed", "first", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L86-L95
train
Clean up all the files and directories in the current order.
click-contrib/click-configfile
tasks/clean.py
clean_python
def clean_python(ctx, dry_run=False): """Cleanup python related files/dirs: *.pyc, *.pyo, ...""" # MAYBE NOT: "**/__pycache__" cleanup_dirs(["build", "dist", "*.egg-info", "**/__pycache__"], dry_run=dry_run) if not dry_run: ctx.run("py.cleanup") cleanup_files(["**/*.pyc", "*...
python
def clean_python(ctx, dry_run=False): """Cleanup python related files/dirs: *.pyc, *.pyo, ...""" # MAYBE NOT: "**/__pycache__" cleanup_dirs(["build", "dist", "*.egg-info", "**/__pycache__"], dry_run=dry_run) if not dry_run: ctx.run("py.cleanup") cleanup_files(["**/*.pyc", "*...
[ "def", "clean_python", "(", "ctx", ",", "dry_run", "=", "False", ")", ":", "# MAYBE NOT: \"**/__pycache__\"", "cleanup_dirs", "(", "[", "\"build\"", ",", "\"dist\"", ",", "\"*.egg-info\"", ",", "\"**/__pycache__\"", "]", ",", "dry_run", "=", "dry_run", ")", "if"...
Cleanup python related files/dirs: *.pyc, *.pyo, ...
[ "Cleanup", "python", "related", "files", "/", "dirs", ":", "*", ".", "pyc", "*", ".", "pyo", "..." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L99-L106
train
Clean python related files and directories.
click-contrib/click-configfile
tasks/clean.py
cleanup_files
def cleanup_files(patterns, dry_run=False, workdir="."): """Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work dir...
python
def cleanup_files(patterns, dry_run=False, workdir="."): """Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work dir...
[ "def", "cleanup_files", "(", "patterns", ",", "dry_run", "=", "False", ",", "workdir", "=", "\".\"", ")", ":", "current_dir", "=", "Path", "(", "workdir", ")", "python_basedir", "=", "Path", "(", "Path", "(", "sys", ".", "executable", ")", ".", "dirname"...
Remove files or files selected by file patterns. Skips removal if file does not exist. :param patterns: File patterns, like "**/*.pyc" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work directory (default=".")
[ "Remove", "files", "or", "files", "selected", "by", "file", "patterns", ".", "Skips", "removal", "if", "file", "does", "not", "exist", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L157-L189
train
Remove files or files selected by patterns.
click-contrib/click-configfile
tasks/clean.py
path_glob
def path_glob(pattern, current_dir=None): """Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path). """ if not current_di...
python
def path_glob(pattern, current_dir=None): """Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path). """ if not current_di...
[ "def", "path_glob", "(", "pattern", ",", "current_dir", "=", "None", ")", ":", "if", "not", "current_dir", ":", "current_dir", "=", "pathlib", ".", "Path", ".", "cwd", "(", ")", "elif", "not", "isinstance", "(", "current_dir", ",", "pathlib", ".", "Path"...
Use pathlib for ant-like patterns, like: "**/*.py" :param pattern: File/directory pattern to use (as string). :param current_dir: Current working directory (as Path, pathlib.Path, str) :return Resolved Path (as path.Path).
[ "Use", "pathlib", "for", "ant", "-", "like", "patterns", "like", ":", "**", "/", "*", ".", "py" ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/clean.py#L191-L205
train
Use pathlib for ant - like patterns like. py
thefab/tornadis
tornadis/pipeline.py
Pipeline.stack_call
def stack_call(self, *args): """Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipelin...
python
def stack_call(self, *args): """Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipelin...
[ "def", "stack_call", "(", "self", ",", "*", "args", ")", ":", "self", ".", "pipelined_args", ".", "append", "(", "args", ")", "self", ".", "number_of_stacked_calls", "=", "self", ".", "number_of_stacked_calls", "+", "1" ]
Stacks a redis command inside the object. The syntax is the same than the call() method a Client class. Args: *args: full redis command as variable length argument list. Examples: >>> pipeline = Pipeline() >>> pipeline.stack_call("HSET", "key", "field", "va...
[ "Stacks", "a", "redis", "command", "inside", "the", "object", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/pipeline.py#L31-L46
train
Stack a redis command inside the object.
thefab/tornadis
tornadis/connection.py
Connection.connect
def connect(self): """Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok. """ if self.is_connected() or self.is_connecting(): raise tornado.gen.Return(True) if self.u...
python
def connect(self): """Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok. """ if self.is_connected() or self.is_connecting(): raise tornado.gen.Return(True) if self.u...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "is_connected", "(", ")", "or", "self", ".", "is_connecting", "(", ")", ":", "raise", "tornado", ".", "gen", ".", "Return", "(", "True", ")", "if", "self", ".", "unix_domain_socket", "is", "...
Connects the object to the host:port. Returns: Future: a Future object with True as result if the connection process was ok.
[ "Connects", "the", "object", "to", "the", "host", ":", "port", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L127-L173
train
Connects the object to the redis server.
thefab/tornadis
tornadis/connection.py
Connection.disconnect
def disconnect(self): """Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors). """ if not self.is_connected() and not self.is_connecting(): return LOG.debug("disconnecting from %s...", se...
python
def disconnect(self): """Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors). """ if not self.is_connected() and not self.is_connecting(): return LOG.debug("disconnecting from %s...", se...
[ "def", "disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "is_connected", "(", ")", "and", "not", "self", ".", "is_connecting", "(", ")", ":", "return", "LOG", ".", "debug", "(", "\"disconnecting from %s...\"", ",", "self", ".", "_redis_server"...
Disconnects the object. Safe method (no exception, even if it's already disconnected or if there are some connection errors).
[ "Disconnects", "the", "object", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L208-L230
train
Disconnects the object from the Redis server.
thefab/tornadis
tornadis/connection.py
Connection.write
def write(self, data): """Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this...
python
def write(self, data): """Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this...
[ "def", "write", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "WriteBuffer", ")", ":", "self", ".", "_write_buffer", ".", "append", "(", "data", ")", "else", ":", "if", "len", "(", "data", ")", ">", "0", ":", "self", "...
Buffers some data to be sent to the host:port in a non blocking way. So the data is always buffered and not sent on the socket in a synchronous way. You can give a WriteBuffer as parameter. The internal Connection WriteBuffer will be extended with this one (without copying). A...
[ "Buffers", "some", "data", "to", "be", "sent", "to", "the", "host", ":", "port", "in", "a", "non", "blocking", "way", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/connection.py#L302-L323
train
Writes some data to the internal connection.
click-contrib/click-configfile
tasks/_vendor/path.py
surrogate_escape
def surrogate_escape(error): """ Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only. """ chars = error.object[error.start:error.end] assert len(chars) == 1 val = ord(chars) val += 0xdc00 return __builtin__.unichr(val), error.end
python
def surrogate_escape(error): """ Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only. """ chars = error.object[error.start:error.end] assert len(chars) == 1 val = ord(chars) val += 0xdc00 return __builtin__.unichr(val), error.end
[ "def", "surrogate_escape", "(", "error", ")", ":", "chars", "=", "error", ".", "object", "[", "error", ".", "start", ":", "error", ".", "end", "]", "assert", "len", "(", "chars", ")", "==", "1", "val", "=", "ord", "(", "chars", ")", "val", "+=", ...
Simulate the Python 3 ``surrogateescape`` handler, but for Python 2 only.
[ "Simulate", "the", "Python", "3", "surrogateescape", "handler", "but", "for", "Python", "2", "only", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L83-L91
train
Simulate the Python 3 surrogateescape handler but for Python 2 only.
click-contrib/click-configfile
tasks/_vendor/path.py
Path._always_unicode
def _always_unicode(cls, path): """ Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string. """ if PY3 or isinstance(path, text_type): return path return path.decode(sys.getfilesystemencoding(), 'surrogateescape'...
python
def _always_unicode(cls, path): """ Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string. """ if PY3 or isinstance(path, text_type): return path return path.decode(sys.getfilesystemencoding(), 'surrogateescape'...
[ "def", "_always_unicode", "(", "cls", ",", "path", ")", ":", "if", "PY3", "or", "isinstance", "(", "path", ",", "text_type", ")", ":", "return", "path", "return", "path", ".", "decode", "(", "sys", ".", "getfilesystemencoding", "(", ")", ",", "'surrogate...
Ensure the path as retrieved from a Python API, such as :func:`os.listdir`, is a proper Unicode string.
[ "Ensure", "the", "path", "as", "retrieved", "from", "a", "Python", "API", "such", "as", ":", "func", ":", "os", ".", "listdir", "is", "a", "proper", "Unicode", "string", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L221-L228
train
Ensure the path as retrieved from a Python API is a proper Unicode string.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.namebase
def namebase(self): """ The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``. """ base, ext = self.module...
python
def namebase(self): """ The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``. """ base, ext = self.module...
[ "def", "namebase", "(", "self", ")", ":", "base", ",", "ext", "=", "self", ".", "module", ".", "splitext", "(", "self", ".", "name", ")", "return", "base" ]
The same as :meth:`name`, but with one file extension stripped off. For example, ``Path('/home/guido/python.tar.gz').name == 'python.tar.gz'``, but ``Path('/home/guido/python.tar.gz').namebase == 'python.tar'``.
[ "The", "same", "as", ":", "meth", ":", "name", "but", "with", "one", "file", "extension", "stripped", "off", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L336-L345
train
The same as name but with one file extension stripped off.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.listdir
def listdir(self, pattern=None): """ D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only...
python
def listdir(self, pattern=None): """ D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only...
[ "def", "listdir", "(", "self", ",", "pattern", "=", "None", ")", ":", "if", "pattern", "is", "None", ":", "pattern", "=", "'*'", "return", "[", "self", "/", "child", "for", "child", "in", "map", "(", "self", ".", "_always_unicode", ",", "os", ".", ...
D.listdir() -> List of items in this directory. Use :meth:`files` or :meth:`dirs` instead if you want a listing of just files or just subdirectories. The elements of the list are Path objects. With the optional `pattern` argument, this only lists items whose names match the gi...
[ "D", ".", "listdir", "()", "-", ">", "List", "of", "items", "in", "this", "directory", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L522-L541
train
D. listdir - Returns a list of items in this directory.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.dirs
def dirs(self, pattern=None): """ D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directo...
python
def dirs(self, pattern=None): """ D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directo...
[ "def", "dirs", "(", "self", ",", "pattern", "=", "None", ")", ":", "return", "[", "p", "for", "p", "in", "self", ".", "listdir", "(", "pattern", ")", "if", "p", ".", "isdir", "(", ")", "]" ]
D.dirs() -> List of this directory's subdirectories. The elements of the list are Path objects. This does not walk recursively into subdirectories (but see :meth:`walkdirs`). With the optional `pattern` argument, this only lists directories whose names match the given pattern. ...
[ "D", ".", "dirs", "()", "-", ">", "List", "of", "this", "directory", "s", "subdirectories", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L543-L554
train
Returns a list of all directories in this directory.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.files
def files(self, pattern=None): """ D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the give...
python
def files(self, pattern=None): """ D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the give...
[ "def", "files", "(", "self", ",", "pattern", "=", "None", ")", ":", "return", "[", "p", "for", "p", "in", "self", ".", "listdir", "(", "pattern", ")", "if", "p", ".", "isfile", "(", ")", "]" ]
D.files() -> List of the files in this directory. The elements of the list are Path objects. This does not walk into subdirectories (see :meth:`walkfiles`). With the optional `pattern` argument, this only lists files whose names match the given pattern. For example, ``d.files(...
[ "D", ".", "files", "()", "-", ">", "List", "of", "the", "files", "in", "this", "directory", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L556-L567
train
D. files - > List of the files in this directory.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.walkdirs
def walkdirs(self, pattern=None, errors='strict'): """ D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories wi...
python
def walkdirs(self, pattern=None, errors='strict'): """ D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories wi...
[ "def", "walkdirs", "(", "self", ",", "pattern", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "errors", "not", "in", "(", "'strict'", ",", "'warn'", ",", "'ignore'", ")", ":", "raise", "ValueError", "(", "\"invalid errors parameter\"", ")", ...
D.walkdirs() -> iterator over subdirs, recursively. With the optional `pattern` argument, this yields only directories whose names match the given pattern. For example, ``mydir.walkdirs('*test')`` yields only directories with names ending in ``'test'``. The `errors=` keyword a...
[ "D", ".", "walkdirs", "()", "-", ">", "iterator", "over", "subdirs", "recursively", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L624-L658
train
A generator function that iterates over all directories in the directory and returns only directories whose names match the pattern.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.walkfiles
def walkfiles(self, pattern=None, errors='strict'): """ D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` ...
python
def walkfiles(self, pattern=None, errors='strict'): """ D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` ...
[ "def", "walkfiles", "(", "self", ",", "pattern", "=", "None", ",", "errors", "=", "'strict'", ")", ":", "if", "errors", "not", "in", "(", "'strict'", ",", "'warn'", ",", "'ignore'", ")", ":", "raise", "ValueError", "(", "\"invalid errors parameter\"", ")",...
D.walkfiles() -> iterator over files in D, recursively. The optional argument `pattern` limits the results to files with names that match the pattern. For example, ``mydir.walkfiles('*.tmp')`` yields only files with the ``.tmp`` extension.
[ "D", ".", "walkfiles", "()", "-", ">", "iterator", "over", "files", "in", "D", "recursively", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L660-L706
train
A generator function that returns all files in the directory and directories that match the pattern.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.open
def open(self, *args, **kwargs): """ Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised. """ with io_error_compat(): return io.open(sel...
python
def open(self, *args, **kwargs): """ Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised. """ with io_error_compat(): return io.open(sel...
[ "def", "open", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "io_error_compat", "(", ")", ":", "return", "io", ".", "open", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Open this file and return a corresponding :class:`file` object. Keyword arguments work as in :func:`io.open`. If the file cannot be opened, an :class:`~exceptions.OSError` is raised.
[ "Open", "this", "file", "and", "return", "a", "corresponding", ":", "class", ":", "file", "object", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L743-L750
train
Open this file and return a corresponding file object.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.write_text
def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two diff...
python
def write_text(self, text, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two diff...
[ "def", "write_text", "(", "self", ",", "text", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "linesep", "=", "os", ".", "linesep", ",", "append", "=", "False", ")", ":", "if", "isinstance", "(", "text", ",", "text_type", ")", ":"...
r""" Write the given text to this file. The default behavior is to overwrite any existing file; to append instead, use the `append=True` keyword argument. There are two differences between :meth:`write_text` and :meth:`write_bytes`: newline handling and Unicode handling. See be...
[ "r", "Write", "the", "given", "text", "to", "this", "file", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L799-L871
train
r This method writes the given text to the current file.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.write_lines
def write_lines(self, lines, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. ...
python
def write_lines(self, lines, encoding=None, errors='strict', linesep=os.linesep, append=False): r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. ...
[ "def", "write_lines", "(", "self", ",", "lines", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "linesep", "=", "os", ".", "linesep", ",", "append", "=", "False", ")", ":", "with", "self", ".", "open", "(", "'ab'", "if", "append",...
r""" Write the given lines of text to this file. By default this overwrites any existing file at this path. This puts a platform-specific newline sequence on every line. See `linesep` below. `lines` - A list of strings. `encoding` - A Unicode encoding to use. This ap...
[ "r", "Write", "the", "given", "lines", "of", "text", "to", "this", "file", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L898-L944
train
r Write the given lines of text to the file.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.mkdir_p
def mkdir_p(self, mode=0o777): """ Like :meth:`mkdir`, but does not raise an exception if the directory already exists. """ try: self.mkdir(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise return ...
python
def mkdir_p(self, mode=0o777): """ Like :meth:`mkdir`, but does not raise an exception if the directory already exists. """ try: self.mkdir(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise return ...
[ "def", "mkdir_p", "(", "self", ",", "mode", "=", "0o777", ")", ":", "try", ":", "self", ".", "mkdir", "(", "mode", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "...
Like :meth:`mkdir`, but does not raise an exception if the directory already exists.
[ "Like", ":", "meth", ":", "mkdir", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "already", "exists", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1203-L1212
train
Like mkdir but does not raise an exception.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.makedirs_p
def makedirs_p(self, mode=0o777): """ Like :meth:`makedirs`, but does not raise an exception if the directory already exists. """ try: self.makedirs(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise ...
python
def makedirs_p(self, mode=0o777): """ Like :meth:`makedirs`, but does not raise an exception if the directory already exists. """ try: self.makedirs(mode) except OSError: _, e, _ = sys.exc_info() if e.errno != errno.EEXIST: raise ...
[ "def", "makedirs_p", "(", "self", ",", "mode", "=", "0o777", ")", ":", "try", ":", "self", ".", "makedirs", "(", "mode", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=...
Like :meth:`makedirs`, but does not raise an exception if the directory already exists.
[ "Like", ":", "meth", ":", "makedirs", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "already", "exists", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1219-L1228
train
Like makedirs but does not raise an exception.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.rmdir_p
def rmdir_p(self): """ Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.rmdir() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST: ...
python
def rmdir_p(self): """ Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.rmdir() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno.EEXIST: ...
[ "def", "rmdir_p", "(", "self", ")", ":", "try", ":", "self", ".", "rmdir", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOTEMPTY", "and", "e",...
Like :meth:`rmdir`, but does not raise an exception if the directory is not empty or does not exist.
[ "Like", ":", "meth", ":", "rmdir", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "is", "not", "empty", "or", "does", "not", "exist", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1235-L1244
train
Like rmdir but does not raise an exception if the directory is not empty.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.removedirs_p
def removedirs_p(self): """ Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.removedirs() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno...
python
def removedirs_p(self): """ Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist. """ try: self.removedirs() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOTEMPTY and e.errno != errno...
[ "def", "removedirs_p", "(", "self", ")", ":", "try", ":", "self", ".", "removedirs", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOTEMPTY", "an...
Like :meth:`removedirs`, but does not raise an exception if the directory is not empty or does not exist.
[ "Like", ":", "meth", ":", "removedirs", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "is", "not", "empty", "or", "does", "not", "exist", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1251-L1260
train
Like removedirs but does not raise an exception if the the directory is not empty.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.remove_p
def remove_p(self): """ Like :meth:`remove`, but does not raise an exception if the file does not exist. """ try: self.unlink() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
python
def remove_p(self): """ Like :meth:`remove`, but does not raise an exception if the file does not exist. """ try: self.unlink() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
[ "def", "remove_p", "(", "self", ")", ":", "try", ":", "self", ".", "unlink", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOENT", ":", "raise"...
Like :meth:`remove`, but does not raise an exception if the file does not exist.
[ "Like", ":", "meth", ":", "remove", "but", "does", "not", "raise", "an", "exception", "if", "the", "file", "does", "not", "exist", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1278-L1287
train
Like remove but does not raise an exception if the the file does not exist.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.rmtree_p
def rmtree_p(self): """ Like :meth:`rmtree`, but does not raise an exception if the directory does not exist. """ try: self.rmtree() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
python
def rmtree_p(self): """ Like :meth:`rmtree`, but does not raise an exception if the directory does not exist. """ try: self.rmtree() except OSError: _, e, _ = sys.exc_info() if e.errno != errno.ENOENT: raise return self
[ "def", "rmtree_p", "(", "self", ")", ":", "try", ":", "self", ".", "rmtree", "(", ")", "except", "OSError", ":", "_", ",", "e", ",", "_", "=", "sys", ".", "exc_info", "(", ")", "if", "e", ".", "errno", "!=", "errno", ".", "ENOENT", ":", "raise"...
Like :meth:`rmtree`, but does not raise an exception if the directory does not exist.
[ "Like", ":", "meth", ":", "rmtree", "but", "does", "not", "raise", "an", "exception", "if", "the", "directory", "does", "not", "exist", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1357-L1366
train
Like rmtree but does not raise an exception if the directory does not exist.
click-contrib/click-configfile
tasks/_vendor/path.py
Path.merge_tree
def merge_tree(self, dst, symlinks=False, *args, **kwargs): """ Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is n...
python
def merge_tree(self, dst, symlinks=False, *args, **kwargs): """ Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is n...
[ "def", "merge_tree", "(", "self", ",", "dst", ",", "symlinks", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "update", "=", "kwargs", ".", "pop", "(", "'update'", ",", "False", ")", "with", "tempdir", "(", ")", "as", "_temp_dir...
Copy entire contents of self to dst, overwriting existing contents in dst with those in self. If the additional keyword `update` is True, each `src` will only be copied if `dst` does not exist, or `src` is newer than `dst`. Note that the technique employed stages the files in a...
[ "Copy", "entire", "contents", "of", "self", "to", "dst", "overwriting", "existing", "contents", "in", "dst", "with", "those", "in", "self", "." ]
a616204cb9944125fd5051556f27a7ccef611e22
https://github.com/click-contrib/click-configfile/blob/a616204cb9944125fd5051556f27a7ccef611e22/tasks/_vendor/path.py#L1374-L1397
train
Copy all contents of self to dst overwriting existing contents in dst.
creare-com/pydem
pydem/reader/gdal_reader.py
GdalReader.__gdal_dataset_default
def __gdal_dataset_default(self): """DiskReader implementation.""" if not os.path.exists(self.file_name): return None if os.path.splitext(self.file_name)[1].lower() not in self.file_types: raise RuntimeError('Filename %s does not have extension type %s.' % (self.file_nam...
python
def __gdal_dataset_default(self): """DiskReader implementation.""" if not os.path.exists(self.file_name): return None if os.path.splitext(self.file_name)[1].lower() not in self.file_types: raise RuntimeError('Filename %s does not have extension type %s.' % (self.file_nam...
[ "def", "__gdal_dataset_default", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "file_name", ")", ":", "return", "None", "if", "os", ".", "path", ".", "splitext", "(", "self", ".", "file_name", ")", "[", "1", ...
DiskReader implementation.
[ "DiskReader", "implementation", "." ]
c2fc8d84cfb411df84f71a6dec9edc4b544f710a
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/reader/gdal_reader.py#L100-L116
train
DiskReader implementation.
thefab/tornadis
tornadis/client.py
Client.connect
def connect(self): """Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok. """ ...
python
def connect(self): """Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok. """ ...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "is_connected", "(", ")", ":", "raise", "tornado", ".", "gen", ".", "Return", "(", "True", ")", "cb1", "=", "self", ".", "_read_callback", "cb2", "=", "self", ".", "_close_callback", "self", ...
Connects the client object to redis. It's safe to use this method even if you are already connected. Note: this method is useless with autoconnect mode (default). Returns: a Future object with True as result if the connection was ok.
[ "Connects", "the", "client", "object", "to", "redis", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L84-L118
train
Connects the client object to redis.
thefab/tornadis
tornadis/client.py
Client._close_callback
def _close_callback(self): """Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client. """ while True: try: callback = self.__callb...
python
def _close_callback(self): """Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client. """ while True: try: callback = self.__callb...
[ "def", "_close_callback", "(", "self", ")", ":", "while", "True", ":", "try", ":", "callback", "=", "self", ".", "__callback_queue", ".", "popleft", "(", ")", "callback", "(", "ConnectionError", "(", "\"closed connection\"", ")", ")", "except", "IndexError", ...
Callback called when redis closed the connection. The callback queue is emptied and we call each callback found with None or with an exception object to wake up blocked client.
[ "Callback", "called", "when", "redis", "closed", "the", "connection", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L130-L145
train
Callback called when redis closed the connection.
thefab/tornadis
tornadis/client.py
Client._read_callback
def _read_callback(self, data=None): """Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket. ""...
python
def _read_callback(self, data=None): """Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket. ""...
[ "def", "_read_callback", "(", "self", ",", "data", "=", "None", ")", ":", "try", ":", "if", "data", "is", "not", "None", ":", "self", ".", "__reader", ".", "feed", "(", "data", ")", "while", "True", ":", "reply", "=", "self", ".", "__reader", ".", ...
Callback called when some data are read on the socket. The buffer is given to the hiredis parser. If a reply is complete, we put the decoded reply to on the reply queue. Args: data (str): string (buffer) read on the socket.
[ "Callback", "called", "when", "some", "data", "are", "read", "on", "the", "socket", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L147-L175
train
Callback called when some data is read on the socket.
thefab/tornadis
tornadis/client.py
Client.call
def call(self, *args, **kwargs): """Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Re...
python
def call(self, *args, **kwargs): """Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Re...
[ "def", "call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_connected", "(", ")", ":", "if", "self", ".", "autoconnect", ":", "# We use this method only when we are not contected", "# to void performance penaly ...
Calls a redis command and returns a Future of the reply. Args: *args: full redis command as variable length argument list or a Pipeline object (as a single argument). **kwargs: internal private options (do not use). Returns: a Future with the decoded...
[ "Calls", "a", "redis", "command", "and", "returns", "a", "Future", "of", "the", "reply", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L177-L208
train
Calls a redis command and returns a Future of the reply.
thefab/tornadis
tornadis/client.py
Client.async_call
def async_call(self, *args, **kwargs): """Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If no...
python
def async_call(self, *args, **kwargs): """Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If no...
[ "def", "async_call", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "after_autoconnect_callback", "(", "future", ")", ":", "if", "self", ".", "is_connected", "(", ")", ":", "self", ".", "_call", "(", "*", "args", ",", "*", ...
Calls a redis command, waits for the reply and call a callback. Following options are available (not part of the redis command itself): - callback Function called (with the result as argument) when the result is available. If not set, the reply is silently discarded. In ...
[ "Calls", "a", "redis", "command", "waits", "for", "the", "reply", "and", "call", "a", "callback", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/client.py#L218-L259
train
Calls a redis command and waits for the reply and call a callback.
thefab/tornadis
tornadis/utils.py
format_args_in_redis_protocol
def format_args_in_redis_protocol(*args): """Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). ...
python
def format_args_in_redis_protocol(*args): """Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). ...
[ "def", "format_args_in_redis_protocol", "(", "*", "args", ")", ":", "buf", "=", "WriteBuffer", "(", ")", "l", "=", "\"*%d\\r\\n\"", "%", "len", "(", "args", ")", "# noqa: E741", "if", "six", ".", "PY2", ":", "buf", ".", "append", "(", "l", ")", "else",...
Formats arguments into redis protocol... This function makes and returns a string/buffer corresponding to given arguments formated with the redis protocol. integer, text, string or binary types are automatically converted (using utf8 if necessary). More informations about the protocol: http://red...
[ "Formats", "arguments", "into", "redis", "protocol", "..." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L14-L70
train
Formats arguments into the redis protocol
thefab/tornadis
tornadis/utils.py
ContextManagerFuture._done_callback
def _done_callback(self, wrapped): """Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future ob...
python
def _done_callback(self, wrapped): """Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future ob...
[ "def", "_done_callback", "(", "self", ",", "wrapped", ")", ":", "if", "wrapped", ".", "exception", "(", ")", ":", "self", ".", "set_exception", "(", "wrapped", ".", "exception", "(", ")", ")", "else", ":", "self", ".", "set_result", "(", "wrapped", "."...
Internal "done callback" to set the result of the object. The result of the object if forced by the wrapped future. So this internal callback must be called when the wrapped future is ready. Args: wrapped (Future): the wrapped Future object
[ "Internal", "done", "callback", "to", "set", "the", "result", "of", "the", "object", "." ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L108-L120
train
Internal done callback to set the result of the object.
thefab/tornadis
tornadis/utils.py
ContextManagerFuture.result
def result(self): """The result method which returns a context manager Returns: ContextManager: The corresponding context manager """ if self.exception(): raise self.exception() # Otherwise return a context manager that cleans up after the block. ...
python
def result(self): """The result method which returns a context manager Returns: ContextManager: The corresponding context manager """ if self.exception(): raise self.exception() # Otherwise return a context manager that cleans up after the block. ...
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "exception", "(", ")", ":", "raise", "self", ".", "exception", "(", ")", "# Otherwise return a context manager that cleans up after the block.", "@", "contextlib", ".", "contextmanager", "def", "f", "(", ...
The result method which returns a context manager Returns: ContextManager: The corresponding context manager
[ "The", "result", "method", "which", "returns", "a", "context", "manager" ]
f9dc883e46eb5971b62eab38346319757e5f900f
https://github.com/thefab/tornadis/blob/f9dc883e46eb5971b62eab38346319757e5f900f/tornadis/utils.py#L122-L138
train
The result method which returns a context manager
enricobacis/lyricwikia
lyricwikia/lyricwikia.py
create_url
def create_url(artist, song): """Create the URL in the LyricWikia format""" return (__BASE_URL__ + '/wiki/{artist}:{song}'.format(artist=urlize(artist), song=urlize(song)))
python
def create_url(artist, song): """Create the URL in the LyricWikia format""" return (__BASE_URL__ + '/wiki/{artist}:{song}'.format(artist=urlize(artist), song=urlize(song)))
[ "def", "create_url", "(", "artist", ",", "song", ")", ":", "return", "(", "__BASE_URL__", "+", "'/wiki/{artist}:{song}'", ".", "format", "(", "artist", "=", "urlize", "(", "artist", ")", ",", "song", "=", "urlize", "(", "song", ")", ")", ")" ]
Create the URL in the LyricWikia format
[ "Create", "the", "URL", "in", "the", "LyricWikia", "format" ]
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L20-L24
train
Create the URL in the LyricWikia format
enricobacis/lyricwikia
lyricwikia/lyricwikia.py
get_lyrics
def get_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve the lyrics of the song and return the first one in case multiple versions are available.""" return get_all_lyrics(artist, song, linesep, timeout)[0]
python
def get_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve the lyrics of the song and return the first one in case multiple versions are available.""" return get_all_lyrics(artist, song, linesep, timeout)[0]
[ "def", "get_lyrics", "(", "artist", ",", "song", ",", "linesep", "=", "'\\n'", ",", "timeout", "=", "None", ")", ":", "return", "get_all_lyrics", "(", "artist", ",", "song", ",", "linesep", ",", "timeout", ")", "[", "0", "]" ]
Retrieve the lyrics of the song and return the first one in case multiple versions are available.
[ "Retrieve", "the", "lyrics", "of", "the", "song", "and", "return", "the", "first", "one", "in", "case", "multiple", "versions", "are", "available", "." ]
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L27-L30
train
Retrieve the lyrics of the song and return the first one in case multiple versions are available.
enricobacis/lyricwikia
lyricwikia/lyricwikia.py
get_all_lyrics
def get_all_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve a list of all the lyrics versions of a song.""" url = create_url(artist, song) response = _requests.get(url, timeout=timeout) soup = _BeautifulSoup(response.content, "html.parser") lyricboxes = soup.findAll('div', {'class': 'l...
python
def get_all_lyrics(artist, song, linesep='\n', timeout=None): """Retrieve a list of all the lyrics versions of a song.""" url = create_url(artist, song) response = _requests.get(url, timeout=timeout) soup = _BeautifulSoup(response.content, "html.parser") lyricboxes = soup.findAll('div', {'class': 'l...
[ "def", "get_all_lyrics", "(", "artist", ",", "song", ",", "linesep", "=", "'\\n'", ",", "timeout", "=", "None", ")", ":", "url", "=", "create_url", "(", "artist", ",", "song", ")", "response", "=", "_requests", ".", "get", "(", "url", ",", "timeout", ...
Retrieve a list of all the lyrics versions of a song.
[ "Retrieve", "a", "list", "of", "all", "the", "lyrics", "versions", "of", "a", "song", "." ]
bc6caa7f745f1d54adf3ba1a72df76d593164cfa
https://github.com/enricobacis/lyricwikia/blob/bc6caa7f745f1d54adf3ba1a72df76d593164cfa/lyricwikia/lyricwikia.py#L33-L47
train
Retrieve a list of all the lyrics versions of a song.
melizalab/arf
arf.py
open_file
def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, **kwargs): """Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly. """ import sys import os from h5py im...
python
def open_file(name, mode=None, driver=None, libver=None, userblock_size=None, **kwargs): """Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly. """ import sys import os from h5py im...
[ "def", "open_file", "(", "name", ",", "mode", "=", "None", ",", "driver", "=", "None", ",", "libver", "=", "None", ",", "userblock_size", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "sys", "import", "os", "from", "h5py", "import", "h5p"...
Open an ARF file, creating as necessary. Use this instead of h5py.File to ensure that root-level attributes and group creation property lists are set correctly.
[ "Open", "an", "ARF", "file", "creating", "as", "necessary", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L42-L79
train
Open an ARF file creating as necessary.
melizalab/arf
arf.py
create_entry
def create_entry(group, name, timestamp, **attributes): """Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike time...
python
def create_entry(group, name, timestamp, **attributes): """Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike time...
[ "def", "create_entry", "(", "group", ",", "name", ",", "timestamp", ",", "*", "*", "attributes", ")", ":", "# create group using low-level interface to store creation order", "from", "h5py", "import", "h5p", ",", "h5g", ",", "_hl", "try", ":", "gcpl", "=", "h5p"...
Create a new ARF entry under group, setting required attributes. An entry is an abstract collection of data which all refer to the same time frame. Data can include physiological recordings, sound recordings, and derived data such as spike times and labels. See add_data() for information on how data ar...
[ "Create", "a", "new", "ARF", "entry", "under", "group", "setting", "required", "attributes", "." ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L82-L116
train
Create a new ARF entry under a group.
melizalab/arf
arf.py
create_dataset
def create_dataset(group, name, data, units='', datatype=DataTypes.UNDEFINED, chunks=True, maxshape=None, compression=None, **attributes): """Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to st...
python
def create_dataset(group, name, data, units='', datatype=DataTypes.UNDEFINED, chunks=True, maxshape=None, compression=None, **attributes): """Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to st...
[ "def", "create_dataset", "(", "group", ",", "name", ",", "data", ",", "units", "=", "''", ",", "datatype", "=", "DataTypes", ".", "UNDEFINED", ",", "chunks", "=", "True", ",", "maxshape", "=", "None", ",", "compression", "=", "None", ",", "*", "*", "...
Create an ARF dataset under group, setting required attributes Required arguments: name -- the name of dataset in which to store the data data -- the data to store Data can be of the following types: * sampled data: an N-D numerical array of measurements * "simple" event data: a 1-D array...
[ "Create", "an", "ARF", "dataset", "under", "group", "setting", "required", "attributes" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L119-L181
train
Create an ARF dataset under the specified group.
melizalab/arf
arf.py
create_table
def create_table(group, name, dtype, **attributes): """Create a new array dataset under group with compound datatype and maxshape=(None,)""" dset = group.create_dataset( name, shape=(0,), dtype=dtype, maxshape=(None,)) set_attributes(dset, **attributes) return dset
python
def create_table(group, name, dtype, **attributes): """Create a new array dataset under group with compound datatype and maxshape=(None,)""" dset = group.create_dataset( name, shape=(0,), dtype=dtype, maxshape=(None,)) set_attributes(dset, **attributes) return dset
[ "def", "create_table", "(", "group", ",", "name", ",", "dtype", ",", "*", "*", "attributes", ")", ":", "dset", "=", "group", ".", "create_dataset", "(", "name", ",", "shape", "=", "(", "0", ",", ")", ",", "dtype", "=", "dtype", ",", "maxshape", "="...
Create a new array dataset under group with compound datatype and maxshape=(None,)
[ "Create", "a", "new", "array", "dataset", "under", "group", "with", "compound", "datatype", "and", "maxshape", "=", "(", "None", ")" ]
71746d9edbe7993a783d4acaf84b9631f3230283
https://github.com/melizalab/arf/blob/71746d9edbe7993a783d4acaf84b9631f3230283/arf.py#L184-L189
train
Create a new array dataset under group with compound datatype and maxshape = None.