MCPcopy
hub / github.com/deadc0de6/dotdrop / _compare_dirs2

Method _compare_dirs2

dotdrop/comparator.py:138–172  ·  view source on GitHub ↗

compare directories

(self, local_path, deployed_path, ignore)

Source from the content-addressed store, hash-verified

136 return self._compare_dirs2(local_path, deployed_path, ignore)
137
138 def _compare_dirs2(self, local_path, deployed_path, ignore):
139 """compare directories"""
140 self.log.dbg(f'compare dirs {local_path} and {deployed_path}')
141 ret = []
142
143 local_tree = FTreeDir(local_path, ignores=ignore, debug=self.debug)
144 deploy_tree = FTreeDir(deployed_path, ignores=ignore, debug=self.debug)
145 lonly, ronly, common = local_tree.compare(deploy_tree)
146
147 for i in lonly:
148 path = os.path.join(local_path, i)
149 if os.path.isdir(path):
150 # ignore dir
151 continue
152 ret.append(f'=> \"{path}\" does not exist on destination\n')
153 if not self.ignore_missing_in_dotdrop:
154 for i in ronly:
155 path = os.path.join(deployed_path, i)
156 if os.path.isdir(path):
157 # ignore dir
158 continue
159 ret.append(f'=> \"{path}\" does not exist in dotdrop\n')
160
161 # test for content difference
162 # and mode difference
163 self.log.dbg(f'common files {common}')
164 for i in common:
165 source_file = os.path.join(local_path, i)
166 deployed_file = os.path.join(deployed_path, i)
167 subret = self._compare(source_file, deployed_file,
168 ignore=None, mode=None,
169 recurse=False)
170 ret.extend(subret)
171
172 return ''.join(ret)
173
174 def _diff(self, local_path, deployed_path, header=False):
175 """diff two files"""

Callers 1

_comp_dirMethod · 0.95

Calls 4

compareMethod · 0.95
_compareMethod · 0.95
FTreeDirClass · 0.90
dbgMethod · 0.80

Tested by

no test coverage detected