[skip ci] started to replace .format() with f-strings
This commit is contained in:
parent
3d93a5ff00
commit
4314ec1f37
|
@ -157,7 +157,7 @@ class ASCIItable():
|
|||
def head_write(self,
|
||||
header = True):
|
||||
"""Write current header information (info + labels)."""
|
||||
head = ['{}\theader'.format(len(self.info)+self.__IO__['labeled'])] if header else []
|
||||
head = [f"{len(self.info)+self.__IO__['labeled']}\theader"] if header else []
|
||||
head.append(self.info)
|
||||
if self.__IO__['labeled']:
|
||||
head.append('\t'.join(map(self._quote,self.tags)))
|
||||
|
@ -209,7 +209,7 @@ class ASCIItable():
|
|||
labelList.append(tags[id])
|
||||
else:
|
||||
label = tags[id][2:] # get label
|
||||
while id < len(tags) and tags[id] == '{}_{}'.format(dim,label): # check successors
|
||||
while id < len(tags) and tags[id] == f'{dim}_{label}': # check successors
|
||||
id += 1 # next label...
|
||||
dim += 1 # ...should be one higher dimension
|
||||
labelList.append(label) # reached end --> store
|
||||
|
|
|
@ -233,7 +233,7 @@ def cell_coord0_gridSizeOrigin(coord0,ordered=True):
|
|||
origin[_np.where(grid==1)] = 0.0
|
||||
|
||||
if grid.prod() != len(coord0):
|
||||
raise ValueError('Data count {} does not match grid {}.'.format(len(coord0),grid))
|
||||
raise ValueError('Data count {len(coord0)} does not match grid {grid}.')
|
||||
|
||||
start = origin + delta*.5
|
||||
end = origin - delta*.5 + size
|
||||
|
@ -384,7 +384,7 @@ def node_coord0_gridSizeOrigin(coord0,ordered=True):
|
|||
origin = mincorner
|
||||
|
||||
if (grid+1).prod() != len(coord0):
|
||||
raise ValueError('Data count {} does not match grid {}.'.format(len(coord0),grid))
|
||||
raise ValueError('Data count {len(coord0)} does not match grid {grid}.')
|
||||
|
||||
atol = _np.max(size)*5e-2
|
||||
if not (_np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],grid[0]+1),atol=atol) and \
|
||||
|
|
|
@ -125,7 +125,7 @@ def execute(cmd,
|
|||
stdout = stdout.decode('utf-8').replace('\x08','')
|
||||
stderr = stderr.decode('utf-8').replace('\x08','')
|
||||
if process.returncode != 0:
|
||||
raise RuntimeError('{} failed with returncode {}'.format(cmd,process.returncode))
|
||||
raise RuntimeError(f'{cmd} failed with returncode {process.returncode}')
|
||||
return stdout, stderr
|
||||
|
||||
|
||||
|
@ -223,21 +223,20 @@ class _ProgressBar:
|
|||
self.start_time = datetime.datetime.now()
|
||||
self.last_fraction = 0.0
|
||||
|
||||
sys.stderr.write('{} {} 0% ETA n/a'.format(self.prefix, '░'*self.bar_length))
|
||||
sys.stderr.write(f"{self.prefix} {'░'*self.bar_length} 0% ETA n/a")
|
||||
sys.stderr.flush()
|
||||
|
||||
def update(self,iteration):
|
||||
|
||||
fraction = (iteration+1) / self.total
|
||||
filled_length = int(self.bar_length * fraction)
|
||||
|
||||
if int(self.bar_length * fraction) > int(self.bar_length * self.last_fraction):
|
||||
if filled_length > int(self.bar_length * self.last_fraction):
|
||||
bar = '█' * filled_length + '░' * (self.bar_length - filled_length)
|
||||
delta_time = datetime.datetime.now() - self.start_time
|
||||
remaining_time = (self.total - (iteration+1)) * delta_time / (iteration+1)
|
||||
remaining_time -= datetime.timedelta(microseconds=remaining_time.microseconds) # remove μs
|
||||
|
||||
filled_length = int(self.bar_length * fraction)
|
||||
bar = '█' * filled_length + '░' * (self.bar_length - filled_length)
|
||||
sys.stderr.write('\r{} {} {:>4.0%} ETA {}'.format(self.prefix, bar, fraction, remaining_time))
|
||||
sys.stderr.write('\r{self.prefix} {bar} {fraction:>4.0%} ETA {remaining_time}')
|
||||
sys.stderr.flush()
|
||||
|
||||
self.last_fraction = fraction
|
||||
|
@ -249,7 +248,7 @@ class _ProgressBar:
|
|||
|
||||
class bcolors:
|
||||
"""
|
||||
ASCII Colors.
|
||||
ASCII colors.
|
||||
|
||||
https://svn.blender.org/svnroot/bf-blender/trunk/blender/build_files/scons/tools/bcolors.py
|
||||
https://stackoverflow.com/questions/287871
|
||||
|
|
Loading…
Reference in New Issue