Skip to content

Commit e1677da

Browse files
authored
Merge branch 'gonzobot' into gonzobot+nick-re-checks
2 parents 5c326f1 + ba4d4de commit e1677da

132 files changed

Lines changed: 714 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ install:
1111
- "pip install -r ./travis/requirements.txt"
1212

1313
script:
14-
- "python ./travis/test_json.py"
1514
- "git diff --diff-filter=d --name-only ${TRAVIS_COMMIT_RANGE} | grep -i '\\.py$' | xargs -r pylint --rcfile=travis/pylintrc"
1615
- "py.test . -v --cov . --cov-report term-missing"
1716

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ The following guidelines for contribution should be followed if you want to subm
2222

2323
* You need a [GitHub account](https://github.com/signup/free)
2424
* Submit an [issue ticket](https://github.com/ClouDev/CloudBot/issues) for your issue if there is no one yet.
25-
* Try to describe the issue and include steps to reproduce if it's a bug.
25+
* Try to describe the issue and include steps to reproduce if it's a bug.
2626
* If you are able and want to fix this, fork the repository on GitHub
2727

2828
## Make Changes
2929

30-
* In your forked repository, create a topic branch for your upcoming patch. (optional)
30+
* In your forked repository, create a topic branch for your upcoming patch. (optional)
3131
* Make sure you stick to the coding style that is used already.
3232
* Make use of the [`.editorconfig`](http://editorconfig.org/) file.
3333
* Make commits that make sense and describe them properly.
@@ -38,7 +38,7 @@ The following guidelines for contribution should be followed if you want to subm
3838

3939
* Push your changes to a topic branch in your fork of the repository.
4040
* Open a pull request to the original repository and choose the `python3.4` branch.
41-
_Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
41+
_Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
4242
* If not done in commit messages (which you really should do) please reference and update your issue with the code changes. But _please do not close the issue yourself_.
4343
_Notice: You can [turn your previously filed issues into a pull-request here](http://issue2pr.herokuapp.com/)._
4444

cloudbot/__init__.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
__version__ = "1.0.9"
1414

15-
__all__ = ["clients", "util", "bot", "client", "config", "event", "hook", "permissions", "plugin", "reloader", "logging_dir"]
15+
__all__ = ["clients", "util", "bot", "client", "config", "event", "hook", "permissions", "plugin", "reloader",
16+
"logging_dir"]
1617

1718

1819
def _setup():
@@ -23,6 +24,8 @@ def _setup():
2324
else:
2425
logging_config = {}
2526

27+
file_log = logging_config.get("file_log", False)
28+
2629
global logging_dir
2730
logging_dir = os.path.join(os.path.abspath(os.path.curdir), "logs")
2831

@@ -49,25 +52,29 @@ def _setup():
4952
"formatter": "brief",
5053
"level": "INFO",
5154
"stream": "ext://sys.stdout"
52-
},
53-
"file": {
54-
"class": "logging.handlers.RotatingFileHandler",
55-
"maxBytes": 1000000,
56-
"backupCount": 5,
57-
"formatter": "full",
58-
"level": "INFO",
59-
"encoding": "utf-8",
60-
"filename": os.path.join(logging_dir, "bot.log")
6155
}
6256
},
6357
"loggers": {
6458
"cloudbot": {
6559
"level": "DEBUG",
66-
"handlers": ["console", "file"]
60+
"handlers": ["console"]
6761
}
6862
}
6963
}
7064

65+
if file_log:
66+
dict_config["handlers"]["file"] = {
67+
"class": "logging.handlers.RotatingFileHandler",
68+
"maxBytes": 1000000,
69+
"backupCount": 5,
70+
"formatter": "full",
71+
"level": "INFO",
72+
"encoding": "utf-8",
73+
"filename": os.path.join(logging_dir, "bot.log")
74+
}
75+
76+
dict_config["loggers"]["cloudbot"]["handlers"].append("file")
77+
7178
if logging_config.get("console_debug", False):
7279
dict_config["handlers"]["console"]["level"] = "DEBUG"
7380
dict_config["loggers"]["asyncio"] = {
@@ -89,4 +96,5 @@ def _setup():
8996

9097
logging.config.dictConfig(dict_config)
9198

99+
92100
_setup()

cloudbot/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def main():
4141
# define closure for signal handling
4242
# The handler is called with two arguments: the signal number and the current stack frame
4343
# These parameters should NOT be removed
44+
# noinspection PyUnusedLocal
4445
def exit_gracefully(signum, frame):
4546
nonlocal stopped_while_restarting
4647
if not _bot:

cloudbot/bot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
web_installed = True
2929
except ImportError:
30+
WebInterface = None
3031
web_installed = False
3132

3233
logger = logging.getLogger("cloudbot")
@@ -44,7 +45,7 @@ class CloudBot:
4445
"""
4546
:type start_time: float
4647
:type running: bool
47-
:type connections: list[Client | IrcClient]
48+
:type connections: dict[str, Client]
4849
:type data_dir: bytes
4950
:type config: core.config.Config
5051
:type plugin_manager: PluginManager

cloudbot/clients/irc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def close(self):
177177

178178
def message(self, target, *messages):
179179
for text in messages:
180-
text = "".join(text.splitlines())
181180
self.cmd("PRIVMSG", target, text)
182181

183182
def admin_log(self, text, console=True):
@@ -189,11 +188,9 @@ def admin_log(self, text, console=True):
189188
logger.info("[%s|admin] %s", self.name, text)
190189

191190
def action(self, target, text):
192-
text = "".join(text.splitlines())
193191
self.ctcp(target, "ACTION", text)
194192

195193
def notice(self, target, text):
196-
text = "".join(text.splitlines())
197194
self.cmd("NOTICE", target, text)
198195

199196
def set_nick(self, nick):

cloudbot/hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def sieve(param=None, **kwargs):
318318
"""
319319

320320
def _sieve_hook(func):
321-
assert len(inspect.getfullargspec(func).args) == 3, \
321+
assert len(inspect.signature(func).parameters) == 3, \
322322
"Sieve plugin has incorrect argument count. Needs params: bot, input, plugin"
323323

324324
hook = _get_hook(func, "sieve")

cloudbot/permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from fnmatch import fnmatch
21
import logging
2+
from fnmatch import fnmatch
33

44
logger = logging.getLogger("cloudbot")
55

cloudbot/util/colors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import re
4040
from random import randint
4141

42-
4342
IRC_COLOUR_DICT = {
4443
"white": "00",
4544
"black": "01",
@@ -90,7 +89,6 @@
9089
"clear": "\x0F"
9190
}
9291

93-
9492
COLOR_RE = re.compile(r"\$\(.*?\)", re.I)
9593
IRC_COLOR_RE = re.compile(r"(\x03(\d+,\d+|\d)|[\x0f\x02\x16\x1f])", re.I)
9694

@@ -224,4 +222,4 @@ def _convert(string):
224222
elif formatting in IRC_FORMATTING_DICT:
225223
ret += get_format(formatting)
226224

227-
return ret.strip()
225+
return ret

cloudbot/util/filesize.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,50 +52,50 @@
5252
are listed in the accompanying credits file.
5353
"""
5454

55-
traditional = [
55+
traditional = (
5656
(1024 ** 5, 'P'),
5757
(1024 ** 4, 'T'),
5858
(1024 ** 3, 'G'),
5959
(1024 ** 2, 'M'),
6060
(1024 ** 1, 'K'),
6161
(1024 ** 0, 'B'),
62-
]
62+
)
6363

64-
alternative = [
64+
alternative = (
6565
(1024 ** 5, ' PB'),
6666
(1024 ** 4, ' TB'),
6767
(1024 ** 3, ' GB'),
6868
(1024 ** 2, ' MB'),
6969
(1024 ** 1, ' KB'),
7070
(1024 ** 0, (' byte', ' bytes')),
71-
]
71+
)
7272

73-
verbose = [
73+
verbose = (
7474
(1024 ** 5, (' petabyte', ' petabytes')),
7575
(1024 ** 4, (' terabyte', ' terabytes')),
7676
(1024 ** 3, (' gigabyte', ' gigabytes')),
7777
(1024 ** 2, (' megabyte', ' megabytes')),
7878
(1024 ** 1, (' kilobyte', ' kilobytes')),
7979
(1024 ** 0, (' byte', ' bytes')),
80-
]
80+
)
8181

82-
iec = [
82+
iec = (
8383
(1024 ** 5, 'Pi'),
8484
(1024 ** 4, 'Ti'),
8585
(1024 ** 3, 'Gi'),
8686
(1024 ** 2, 'Mi'),
8787
(1024 ** 1, 'Ki'),
8888
(1024 ** 0, ''),
89-
]
89+
)
9090

91-
si = [
91+
si = (
9292
(1000 ** 5, 'P'),
9393
(1000 ** 4, 'T'),
9494
(1000 ** 3, 'G'),
9595
(1000 ** 2, 'M'),
9696
(1000 ** 1, 'K'),
9797
(1000 ** 0, 'B'),
98-
]
98+
)
9999

100100
# re.I style aliases
101101
T = traditional
@@ -109,7 +109,7 @@ def size(b, system=traditional):
109109
"""Human-readable file size.
110110
111111
Using the traditional system, where a factor of 1024 is used::
112-
112+
113113
>>> size(10)
114114
'10B'
115115
>>> size(100)
@@ -130,7 +130,7 @@ def size(b, system=traditional):
130130
'976K'
131131
>>> size(2000000)
132132
'1M'
133-
133+
134134
Using the SI system, with a factor 1000::
135135
136136
>>> size(10, system=si)
@@ -153,11 +153,14 @@ def size(b, system=traditional):
153153
'1M'
154154
>>> size(2000000, system=si)
155155
'2M'
156-
156+
157157
"""
158158
for factor, suffix in system:
159159
if b >= factor:
160160
break
161+
else:
162+
return
163+
161164
amount = int(b / factor)
162165
if isinstance(suffix, tuple):
163166
singular, multiple = suffix

0 commit comments

Comments
 (0)