コード例 #1
0
ファイル: podiffutils.py プロジェクト: jan-hudec/podiffutils
    def _merge_header(self, out, base, local, remote):
        def newer(left, right, attribute):
            if self._get_time(left.get(attribute)) >= self._get_time(right.get(attribute)):
                return True
            else:
                return False

        base_dict = poheader.parseheaderstring(base.target)
        local_dict = poheader.parseheaderstring(local.target)
        remote_dict = poheader.parseheaderstring(remote.target)
        out.target = ''
        c = 0

        allkeys = self.merge_list(base_dict.keys(),
                local_dict.keys(), remote_dict.keys())
        for key in allkeys:
            b = base_dict.get(key, None)
            l = local_dict.get(key, None)
            r = remote_dict.get(key, None)
            if b == l:
                res = r
            elif b == r or l == r:
                res = l
            else: # conflict...
                if key in self._template_headers:
                    use_local = newer(local_dict, remote_dict, 'POT-Creation-Date')
                else:
                    use_local = newer(local_dict, remote_dict, 'PO-Revision-Date')
                if use_local:
                    used, other, ofile = local_dict, remote_dict, remote
                else:
                    used, other, ofile = remote_dict, local_dict, local

                res = used.get(key, None)
                out.addnote(u'(conflict) %(file)s (%(project)s): %(key)s: %(value)s' % {
                    'file': _getname(ofile._store, ('remote' if use_local else 'local')),
                    'project': other.get('Project-Id-Version', u'???'),
                    'key': key,
                    'value': other.get(key, u'<unset>'),
                    })
                c = 1
            if res is not None:
                out.target += '%s: %s\n' % (key, res)
        out.markfuzzy(
                self.merge_simple(base.isfuzzy(), local.isfuzzy(),
                        remote.isfuzzy()))
        return c
コード例 #2
0
def test_parseheaderstring():
    """ test for the header parsing function"""
    source = r'''item1: one
item2: two:two
this item must get ignored because there is no colon sign in it
item3: three
'''
    d = poheader.parseheaderstring(source)
    print(type(d))
    assert len(d) == 3
    assert d['item1'] == 'one'
    assert d['item2'] == 'two:two'
    assert d['item3'] == 'three'
コード例 #3
0
def test_parseheaderstring():
    """test for the header parsing function"""
    source = r"""item1: one
item2: two:two
this item must get ignored because there is no colon sign in it
item3: three
"""
    d = poheader.parseheaderstring(source)
    print(type(d))
    assert len(d) == 3
    assert d["item1"] == "one"
    assert d["item2"] == "two:two"
    assert d["item3"] == "three"
コード例 #4
0
ファイル: test_poheader.py プロジェクト: alexbriski/pootleDev
def test_parseheaderstring():
    """ test for the header parsing function"""
    source = r'''item1: one
item2: two:two
this item must get ignored because there is no colon sign in it
item3: three
'''
    d = poheader.parseheaderstring(source)
    print(type(d))
    assert len(d) == 3
    assert d['item1'] == 'one'
    assert d['item2'] == 'two:two'
    assert d['item3'] == 'three'
コード例 #5
0
ファイル: test_poheader.py プロジェクト: riverspirit/kuma
def test_parseheaderstring():
    """ test for the header parsing function"""
    source = r"""item1: one
item2: two:two
this item must get ignored because there is no colon sign in it
item3: three
"""
    d = poheader.parseheaderstring(source)
    print(type(d))
    assert len(d) == 3
    assert d["item1"] == "one"
    assert d["item2"] == "two:two"
    assert d["item3"] == "three"