Skip to content

Commit c991ca1

Browse files
committed
allows now for filtering by single string!
1 parent cdf1119 commit c991ca1

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

data_reader/logic.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ def isvalidselection(self, **kargs):
3838
valid = True
3939
if("ext" in kargs):
4040
extensions = kargs.get("ext")
41-
extensions = [x.strip().lower() for x in extensions]
41+
extensions = aux.sanitize(extensions)
4242
valid *= (("."+self.extension) in extensions)
4343
if("value" in kargs):
4444
values = kargs.get("value")
45-
values = [x.strip().lower() for x in values]
45+
values = aux.sanitize(values)
4646
valid *= (self.value in values)
4747
if("unit" in kargs):
48-
units = kargs.get("unit")
49-
units = [x.strip().lower() for x in units] #makes sure that the lower or capitalletter wont affect a comparison
48+
units = aux.sanitize(kargs.get("unit")) #makes sure that the lower or capitalletter wont affect a comparison
5049
#print("units of the file: " + str(units))
5150
valid *= (self.unit in units)
5251
if("prefix" in kargs):
53-
prefixes = kargs.get("prefix")
54-
prefixes = [x.strip().lower() for x in prefixes]
52+
prefixes = aux.sanitize(kargs.get("prefix"))
5553
valid *= self.prefix != "" and (self.prefix in prefixes)
5654
#as you can see you can add many more criteria in a very general way.
5755
#you just have to define put arg1 = value1 and create the code here to deal
@@ -154,7 +152,10 @@ def frompathlist(cls, pathlist, type = DataFile, ignore_empty_fn = False, **karg
154152
Filter by value using value = ('0800', '0900') for example.
155153
Filter by unit using unit = ('ma', ).
156154
157-
ALL FILTERS NEED TO BE PUT IN TUPLES EVEN IF A SINGLE VALUE. TODO: Allow for string input.
155+
ALL FILTERS CAN BE PUT IN TUPLES EVEN IF A SINGLE VALUE.
156+
Or USE A SINGLE STRING FOR INPUT.
157+
158+
value = "0800" is valid.
158159
159160
Use type to use classes which are derivated from DataFile through inheritance.
160161
"""

0 commit comments

Comments
 (0)