Commit 47cb74ab authored by Michal Čihař's avatar Michal Čihař

Prevent overriding pounit name

parent c7394db7
...@@ -316,48 +316,48 @@ class FileFormat(object): ...@@ -316,48 +316,48 @@ class FileFormat(object):
''' '''
Finds unit by context and source. Finds unit by context and source.
Returns tuple (pounit, created) indicating whether returned Returns tuple (ttkit_unit, created) indicating whether returned
unit is new one. unit is new one.
''' '''
if self.has_template: if self.has_template:
# Need to create new unit based on template # Need to create new unit based on template
template_pounit = self.template_store.findid(context) template_ttkit_unit = self.template_store.findid(context)
# We search by ID when using template # We search by ID when using template
pounit = self.store.findid(context) ttkit_unit = self.store.findid(context)
# We always need new unit to translate # We always need new unit to translate
if pounit is None: if ttkit_unit is None:
pounit = template_pounit ttkit_unit = template_ttkit_unit
add = True add = True
else: else:
add = False add = False
return (FileUnit(pounit, template_pounit), add) return (FileUnit(ttkit_unit, template_ttkit_unit), add)
else: else:
# Find all units with same source # Find all units with same source
found_units = self.store.findunits(source) found_units = self.store.findunits(source)
if len(found_units) > 0: if len(found_units) > 0:
for pounit in found_units: for ttkit_unit in found_units:
# Does context match? # Does context match?
if pounit.getcontext() == context: if ttkit_unit.getcontext() == context:
return (FileUnit(pounit), False) return (FileUnit(ttkit_unit), False)
else: else:
# Fallback to manual find for value based files # Fallback to manual find for value based files
for pounit in self.store.units: for ttkit_unit in self.store.units:
pounit = FileUnit(pounit) ttkit_unit = FileUnit(ttkit_unit)
if pounit.get_source() == source: if ttkit_unit.get_source() == source:
return (pounit, False) return (ttkit_unit, False)
return (None, False) return (None, False)
def add_unit(self, pounit): def add_unit(self, ttkit_unit):
''' '''
Adds new unit to underlaying store. Adds new unit to underlaying store.
''' '''
if isinstance(self.store, LISAfile): if isinstance(self.store, LISAfile):
# LISA based stores need to know this # LISA based stores need to know this
self.store.addunit(pounit.unit, new=True) self.store.addunit(ttkit_unit.unit, new=True)
else: else:
self.store.addunit(pounit.unit) self.store.addunit(ttkit_unit.unit)
def update_header(self, **kwargs): def update_header(self, **kwargs):
''' '''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment