Browse Source

Make interhost, force_metadata private to Filter

tags/nilmtools-1.4.6^0
Jim Paris 8 years ago
parent
commit
dc26e32b6e
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      nilmtools/filter.py

+ 12
- 11
nilmtools/filter.py View File

@@ -172,8 +172,8 @@ class Filter(object):
self.dest = None
self.start = None
self.end = None
self.interhost = False
self.force_metadata = False
self._interhost = False
self._force_metadata = False
if parser_description is not None:
self.setup_parser(parser_description)
self.parse_args()
@@ -236,12 +236,12 @@ class Filter(object):
if dest_url is None:
dest_url = url
if url != dest_url:
self.interhost = True
self._interhost = True

self._client_src = Client(url)
self._client_dest = Client(dest_url)

if (not self.interhost) and (srcpath == destpath):
if (not self._interhost) and (srcpath == destpath):
raise ArgumentError("source and destination path must be different")

# Open the streams
@@ -259,8 +259,8 @@ class Filter(object):

# Print info
if not quiet:
print "Source:", self.src.string(self.interhost)
print " Dest:", self.dest.string(self.interhost)
print "Source:", self.src.string(self._interhost)
print " Dest:", self.dest.string(self._interhost)

def parse_args(self, argv = None):
"""Parse arguments from a command line"""
@@ -269,7 +269,7 @@ class Filter(object):
self.set_args(args.url, args.dest_url, args.srcpath, args.destpath,
args.start, args.end, quiet = False, parsed_args = args)

self.force_metadata = args.force_metadata
self._force_metadata = args.force_metadata
if args.dry_run:
for interval in self.intervals():
print interval.human_string()
@@ -280,7 +280,7 @@ class Filter(object):
"""Generate all the intervals that this filter should process"""
self._using_client = True

if self.interhost:
if self._interhost:
# Do the difference ourselves
s_intervals = ( Interval(start, end)
for (start, end) in
@@ -317,10 +317,11 @@ class Filter(object):
str(e), toparse))

def check_dest_metadata(self, data):
"""See if the metadata jives, and complain if it doesn't. If
there's no conflict, update the metadata to match 'data'."""
"""See if the metadata jives, and complain if it doesn't. For
each key in data, if the stream contains the key, it must match
values. If the stream does not contain the key, it is created."""
metadata = self._client_dest.stream_get_metadata(self.dest.path)
if not self.force_metadata:
if not self._force_metadata:
for key in data:
wanted = data[key]
if not isinstance(wanted, basestring):


Loading…
Cancel
Save