Beispiel #1
0
 def query(self, input, playlist=False):
     """
     Async method which will process the given input,
     create thread classes for each type of query
     and then start those thread classes.
     When done they will call the callback above
     :param input: text input from the main window
     :return: None, thread classes will call the callback above
     """
     self.latestQuery = input
     data = SearchProcessor.process(input)
     OfflineThread = qt_threading.QueryThread(self, self.manager.runQueries,
                                              (data, ), False)
     QtCore.QObject.connect(OfflineThread,
                            QtCore.SIGNAL("dataReady(PyQt_PyObject, bool)"),
                            self.onQueryComplete)
     OfflineThread.run()
     if self.wifi:
         OnlineThread = qt_threading.QueryThread(self,
                                                 self.manager.runQueries,
                                                 (data, ), True)
         QtCore.QObject.connect(
             OnlineThread, QtCore.SIGNAL("dataReady(PyQt_PyObject, bool)"),
             self.onQueryComplete)
         OnlineThread.run()
Beispiel #2
0
 def testCombineDictionaries(self):
     dict1 = {"key": {"other": ["Hello"]}}
     dict2 = {"key": {"other": ["World"]}}
     result = SearchProcessor.combine_dictionaries(dict1, dict2)
     self.assertEqual(list(result.keys()), ["key"])
     self.assertEqual(list(result["key"].keys()), ["other"])
     self.assertEqual(result["key"]["other"], ["Hello", "World"])
 def testCombineDictionaries(self):
     dict1 = {"key": {"other": ["Hello"]}}
     dict2 = {"key": {"other": ["World"]}}
     result = SearchProcessor.combine_dictionaries(dict1, dict2)
     self.assertEqual(list(result.keys()), ["key"])
     self.assertEqual(list(result["key"].keys()), ["other"])
     self.assertEqual(result["key"]["other"], ["Hello", "World"])
Beispiel #4
0
    def queryNotThreaded(self, input):
        """
        Method which does the querying for adding pieces
        to playlists without using threads.
        exists because pyqt fell over when threading

        :return:
        """
        data = SearchProcessor.process(input)
        results = self.manager.runQueries(data)
        return results
Beispiel #5
0
    def queryNotThreaded(self, input):
        """
        Method which does the querying for adding pieces
        to playlists without using threads.
        exists because pyqt fell over when threading

        :return:
        """
        data = SearchProcessor.process(input)
        results = self.manager.runQueries(data)
        return results
Beispiel #6
0
 def query(self, input, playlist=False):
     """
     Async method which will process the given input,
     create thread classes for each type of query
     and then start those thread classes.
     When done they will call the callback above
     :param input: text input from the main window
     :return: None, thread classes will call the callback above
     """
     self.latestQuery = input
     data = SearchProcessor.process(input)
     OfflineThread = qt_threading.QueryThread(
         self, self.manager.runQueries, (data,), False)
     QtCore.QObject.connect(OfflineThread, QtCore.SIGNAL(
         "dataReady(PyQt_PyObject, bool)"), self.onQueryComplete)
     OfflineThread.run()
     if self.wifi:
         OnlineThread = qt_threading.QueryThread(
             self, self.manager.runQueries, (data,), True)
         QtCore.QObject.connect(OnlineThread, QtCore.SIGNAL(
             "dataReady(PyQt_PyObject, bool)"), self.onQueryComplete)
         OnlineThread.run()
 def testFilenameOnNewMethod(self):
     token = "hello.xml"
     result = SearchProcessor.process(token)
     self.assertEqual(result["filename"], [token])
 def testCreatesMeter(self):
     token = "2/4"
     result = SearchProcessor.process(token)
     self.assertEqual(result["meter"], [token])
