Esempio n. 1
0
	def format_meta_info(x, t = '  '):
		r = ['PRODUCT META INFO:',]
		for k in BirdEyeIndexer._PRODUCT_META_INFO_KEYS:
			r.append(t+k+': ' + ';'.join(BirdEyeUtil.sorted(x[k])))
		for k in BirdEyeIndexer._PRODUCT_META_INFO_TIME_KEYS:
			r.append(t+k+': ' + x[k].format())
		r.append('\n')
		return '\n'.join(r)
Esempio n. 2
0
 def normalize_query_dict(q):
     r = dict()
     if isinstance(q, dict):
         for k, v in q.items():
             if isinstance(v, str):
                 r[k] = {v}
             elif BirdEyeUtil.is_str_collection(v):
                 r[k] = set(v)
     return r
Esempio n. 3
0
	def format_dict(d, leading_white_space=''):
		r = []
		k = sorted(list(d.keys()))
		for a in k:
			if isinstance(d[a], str):
				v = leading_white_space + a  +': ' + d[a]
			else:
				s = '('+str(len(d[a])) + ')'
				v = leading_white_space + a + s +': ' + ' '.join(BirdEyeUtil.sorted(d[a]))
			r.append(v)
		r.append('\n')
		return r
	def is_insight(dat):
		if not isinstance(dat, list):
			return False
		if len(dat) < 7:
			return False
		for line in dat:
			if not BirdEyeUtil.is_str_collection(line):
				return False
		line_lens = set([len(line) for line in dat])
		if len(line_lens) > 2:
			return False
		x = sorted(list(line_lens))
		if x[0] != len(dat[0]) or x[0] != len(dat[2]):
			return False
		return True
Esempio n. 5
0
 def unzip(self, raw):
     if raw.exists():
         csv = self.transform_path(raw, BirdEyeStorageType.RAW,
                                   BirdEyeStorageType.CSV)
         csv.parent.mkdir(parents=True, exist_ok=True)
         BirdEyeUtil.unzip(raw, csv)
Esempio n. 6
0
 def write_stations(self, project, date, site_stations_json):
     f = self.station_file_path(project, date)
     f.parent.mkdir(parents=True, exist_ok=True)
     BirdEyeUtil.write(f, 'w', site_stations_json)
Esempio n. 7
0
 def write(self, project, station, site, date, type, payload):
     f = self.file_path(project, station, site, type, date)
     f.parent.mkdir(parents=True, exist_ok=True)
     fmode = 'wb' if BirdEyeStorageType.is_binary(type) else 'w'
     BirdEyeUtil.write(f, fmode, payload)