当前位置: 首页>>代码示例>>Python>>正文


Python Commons.Commons类代码示例

本文整理汇总了Python中inc.Commons.Commons的典型用法代码示例。如果您正苦于以下问题:Python Commons类的具体用法?Python Commons怎么用?Python Commons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Commons类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_list_feeds

 def test_list_feeds(self):
     another_chan = self.server.get_channel_by_address("another_channel")
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
     rfl = rss_check_obj.get_sub_repo(self.hallo)
     # Add RSS feeds to feed list
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, another_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed2", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf3)
     # Run FeedList and check output
     self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user, "rss list"))
     data = self.server.get_send_data(1, self.test_chan, EventMessage)
     data_split = data[0].text.split("\n")
     assert "subscriptions posting" in data_split[0].lower(), "Actual message: {}".format(data[0].text)
     assert "test_feed1" in data_split[1].lower() or "test_feed1" in data_split[2].lower()
     assert "test_feed3" in data_split[1].lower() or "test_feed3" in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?1" in data_split[1].lower() or \
            "http://spangle.org.uk/hallo/test_rss.xml?1" in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?3" in data_split[1].lower() or \
            "http://spangle.org.uk/hallo/test_rss.xml?3" in data_split[2].lower()
     assert "test_feed2" not in data_split[1].lower() and "test_feed2" not in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?2" not in data_split[1].lower() and \
            "http://spangle.org.uk/hallo/test_rss.xml?2" not in data_split[2].lower()
开发者ID:joshcoales,项目名称:Hallo,代码行数:30,代码来源:testSubscriptionListRss.py

示例2: test_xml

 def test_xml(self):
     # Setup a feed list
     rfl = SubscriptionRepo()
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("P0T3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed2", update_frequency=Commons.load_time_delta("P1TS"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT60S"))
     rfl.add_sub(rf3)
     # Save to XML and load
     try:
         try:
             os.rename("store/subscriptions.json", "store/subscriptions.json.tmp")
         except OSError:
             pass
         rfl.save_json()
         new_rfl = SubscriptionRepo.load_json(self.hallo)
         assert len(new_rfl.sub_list) == 3
     finally:
         try:
             os.remove("store/subscriptions.json")
         except OSError:
             pass
         try:
             os.rename("store/subscriptions.json.tmp", "store/subscriptions.json")
         except OSError:
             pass
开发者ID:joshcoales,项目名称:Hallo,代码行数:30,代码来源:testSubscriptionRepo.py

示例3: test_remove_by_title

 def test_remove_by_title(self):
     another_chan = self.server.get_channel_by_address("another_channel")
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
     rfl = rss_check_obj.get_sub_repo(self.hallo)
     # Add RSS feeds to feed list
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, another_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf3)
     # Remove test feed
     self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user,
                                                    "rss remove test_feed1"))
     data = self.server.get_send_data(1, self.test_chan, EventMessage)
     assert "removed rss subscription to test_feed1" in data[0].text.lower(), \
         "Response did not contain expected string. Response was: {}".format(data[0].text)
     assert rf1 not in rfl.sub_list
     assert rf2 in rfl.sub_list
     assert rf3 in rfl.sub_list
开发者ID:joshcoales,项目名称:Hallo,代码行数:25,代码来源:testSubscriptionRemoveRss.py

