Skip to content

Commit

Permalink
get_single does not search by itself
Browse files Browse the repository at this point in the history
  • Loading branch information
ARSadri committed Nov 3, 2023
1 parent a74291c commit 9758c97
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 127 deletions.
7 changes: 6 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,9 @@ History
0.10.6 (2023-10-19)
-----------------
* bugs fixed in multiprocessor and loopprocessor
* tests added
* tests added

0.10.7 (2023-11-01)
-----------------
* multiprocessor_gen is a generator that yields the list of arrived results
* get_flist and thus get_single do not put asterisks on their own.
2 changes: 1 addition & 1 deletion lognflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Alireza Sadri'
__email__ = '[email protected]'
__version__ = '0.10.5'
__version__ = '0.10.7'

from .lognflow import lognflow
from .logviewer import logviewer
Expand Down
34 changes: 16 additions & 18 deletions lognflow/logviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,9 @@ def get_flist(self, var_name, suffix = None):
else:
_var_name = (self.log_dir / var_name).name
_var_dir = (self.log_dir / var_name).parent
search_patt = f'{_var_name}*.{suffix}'
search_patt = f'{_var_name}.{suffix}'
search_patt = replace_all(search_patt, '**', '*')
flist = list(_var_dir.glob(search_patt))
if(len(flist) == 0):
search_patt = f'{_var_name}*.*'
search_patt = replace_all(search_patt, '**', '*')
flist = list(_var_dir.glob(search_patt))
if(len(flist) > 0):
self.logger(
'I Can not find the file with the given suffix, '\
+ 'but found some with a different suffix, '\
+ f'one file is: {flist[-1]}. This is what I'\
+ ' will return.' )

if(flist):
flist.sort()
else:
Expand Down Expand Up @@ -174,7 +163,7 @@ def get_text(self, log_name='main_log', flist = None, suffix = 'txt',
txt = txt[0]
return txt

def _get_single(self, var_name, file_index = -1,
def _get_single(self, var_name, file_index = None,
suffix = None, read_func = None, verbose = False):
""" get a single variable
return the value of a saved variable.
Expand Down Expand Up @@ -202,11 +191,20 @@ def _get_single(self, var_name, file_index = -1,
var_path = None
if flist:
if len(flist)>1:
if verbose:
self.logger( f'There are {len(flist)} files, logged with'
+ f' name {var_name}.'
+ f' The given index is {file_index}.')
var_path = flist[file_index]
if file_index is not None:
if verbose:
self.logger(
f'There are {len(flist)} files, logged with'
+ f' name {var_name}.'
+ f' The given index is {file_index}.')
var_path = flist[file_index]
else:
self.logger('-'*60)
self.logger(
f'There are {len(flist)} files, logged with'
+ f' name {var_name} but the index is not given.')
self.logger('-'*60)
return None

if(var_path.is_file()):
if verbose:
Expand Down
Loading

0 comments on commit 9758c97

Please sign in to comment.