Skip to content

Commit 1ec40e1

Browse files
authored
Merge pull request #161 from TotallyNotRobots/tvdb-update
Update tvdb API
2 parents c4e356d + ad9dac7 commit 1ec40e1

File tree

8 files changed

+1089
-155
lines changed

8 files changed

+1089
-155
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exclude_lines =
77
if __name__ == .__main__.:
88
if sys.version_info
99
class .*\(.*(Error|Exception)\):
10+
^ *\.\.\.$
1011

1112
[run]
1213
omit =

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Update mylife.py for website changes
2525
- Fixed handling of colons in core IRC parser
2626
- Fix FML random URL
27+
- Update tvdb.py to v3 TVDB API
2728
### Removed
2829
- twitch.py removed due to outdated API and lack of maintainer
2930

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ This product includes GeoLite2 data created by MaxMind, available from
8484

8585
![Powered by wordnik](https://www.wordnik.com/img/wordnik_badge_a1.png)
8686

87+
TV information is provided by [TheTVDB.com], but we are not endorsed or certified by [TheTVDB.com] or its affiliates.
88+
8789
Translations are Powered by [Yandex.Translate](https://translate.yandex.com)
8890

8991
This product uses data from <a href="http://wordnik.com">http://wordnik.com</a> in accordance with the wordnik.com API <a href="http://developer.wordnik.com/#!/terms">terms of service</a>.
9092

9193
[latest source]: https://github.com/TotallyNotRobots/CloudBot/archive/master.zip
9294
[latest release]: https://github.com/TotallyNotRobots/CloudBot/releases/latest
95+
[TheTVDB.com]: https://thetvdb.com/

cloudbot/__init__.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
import json
2+
import logging
3+
import logging.config
4+
import os
15
import sys
26

37
# check python version
48
if sys.version_info < (3, 5, 3):
59
print("CloudBot requires Python 3.5.3 or newer.")
610
sys.exit(1)
711

8-
import json
9-
import logging.config
10-
import logging
11-
import os
1212

1313
version = (1, 3, 0)
14-
__version__ = '.'.join(str(i) for i in version)
14+
__version__ = ".".join(str(i) for i in version)
1515

1616
__all__ = (
1717
"clients",
@@ -52,40 +52,41 @@ def _setup():
5252
logging_config = {}
5353

5454
file_log = logging_config.get("file_log", False)
55-
console_level = "INFO" if logging_config.get("console_log_info", True) else "WARNING"
55+
console_level = (
56+
"INFO" if logging_config.get("console_log_info", True) else "WARNING"
57+
)
5658

5759
logging_info.dir = os.path.join(os.path.abspath(os.path.curdir), "logs")
5860

5961
logging_info.make_dir()
6062

6163
logging.captureWarnings(True)
6264

65+
logger_names = ["cloudbot", "plugins"]
66+
6367
dict_config = {
6468
"version": 1,
6569
"formatters": {
6670
"brief": {
6771
"format": "[%(asctime)s] [%(levelname)s] %(message)s",
68-
"datefmt": "%H:%M:%S"
72+
"datefmt": "%H:%M:%S",
6973
},
7074
"full": {
7175
"format": "[%(asctime)s] [%(levelname)s] %(message)s",
72-
"datefmt": "%Y-%m-%d][%H:%M:%S"
73-
}
76+
"datefmt": "%Y-%m-%d][%H:%M:%S",
77+
},
7478
},
7579
"handlers": {
7680
"console": {
7781
"class": "logging.StreamHandler",
7882
"formatter": "brief",
7983
"level": console_level,
80-
"stream": "ext://sys.stdout"
84+
"stream": "ext://sys.stdout",
8185
}
8286
},
8387
"loggers": {
84-
"cloudbot": {
85-
"level": "DEBUG",
86-
"handlers": ["console"]
87-
}
88-
}
88+
name: {"level": "DEBUG", "handlers": ["console"]} for name in logger_names
89+
},
8990
}
9091

9192
if file_log:
@@ -96,17 +97,15 @@ def _setup():
9697
"formatter": "full",
9798
"level": "INFO",
9899
"encoding": "utf-8",
99-
"filename": logging_info.add_path("bot.log")
100+
"filename": logging_info.add_path("bot.log"),
100101
}
101102

102-
dict_config["loggers"]["cloudbot"]["handlers"].append("file")
103+
for name in logger_names:
104+
dict_config["loggers"][name]["handlers"].append("file")
103105

104106
if logging_config.get("console_debug", False):
105107
dict_config["handlers"]["console"]["level"] = "DEBUG"
106-
dict_config["loggers"]["asyncio"] = {
107-
"level": "DEBUG",
108-
"handlers": ["console"]
109-
}
108+
dict_config["loggers"]["asyncio"] = {"level": "DEBUG", "handlers": ["console"]}
110109
if file_log:
111110
dict_config["loggers"]["asyncio"]["handlers"].append("file")
112111

@@ -118,9 +117,10 @@ def _setup():
118117
"formatter": "full",
119118
"encoding": "utf-8",
120119
"level": "DEBUG",
121-
"filename": logging_info.add_path("debug.log")
120+
"filename": logging_info.add_path("debug.log"),
122121
}
123-
dict_config["loggers"]["cloudbot"]["handlers"].append("debug_file")
122+
for name in logger_names:
123+
dict_config["loggers"][name]["handlers"].append("debug_file")
124124

125125
logging.config.dictConfig(dict_config)
126126

cloudbot/util/func_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class ParameterError(Exception):
55
def __init__(self, name, valid_args):
66
super().__init__(
7-
"'{}' is not a valid parameter, valid parameters are: {}".format(
7+
"{!r} is not a valid parameter, valid parameters are: {}".format(
88
name, list(valid_args)
99
)
1010
)
@@ -13,9 +13,11 @@ def __init__(self, name, valid_args):
1313

1414

1515
def call_with_args(func, arg_data):
16-
sig = inspect.signature(func)
16+
sig = inspect.signature(func, follow_wrapped=False)
1717
try:
18-
args = [arg_data[key] for key in sig.parameters.keys() if not key.startswith('_')]
18+
args = [
19+
arg_data[key] for key in sig.parameters.keys() if not key.startswith("_")
20+
]
1921
except KeyError as e:
2022
raise ParameterError(e.args[0], arg_data.keys()) from e
2123

0 commit comments

Comments
 (0)