MCPcopy
hub / github.com/eudicots/Cactus / build

Method build

cactus/static/__init__.py:156–183  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

154 self.discarded = True #TODO: Warn on usage of the static!
155
156 def build(self):
157
158 # See if we can maybe skip this if the file did not change
159 curr_hash = file_changed_hash(self.full_source_path)
160 prev_hash = self.site._static_file_cache.get(self.full_source_path)
161
162 if os.path.exists(self.full_build_path):
163 if curr_hash == prev_hash:
164 logger.debug("skip building (unchanged) %s %s", self.src_name, self.final_url)
165 return
166
167 self.site._static_file_cache[self.full_source_path] = curr_hash
168
169 self.site.plugin_manager.preBuildStatic(self)
170
171 if self.discarded:
172 return
173
174 logger.debug('Building {0} --> {1}'.format(self.src_name, self.full_build_path))
175
176 try:
177 os.makedirs(os.path.dirname(self.full_build_path))
178 except OSError:
179 pass
180
181 shutil.copy(self._preprocessing_path, self.full_build_path)
182
183 # self.site.plugin_manager.postBuildStatic(self)
184
185 def __repr__(self):
186 return '<Static: {0}>'.format(self.src_filename)

Callers 15

test_non_criticalMethod · 0.45
test_deregisterMethod · 0.45
test_runMethod · 0.45
test_extensionsMethod · 0.45
test_discardMethod · 0.45
test_callMethod · 0.45
testBuildMethod · 0.45
testRenderPageMethod · 0.45
testPageContextMethod · 0.45
testStaticLoaderMethod · 0.45
test_current_pageMethod · 0.45

Calls 4

file_changed_hashFunction · 0.90
preBuildStaticMethod · 0.80
formatMethod · 0.80
getMethod · 0.45

Tested by 15

test_non_criticalMethod · 0.36
test_deregisterMethod · 0.36
test_runMethod · 0.36
test_extensionsMethod · 0.36
test_discardMethod · 0.36
test_callMethod · 0.36
testBuildMethod · 0.36
testRenderPageMethod · 0.36
testPageContextMethod · 0.36
testStaticLoaderMethod · 0.36
test_current_pageMethod · 0.36