mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / get_css.mdwn
1 [[!meta  title="get_css.py"]]
2
3 The [Drexel physics department][dept] moved most of its content off of
4 the department servers and onto college servers this quarter.  The
5 college servers manage their content with SiteCore, so there was a
6 reasonable amount of trouble getting everything over (see
7 [[SiteCorePy]]).  Luckily, I got *lots* of help, and now I don't have
8 to worry about the content that has migrated :).  However, not all of
9 the content made the switch.
10
11 We have a number of forms and databases that stayed on our department
12 servers, and it's my job to make sure those pages look similar to the
13 SiteCore pages that link to them.  No problem, you say, just clone the
14 SiteCore page's CSS, and apply it to the local pages.  That's exactly
15 what I want to do, but the jittery folks upstream keep changing the
16 CSS, so my cloned CSS gets out of sync fairly quickly.  To minimize my
17 suffering, I've written a little script to automate the task of
18 cloning another page's CSS.
19
20 [[get_css.py]] scrapes an (X)HTML page for stylesheets (assuming there
21 is no embedded styling in the HTML itself).  It then downloads all
22 those CSS files, cleans them up with [cssutils][], and saves a single
23 clone stylesheet mimicking their behaviour.  It also downloads all
24 media referenced via `url(...)` entries in the CSS (e.g. background
25 images), and adjusts the CSS to point to the local copies.
26
27 [dept]: http://www.drexel.edu/physics/
28 [cssutils]: http://code.google.com/p/cssutils/
29
30 [[!tag tags/code]]
31 [[!tag tags/python]]
32 [[!tag tags/web]]