From 67e562e2f387334d24fac85e2d2141e02bf59820 Mon Sep 17 00:00:00 2001 From: Konstantin Stepanov Date: Mon, 20 Dec 2010 21:31:20 +0200 Subject: [PATCH] support \xXX escape characters in args field --- dbuscron/parser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dbuscron/parser.py b/dbuscron/parser.py index 8184d75..8610f79 100644 --- a/dbuscron/parser.py +++ b/dbuscron/parser.py @@ -3,6 +3,13 @@ from __future__ import with_statement import re from dbuscron.bus import DbusBus +def unescape(value): + if not value or r'\x' not in value: + return value + + r = re.compile(r'\\x([0-9A-Fa-f]{2})') + return r.sub(lambda m: chr(int(m.group(1), 16)), value) + def product(*args): if args: head, tail = args[0], args[1:] @@ -96,7 +103,7 @@ class CrontabParser(object): raise CrontabParserError('Unexpected bus value', lineno, expected=('S', 's', '*')) if r[7]: - r[7] = r[7].split(';') + r[7] = map(unescape, r[7].split(';')) ruled = dict() for i, f in enumerate(self.__fields): -- 1.7.9.5