本文整理匯總了Python中distutils.filelist.glob_to_re方法的典型用法代碼示例。如果您正苦於以下問題:Python filelist.glob_to_re方法的具體用法?Python filelist.glob_to_re怎麽用?Python filelist.glob_to_re使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils.filelist
的用法示例。
在下文中一共展示了filelist.glob_to_re方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_glob_to_re
# 需要導入模塊: from distutils import filelist [as 別名]
# 或者: from distutils.filelist import glob_to_re [as 別名]
def test_glob_to_re(self):
sep = os.sep
if os.sep == '\\':
sep = re.escape(os.sep)
for glob, regex in (
# simple cases
('foo*', r'foo[^%(sep)s]*\Z(?ms)'),
('foo?', r'foo[^%(sep)s]\Z(?ms)'),
('foo??', r'foo[^%(sep)s][^%(sep)s]\Z(?ms)'),
# special cases
(r'foo\\*', r'foo\\\\[^%(sep)s]*\Z(?ms)'),
(r'foo\\\*', r'foo\\\\\\[^%(sep)s]*\Z(?ms)'),
('foo????', r'foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s]\Z(?ms)'),
(r'foo\\??', r'foo\\\\[^%(sep)s][^%(sep)s]\Z(?ms)')):
regex = regex % {'sep': sep}
self.assertEqual(glob_to_re(glob), regex)
示例2: test_glob_to_re
# 需要導入模塊: from distutils import filelist [as 別名]
# 或者: from distutils.filelist import glob_to_re [as 別名]
def test_glob_to_re(self):
sep = os.sep
if os.sep == '\\':
sep = re.escape(os.sep)
for glob, regex in (
# simple cases
('foo*', r'(?s:foo[^%(sep)s]*)\Z'),
('foo?', r'(?s:foo[^%(sep)s])\Z'),
('foo??', r'(?s:foo[^%(sep)s][^%(sep)s])\Z'),
# special cases
(r'foo\\*', r'(?s:foo\\\\[^%(sep)s]*)\Z'),
(r'foo\\\*', r'(?s:foo\\\\\\[^%(sep)s]*)\Z'),
('foo????', r'(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z'),
(r'foo\\??', r'(?s:foo\\\\[^%(sep)s][^%(sep)s])\Z')):
regex = regex % {'sep': sep}
self.assertEqual(glob_to_re(glob), regex)
示例3: test_glob_to_re
# 需要導入模塊: from distutils import filelist [as 別名]
# 或者: from distutils.filelist import glob_to_re [as 別名]
def test_glob_to_re(self):
sep = os.sep
if os.sep == '\\':
sep = re.escape(os.sep)
for glob, regex in (
# simple cases
('foo*', r'(?s:foo[^%(sep)s]*)\Z'),
('foo?', r'(?s:foo[^%(sep)s])\Z'),
('foo??', r'(?s:foo[^%(sep)s][^%(sep)s])\Z'),
# special cases
(r'foo\\*', r'(?s:foo\\\\[^%(sep)s]*)\Z'),
(r'foo\\\*', r'(?s:foo\\\\\\[^%(sep)s]*)\Z'),
('foo????', r'(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z'),
(r'foo\\??', r'(?s:foo\\\\[^%(sep)s][^%(sep)s])\Z')):
regex = regex % {'sep': sep}
self.assertEqual(glob_to_re(glob), adapt_glob(regex))
示例4: test_glob_to_re
# 需要導入模塊: from distutils import filelist [as 別名]
# 或者: from distutils.filelist import glob_to_re [as 別名]
def test_glob_to_re(self):
# simple cases
self.assertEqual(glob_to_re('foo*'), 'foo[^/]*\\Z(?ms)')
self.assertEqual(glob_to_re('foo?'), 'foo[^/]\\Z(?ms)')
self.assertEqual(glob_to_re('foo??'), 'foo[^/][^/]\\Z(?ms)')
# special cases
self.assertEqual(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*\Z(?ms)')
self.assertEqual(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*\Z(?ms)')
self.assertEqual(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)')
self.assertEqual(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)')