diff --git a/python/podio_class_generator.py b/python/podio_class_generator.py index 46ae0e422..836620f0f 100755 --- a/python/podio_class_generator.py +++ b/python/podio_class_generator.py @@ -51,8 +51,7 @@ def configure_clang_format(self, apply): print " Please make sure it is in the PATH." self.clang_format = [] return - self.clang_format = [cformat_exe, "-i", "-style=file", "-fallback-style=llvm"] - + self.clang_format = [cformat_exe, "-style=file", "-fallback-style=llvm"] def process(self): self.reader.read() @@ -1034,7 +1033,7 @@ def prepare_vectorized_access(self, classname,members ): declaration += "\ttemplate\n\tconst std::array<%s,arraysize> %s() const;\n" %(klass, name) return declaration, implementation - def write_file(self, name,content): + def write_file(self, name, content): #dispatch headers to header dir, the rest to /src # fullname = os.path.join(self.install_dir,self.package_name,name) if name.endswith("h"): @@ -1042,9 +1041,14 @@ def write_file(self, name,content): else: fullname = os.path.join(self.install_dir,"src",name) if not self.dryrun: - open(fullname, "w").write(content) if self.clang_format: - subprocess.call(self.clang_format + [fullname]) + cfproc = subprocess.Popen(self.clang_format, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + content = cfproc.communicate(input=content)[0] + existing_content = '' + if os.path.exists(fullname): + existing_content = open(fullname, 'r').read() + if existing_content != content: + open(fullname, 'w').write(content) def evaluate_template(self, filename, substitutions): """ reads in a given template, evaluates it