Commit 2dbe2009 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed some docstyle issues.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 5bca4456
......@@ -25,8 +25,8 @@ __author__ = "Daniel Scheffler"
class TimeoutError(OSError):
""" Timeout expired. """
"""Timeout expired."""
class FileNotFoundError(OSError):
""" File not found. """
"""File not found."""
......@@ -32,7 +32,8 @@ __author__ = 'Daniel Scheffler'
def decompress(compressed_file, outputpath=None, logger=getLogger('decompressor')):
"""Decompresses ZIP, TAR, TAR.GZ, TGZ and GZ archives to a given output path.
"""Decompress ZIP, TAR, TAR.GZ, TGZ and GZ archives to a given output path.
:param compressed_file:
:param outputpath:
:param logger: instance of logging.Logger
......
......@@ -32,12 +32,11 @@ from six import PY3
def data_DB_updater(gms_obj_dict, path_db):
# type: (dict, str) -> None
"""Updates the table "scenes_proc" or "mgrs_tiles_proc within a postgreSQL or an SQL database
"""Update the table "scenes_proc" or "mgrs_tiles_proc within a postgreSQL or an SQL database
according to the given dictionary of a GMS object.
:param gms_obj_dict: <dict> a copy of the dictionary of the respective GMS object
"""
assert isinstance(gms_obj_dict, dict), 'The input for data_DB_updater() has to be a dictionary.'
def list2str(list2convert): return ''.join([str(val) for val in list2convert])
......@@ -80,7 +79,7 @@ def data_DB_updater(gms_obj_dict, path_db):
def get_info_from_SQLdb(path_db, tablename, vals2return, cond_dict, records2fetch=0):
# type: (str,str,list,dict,int) -> Union[list, str]
"""Queries an SQL database for the given parameters.
"""Query an SQL database for the given parameters.
:param path_db: <str> the physical path of the SQL database on disk
:param tablename: <str> name of the table within the database to be queried
......@@ -88,7 +87,6 @@ def get_info_from_SQLdb(path_db, tablename, vals2return, cond_dict, records2fetc
:param cond_dict: <dict> a dictionary containing the query conditions in the form {'column_name':<value>}
:param records2fetch: <int> number of records to be fetched (default=0: fetch unlimited records)
"""
if not isinstance(vals2return, list):
vals2return = [vals2return]
assert isinstance(records2fetch, int), \
......
......@@ -32,7 +32,7 @@ __author__ = "Daniel Scheffler"
def get_corner_coordinates(gt, cols, rows):
"""Returns (ULxy, LLxy, LRxy, URxy) in the same coordinate units like the given geotransform."""
"""Return (ULxy, LLxy, LRxy, URxy) in the same coordinate units like the given geotransform."""
ext = []
xarr = [0, cols]
yarr = [0, rows]
......@@ -47,8 +47,7 @@ def get_corner_coordinates(gt, cols, rows):
def calc_FullDataset_corner_positions(mask_1bit, assert_four_corners=True, algorithm='shapely'):
# type: (np.ndarray, bool, str) -> list
"""
Calculates the image coordinates of the true data corners from a nodata mask.
"""Calculate the image coordinates of the true data corners from a nodata mask.
NOTE: Algorithm 'shapely' calculates the corner coordinates of the convex hull of the given mask. Since the convex
hull not always reflects all of the true corner coordinates the result can have a limitation in this regard.
......@@ -58,7 +57,6 @@ def calc_FullDataset_corner_positions(mask_1bit, assert_four_corners=True, algor
:param algorithm: <str> 'shapely' or 'numpy' (default: 'shapely')
:return: [UL, UR, LL, LR] as [(ULrow,ULcol),(URrow,URcol),...]
"""
# check if the mask extent covers real data or only nodata
pixVals = np.unique(mask_1bit)
if not (True in pixVals or 1 in pixVals):
......@@ -166,7 +164,7 @@ def calc_FullDataset_corner_positions(mask_1bit, assert_four_corners=True, algor
def corner_coord_to_minmax(corner_coords):
# type: (Iterable[Tuple[float, float], Tuple[float, float], Tuple[float, float], Tuple[float, float]]) -> tuple
"""Returns the bounding coordinates for a given set of XY coordinates.
"""Return the bounding coordinates for a given set of XY coordinates.
:param corner_coords: # four XY tuples of corner coordinates. Their order does not matter.
:return: xmin,xmax,ymin,ymax
......
......@@ -43,7 +43,8 @@ def get_coord_grid(ULxy, LRxy, out_resXY):
def snap_bounds_to_pixGrid(bounds, gt, roundAlg='auto'):
# type: (Sequence[float], Sequence[float], str) -> Tuple[float, float, float, float]
"""Snaps the given bounds to the given grid (defined by gt) under the use of the given round algorithm.
"""Snap the given bounds to the given grid (defined by gt) under the use of the given round algorithm.
NOTE: asserts equal projections of source and target grid
:param bounds: <tuple, list> (xmin, ymin, xmax, ymax)
......@@ -64,7 +65,7 @@ def snap_bounds_to_pixGrid(bounds, gt, roundAlg='auto'):
def is_coord_grid_equal(gt, xgrid, ygrid, tolerance=0.):
# type: (Sequence[float], Sequence[float], Sequence[float], float) -> bool
"""Checks if a given GeoTransform exactly matches the given X/Y grid.
"""Check if a given GeoTransform exactly matches the given X/Y grid.
:param gt: GDAL GeoTransform
:param xgrid: numpy array defining the coordinate grid in x-direction
......@@ -83,7 +84,7 @@ def is_coord_grid_equal(gt, xgrid, ygrid, tolerance=0.):
def is_point_on_grid(pointXY, xgrid, ygrid, tolerance=0.):
# type: (Sequence[float, float], Sequence[float], Sequence[float], float) -> bool
"""Checks if a given point is exactly on the given coordinate grid.
"""Check if a given point is exactly on the given coordinate grid.
:param pointXY: (X,Y) coordinates of the point to check
:param xgrid: numpy array defining the coordinate grid in x-direction
......
......@@ -49,6 +49,7 @@ def get_utm_zone(longitude):
def transform_wgs84_to_utm(lon, lat, zone=None):
# type: (float, float, int) -> (float, float)
"""Return easting, northing, altitude for the given Lon/Lat coordinate.
:param lon: longitude
:param lat: latitude
:param zone: UTM zone (if not set it is derived automatically)
......
......@@ -234,7 +234,8 @@ class Geocoding(object):
def geotransform2mapinfo(gt, prj):
# type: (Union[list, tuple, None], Union[str, None]) -> list
"""Builds an ENVI geo info from given GDAL GeoTransform and Projection (compatible with UTM and LonLat projections).
"""Build an ENVI geo info from given GDAL GeoTransform and Projection (compatible with UTM and LonLat projections).
:param gt: GDAL GeoTransform, e.g. (249885.0, 30.0, 0.0, 4578615.0, 0.0, -30.0)
:param prj: GDAL Projection - WKT Format
:returns: ENVI geo info, e.g. [ UTM , 1 , 1 , 256785.0 , 4572015.0 , 30.0 , 30.0 , 43 , North , WGS-84 ]
......@@ -278,7 +279,7 @@ def geotransform2mapinfo(gt, prj):
def mapinfo2geotransform(map_info):
# type: (Union[list, None]) -> tuple
"""Builds GDAL GeoTransform tuple from an ENVI geo info.
"""Build GDAL GeoTransform tuple from an ENVI geo info.
:param map_info: ENVI geo info (list), e.g., ['UTM', 1, 1, 192585.0, 5379315.0, 30.0, 30.0, 41, 'North', 'WGS-84']
:returns: GDAL GeoTransform, e.g. [249885.0, 30.0, 0.0, 4578615.0, 0.0, -30.0]
......@@ -313,7 +314,7 @@ def mapinfo2geotransform(map_info):
def get_corner_coordinates(gdal_ds=None, gt=None, cols=None, rows=None):
"""Returns (ULxy, LLxy, LRxy, URxy) in the same coordinate units like the given geotransform."""
"""Return (ULxy, LLxy, LRxy, URxy) in the same coordinate units like the given geotransform."""
assert gdal_ds or (gt and cols and rows), \
"GEOP.get_corner_coordinates: Missing argument! Please provide either 'gdal_ds' or 'gt', 'cols' AND 'rows'."
......
......@@ -38,7 +38,7 @@ gdal_env.try2set_GDAL_DATA()
def get_proj4info(proj=None):
# type: (Union[str, int]) -> str
"""Returns PROJ4 formatted projection info for the given projection.
"""Return PROJ4 formatted projection info for the given projection.
e.g. '+proj=utm +zone=43 +datum=WGS84 +units=m +no_defs '
......@@ -49,7 +49,8 @@ def get_proj4info(proj=None):
def proj4_to_dict(proj4):
# type: (str) -> dict
"""Converts a PROJ4-like string into a dictionary.
"""Convert a PROJ4-like string into a dictionary.
:param proj4: <str> the PROJ4-like string
"""
return CRS.from_proj4(proj4).to_dict()
......@@ -57,7 +58,8 @@ def proj4_to_dict(proj4):
def dict_to_proj4(proj4dict):
# type: (dict) -> str
"""Converts a PROJ4-like dictionary into a PROJ4 string.
"""Convert a PROJ4-like dictionary into a PROJ4 string.
:param proj4dict: <dict> the PROJ4-like dictionary
"""
return CRS.from_dict(proj4dict).to_proj4()
......@@ -65,7 +67,8 @@ def dict_to_proj4(proj4dict):
def proj4_to_WKT(proj4str):
# type: (str) -> str
"""Converts a PROJ4-like string into a WKT string.
"""Convert a PROJ4-like string into a WKT string.
:param proj4str: <dict> the PROJ4-like string
"""
return CRS.from_proj4(proj4str).to_wkt()
......@@ -73,7 +76,7 @@ def proj4_to_WKT(proj4str):
def prj_equal(prj1, prj2):
# type: (Union[None, int, str], Union[None, int, str]) -> bool
"""Checks if the given two projections are equal.
"""Check if the given two projections are equal.
:param prj1: projection 1 (WKT or 'epsg:1234' or <EPSG_int>)
:param prj2: projection 2 (WKT or 'epsg:1234' or <EPSG_int>)
......@@ -146,7 +149,8 @@ def EPSG2WKT(EPSG_code):
def WKT2EPSG(wkt):
# type: (str) -> Union[int, None]
""" Transform a WKT string to an EPSG code
"""Transform a WKT string to an EPSG code.
:param wkt: WKT definition
:returns: EPSG code
"""
......@@ -180,7 +184,8 @@ def get_UTMzone(prj):
def get_prjLonLat(fmt='wkt'):
# type: (str) -> Union[str, dict]
"""Returns standard geographic projection (EPSG 4326) in the WKT or PROJ4 format.
"""Return standard geographic projection (EPSG 4326) in the WKT or PROJ4 format.
:param fmt: <str> target format - 'WKT' or 'PROJ4'
"""
if not re.search('wkt', fmt, re.I) or re.search('Proj4', fmt, re.I):
......
......@@ -35,7 +35,7 @@ from ...compatibility.python.exceptions import TimeoutError as TimeoutError_comp
def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
timeout=None, progress=True, q=False):
"""Calculates a footprint polygon for the given array.
"""Calculate a footprint polygon for the given array.
:param array: 2D numpy array
:param gt:
......@@ -49,7 +49,6 @@ def raster2polygon(array, gt, prj, DN2extract=1, exact=True, maxfeatCount=None,
:param q: quiet mode (default: False)
:return:
"""
assert array.ndim == 2, "Only 2D arrays are supported. Got a %sD array." % array.ndim
# downsample input array in case is has more than 1e8 pixels to prevent crash
......
......@@ -67,7 +67,6 @@ def warp_ndarray_rasterio(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsC
:return out_gt: warped gdal GeoTransform
:return out_prj: warped projection as WKT string
"""
if not find_loader('rasterio'):
raise ImportError('This function requires rasterio. You need to install it manually '
'(conda install -c conda-forge rasterio). It is not automatically installed.')
......@@ -254,7 +253,7 @@ def warp_ndarray(ndarray, in_gt, in_prj=None, out_prj=None, out_dtype=None,
out_alpha=False, targetAlignedPixels=False, gcpList=None, polynomialOrder=None, options=None,
transformerOptions=None, warpOptions=None, CPUs=1, warpMemoryLimit=0, progress=True, q=False):
# type: () -> (np.ndarray, tuple, str)
"""
r"""
:param ndarray: numpy array to be warped (or a list of numpy arrays (requires lists for in_gt/in_prj))
:param in_gt: input GDAL geotransform (or a list of GDAL geotransforms)
......
......@@ -73,8 +73,9 @@ def shapelyBox2BoxYX(shapelyBox, coord_type='image'):
def get_boxImXY_from_shapelyPoly(shapelyPoly, im_gt):
# type: (Polygon, tuple) -> list
"""Converts each vertex coordinate of a shapely polygon into image coordinates corresponding to the given
"""Convert each vertex coordinate of a shapely polygon into image coordinates corresponding to the given
geotransform without respect to invalid image coordinates. Those must be filtered later.
:param shapelyPoly: <shapely.Polygon>
:param im_gt: <list> the GDAL geotransform of the target image
"""
......@@ -99,7 +100,7 @@ def round_shapelyPoly_coords(shapelyPoly, precision=10):
def points_to_raster(points, values, tgt_res, prj=None, fillVal=None):
# type: (np.ndarray, np.ndarray, float, str, float) -> (np.ndarray, list, str)
"""
Converts a set of point geometries with associated values into a raster array.
Convert a set of point geometries with associated values into a raster array.
:param points: list or 1D numpy.ndarray containings shapely.geometry point geometries
:param values: list or 1D numpy.ndarray containing int or float values
......@@ -107,7 +108,6 @@ def points_to_raster(points, values, tgt_res, prj=None, fillVal=None):
:param prj: WKT projection string
:param fillVal: fill value used to fill in where no point geometry is available
"""
ds = ogr.GetDriverByName("Memory").CreateDataSource('wrk')
if prj is not None:
......
......@@ -21,6 +21,8 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from typing import Tuple
from shapely.geometry import Polygon, box
import numpy as np
......@@ -37,6 +39,7 @@ class boxObj(object):
def __init__(self, **kwargs):
"""Create a dynamic/self-updating box object that represents a rectangular or quadratic coordinate box
according to the given keyword arguments.
Note: Either mapPoly+gt or imPoly+gt or wp+ws or boxMapYX+gt or boxImYX+gt must be passed.
:Keyword Arguments:
......@@ -99,7 +102,7 @@ class boxObj(object):
@property
def boxMapYX(self):
"""Returns a list of YX coordinate tuples for all corners in the order UL_YX, UR_YX, LR_YX, LL_YX.
"""Return a list of YX coordinate tuples for all corners in the order UL_YX, UR_YX, LR_YX, LL_YX.
:return: UL_YX, UR_YX, LR_YX, LL_YX
"""
......@@ -113,7 +116,7 @@ class boxObj(object):
@property
def boxMapXY(self):
"""Returns a list of XY coordinate tuples for all corners in the order UL_XY, UR_XY, LR_XY, LL_XY.
"""Return a list of XY coordinate tuples for all corners in the order UL_XY, UR_XY, LR_XY, LL_XY.
:return: UL_XY, UR_XY, LR_XY, LL_XY
"""
......@@ -147,14 +150,14 @@ class boxObj(object):
@property
def boundsMap(self):
"""Returns xmin,xmax,ymin,ymax in map coordinates."""
"""Return xmin,xmax,ymin,ymax in map coordinates."""
boxMapYX = shapelyBox2BoxYX(self.mapPoly, coord_type='image')
boxMapXY = [(i[1], i[0]) for i in boxMapYX]
return corner_coord_to_minmax(boxMapXY)
@property
def boundsIm(self):
"""Returns xmin,xmax,ymin,ymax in image coordinates."""
"""Return xmin,xmax,ymin,ymax in image coordinates."""
boxImXY = [(round(x, 0), round(y, 0)) for x, y in get_boxImXY_from_shapelyPoly(self.mapPoly, self.gt)]
return corner_coord_to_minmax(boxImXY) # xmin,xmax,ymin,ymax
......@@ -179,6 +182,7 @@ class boxObj(object):
def buffer_imXY(self, buffImX=0, buffImY=0):
# type: (float, float) -> None
"""Buffer the box in X- and/or Y-direction.
:param buffImX: <float> buffer value in x-direction as IMAGE UNITS (pixels)
:param buffImY: <float> buffer value in y-direction as IMAGE UNITS (pixels)
"""
......@@ -189,6 +193,7 @@ class boxObj(object):
def buffer_mapXY(self, buffMapX=0, buffMapY=0):
# type: (float, float) -> None
"""Buffer the box in X- and/or Y-direction.
:param buffMapX: <float> buffer value in x-direction as MAP UNITS
:param buffMapY: <float> buffer value in y-direction as MAP UNITS
"""
......@@ -198,7 +203,8 @@ class boxObj(object):
def is_larger_DimXY(self, boundsIm2test):
# type: (tuple) -> (bool,bool)
"""Checks if the boxObj is larger than a given set of bounding image coordinates (in X- and/or Y-direction).
"""Check if the boxObj is larger than a given set of bounding image coordinates (in X- and/or Y-direction).
:param boundsIm2test: <tuple> (xmin,xmax,ymin,ymax) as image coordinates
"""
b2t_xmin, b2t_xmax, b2t_ymin, b2t_ymax = boundsIm2test
......@@ -208,8 +214,10 @@ class boxObj(object):
return x_is_larger, y_is_larger
def get_coordArray_MapXY(self, prj=None):
"""Returns two coordinate arrays for X and Y coordinates in the given projection. If no projection is given,
<boxObj>.prj is used.
# type: (str) -> Tuple[np.ndarray]
"""Return two coordinate arrays for X and Y coordinates in the given projection.
NOTE: If no projection is given, <boxObj>.prj is used.
:param prj: GDAL projection as WKT string
:return:
......@@ -229,7 +237,8 @@ class boxObj(object):
def get_winPoly(wp_imYX, ws, gt, match_grid=0):
# type: (tuple, tuple, list, bool) -> (Polygon, tuple, tuple)
"""Creates a shapely polygon from a given set of image cordinates, window size and geotransform.
"""Create a shapely polygon from a given set of image cordinates, window size and geotransform.
:param wp_imYX:
:param ws: <tuple> X/Y window size
:param gt:
......
......@@ -36,7 +36,7 @@ __author__ = "Daniel Scheffler"
def get_overlap_polygon(poly1, poly2, v=False):
""" Return a dict with the overlap of two shapely.Polygon() objects, the overlap percentage and the overlap area.
"""Return a dict with the overlap of two shapely.Polygon() objects, the overlap percentage and the overlap area.
:param poly1: first shapely.Polygon() object
:param poly2: second shapely.Polygon() object
......@@ -68,14 +68,13 @@ def get_overlap_polygon(poly1, poly2, v=False):
def get_footprint_polygon(CornerLonLat, fix_invalid=False):
""" Convert a list of coordinates into a shapely polygon object.
"""Convert a list of coordinates into a shapely polygon object.
:param CornerLonLat: a list of coordinate tuples like [[lon,lat], [lon. lat], ..]
in clockwise or counter clockwise order
:param fix_invalid: fix invalid output polygon by returning its convex hull (sometimes this can be different)
:return: a shapely.Polygon() object
"""
if fix_invalid:
with warnings.catch_warnings():
warnings.simplefilter('ignore') # FIXME not working
......@@ -152,7 +151,6 @@ def polyVertices_outside_poly(inner_poly, outer_poly, tolerance=0):
:param outer_poly: the polygon where all vertices have to be inside
:param tolerance: tolerance of the decision
"""
if inner_poly.within(outer_poly.buffer(tolerance)):
# all vertices are inside outer_poly
return False
......
......@@ -28,12 +28,14 @@ __author__ = "Daniel Scheffler"
def get_tempfile(ext=None, prefix=None, tgt_dir=None):
"""Returns the path to a tempfile.mkstemp() file that can be passed to any function that expects a physical path.
The tempfile has to be deleted manually.
"""Return the path to a tempfile.mkstemp() file that can be passed to any function that expects a physical path.
NOTE: The tempfile has to be deleted manually.
:param ext: file extension (None if None)
:param prefix: optional file prefix
:param tgt_dir: target directory (automatically set if None)
"""
"""
prefix = 'py_tools_ds__' if prefix is None else prefix
fd, path = tempfile.mkstemp(prefix=prefix, suffix=ext, dir=tgt_dir)
os.close(fd)
......@@ -42,7 +44,7 @@ def get_tempfile(ext=None, prefix=None, tgt_dir=None):
def get_generic_outpath(dir_out='', fName_out='', prefix='', ext='', create_outDir=True,
prevent_overwriting=False):
"""Generates an output path accourding to the given parameters.
"""Generate an output path accourding to the given parameters.
:param dir_out: output directory
:param fName_out: output filename
......
......@@ -36,6 +36,7 @@ from ...dtypes.conversion import dTypeDic_NumPy2GDALcompatible
def get_GDAL_ds_inmem(array, gt=None, prj=None, nodata=None):
"""Convert a numpy array into a GDAL dataset.
NOTE: Possibly the data type has to be automatically changed in order ensure GDAL compatibility!
:param array: <numpy.ndarray> in the shape (rows, columns, bands)
......
......@@ -102,6 +102,7 @@ def fill_arr_on_disk(argDict):
def convert_gdal_to_bsq__mp(in_path, out_path, band=1):
"""
Usage:
ref_ds,tgt_ds = gdal.Open(self.path_imref),gdal.Open(self.path_im2shift)
ref_pathTmp, tgt_pathTmp = None,None
......
......@@ -27,11 +27,10 @@ import numpy as np
from typing import List, Iterable # noqa F401 # flake8 issue
def get_outFillZeroSaturated(dtype):
"""Returns the values for 'fill-', 'zero-' and 'saturated' pixels of an image
to be written with regard to the target data type.
def get_outFillZeroSaturated(dtype) -> tuple:
"""Return proper 'fill-', 'zero-' and 'saturated' values with respect to the given data type.
:param dtype: data type of the image to be written
:param dtype: data type
"""
dtype = str(np.dtype(dtype))
assert dtype in ['int8', 'uint8', 'int16', 'uint16', 'float32'], \
......@@ -39,6 +38,7 @@ def get_outFillZeroSaturated(dtype):
dict_outFill = {'int8': -128, 'uint8': 0, 'int16': -9999, 'uint16': 9999, 'float32': -9999.}
dict_outZero = {'int8': 0, 'uint8': 1, 'int16': 0, 'uint16': 1, 'float32': 0.}
dict_outSaturated = {'int8': 127, 'uint8': 256, 'int16': 32767, 'uint16': 65535, 'float32': 65535.}
return dict_outFill[dtype], dict_outZero[dtype], dict_outSaturated[dtype]
......
......@@ -31,7 +31,8 @@ __author__ = "Daniel Scheffler"
def find_nearest(array, value, roundAlg='auto', extrapolate=False, exclude_val=False, tolerance=0):
# type: (Iterable, float, str, bool, bool, float) -> float
"""finds the value of an array nearest to a another single value
"""Find the value of an array nearest to a another single value.
NOTE: In case of extrapolation an EQUALLY INCREMENTED array (like a coordinate grid) is assumed!
:param array: array or list of numbers
......
......@@ -56,8 +56,7 @@ class Timer(object):
# return '%.2f sek' %(time()-self.starttime)
def __call__(self, percent01, message, user_data):
"""This allows that Timer instances are callable and thus can be used as callback function,
e.g. for GDAL.
"""Allow Timer instances to be callable and thus to be used as callback function, e.g., for GDAL.
:param percent01: this is not used but expected when used as GDAL callback
:param message: this is not used but expected when used as GDAL callback
......@@ -70,8 +69,10 @@ class Timer(object):
class ProgressBar(object):
def __init__(self, prefix='', suffix='Complete', decimals=1, barLength=50, show_elapsed=True,
timeout=None, use_as_callback=False, out=sys.stderr):
"""Call an instance of this class in a loop to create terminal progress bar. This class can also be used as
callback function, e.g. for GDAL. Just pass an instance of ProgressBar to the respective callback keyword.
"""Call an instance of this class in a loop to create terminal progress bar.
NOTE: This class can also be used as callback function, e.g. for GDAL.
Just pass an instance of ProgressBar to the respective callback keyword.
:param prefix: prefix string (Str)
:param suffix: suffix string (Str)
......@@ -92,7 +93,9 @@ class ProgressBar(object):
self.out = out
def print_progress(self, percent):
"""Based on http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console
"""Print progress.
- based on http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console.
:param percent: <float> a number between 0 and 100
:return:
......@@ -121,8 +124,7 @@ class ProgressBar(object):
self.out.flush()
def __call__(self, percent01, message, user_data):
"""This allows that ProgressBar instances are callable and thus can be used as callback function,
e.g. for GDAL.
"""Allow ProgressBar instances ato be callable and thus to be used as callback function, e.g., for GDAL.
:param percent01: a float number between 0 and 1
:param message: this is not used but expected when used as GDAL callback
......@@ -134,6 +136,7 @@ class ProgressBar(object):
def tqdm_hook(t):
"""
Wraps tqdm instance. Don't forget to close() or __exit__()
the tqdm instance once you're done with it (easiest using `with` syntax).
......@@ -166,7 +169,7 @@ def tqdm_hook(t):
def printPercentage(i, i_total):
"""Prints a percentage counter from within a loop.
"""Print a percentage counter from within a loop.
Example:
for i in range(100+1):
......
......@@ -12,7 +12,7 @@ else:
def get_geoinfo():
"""Returns a dictionary containing country, city, longitude, latitude and IP of the executing host."""
"""Return a dictionary containing country, city, longitude, latitude and IP of the executing host."""
url = 'http://ipinfo.io/json'
info = json.loads(urlopen(url).read())
......@@ -31,8 +31,7 @@ def get_geoinfo():
def is_connected(REMOTE_SERVER="www.google.com"):
"""Checks if an internet connection is present."""
"""Check if an internet connection is present."""
try:
# see if we can resolve the host name -- tells us if there is
# a DNS listening
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment