예제 #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()
예제 #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"])
예제 #3
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"])
예제 #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
예제 #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
예제 #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()
예제 #7
0
 def testFilenameOnNewMethod(self):
     token = "hello.xml"
     result = SearchProcessor.process(token)
     self.assertEqual(result["filename"], [token])
예제 #8
0
 def testCreatesMeter(self):
     token = "2/4"
     result = SearchProcessor.process(token)
     self.assertEqual(result["meter"], [token])
예제 #9
0
 def testFilenameOnNewMethod(self):
     token = "hello.xml"
     result = SearchProcessor.process(token)
     self.assertEqual(result["filename"], [token])
예제 #10
0
 def testIsKeyFlat(self):
     token = ["Cflat", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #11
0
 def testIsNotMeter2Chars(self):
     token = "h/c"
     self.assertFalse(SearchProcessor.is_meter(token))
예제 #12
0
 def testIsTempoTwoWords(self):
     token = "quaver=crotchet"
     self.assertTrue(SearchProcessor.is_tempo(token))
예제 #13
0
 def testTransposition(self):
     input = "transposition:clarinet"
     self.assertEqual(
         {"transposition": ["clarinet"]}, SearchProcessor.process(input))
예제 #14
0
 def testTransposition(self):
     input = "transposition:clarinet"
     self.assertEqual({"transposition": ["clarinet"]},
                      SearchProcessor.process(input))
예제 #15
0
 def testKey(self):
     input = "C major"
     self.assertEqual({"key": ["C major"]}, SearchProcessor.process(input))
예제 #16
0
 def testTimeSigWithMeterLabel(self):
     input = "meter:4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
예제 #17
0
 def testTimeSig(self):
     input = "4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
예제 #18
0
 def testFilename(self):
     input = "lottie.xml"
     self.assertEqual({"filename": [input]}, SearchProcessor.process(input))
예제 #19
0
 def testTitleOrComposerOrLyricist(self):
     input = "hello, world"
     self.assertDictEqual({"text": ["hello,", "world"]},
                          SearchProcessor.process(input))
예제 #20
0
 def testFilename(self):
     input = "lottie.xml"
     self.assertEqual({"filename": [input]}, SearchProcessor.process(input))
예제 #21
0
 def testTimeSigWithMeterLabel(self):
     input = "meter:4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
예제 #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)
예제 #23
0
 def testSplittingByTwoColonsAndSpaces(self):
     token = "instrument:clarinet key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": ["Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
예제 #24
0
 def testSplittingByTwoColonsAndSpaces(self):
     token = "instrument:clarinet key:Cmaj"
     expected = {"instrument": ["clarinet"], "key": ["Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
예제 #25
0
 def testIsMeter(self):
     token = "4/4"
     self.assertTrue(SearchProcessor.is_meter(token))
예제 #26
0
 def testSplittingBySpaceColonTokens(self):
     token = "\"C major\" key:Cmaj"
     expected = {"key": ["C major", "Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
예제 #27
0
 def testIsKey(self):
     token = ["C", "major"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #28
0
 def testCreatesMeter(self):
     token = "2/4"
     result = SearchProcessor.process(token)
     self.assertEqual(result["meter"], [token])
예제 #29
0
 def testIsTempoOneWord(self):
     token = "quaver=80"
     self.assertTrue(SearchProcessor.is_tempo(token))
예제 #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)
예제 #31
0
 def testCreatesTempo(self):
     token = "quaver=crotchet"
     result = SearchProcessor.process(token)
     self.assertEqual(result["tempo"], [token])
예제 #32
0
 def testSplittingByColon(self):
     token = "instrument:world"
     result = SearchProcessor.handle_colons_and_semicolons(token)
     expected = {"instrument": ["world"]}
     self.assertDictEqual(result, expected)
예제 #33
0
 def testCreatesText(self):
     token = "nothing"
     result = SearchProcessor.process(token)
     self.assertEqual(result["text"], [token])
예제 #34
0
 def testIsMeter(self):
     token = "4/4"
     self.assertTrue(SearchProcessor.is_meter(token))
예제 #35
0
 def testTitleOrComposerOrLyricist(self):
     input = "hello, world"
     self.assertDictEqual(
         {"text": ["hello,", "world"]}, SearchProcessor.process(input))
예제 #36
0
 def testIsNotMeter2Chars(self):
     token = "h/c"
     self.assertFalse(SearchProcessor.is_meter(token))
예제 #37
0
 def testTimeSig(self):
     input = "4/4"
     self.assertEqual({"meter": ["4/4"]}, SearchProcessor.process(input))
예제 #38
0
 def testIsNotMeterNoDivide(self):
     token = "lol"
     self.assertFalse(SearchProcessor.is_meter(token))
예제 #39
0
 def testKey(self):
     input = "C major"
     self.assertEqual(
         {"key": ["C major"]}, SearchProcessor.process(input))
예제 #40
0
 def testIsKey(self):
     token = ["C", "major"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #41
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)
예제 #42
0
 def testIsKeySharp(self):
     token = ["Csharp", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #43
0
 def testSplittingBySpaceColonTokens(self):
     token = "\"C major\" key:Cmaj"
     expected = {"key": ["C major", "Cmaj"]}
     result = SearchProcessor.process(token)
     self.assertDictEqual(result, expected)
예제 #44
0
 def testIsKeyFlat(self):
     token = ["Cflat", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #45
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)
예제 #46
0
 def testIsNotKey(self):
     token = ["Hello"]
     self.assertFalse(SearchProcessor.is_key(token))
예제 #47
0
 def testSplittingByColon(self):
     token = "instrument:world"
     result = SearchProcessor.handle_colons_and_semicolons(token)
     expected = {"instrument": ["world"]}
     self.assertDictEqual(result, expected)
예제 #48
0
 def testIsTempoOneWord(self):
     token = "quaver=80"
     self.assertTrue(SearchProcessor.is_tempo(token))
예제 #49
0
 def testIsNotMeterNoDivide(self):
     token = "lol"
     self.assertFalse(SearchProcessor.is_meter(token))
예제 #50
0
 def testIsNotTempo(self):
     token = "1=2"
     self.assertFalse(SearchProcessor.is_tempo(token))
예제 #51
0
 def testIsKeySharp(self):
     token = ["Csharp", "minor"]
     self.assertTrue(SearchProcessor.is_key(token))
예제 #52
0
 def testCreatesTempo(self):
     token = "quaver=crotchet"
     result = SearchProcessor.process(token)
     self.assertEqual(result["tempo"], [token])
예제 #53
0
 def testIsNotKey(self):
     token = ["Hello"]
     self.assertFalse(SearchProcessor.is_key(token))
예제 #54
0
 def testIsTempoTwoWords(self):
     token = "quaver=crotchet"
     self.assertTrue(SearchProcessor.is_tempo(token))
예제 #55
0
 def testIsNotTempo(self):
     token = "1=2"
     self.assertFalse(SearchProcessor.is_tempo(token))
예제 #56
0
 def testCreatesText(self):
     token = "nothing"
     result = SearchProcessor.process(token)
     self.assertEqual(result["text"], [token])