def get_css_images(): ''' return some generated CSS with stuff related to images (?) ''' import path sep1 = get('infobox.shortseparatorimage') sep2 = get('infobox.longseparatorimage') return (''' hr { border-style: none; height: %spx; background: url("%s"); }''' % (sep1.Size.height, path.path(sep1.Path).url())) +\ (''' hr[type="2"] { border-style: none; height: %spx; background: url("%s"); } ''' % (sep2.Size.height, path.path(sep2.Path).url()))
def get_svn_revision(): with traceguard: import package return package.getversion() import re import path digsby_root = str(path.path(__file__).parent.parent.parent) revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') for base,dirs,_files in os.walk(digsby_root): if '.svn' not in dirs: dirs[:] = [] continue # no sense walking uncontrolled subdirs dirs.remove('.svn') f = open(os.path.join(base,'.svn','entries')) data = f.read() f.close() if data.startswith('<?xml'): dirurl = urlre.search(data).group(1) # get repository URL localrev = max([int(m.group(1)) for m in revre.finditer(data)]+[0]) else: try: _svnver = int(data.splitlines()[0]) except Exception: _svnver=-1 if data<8: # log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' or '9' dirurl = data[0][3] localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) if base==str(digsby_root): base_url = dirurl+'/' # save the root url elif not dirurl.startswith(base_url): dirs[:] = [] continue # not part of the same svn tree, skip it revision = max(revision, localrev) return str(revision)