MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / dict2string

Method dict2string

dev/scripts/examples/example_generator.py:768–802  ·  view source on GitHub ↗
(self, d)

Source from the content-addressed store, hash-verified

766 return out
767
768 def dict2string(self, d):
769 if d['type'] == 'comment':
770 l = '# ' + d['comment']
771 elif d['type'] == 'function':
772 l = self.map_function(d['function']) + '(' + ', '.join(self.parse_arguments(d['arguments'])) + ')'
773 elif d['type'] == 'print':
774 args = self.parse_arguments(d['arguments'])
775 l = 'writeLines(paste(' + ', \' \', '.join(args) + '))'
776 elif d['type'] == 'vector':
777 args = self.parse_arguments(d['arguments'])
778 l = '[' + ', '.join(args) + ']'
779 elif d['type'] == 'class_dereference':
780 l = d['name'] + '$' + self.dict2string(d['RHS'])
781 elif d['type'] == 'enum':
782 l = '"' + d['key'] + '"'
783 elif d['type'] == 'custom_assignment':
784 type_name = self.type_name_mapping[d['variable_type']]
785 if type_name:
786 LHS = type_name + ' ' + d['variable_name']
787 else:
788 LHS = d['variable_name']
789
790 if d['RHS']['type'] != 'vector':
791 RHS = self.dict2string(d['RHS'])
792 else: # Custom processing for vector assignment
793 pushes = [d['variable_name'] + ' <- ' + arg + ';' for arg in d['RHS']['arguments']]
794 RHS = 'c(' + ', '.join([arg for arg in d['RHS']['arguments']]) + ')'
795
796 l = ' '.join([LHS, '=', RHS])
797 else:
798 l = '??????????????????????????????'
799
800 if 'EOL' in d and d['EOL']:
801 l += ''
802 return l
803
804 def header(self):
805 return 'dyn.load(paste("CoolPropR", .Platform$dynlib.ext, sep=""))\nlibrary(methods) # See http://stackoverflow.com/a/19468533\nsource("CoolProp.R")\ncacheMetaData(1)\n'

Callers 2

parse_argumentsMethod · 0.95
parseMethod · 0.45

Calls 2

parse_argumentsMethod · 0.95
map_functionMethod · 0.80

Tested by

no test coverage detected