annotate scripts/logformat.py @ 7044:eaf600434cf5

less: change markup and styling for the logo shown in the top left corner Based on work by Dominik Ruf, but in this changeset, the goal is just to improve markup and styling while keeping exactly the same look and feel. In that process, it also fixes some browser specific issues that gave odd spacing/positioning. All styling (especially the logo image URL) is moved to CSS/LESS, using background-image styling instead of an img tag. The logo image is made a :before on the site branding text and will usually have to align with this text, so we use inline-block to align to the baseline. We set the right amount of negative margin-bottom so the image can go below the baseline. We use a "big enough" negative margin-top to allow the image to bleed outside the line height and into the 12px top padding. We assume the background image doesn't need cropping or panning and do thus not set background-size, background-position, or background-repeat.
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 27 Nov 2017 02:55:44 +0100
parents 665dfa112f2c
children 4473f1094d3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5599
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
1 #!/usr/bin/env python2
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
2
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
3 import re
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
4 import sys
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
5
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
6 if len(sys.argv) < 2:
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
7 print 'Cleanup of superfluous % formatting of log statements.'
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
8 print 'Usage:'
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
9 print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff'''
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
10 raise SystemExit(1)
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
11
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
12
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
13 logre = r'''
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
14 (log\.(?:error|info|warning|debug)
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
15 [(][ \n]*
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
16 )
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
17 %s
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
18 (
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
19 [ \n]*[)]
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
20 )
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
21 '''
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
22 res = [
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
23 # handle % () - keeping spaces around the old %
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
24 (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
25 # handle % without () - keeping spaces around the old %
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
26 (re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
27 # remove extra space if it is on next line
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
28 (re.compile(logre % r'''("[^"]*"|'[^']*') , (\n [ ]) ([ ][\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
29 # remove extra space if it is on same line
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
30 (re.compile(logre % r'''("[^"]*"|'[^']*') , [ ]+ () ( [\n ]+) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
31 # remove trailing , and space
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
32 (re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
33 ]
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
34
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
35 for f in sys.argv[1:]:
6860
665dfa112f2c py3: replace "file" with "open"
Lars Kruse <devel@sumpfralle.de>
parents: 5599
diff changeset
36 s = open(f).read()
5599
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
37 for r, t in res:
8bc8366a6874 cleanup: introduce scripts/logformat.py for cleanup of string formatting of logging statements
Mads Kiilerich <madski@unity3d.com>
parents:
diff changeset
38 s = r.sub(t, s)
6860
665dfa112f2c py3: replace "file" with "open"
Lars Kruse <devel@sumpfralle.de>
parents: 5599
diff changeset
39 open(f, 'w').write(s)