~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: John Arbash Meinel
  • Date: 2008-08-25 21:50:11 UTC
  • mfrom: (0.11.3 tools)
  • mto: This revision was merged to the branch mainline in revision 3659.
  • Revision ID: john@arbash-meinel.com-20080825215011-de9esmzgkue3e522
Merge in Lukáš's helper scripts.
Update the packaging documents to describe how to do the releases
using bzr-builddeb to package all distro platforms
simultaneously.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2008 Canonical Ltd
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
214
214
            if match:
215
215
                return patterns[match.lastindex -1]
216
216
        return None
217
 
        
 
217
 
 
218
 
 
219
class _OrderedGlobster(Globster):
 
220
    """A Globster that keeps pattern order."""
 
221
 
 
222
    def __init__(self, patterns):
 
223
        """Constructor.
 
224
 
 
225
        :param patterns: sequence of glob patterns
 
226
        """
 
227
        # Note: This could be smarter by running like sequences together
 
228
        self._regex_patterns = []
 
229
        for pat in patterns:
 
230
            pat = normalize_pattern(pat)
 
231
            if pat.startswith(u'RE:') or u'/' in pat:
 
232
                self._add_patterns([pat], _sub_fullpath) 
 
233
            elif pat.startswith(u'*.'):
 
234
                self._add_patterns([pat], _sub_extension,
 
235
                    prefix=r'(?:.*/)?(?!.*/)(?:.*\.)')
 
236
            else:
 
237
                self._add_patterns([pat], _sub_basename, 
 
238
                    prefix=r'(?:.*/)?(?!.*/)')
 
239
 
218
240
 
219
241
def normalize_pattern(pattern):
220
242
    """Converts backslashes in path patterns to forward slashes.