From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C53BC13888B for ; Tue, 5 Feb 2013 17:48:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4387421C00D; Tue, 5 Feb 2013 17:48:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 96FF221C00D for ; Tue, 5 Feb 2013 17:48:26 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5641833DF1C for ; Tue, 5 Feb 2013 17:48:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id EF25CE408E for ; Tue, 5 Feb 2013 17:48:23 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1360085153.24e73a658d50c29d4acc60f91722706a73719386.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/strutil.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 24e73a658d50c29d4acc60f91722706a73719386 X-VCS-Branch: master Date: Tue, 5 Feb 2013 17:48:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d1b6ec06-c90c-4267-b387-421703bc9ef4 X-Archives-Hash: 4f84f75d4038dad6355dadd409a67bed commit: 24e73a658d50c29d4acc60f91722706a73719386 Author: André Erdmann mailerd de> AuthorDate: Tue Feb 5 17:25:53 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Tue Feb 5 17:25:53 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=24e73a65 roverlay/strutil: wildcard_to_regex() --- roverlay/strutil.py | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/roverlay/strutil.py b/roverlay/strutil.py index 4a5ef5d..f5ab8fd 100644 --- a/roverlay/strutil.py +++ b/roverlay/strutil.py @@ -23,6 +23,20 @@ def split_whitespace ( _str, **kwargs ): return _WHITESPACE.split ( _str, **kwargs ) # --- end of split_whitespace (...) --- +def wildcard_to_regex ( _str, unsafe ): + # TODO: find a function that is more efficient + if unsafe: + return _str.replace ( '?', '.' ).replace ( '*', '.*?' ) + else: + return '[*]'.join ( + ( + '[?]'.join ( + i.replace ( '?', '.' ) for i in a.split ( '\\?' ) + ).replace ( '*', '.*?' ) + ) for a in _str.split ( '\\*' ) + ) +# --- end of wildcard_to_regex (...) --- + def fix_ebuild_name ( name ): """Removes illegal chars from an ebuild name by replacing them with an underscore char '_'.