/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/rules.py

  • Committer: Martin
  • Date: 2017-06-05 20:48:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6658.
  • Revision ID: gzlist@googlemail.com-20170605204831-20accykspjcrx0a8
Apply 2to3 dict fixer and clean up resulting mess using view helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
19
19
See ``bzr help rules`` for details.
20
20
"""
21
21
 
22
 
from bzrlib import (
 
22
from __future__ import absolute_import
 
23
 
 
24
import configobj
 
25
 
 
26
from . import (
23
27
    config,
24
28
    cmdline,
25
29
    errors,
26
30
    globbing,
27
31
    osutils,
28
32
    )
29
 
from bzrlib.util.configobj import configobj
30
33
 
31
34
 
32
35
# Name of the file holding rules in a tree
64
67
        """
65
68
        raise NotImplementedError(self.get_selected_items)
66
69
 
 
70
    def get_single_value(self, path, preference_name):
 
71
        """Get a single preference for a single file.
 
72
        
 
73
        :returns: The string preference value, or None.
 
74
        """
 
75
        for key, value in self.get_selected_items(path, [preference_name]):
 
76
            return value
 
77
        return None
 
78
 
67
79
 
68
80
class _IniBasedRulesSearcher(_RulesSearcher):
69
81
 
74
86
 
75
87
        :param inifile: the name of the file or a sequence of lines.
76
88
        """
77
 
        options = {'encoding': 'utf-8'}
78
 
        self._cfg = configobj.ConfigObj(inifile, options=options)
 
89
        self._cfg = configobj.ConfigObj(inifile, encoding='utf-8')
79
90
        sections = self._cfg.keys()
80
91
        patterns = []
81
92
        self.pattern_to_section = {}