# Path: version_metadata/utils.py
# def sanity_check_fail(msg):
# 	def __init__(self, message, iterable):
# 	def __init__(self):
# 	def __call__(self, m):
# 	def entry(self, m): 
# 	def warn(self, m):
# 	def debugonly(self, *args):
# 	def trystr(self, x):
# 	def __init__(self):
# 	def fread(self, f, encoding=''):
# 	def fentries(self, f):
# 	def writel(self, f, entries, sep=b'\n', encoding=None):
# 	def dumpf(self, f, data):
# 	def fexists(self, filename):
# 	def demanduniq(self, iterable):
# 	def tryuniq(self, iterable):
# 	def safedict(self, tuples):
# 	def now(self):
# 	def basename(self, f):
# 	def getpath(data, ifmissing, *args):
# 	def __init__(self):
# 	def loadf(self, f):
# 	def dumpf(self, f, data):
# 	def multidictLoadf(self, f):
# 	def loads(self, data):
# 	def multidictLoadStr(self, data):
# 		def multidictParser(pairs):
# 	def pretty(self, arg):
# 	def pp(self, arg):
# 	def copyobj(self, x):
# class NonUniqException(Exception):
# class Logger:
# class Utils:
# class Json:


from lxml import etree
from collections import defaultdict
from .utils import cmn, json2, logger, NonUniqException
				attrhash[tag].append(value)
			except NonUniqException as err:
				logger.warn("#warn... malformed tag value block {0}\n".format(str([e.findall('TAG'), e.findall('VALUE')])) )

		return dict(attrhash)
	def parse(self, obj):
		hashed =  self.extract_from_sra_body(obj)
		logger.debugonly(hashed, obj)
		hashed['attributes'] = self.parse_attributes_block(obj, obj.tag)
		return self.from_sra_main_to_attributes(hashed)
	def obj_xmljson(self):
		root = self.xml.getroot()
		offspring = list(root.getchildren())
		return [(e, self.parse(e)) for e in offspring]
	def attributes(self):
		root = self.xml.getroot()
		root_tag = root.tag
		if not root_tag in self.expected_root_tags:
			utils.sanity_check_fail('__root_tag_not_as_expected__:' + root_tag)
		objtype = root_tag[0:-4]
		offspring = root.getchildren()
		objs = [self.parse(e) for e in offspring]
		return objs
	def nOffspring(self):
		root = self.xml.getroot()
		return len(root.getchildren())


if __name__ == '__main__':
	x = SRAParseObjSet.from_file('samples.092015.xml')

# Path: version_metadata/utils.py
# def sanity_check_fail(msg):
# 	def __init__(self, message, iterable):
# 	def __init__(self):
# 	def __call__(self, m):
# 	def entry(self, m): 
# 	def warn(self, m):
# 	def debugonly(self, *args):
# 	def trystr(self, x):
# 	def __init__(self):
# 	def fread(self, f, encoding=''):
# 	def fentries(self, f):
# 	def writel(self, f, entries, sep=b'\n', encoding=None):
# 	def dumpf(self, f, data):
# 	def fexists(self, filename):
# 	def demanduniq(self, iterable):
# 	def tryuniq(self, iterable):
# 	def safedict(self, tuples):
# 	def now(self):
# 	def basename(self, f):
# 	def getpath(data, ifmissing, *args):
# 	def __init__(self):
# 	def loadf(self, f):
# 	def dumpf(self, f, data):
# 	def multidictLoadf(self, f):
# 	def loads(self, data):
# 	def multidictLoadStr(self, data):
# 		def multidictParser(pairs):
# 	def pretty(self, arg):
# 	def pp(self, arg):
# 	def copyobj(self, x):
# class NonUniqException(Exception):
# class Logger:
# class Utils:
# class Json:


# Path: version_metadata/sraparse.py
from lxml import etree
from collections import defaultdict
from .utils import cmn, json2, logger, NonUniqException

				attrhash[tag].append(value)
			except NonUniqException as err:
				logger.warn("#warn... malformed tag value block {0}\n".format(str([e.findall('TAG'), e.findall('VALUE')])) )

		return dict(attrhash)
	def parse(self, obj):
		hashed =  self.extract_from_sra_body(obj)
		logger.debugonly(hashed, obj)
		hashed['attributes'] = self.parse_attributes_block(obj, obj.tag)
		return self.from_sra_main_to_attributes(hashed)
	def obj_xmljson(self):
		root = self.xml.getroot()
		offspring = list(root.getchildren())
		return [(e, self.parse(e)) for e in offspring]
	def attributes(self):
		root = self.xml.getroot()
		root_tag = root.tag
		if not root_tag in self.expected_root_tags:
			utils.sanity_check_fail('__root_tag_not_as_expected__:' + root_tag)
		objtype = root_tag[0:-4]
		offspring = root.getchildren()
		objs = [self.parse(e) for e in offspring]
		return objs
	def nOffspring(self):
		root = self.xml.getroot()
		return len(root.getchildren())


if __name__ == '__main__':
	x = SRAParseObjSet.from_file('samples.092015.xml')

	json2.pp(x.attributes())