Beispiel #9
0
 def testFilenameOnNewMethod(self):
     token = "hello.xml"
     result = SearchProcessor.process(token)
     self.assertEqual(result["filename"], [token])
 def testIsKeyFlat(self):
     token = ["Cflat", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
 def testIsNotMeter2Chars(self):
     token = "h/c"
     self.assertFalse(SearchProcessor.is_meter(token))
Beispiel #12
0
 def testIsTempoTwoWords(self):
     token = "quaver=crotchet"
     self.assertTrue(SearchProcessor.is_tempo(token))
 def testTransposition(self):
     input = "transposition:clarinet"
     self.assertEqual(
         {"transposition": ["clarinet"]}, SearchProcessor.process(input))
Beispiel #14
0
 def testTransposition(self):
     input = "transposition:clarinet"
     self.assertEqual({"transposition": ["clarinet"]},
                      SearchProcessor.process(input))
Beispiel #15
0
 def testKey(self):
     input = "C major"
     self.assertEqual({"key": ["C major"]}, SearchProcessor.process(input))
Beispiel #16
0
 def testTimeSigWithMeterLabel(self):
     input = "meter:4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
Beispiel #17
0
 def testTimeSig(self):
     input = "4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
Beispiel #18
0
 def testFilename(self):
     input = "lottie.xml"
     self.assertEqual({"filename": [input]}, SearchProcessor.process(input))
Beispiel #19
0
 def testTitleOrComposerOrLyricist(self):
     input = "hello, world"
     self.assertDictEqual({"text": ["hello,", "world"]},
                          SearchProcessor.process(input))
 def testFilename(self):
     input = "lottie.xml"
     self.assertEqual({"filename": [input]}, SearchProcessor.process(input))
 def testTimeSigWithMeterLabel(self):
     input = "meter:4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
Beispiel #22
0
 def testSplittingByTwoColonsAndOneSemi(self):
     token = "instrument:clarinet;key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": {"clarinet": ["Cmaj"]}}
     result = SearchProcessor.handle_colons_and_semicolons(token)
     self.assertDictEqual(result, expected)
 def testSplittingByTwoColonsAndSpaces(self):
     token = "instrument:clarinet key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": ["Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
Beispiel #24
0
 def testSplittingByTwoColonsAndSpaces(self):
     token = "instrument:clarinet key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": ["Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
 def testIsMeter(self):
     token = "4/4"
     self.assertTrue(SearchProcessor.is_meter(token))
Beispiel #26
0
 def testSplittingBySpaceColonTokens(self):
     token = "\"C major\" key:Cmaj"
     expected = {"key": ["C major", "Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
 def testIsKey(self):
     token = ["C", "major"]
     self.assertTrue(SearchProcessor.is_key(token))
Beispiel #28
0
 def testCreatesMeter(self):
     token = "2/4"
     result = SearchProcessor.process(token)
     self.assertEqual(result["meter"], [token])
 def testIsTempoOneWord(self):
     token = "quaver=80"
     self.assertTrue(SearchProcessor.is_tempo(token))
Beispiel #30
0
 def testCombineDictionariesWithMixOfTypes(self):
     dict1 = {"key": ["hello"]}
     dict2 = {"key": {"clarinet": ["hello"]}}
     result = SearchProcessor.combine_dictionaries(dict1, dict2)
     expected = {"key": {"other": ["hello"], "clarinet": ["hello"]}}
     self.assertDictEqual(result, expected)
 def testCreatesTempo(self):
     token = "quaver=crotchet"
     result = SearchProcessor.process(token)
     self.assertEqual(result["tempo"], [token])
Beispiel #32
0
 def testSplittingByColon(self):
     token = "instrument:world"
     result = SearchProcessor.handle_colons_and_semicolons(token)
     expected = {"instrument": ["world"]}
     self.assertDictEqual(result, expected)
 def testCreatesText(self):
     token = "nothing"
     result = SearchProcessor.process(token)
     self.assertEqual(result["text"], [token])
Beispiel #34
0
 def testIsMeter(self):
     token = "4/4"
     self.assertTrue(SearchProcessor.is_meter(token))
 def testTitleOrComposerOrLyricist(self):
     input = "hello, world"
     self.assertDictEqual(
         {"text": ["hello,", "world"]}, SearchProcessor.process(input))
Beispiel #36
0
 def testIsNotMeter2Chars(self):
     token = "h/c"
     self.assertFalse(SearchProcessor.is_meter(token))
 def testTimeSig(self):
     input = "4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
Beispiel #38
0
 def testIsNotMeterNoDivide(self):
     token = "lol"
     self.assertFalse(SearchProcessor.is_meter(token))
 def testKey(self):
     input = "C major"
     self.assertEqual(
         {"key": ["C major"]}, SearchProcessor.process(input))
Beispiel #40
0
 def testIsKey(self):
     token = ["C", "major"]
     self.assertTrue(SearchProcessor.is_key(token))
 def testSplittingByTwoColonsAndOneSemi(self):
     token = "instrument:clarinet;key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": {"clarinet": ["Cmaj"]}}
     result = SearchProcessor.handle_colons_and_semicolons(token)
     self.assertDictEqual(result, expected)
Beispiel #42
0
 def testIsKeySharp(self):
     token = ["Csharp", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
 def testSplittingBySpaceColonTokens(self):
     token = "\"C major\" key:Cmaj"
     expected = {"key": ["C major", "Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
Beispiel #44
0
 def testIsKeyFlat(self):
     token = ["Cflat", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
 def testCombineDictionariesWithMixOfTypes(self):
     dict1 = {"key": ["hello"]}
     dict2 = {"key": {"clarinet": ["hello"]}}
     result = SearchProcessor.combine_dictionaries(dict1, dict2)
     expected = {"key": {"other": ["hello"], "clarinet": ["hello"]}}
     self.assertDictEqual(result, expected)
Beispiel #46
0
 def testIsNotKey(self):
     token = ["Hello"]
     self.assertFalse(SearchProcessor.is_key(token))
 def testSplittingByColon(self):
     token = "instrument:world"
     result = SearchProcessor.handle_colons_and_semicolons(token)
     expected = {"instrument": ["world"]}
     self.assertDictEqual(result, expected)
Beispiel #48
0
 def testIsTempoOneWord(self):
     token = "quaver=80"
     self.assertTrue(SearchProcessor.is_tempo(token))
 def testIsNotMeterNoDivide(self):
     token = "lol"
     self.assertFalse(SearchProcessor.is_meter(token))
Beispiel #50
0
 def testIsNotTempo(self):
     token = "1=2"
     self.assertFalse(SearchProcessor.is_tempo(token))
 def testIsKeySharp(self):
     token = ["Csharp", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
Beispiel #52
0
 def testCreatesTempo(self):
     token = "quaver=crotchet"
     result = SearchProcessor.process(token)
     self.assertEqual(result["tempo"], [token])
 def testIsNotKey(self):
     token = ["Hello"]
     self.assertFalse(SearchProcessor.is_key(token))
 def testIsTempoTwoWords(self):
     token = "quaver=crotchet"
     self.assertTrue(SearchProcessor.is_tempo(token))
 def testIsNotTempo(self):
     token = "1=2"
     self.assertFalse(SearchProcessor.is_tempo(token))
Beispiel #56
0
 def testCreatesText(self):
     token = "nothing"
     result = SearchProcessor.process(token)
     self.assertEqual(result["text"], [token])