equal
deleted
inserted
replaced
21 # import local interfaces |
21 # import local interfaces |
22 |
22 |
23 # import Zope3 packages |
23 # import Zope3 packages |
24 |
24 |
25 # import local packages |
25 # import local packages |
|
26 from ztfy.utils.unicode import translateString |
26 |
27 |
27 |
28 |
28 def getContentName(container, base_name): |
29 def getContentName(container, base_name, translate=True, max_length=30): |
29 """Get a real name for a given base name and a container |
30 """Get a real name for a given base name and a container |
30 |
31 |
31 Target name will be suffixed with an index if base name already exists |
32 Target name will be suffixed with an index if base name already exists |
32 """ |
33 """ |
|
34 if translate: |
|
35 base_name = translateString(base_name, spaces='-') |
|
36 if max_length: |
|
37 base_name = base_name[0:max_length] |
33 if base_name not in container: |
38 if base_name not in container: |
34 return base_name |
39 return base_name |
35 index = 2 |
40 index = 2 |
36 name = '%s-%02d' % (base_name, index) |
41 name = '%s-%02d' % (base_name, index) |
37 while name in container: |
42 while name in container: |