if type(s) == type(1):
return s
if s and type(s) == type(' '):
- return int(re.match('(^\d+)', s).groups()[0])
+ return int(re.match(r'^\s*(\d+)', s).groups()[0])
return 0
def str2float(s):
if type(s) == type(1.1):
return s
if s and type(s) == type(' '):
- return float(s)
+ m = re.match(r'^\s*([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+))', s)
+ return float(m.groups()[0])
return 0.0
def hr_size(sz, prec=1):
if args.end:
cfg['end'] = hms2s(args.end)
if args.grid:
- grid = re.split('[xX,;:]', args.grid)
+ grid = re.split(r'[xX,;:]', args.grid)
cfg['grid_columns'] = int(grid[0])
if len(grid) > 1:
cfg['grid_rows'] = int(grid[1])
mbox.setWindowTitle('Directory Removal Failed')
mbox.setIcon(QMessageBox.Critical)
mbox.setStandardButtons(QMessageBox.Ok)
- mbox.setText(re.sub('^\[.*\]\s*', '', str(e)).replace(':', ':\n\n', 1))
+ mbox.setText(re.sub(r'^\[.*\]\s*', '', str(e)).replace(':', ':\n\n', 1))
mbox.exec_()
self.refresh_list()
found = False
repl = '%s=%s' % (o[0], str(self.cfg[o[0]]))
for i in range(len(lines)):
- if re.match('^\w*%s\w*=' % o[0], lines[i]):
+ if re.match(r'^\s*%s\s*=' % o[0], lines[i]):
lines[i] = repl
found = True
break
if line:
line = line.decode()
ebuf += line
- x = re.search('pts_time:\d*\.?\d*', line)
+ x = re.search(r'pts_time:\d*\.?\d*', line)
if x is not None:
cnt += 1
t = x.group().split(':')[1]
eprint(0, str(e))
pass
for f in os.listdir(thdir):
- if re.match('^\d{8}\.png$', f):
+ if re.match(r'^\d{8}\.png$', f):
try:
os.unlink(os.path.join(thdir, f))
except Exception as e:
entry['vfile'] = opath
sz = cnt = 0
for f in os.listdir(d):
- if re.match('^\d{8}\.png$', f):
+ if re.match(r'^\d{8}\.png$', f):
cnt += 1
try:
sz += os.path.getsize(os.path.join(d, f))