示例#1
0
 def _get_laya(self, lname):
     try:
         return hindustani.models.Laya.objects.fuzzy(lname)
     except hindustani.models.Laya.DoesNotExist:
         import_logger.warning("Cannot find laya '%s' in the database",
                               lname)
         return None
示例#2
0
 def _get_taal(self, tname):
     try:
         return hindustani.models.Taal.objects.fuzzy(tname)
     except hindustani.models.Taal.DoesNotExist:
         import_logger.warning("Cannot find taal '%s' in the database",
                               tname)
         return None
示例#3
0
 def _get_form(self, fname):
     try:
         return hindustani.models.Form.objects.fuzzy(fname)
     except hindustani.models.Form.DoesNotExist:
         import_logger.warning("Cannot find form '%s' in the database",
                               fname)
         return None
示例#4
0
 def _get_raag(self, rname):
     try:
         return hindustani.models.Raag.objects.fuzzy(rname)
     except hindustani.models.Raag.DoesNotExist:
         import_logger.warning("Cannot find raag '%s' in the database",
                               rname)
         return None
示例#5
0
 def _get_instrument(self, instname):
     if not instname:
         return None
     try:
         return makam.models.Instrument.objects.alias_get(instname)
     except makam.models.Instrument.DoesNotExist:
         import_logger.warning("Cannot find instrument '%s' in database", instname)
         return None
示例#6
0
 def _get_instrument(self, instname):
     try:
         return hindustani.models.Instrument.objects.get(
             name__iexact=instname)
     except hindustani.models.Instrument.DoesNotExist:
         import_logger.warning(
             "Cannot find instrument '%s' in the database", instname)
         return None
示例#7
0
 def _get_instrument(self, instname):
     if not instname:
         return None
     try:
         return makam.models.Instrument.objects.alias_get(instname)
     except makam.models.Instrument.DoesNotExist:
         import_logger.warning("Cannot find instrument '%s' in database",
                               instname)
         return None
示例#8
0
 def _get_form(self, form):
     try:
         return makam.models.Form.objects.unaccent_get(form)
     except makam.models.Form.DoesNotExist:
         try:
             falias = makam.models.FormAlias.objects.unaccent_get(form)
             return falias.form
         except makam.models.FormAlias.DoesNotExist:
             import_logger.warning("Cannot find form '%s' in database", form)
             return None
示例#9
0
 def _get_usul(self, usul):
     try:
         return makam.models.Usul.objects.unaccent_get(usul)
     except makam.models.Usul.DoesNotExist:
         try:
             ualias = makam.models.UsulAlias.objects.unaccent_get(usul)
             return ualias.usul
         except makam.models.UsulAlias.DoesNotExist:
             import_logger.warning("Cannot find usul '%s' in database", usul)
             return None
示例#10
0
 def _get_makam(self, makamname):
     try:
         return makam.models.Makam.objects.unaccent_get(makamname)
     except makam.models.Makam.DoesNotExist:
         malias = makam.models.MakamAlias.objects.unaccent_all(makamname)
         if malias.count():
             return malias[0].makam
         else:
             import_logger.warning("Cannot find makam '%s' in database", makamname)
             return None
示例#11
0
 def _get_form(self, form):
     try:
         return makam.models.Form.objects.unaccent_get(form)
     except makam.models.Form.DoesNotExist:
         try:
             falias = makam.models.FormAlias.objects.unaccent_get(form)
             return falias.form
         except makam.models.FormAlias.DoesNotExist:
             import_logger.warning("Cannot find form '%s' in database",
                                   form)
             return None
示例#12
0
 def _get_makam(self, makamname):
     try:
         return makam.models.Makam.objects.unaccent_get(makamname)
     except makam.models.Makam.DoesNotExist:
         malias = makam.models.MakamAlias.objects.unaccent_all(makamname)
         if malias.count():
             return malias[0].makam
         else:
             import_logger.warning("Cannot find makam '%s' in database",
                                   makamname)
             return None
示例#13
0
 def _get_form(self, form):
     filtered = makam.models.Form.objects.filter(name__unaccent__iexact=form)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         falias = makam.models.FormAlias.objects.filter(name__unaccent__iexact=form)
         if falias.count() == 1:
             return falias.all()[0].form
         else:
             import_logger.warning("Cannot find form '%s' in database", form)
             return None
示例#14
0
 def _get_usul(self, usul):
     filtered = makam.models.Usul.objects.filter(name__unaccent__iexact=usul)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         ualias = makam.models.UsulAlias.objects.filter(name__unaccent__iexact=usul)
         if ualias.count() == 1:
             return ualias.all()[0].usul
         else:
             import_logger.warning("Cannot find usul '%s' in database", usul)
             return None
示例#15
0
 def _get_makam(self, makamname):
     filtered = makam.models.Makam.objects.filter(name__unaccent__iexact=makamname)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         malias = makam.models.MakamAlias.objects.filter(name__unaccent__iexact=makamname)
         if malias.count():
             return malias[0].makam
         else:
             import_logger.warning("Cannot find makam '%s' in database", makamname)
             return None
