Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.2, 1.9.3, and 2.0

util: remove hgview-derived util module which is no longer used

Changeset cb9227a7b531

Parent 7d59d0f1afe2

by Yuya Nishihara

Changes to 2 files · Browse files at cb9227a7b531 Showing diff from parent 7d59d0f1afe2 Diff from another changeset...

 
12
13
14
15
16
17
18
 
12
13
14
 
15
16
17
@@ -12,7 +12,6 @@
 from tortoisehg.hgqt import qtlib, htmlui, wctxactions, visdiff  from tortoisehg.hgqt import thgrepo, cmdui, fileview  from tortoisehg.util import paths, hglib -from tortoisehg.util.util import xml_escape  from tortoisehg.hgqt.i18n import _    from PyQt4.QtCore import *
Change 1 of 1 Show Entire File tortoisehg/​util/​util.py Stacked
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*- -# util functions -# -# Copyright (C) 2009-2010 Logilab. All rights reserved. -# -# This software may be used and distributed according to the terms -# of the GNU General Public License, incorporated herein by reference. -""" -Several helper functions -""" -import string - -from tortoisehg.util import hglib - -class Curry(object): - """Curryfication de fonction (http://fr.wikipedia.org/wiki/Curryfication)""" - def __init__(self, function, *additional_args, **additional_kwargs): - self.func = function - self.additional_args = additional_args - self.additional_kwargs = additional_kwargs - - def __call__(self, *args, **kwargs): - args += self.additional_args - kwarguments = self.additional_kwargs.copy() - kwarguments.update(kwargs) - return self.func(*args, **kwarguments) - -CONTROL_CHARS = [chr(ci) for ci in range(32)] -TR_CONTROL_CHARS = [' '] * len(CONTROL_CHARS) -for c in ('\n', '\r', '\t'): - TR_CONTROL_CHARS[ord(c)] = c -TR_CONTROL_CHARS[ord('\f')] = '\n' -TR_CONTROL_CHARS[ord('\v')] = '\n' -ESC_CAR_TABLE = string.maketrans(''.join(CONTROL_CHARS), - ''.join(TR_CONTROL_CHARS)) -ESC_UCAR_TABLE = unicode(ESC_CAR_TABLE, 'latin1') - -def xml_escape(data): - """escapes XML forbidden characters in attributes and PCDATA""" - if isinstance(data, unicode): - data = data.translate(ESC_UCAR_TABLE) - else: - data = data.translate(ESC_CAR_TABLE) - return (data.replace('&','&amp;').replace('<','&lt;').replace('>','&gt;') - .replace('"','&quot;').replace("'",'&#39;')) - -def format_desc(desc, width): - """ - Helper function to format a ctx description for oneliner - representation (summary view) - """ - desc = xml_escape(hglib.tounicode(desc).split('\n', 1)[0]) - if len(desc) > width: - desc = desc[:width] + '...' - return desc -