Merge lp:~unifield-team/unifield-server/UF_338_reversal_and_correction_abbreviation_substitutions into lp:unifield-server

Proposed by Olivier DOSSMANN
Status: Rejected
Rejected by: jftempo
Proposed branch: lp:~unifield-team/unifield-server/UF_338_reversal_and_correction_abbreviation_substitutions
Merge into: lp:unifield-server
Diff against target: 30 lines (+21/-0)
1 file modified
bin/tools/misc.py (+21/-0)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/UF_338_reversal_and_correction_abbreviation_substitutions
Reviewer Review Type Date Requested Status
jftempo Pending
Review via email: mp+74370@code.launchpad.net

Description of the change

This method is required by UF-338 in order to change "REV - REV - description of reverse" in "REV2 - description of reverse" on all reversal and correction lines.

To post a comment you must log in.
Revision history for this message
jftempo (jfb-tempo-consulting) wrote :

Moved in unifield-wm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/tools/misc.py'
2--- bin/tools/misc.py 2011-01-20 12:40:20 +0000
3+++ bin/tools/misc.py 2011-09-21 07:22:23 +0000
4@@ -1503,6 +1503,27 @@
5 return tuple(resolve_attr(obj, attr) for attr in items)
6 return g
7
8+def join_without_redundancy(text='', string=''):
9+ """
10+ Add string @ begining of text like that:
11+ mystring1 - mysupertext
12+
13+ If mystring1 already exist, increment 1:
14+ mystring1 - mysupertext
15+ give:
16+ mystring2 - mysupertext
17+
18+ """
19+ result = ''.join([string, '1 - ', text])
20+ if text == '' or string == '':
21+ return result
22+ pattern = re.compile('\%s([0-9]*) - ' % string)
23+ m = re.match(pattern, text)
24+ if m and m.groups():
25+ number = m.groups() and m.groups()[0]
26+ replacement = string + str(int(number) + 1) + ' - '
27+ result = re.sub(pattern, replacement, text, 1)
28+ return result
29
30 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31

Subscribers

People subscribed via source and target branches

to all changes: