[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: l10n-kde4/scripts
From: Chusslove Illich <caslav.ilic () gmx ! net>
Date: 2008-06-01 2:28:15
Message-ID: 1212287295.206714.27734.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 815044 by ilic:
Saner mapping format for (e.g. for track-unbundled) in l10n-spec files. Allow globs. \
When reporting new states, output the original and its revision too.
M +68 -22 lbundle-check.py
--- trunk/l10n-kde4/scripts/lbundle-check.py #815043:815044
@@ -1,9 +1,15 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
-import sys, os, re, codecs, shutil
+import sys
+import os
+import re
+import codecs
+import shutil
+import time
+import md5
+import glob
from optparse import OptionParser
-import time, md5
def message (msg, src="", line=0, dest=sys.stdout):
@@ -74,7 +80,7 @@
for state, files in cstats.new_state.iteritems():
if files:
repstr += "New '%s': %d\n" % (state, len(files))
- repstr += "".join([" %s\n" % x for x in files])
+ repstr += "".join([" %s (%s %s)\n" % x for x in files])
if repstr:
repstr = "--------------------\n" + repstr
sys.stdout.write(repstr)
@@ -339,19 +345,56 @@
def _parse_fmap (self, mapstr, key, filepath, lineno):
- lst = mapstr.split()
- if len(lst) % 2 != 0:
- error("need even number of elements in '%s'" % key,
- filepath, lineno)
-
- # Make a map by each pair of elements,
- # but replace second element with first when requested.
fmap = {}
- for lfile, sfile in zip(lst[::2], lst[1::2]):
- if sfile == "<":
- fmap[lfile] = lfile
+ mapstr += " " # sentry
+ basedir = os.path.dirname(filepath)
+ offbase = len(basedir + os.path.sep)
+ cpath = [""]
+ inpair = False
+ inpath = False
+ escaped = False
+ for c in mapstr:
+ if escaped:
+ escaped = False
+ cpath[-1] += c
+ elif inpath:
+ if c == "\\":
+ escaped = True
+ elif c.isspace():
+ inpath = False
+ lst = glob.glob(os.path.join(basedir, cpath[0]))
+ for path in lst:
+ path = path[offbase:]
+ fmap[path] = path
+ cpath = [""]
+ else:
+ cpath[-1] += c
+ elif inpair:
+ if c == "\\":
+ escaped = True
+ elif c == ")":
+ if not cpath[-1]:
+ cpath.pop()
+ if len(cpath) != 2:
+ print cpath
+ error("wrong number of paths in mapping pair",
+ filepath, lineno)
+ fmap[cpath[0]] = cpath[1]
+ inpair = False
+ cpath = [""]
+ elif c.isspace():
+ cpath.append("")
+ else:
+ cpath[-1] += c
else:
- fmap[lfile] = sfile
+ if c == "(":
+ inpair = True
+ elif not c.isspace():
+ inpath = True
+ if c == "\\":
+ escaped = True
+ else:
+ cpath = [c]
return fmap
@@ -594,6 +637,7 @@
track_filename = "l10n-track"
bspecs = {}
btracks = {}
+ path = os.path.normpath(path)
for root, dirs, files in os.walk(path):
@@ -781,8 +825,8 @@
# or warn about bundled file with no original.
# Stop further processing.
if not os.path.isfile(origpath):
- set_file_state(filepath, bfilepath, bspec, btrack, cstats, options,
- BTR_S_OBSOLETE)
+ set_file_state(filepath, bfilepath, origpath, bspec, btrack, cstats,
+ options, BTR_S_OBSOLETE)
return
# Compare the current checksum of the original file with the recorded.
@@ -790,16 +834,17 @@
# Stop further processing.
checksum = file_checksum(origpath)
if btrack[bfilepath].checksum != checksum:
- set_file_state(filepath, bfilepath, bspec, btrack, cstats, options,
- BTR_S_FUZZY)
+ set_file_state(filepath, bfilepath, origpath, bspec, btrack, cstats,
+ options, BTR_S_FUZZY)
return
# All checks passed, bundled file in pristine state.
- set_file_state(filepath, bfilepath, bspec, btrack, cstats, options,
- BTR_S_OK)
+ set_file_state(filepath, bfilepath, origpath, bspec, btrack, cstats,
+ options, BTR_S_OK)
-def set_file_state (filepath, bfilepath, bspec, btrack, cstats, options, state):
+def set_file_state (filepath, bfilepath, origpath, bspec, btrack, cstats,
+ options, state):
if bspec.strict:
nbfilepath = filename_by_state(bfilepath, state)
@@ -821,7 +866,8 @@
bfilepath = nbfilepath
if btrack[bfilepath].state != state:
- cstats.new_state[state].append(filepath)
+ cstats.new_state[state].append((filepath, origpath,
+ btrack[bfilepath].revision))
btrack[bfilepath].state = state
if not bspec.locvcs.is_versioned_file(filepath):
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic