nicer printing on terminal
This commit is contained in:
@@ -324,6 +324,7 @@ def createthumbs(path,list,options):
|
|||||||
nsum=len(list)
|
nsum=len(list)
|
||||||
r=str(options.width)
|
r=str(options.width)
|
||||||
res=r+'x'+r+'>'
|
res=r+'x'+r+'>'
|
||||||
|
print('')
|
||||||
for i in list:
|
for i in list:
|
||||||
outmedium=os.path.join(path,'.med',i+'.jpg')
|
outmedium=os.path.join(path,'.med',i+'.jpg')
|
||||||
outthumb=os.path.join(path,'.tn',i+'.jpg')
|
outthumb=os.path.join(path,'.tn',i+'.jpg')
|
||||||
@@ -333,12 +334,13 @@ def createthumbs(path,list,options):
|
|||||||
if (options.force) and os.path.exists(outthumb):
|
if (options.force) and os.path.exists(outthumb):
|
||||||
os.unlink(outthumb)
|
os.unlink(outthumb)
|
||||||
if (not os.path.exists(outmedium)):
|
if (not os.path.exists(outmedium)):
|
||||||
print('Medium.. '+i+' '+str(n)+'/'+str(nsum))
|
print_clear('Medium.. '+str(n)+'/'+str(nsum)+' '+i)
|
||||||
create_medium_bitmap(inpath,outmedium,r,link=options.link,vector=vectorsearch.match(i))
|
create_medium_bitmap(inpath,outmedium,r,link=options.link,vector=vectorsearch.match(i))
|
||||||
if (not os.path.exists(outthumb)):
|
if (not os.path.exists(outthumb)):
|
||||||
print('Thumbnail.. '+i+' '+str(n)+'/'+str(nsum))
|
print_clear('Thumbnail.. '+str(n)+'/'+str(nsum)+' '+i)
|
||||||
create_thumb_bitmap(outmedium,outthumb,vector=vectorsearch.match(i),gravity=options.gravity)
|
create_thumb_bitmap(outmedium,outthumb,vector=vectorsearch.match(i),gravity=options.gravity)
|
||||||
n+=1
|
n+=1
|
||||||
|
print_clear('')
|
||||||
return
|
return
|
||||||
|
|
||||||
def create_medium_bitmap(infile,outfile,r,link=False,vector=False):
|
def create_medium_bitmap(infile,outfile,r,link=False,vector=False):
|
||||||
@@ -407,6 +409,11 @@ def crumblinks(crumbs,title,parent):
|
|||||||
strout+='</div>'
|
strout+='</div>'
|
||||||
return strout
|
return strout
|
||||||
|
|
||||||
|
def print_clear(s):
|
||||||
|
sys.stdout.write("\033[1K\r")
|
||||||
|
sys.stdout.write(str(s))
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
def nicestring(s):
|
def nicestring(s):
|
||||||
''' Returns a nice version of a long string '''
|
''' Returns a nice version of a long string '''
|
||||||
s = unicode(s, encoding = "utf8")
|
s = unicode(s, encoding = "utf8")
|
||||||
@@ -428,11 +435,13 @@ def sizestring(size):
|
|||||||
return "%3.1f%s" % (size, x)
|
return "%3.1f%s" % (size, x)
|
||||||
size /= 1024.0
|
size /= 1024.0
|
||||||
|
|
||||||
|
|
||||||
def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
|
def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
|
||||||
''' Natural sort / Claudiu@Stackoverflow '''
|
''' Natural sort / Claudiu@Stackoverflow '''
|
||||||
return [int(text) if text.isdigit() else text.lower()
|
return [int(text) if text.isdigit() else text.lower()
|
||||||
for text in re.split(_nsre, s)]
|
for text in re.split(_nsre, s)]
|
||||||
|
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
''' emulate shell which command '''
|
''' emulate shell which command '''
|
||||||
def is_exe(fpath):
|
def is_exe(fpath):
|
||||||
|
|||||||
Reference in New Issue
Block a user