示例#16
0
 def _get_usul(self, usul):
     try:
         return makam.models.Usul.objects.unaccent_get(usul)
     except makam.models.Usul.DoesNotExist:
         try:
             ualias = makam.models.UsulAlias.objects.unaccent_get(usul)
             return ualias.usul
         except makam.models.UsulAlias.DoesNotExist:
             import_logger.warning("Cannot find usul '%s' in database",
                                   usul)
             return None
示例#17
0
 def _get_form(self, form):
     filtered = makam.models.Form.objects.filter(
         name__unaccent__iexact=form)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         falias = makam.models.FormAlias.objects.filter(
             name__unaccent__iexact=form)
         if falias.count() == 1:
             return falias.all()[0].form
         else:
             import_logger.warning("Cannot find form '%s' in database",
                                   form)
             return None
示例#18
0
 def _get_makam(self, makamname):
     filtered = makam.models.Makam.objects.filter(
         name__unaccent__iexact=makamname)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         malias = makam.models.MakamAlias.objects.filter(
             name__unaccent__iexact=makamname)
         if malias.count():
             return malias[0].makam
         else:
             import_logger.warning("Cannot find makam '%s' in database",
                                   makamname)
             return None
示例#19
0
 def _get_usul(self, usul):
     filtered = makam.models.Usul.objects.filter(
         name__unaccent__iexact=usul)
     if filtered.count() == 1:
         return filtered.all()[0]
     else:
         ualias = makam.models.UsulAlias.objects.filter(
             name__unaccent__iexact=usul)
         if ualias.count() == 1:
             return ualias.all()[0].usul
         else:
             import_logger.warning("Cannot find usul '%s' in database",
                                   usul)
             return None
示例#20
0
    def _apply_tags(self, recording, work, tags):
        raags = self._get_raag_tags(tags)
        taals = self._get_taal_tags(tags)
        layas = self._get_laya_tags(tags)
        forms = self._get_form_tags(tags)

        hindustani.models.RecordingTaal.objects.filter(recording=recording).delete()
        hindustani.models.RecordingLaya.objects.filter(recording=recording).delete()
        hindustani.models.RecordingRaag.objects.filter(recording=recording).delete()
        hindustani.models.RecordingForm.objects.filter(recording=recording).delete()

        if not layas:
            import_logger.warning("No laya tags found on recording")
        for l in layas:
            import_logger.info("Found laya tag %s", l)
            lpos = l[0]
            lob = self._get_laya(l[1])
            if lob:
                hindustani.models.RecordingLaya.objects.create(recording=recording, laya=lob, sequence=lpos)
            else:
                print "couldn't find a laya", l

        if not taals:
            import_logger.warning("No taal tags found on recording")
        for t in taals:
            import_logger.info("Found taal tag %s", t)
            tpos = t[0]
            tob = self._get_taal(t[1])
            if tob:
                hindustani.models.RecordingTaal.objects.create(recording=recording, taal=tob, sequence=tpos)
            else:
                print "couldn't find a taal", t

        if not raags:
            import_logger.warning("No raag tags found on recording")
        for r in raags:
            import_logger.info("Found raag tag %s", r)
            rpos = r[0]
            rob = self._get_raag(r[1])
            if rob:
                hindustani.models.RecordingRaag.objects.create(recording=recording, raag=rob, sequence=rpos)
            else:
                print "could't find a raag", r

        if not forms:
            import_logger.warning("No form tags found on recording")
        for f in forms:
            import_logger.info("Found form tag %s", f)
            fpos = f[0]
            fob = self._get_form(f[1])
            if fob:
                hindustani.models.RecordingForm.objects.create(recording=recording, form=fob, sequence=fpos)
            else:
                print "couldn't find a form", f
示例#21
0
 def _get_raag(self, rname):
     try:
         return hindustani.models.Raag.objects.fuzzy(rname)
     except hindustani.models.Raag.DoesNotExist:
         import_logger.warning("Cannot find raag '%s' in the database", rname)
         return None
示例#22
0
 def _get_taal(self, tname):
     try:
         return hindustani.models.Taal.objects.fuzzy(tname)
     except hindustani.models.Taal.DoesNotExist:
         import_logger.warning("Cannot find taal '%s' in the database", tname)
         return None
示例#23
0
 def _get_instrument(self, instname):
     try:
         return hindustani.models.Instrument.objects.get(name__iexact=instname)
     except hindustani.models.Instrument.DoesNotExist:
         import_logger.warning("Cannot find instrument '%s' in the database", instname)
         return None
示例#24
0
 def _get_laya(self, lname):
     try:
         return hindustani.models.Laya.objects.fuzzy(lname)
     except hindustani.models.Laya.DoesNotExist:
         import_logger.warning("Cannot find laya '%s' in the database", lname)
         return None
示例#25
0
 def _get_form(self, fname):
     try:
         return hindustani.models.Form.objects.fuzzy(fname)
     except hindustani.models.Form.DoesNotExist:
         import_logger.warning("Cannot find form '%s' in the database", fname)
         return None