| 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) |