Browse Source

More filter cleanup

tags/nilmtools-1.3.1
Jim Paris 9 years ago
parent
commit
d7d5ccc9a7
1 changed files with 6 additions and 11 deletions
  1. +6
    -11
      nilmtools/filter.py

+ 6
- 11
nilmtools/filter.py View File

@@ -70,8 +70,8 @@ def get_stream_info(client, path):
return StreamInfo(client.geturl(), streams[0])

# Filter processing for a single interval of data.
def process_numpy_interval(interval, extractor, inserter,
function, args = None, warn_rows = None):
def process_numpy_interval(interval, extractor, inserter, warn_rows,
function, args = None):
"""For the given 'interval' of data, extract data, process it
through 'function', and insert the result.

@@ -202,11 +202,6 @@ class Filter(object):
self._parser = parser
return parser

def interval_string(self, interval):
return sprintf("[ %s -> %s ]",
timestamp_to_human(interval.start),
timestamp_to_human(interval.end))

def set_args(self, url, dest_url, srcpath, destpath, start, end,
parsed_args = None, quiet = True):
"""Set arguments directly from parameters"""
@@ -249,7 +244,7 @@ class Filter(object):
self.force_metadata = args.force_metadata
if args.dry_run:
for interval in self.intervals():
print self.interval_string(interval)
print interval.human_string()
raise SystemExit(0)
return args

@@ -364,9 +359,9 @@ class Filter(object):
inserter_func = functools.partial(inserter, self.dest.path)

for interval in self.intervals():
print "Processing", self.interval_string(interval)
print "Processing", interval.human_string()
process_numpy_interval(interval, extractor_func, inserter_func,
function, args, warn_rows = rows * 3)
rows * 3, function, args)

def main(argv = None):
# This is just a dummy function; actual filters can use the other
@@ -375,7 +370,7 @@ def main(argv = None):
parser = f.setup_parser()
args = f.parse_args(argv)
for i in f.intervals():
print "Generic filter: need to handle", f.interval_string(i)
print "Generic filter: need to handle", i.human_string()

if __name__ == "__main__":
main()

Loading…
Cancel
Save