[TASK] Big unicode cleanup.
This commit is contained in:
1 parent
9b06e3aac6
commit
13058a41f7
9 files changed
+94
-86
No files matched your search
+5
-5
@@ -31,19 +31,19 @@ class Project():
|
||||
except:
|
||||
self._is_error = True
|
||||
# TODO: better error handling!
|
||||
print "An error occured within a get_persons call!"
|
||||
print u"An error occured within a get_persons call!"
|
||||
return False
|
||||
|
||||
def get_person_by_uuid(self, uuid):
|
||||
""" Returns a person from the Citavi project by their uuid. """
|
||||
try:
|
||||
person_class = self._sa_sqlite_autobase.classes.Person
|
||||
citavi_person = self._sa_sqlite_session.query(person_class).filter('ID=\'' + str(uuid) + '\'').all()
|
||||
citavi_person = self._sa_sqlite_session.query(person_class).filter(u'ID=\'' + unicode(uuid) + u'\'').all()
|
||||
return citavi_person[0]
|
||||
except:
|
||||
self._is_error = True
|
||||
# TODO: better error handling!
|
||||
print "An error occured within a get_person_by_uuid call!"
|
||||
print u"An error occured within a get_person_by_uuid call!"
|
||||
return False
|
||||
|
||||
def open(self):
|
||||
@@ -59,7 +59,7 @@ class Project():
|
||||
def _open(self):
|
||||
""" Internal method to open a citavi project file. """
|
||||
try:
|
||||
self._sa_sqlite_engine = create_engine('sqlite+pysqlite:///' + self.sqlite_file)
|
||||
self._sa_sqlite_engine = create_engine(u'sqlite+pysqlite:///' + self.sqlite_file)
|
||||
self._sa_sqlite_session = Session(self._sa_sqlite_engine)
|
||||
self._sa_sqlite_meta = MetaData(bind=self._sa_sqlite_engine)
|
||||
self._sa_sqlite_meta.reflect()
|
||||
@@ -96,7 +96,7 @@ class ProjectManager():
|
||||
self._projects.clear()
|
||||
|
||||
def get_path_for_project_id(self, project_id):
|
||||
return 'media/citavi/project_' + str(project_id) + '.ctt4'
|
||||
return u'media/citavi/project_' + unicode(project_id) + u'.ctt4'
|
||||
|
||||
def _add_project(self, project_id):
|
||||
""" Internal method to add a Project instance if not existing. """
|
||||
|
||||
@@ -26,3 +26,7 @@ class PersonIdentityManager():
|
||||
def get_mapped_identities_for_project(self, project_instance):
|
||||
""" Returns all existing (mapped) identies for a given project. """
|
||||
return CitaviProjectIdentity.objects.filter(project=project_instance).all()
|
||||
|
||||
def get_citavi_identity_by_global_identity(self, global_identity):
|
||||
""" Returns the preferred citavi identity based on their global identity. """
|
||||
return CitaviProjectIdentity.objects.filter(global_identity=global_identity, preferred=True).all()[0]
|
||||
@@ -46,3 +46,12 @@ class PersonMapper():
|
||||
def get_person_by_uuid(self, project, uuid):
|
||||
""" Returns a person from a citavi project by uuid. """
|
||||
return self._citavi_project_manager.get_person_by_uuid(project.id, uuid)
|
||||
|
||||
def get_representation_for_global_identity(self, global_identity):
|
||||
""" Returns a unicode string representation for a global identiy. """
|
||||
if global_identity.type == 'citavi':
|
||||
citavi_identity = self._person_identity_manager.get_citavi_identity_by_global_identity(global_identity)
|
||||
citavi_person = self._citavi_project_manager.get_person_by_uuid(citavi_identity.project_id, citavi_identity.citavi_uuid)
|
||||
return unicode(citavi_person.ID) + u" " + unicode(citavi_person.FirstName) + u" " + unicode(citavi_person.LastName)
|
||||
else:
|
||||
return unicode(global_identity)
|
||||
Reference in new issue
Block a user