示例4: test_list_feeds

 def test_list_feeds(self):
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("e621 sub check")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubE621Check
     rfl = rss_check_obj.e621_sub_list
     # Add RSS feeds to feed list
     rf1 = E621Sub()
     rf1.search = "butt"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf1)
     rf2 = E621Sub()
     rf2.search = "deer"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf2)
     rf3 = E621Sub()
     rf3.search = "dragon"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf3)
     # Run FeedList and check output
     self.function_dispatcher.dispatch("e621 sub list", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     data_split = data[0][0].split("\n")
     assert "e621 search subscriptions posting" in data_split[0].lower()
     assert "butt" in data_split[1].lower() or "butt" in data_split[2].lower()
     assert "deer" not in data_split[1].lower() and "deer" not in data_split[2].lower()
     assert "dragon" in data_split[1].lower() or "dragon" in data_split[2].lower()
开发者ID:,项目名称:,代码行数:32,代码来源:

示例5: test_remove_no_match

 def test_remove_no_match(self):
     # Get subscription list
     e621_check_class = self.function_dispatcher.get_function_by_name("e621 sub check")
     e621_check_obj = self.function_dispatcher.get_function_object(e621_check_class)  # type: SubE621Check
     rfl = e621_check_obj.e621_sub_list
     # Add E621 searches to subscription list
     rf1 = E621Sub()
     rf1.search = "butt"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf1)
     rf2 = E621Sub()
     rf2.search = "deer"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf2)
     rf3 = E621Sub()
     rf3.search = "dragon"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf3)
     # Try to remove invalid search
     self.function_dispatcher.dispatch("e621 sub remove not_a_search", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     assert "error" in data[0][0].lower()
     assert rf1 in rfl.sub_list
     assert rf2 in rfl.sub_list
     assert rf3 in rfl.sub_list
开发者ID:,项目名称:,代码行数:31,代码来源:

示例6: run

 def run(self, line, user_obj, destination_obj):
     # See if last argument is check period.
     try:
         try_period = line.split()[-1]
         search_delta = Commons.load_time_delta(try_period)
         search = line[:-len(try_period)]
     except ISO8601ParseError:
         search = line
         search_delta = Commons.load_time_delta("PT300S")
     search = search.strip()
     # Get current RSS feed list
     function_dispatcher = user_obj.server.hallo.function_dispatcher
     sub_check_class = function_dispatcher.get_function_by_name("e621 sub check")
     sub_check_obj = function_dispatcher.get_function_object(sub_check_class)  # type: SubE621Check
     e621_sub_list = sub_check_obj.e621_sub_list  # type: E621SubList
     # Create new e621 search subscription
     e621_sub = E621Sub()
     e621_sub.server_name = user_obj.server.name
     e621_sub.search = search
     e621_sub.update_frequency = search_delta
     if destination_obj.is_channel():
         e621_sub.channel_name = destination_obj.name
     else:
         e621_sub.user_name = destination_obj.name
     # Update feed
     first_results = e621_sub.check_subscription()
     # If no results, this is an invalid search subscription
     if len(first_results) == 0:
         return "Error, this does not appear to be a valid search, or does not have results."
     # Add new rss feed to list
     e621_sub_list.add_sub(e621_sub)
     # Save list
     e621_sub_list.to_xml()
     # Return output
     return "I have added new e621 subscription for the search \"" + e621_sub.search + "\""
开发者ID:,项目名称:,代码行数:35,代码来源:

示例7: test_remove_multiple_matching_titles

 def test_remove_multiple_matching_titles(self):
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("rss check")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: FeedCheck
     rfl = rss_check_obj.rss_feed_list
     # Add RSS feeds to feed list
     rf1 = RssFeed()
     rf1.url = "http://spangle.org.uk/hallo/test_rss.xml?1"
     rf1.title = "test_feed1"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf1)
     rf2 = RssFeed()
     rf2.url = "http://spangle.org.uk/hallo/test_rss.xml?2"
     rf2.title = "test_feed1"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf2)
     rf3 = RssFeed()
     rf3.url = "http://spangle.org.uk/hallo/test_rss.xml?3"
     rf3.title = "test_feed1"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf3)
     # Remove test feed
     self.function_dispatcher.dispatch("rss remove test_feed1", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     assert "error" in data[0][0].lower()
     assert rf1 in rfl.feed_list
     assert rf2 in rfl.feed_list
     assert rf3 in rfl.feed_list
开发者ID:,项目名称:,代码行数:34,代码来源:

示例8: test_run_by_title

 def test_run_by_title(self):
     # Set up test servers and channels
     serv1 = ServerMock(self.hallo)
     serv1.name = "test_serv1"
     chan1 = serv1.get_channel_by_name("test_chan1")
     chan2 = serv1.get_channel_by_name("test_chan2")
     serv2 = ServerMock(self.hallo)
     serv2.name = "test_serv2"
     chan3 = serv2.get_channel_by_name("test_chan1")
     try:
         self.hallo.add_server(serv1)
         self.hallo.add_server(serv2)
         # Set up rss feeds
         rfl = RssFeedList()
         rf1 = RssFeed()
         rf1.url = "http://spangle.org.uk/hallo/test_rss.xml?1"
         rf1.title = "test_feed1"
         rf1.server_name = chan1.server.name
         rf1.channel_name = chan1.name
         rf1.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf1)
         rf2 = RssFeed()
         rf2.url = "http://spangle.org.uk/hallo/test_rss.xml?2"
         rf2.title = "test_feed2"
         rf2.server_name = chan2.server.name
         rf2.channel_name = chan2.name
         rf2.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf2)
         rf3 = RssFeed()
         rf3.url = "http://spangle.org.uk/hallo/test_rss.xml?3"
         rf3.title = "test_feed1"
         rf3.server_name = chan3.server.name
         rf3.channel_name = chan3.name
         rf3.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf3)
         # Splice this rss feed list into the function dispatcher's rss check object
         rss_check_class = self.function_dispatcher.get_function_by_name("rss check")
         rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: FeedCheck
         rss_check_obj.rss_feed_list = rfl
         # Invalid title
         self.function_dispatcher.dispatch("rss check Not a valid feed", self.test_user, self.test_chan)
         data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title but wrong channel
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan1)
         data = serv1.get_send_data(1, chan1, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title check update
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "feed updates were found" in data[0][0].lower()
         assert len(data[0][0].lower().split("\n")) == 4
         # No updates
         rf2.title = "test_feed2"
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "no updates" in data[0][0], "No further updates should be found."
     finally:
         self.hallo.remove_server(serv2)
         self.hallo.remove_server(serv1)
开发者ID:,项目名称:,代码行数:60,代码来源:

示例9: test_domain_name

 def test_domain_name(self):
     url1 = "https://github.com/joshcoales"
     assert Commons.get_domain_name(url1) == "github", "Failed to get domain from url1"
     url2 = "http://spangle.org.uk/things/stuff/hallo.html.com"
     assert Commons.get_domain_name(url2) == "spangle", "Failed to get domain from url2"
     url3 = "irc://irc.freenode.net:6666"
     assert Commons.get_domain_name(url3) == "freenode", "Failed to get domain from url3"
     url4 = "http://www.longurlmaker.com/go?id=143GetShortyShrtndspread%2Bout1tprotractedlongishYepItlofty1stretch" \
            "100RedirxMyURL1Sitelutionsspread%2Bout56706Ne1kfar%2Breachingstretchenlarged8U76SimURL01URLvi00distan" \
            "tr1towering46URLcutNe14m3q5stringy0elongatedremote7RubyURLRubyURL0300lasting52ny54blnk.inRedirx0t0aks" \
            "tretchedst765330DigBigf14922f8014v03121qeURl.ied99FhURL1MyURLFhURL8sustainedlingeringrunning07bYATUC6" \
            "8yU7618farawaystretchedxlfarawaySHurlcU760stretched01drangyccmstretchkrunningrremote52ganglingMyURL81" \
            "outstretchedTraceURL5aenduring60Is.gd5stretch69660Miniliengangling112vYATUC01drawn%2Bout29extensive1U" \
            "RLcutc03ShredURLfspread%2Boutoutstretched1EzURLTinyURLhigh0301URL7WapURL0u7Redirx5229NutshellURLdrawn" \
            "%2Boutwcfy68rangy4longish4SitelutionsG8LFwdURLe1stretchNanoRef56running2StartURLspun%2BoutShortURL165" \
            "MooURL4bTightURL00URLPieprolongedWapURLw0TightURL61runningdistantShorl8951hw2MooURLelongatek8lofty1Ti" \
            "nyURLc1qMetamark920bgelongate19n103c1dTinyLinkcontinuedlnk.in96591DecentURL0afar%2Breaching81elongish" \
            "504zremotec0l0e0adistants11high04DecentURL2stretchYATUCSnipURLstringys7b8deepTightURL1PiURLpa7elongat" \
            "edix0101Shim0Is.gdfar%2BreachingB65f8ctoweringNutshellURLWapURL1v9runningRubyURLURl.ie0ganglingEasyUR" \
            "L1ShortURL161stringy0h8extensivePiURL14prolongedEzURLt710distant1100rNanoRefh5311450ShrinkURLFwdURL1m" \
            "stretched119ganglingURLCuttera11fFhURL1b6tallFwdURLdlengthy110spun%2Bout7lastingf49Fly29loftyf5jXil0s" \
            "pread%2Bout4lengthyrangystretch8up0URL.co.uklingeringegURLHawk48zlengthyb3prolonged58loftyg18drawn%2B" \
            "outURLCutterURLHawk01cShortlinkshigh4remote1StartURLprolongedURLHawk0z03Shortlinks54gURLvi18elongated" \
            "EasyURL18elongated04WapURL1lofty51spread%2Bout1Redirx1A2N5411zfar%2Breachingf001prolonged01a4dstretch" \
            "sustainedoutstretchedShortURL612TraceURLURLvi00lasting28ec1URLcutcstringy827klengthyk1141DigBig9fcSHu" \
            "rl1Beam.toShorl0tstretchxURLCutterYepItnblasting080stretched1FhURL15rangy1x6600continuedShredURLblnk." \
            "inelongated00413outstretched0090146stretched589z05stringyc8sdielongatelongish6kprolongedfar%2Breachin" \
            "gf36ubaTinyURL1TinyLink341028017EasyURLd1runningfar%2Breaching06stretching1U76spun%2Bout1cstretch"
     assert Commons.get_domain_name(url4) == "longurlmaker", "Failed to get domain from url4"
     url5 = "http://domains.ninja"
     assert Commons.get_domain_name(url5) == "domains", "Failed to get domain from url5"
开发者ID:joshcoales,项目名称:Hallo,代码行数:31,代码来源:testCommons.py

示例10: test_format_unix_time

 def test_format_unix_time(self):
     unix1 = 0
     assert Commons.format_unix_time(unix1) == "1970-01-01 00:00:00"
     unix2 = 1000000000
     assert Commons.format_unix_time(unix2) == "2001-09-09 01:46:40"
     unix3 = 1234567890
     assert Commons.format_unix_time(unix3) == "2009-02-13 23:31:30"
开发者ID:joshcoales,项目名称:Hallo,代码行数:7,代码来源:testCommons.py

示例11: test_chunk_string

 def test_chunk_string(self):
     chunks = Commons.chunk_string("a"*500, 100)
     assert len(chunks) == 5, "Did not return correct number of chunks"
     for chunk in chunks:
         assert len(chunk) <= 100, "Chunk of string is too long"
     chunks = Commons.chunk_string("", 100)
     assert len(chunks) == 0, "Did not handle empty string correctly."
开发者ID:joshcoales,项目名称:Hallo,代码行数:7,代码来源:testCommons.py

示例12: run

 def run(self, event):
     """
     Say a message into a channel or server/channel pair (in the format "{server,channel}").
     Format: say <channel> <message>
     """
     # Setting up variables
     line = event.command_args
     hallo_obj = event.server.hallo
     # See if server and channel are specified as parameters
     server_name = Commons.find_parameter("server", line)
     if server_name is not None:
         line = line.replace("server={}".format(server_name), "").strip()
     channel_name = Commons.find_parameter("channel", line)
     if channel_name is not None:
         line = line.replace("channel={}".format(channel_name), "").strip()
     # If channel_name is not found as a parameter, see if server/channel is given as a first argument pair.
     if channel_name is None:
         destination_pair = line.split()[0]
         line = line[len(destination_pair):].strip()
         destination_separators = ["->", ">", ",", ".", "/", ":"]
         for destination_separator in destination_separators:
             if destination_pair.count(destination_separator) != 0:
                 server_name = destination_pair.split(destination_separator)[0]
                 channel_name = destination_pair.split(destination_separator)[1]
                 break
         if channel_name is None:
             channel_name = destination_pair
     # Get server_obj list from server_name
     server_objs = []
     if server_name is None:
         server_objs = [event.server]
     else:
         # Create a regex query from their input
         server_regex = re.escape(server_name).replace(r"\*", ".*")
         server_list = hallo_obj.server_list
         for server_obj in server_list:
             if not server_obj.is_connected():
                 continue
             if re.match(server_regex, server_obj.name, re.IGNORECASE):
                 server_objs.append(server_obj)
     # If server is not recognised or found, respond with an error
     if len(server_objs) == 0:
         return event.create_response("Unrecognised server.")
     # Get channel_obj list from server_obj and channel_name
     channel_objs = []
     for server_obj in server_objs:
         channel_regex = re.escape(channel_name).replace(r"\*", ".*")
         channel_list = server_obj.channel_list
         for channel_obj in channel_list:
             if not channel_obj.in_channel:
                 continue
             if re.match(channel_regex, channel_obj.name, re.IGNORECASE):
                 channel_objs.append(channel_obj)
     # If no channels were found that match, respond with an error
     if len(channel_objs) == 0:
         return event.create_response("Unrecognised channel.")
     # Send message to all matching channels
     for channel_obj in channel_objs:
         event.server.send(EventMessage(event.server, channel_obj, None, line, inbound=False))
     return event.create_response("Message sent.")
开发者ID:joshcoales,项目名称:Hallo,代码行数:60,代码来源:ServerControl.py

示例13: test_is_string_null

 def test_is_string_null(self):
     valid = ['0', 'false', 'off', 'disabled', 'disable', '', 'nul', 'null', 'none', 'nil']
     invalid = ["true", "enable", "hello", "example", "test"]
     for valid_str in valid:
         assert Commons.is_string_null(valid_str), "Valid string judged to be not null, "+valid_str
     for invalid_str in invalid:
         assert not Commons.is_string_null(invalid_str), "Invalid string judged to be null, "+invalid_str
开发者ID:joshcoales,项目名称:Hallo,代码行数:7,代码来源:testCommons.py

示例14: create_from_input

 def create_from_input(input_evt, sub_repo):
     # Get event data
     server = input_evt.server
     destination = input_evt.channel if input_evt.channel is not None else input_evt.user
     clean_text = input_evt.command_args.strip().lower()
     text_split = clean_text.split()
     # Subreddit regex
     sub_regex = re.compile(r"r/([^\s]*)/?")
     if len(text_split) == 1:
         sub_name = clean_text if sub_regex.search(clean_text) is None else sub_regex.search(clean_text).group(1)
         reddit_sub = RedditSub(server, destination, sub_name)
         reddit_sub.check()
         return reddit_sub
     if len(text_split) > 2:
         raise SubscriptionException("Too many arguments. Please give a subreddit, and optionally, a check period.")
     try:
         search_delta = Commons.load_time_delta(text_split[0])
         subreddit = text_split[1]
     except ISO8601ParseError:
         subreddit = text_split[0]
         search_delta = Commons.load_time_delta(text_split[1])
     sub_name = clean_text if sub_regex.search(subreddit) is None else sub_regex.search(subreddit).group(1)
     reddit_sub = RedditSub(server, destination, sub_name, update_frequency=search_delta)
     reddit_sub.check()
     return reddit_sub
开发者ID:joshcoales,项目名称:Hallo,代码行数:25,代码来源:Subscriptions.py

示例15: test_check_calculation

 def test_check_calculation(self):
     valid = ["23", "2.123", "cos(12.2)", "tan(sin(atan(cosh(1))))", "pie", "1+2*3/4^5%6", "gamma(17)"]
     invalid = ["hello", "1&2", "$13.50", "1::", "cos(tan(12+t+15))"]
     for valid_str in valid:
         assert Commons.check_calculation(valid_str), "Valid string judged to be not calculation, "+valid_str
     for invalid_str in invalid:
         assert not Commons.check_calculation(invalid_str), "Invalid string judged to be calculation, "+invalid_str
开发者ID:joshcoales,项目名称:Hallo,代码行数:7,代码来源:testCommons.py


注:本文中的inc.Commons.Commons类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。