Пример #1
0
	def write_data(self, data, dir, name):
		if len(data) == 0:
			print('	   WARNING: skipping writing ' + name + '; no namespace data found.')
		else:
			with open(os.path.join(dir, name), mode='w', encoding='utf8') as f:
				# insert header chunk
				if os.path.exists(dir+'/templates/'+name):
					tf = open(dir+'/templates/'+name, encoding="utf-8")
					header = tf.read().rstrip()
					tf.close()
					# add Namespace, Citation and Author values
					# source_file attribute added to object during parsing
					header = get_citation_info(name, header, self.source_file)
				else:
					print('WARNING: Missing header template for {0}'.format(name))
					header = '[Values]'
				f.write(header+'\n')
				# write data
				for i in sorted(data.items()):
					f.write('|'.join(i) + '\n')
Пример #2
0
def write_beleq(eq_dict, filename, source_file):
	""" Writes values and uuids from equivalence dictionary to .beleq file. """
	fullname = '.'.join((filename, 'beleq'))
	if len(eq_dict) == 0:
		print('	   WARNING: skipping writing ' + fullname + '; no equivalence data found.')
	else:
		with open(fullname, 'w') as f:
			# insert header chunk
			if os.path.exists('./templates/'+fullname):
				tf = open('./templates/'+fullname, encoding="utf-8")
				header = tf.read().rstrip()
				tf.close()
				# add Namespace and Author values
				header = get_citation_info(fullname, header, source_file)
			else:
				header = '[Values]'
			f.write(header+'\n')
			# write data
			for name, uid in sorted(eq_dict.items()):
				f.write('|'.join((name,str(uid))) + '\n')
Пример #3
0
 def write_data(self, data, dir, name):
     if len(data) == 0:
         print('	   WARNING: skipping writing ' + name +
               '; no namespace data found.')
     else:
         with open(os.path.join(dir, name), mode='w', encoding='utf8') as f:
             # insert header chunk
             if os.path.exists(dir + '/templates/' + name):
                 tf = open(dir + '/templates/' + name, encoding="utf-8")
                 header = tf.read().rstrip()
                 tf.close()
                 # add Namespace, Citation and Author values
                 # source_file attribute added to object during parsing
                 header = get_citation_info(name, header, self.source_file)
             else:
                 print('WARNING: Missing header template for {0}'.format(
                     name))
                 header = '[Values]'
             f.write(header + '\n')
             # write data
             for i in sorted(data.items()):
                 f.write('|'.join(i) + '\n')
Пример #4
0
def write_beleq(eq_dict, filename, source_file):
    """ Writes values and uuids from equivalence dictionary to .beleq file. """
    fullname = '.'.join((filename, 'beleq'))
    if len(eq_dict) == 0:
        print(
            '	   WARNING: skipping writing ' +
            fullname +
            '; no equivalence data found.')
    else:
        with open(fullname, 'w') as f:
            # insert header chunk
            if os.path.exists('./templates/' + fullname):
                tf = open('./templates/' + fullname, encoding="utf-8")
                header = tf.read().rstrip()
                tf.close()
                # add Namespace and Author values
                header = get_citation_info(fullname, header, source_file)
            else:
                header = '[Values]'
            f.write(header + '\n')
            # write data
            for name, uid in sorted(eq_dict.items()):
                f.write('|'.join((name, str(uid))) + '\n')