hbmartin commited on
Commit
eb4bae7
·
1 Parent(s): 808189a

automate release versioning, move create_logger to helpers

Browse files
Files changed (6) hide show
  1. Makefile +6 -0
  2. Pipfile +0 -3
  3. pytube/__init__.py +1 -1
  4. pytube/helpers.py +20 -0
  5. pytube/logging.py +0 -24
  6. pytube/version.py +3 -0
Makefile CHANGED
@@ -35,3 +35,9 @@ package: clean-build
35
 
36
  upload:
37
  twine upload dist/*
 
 
 
 
 
 
 
35
 
36
  upload:
37
  twine upload dist/*
38
+
39
+ tag:
40
+ git tag "v`pipenv run python pytube/version.py`"
41
+ git push --tags
42
+
43
+ release: tag package upload
Pipfile CHANGED
@@ -19,6 +19,3 @@ coveralls = "*"
19
  sphinx_rtd_theme = "*"
20
  mypy = "*"
21
  black = "==19.10b0"
22
-
23
- [requires]
24
- python_version = "3.5"
 
19
  sphinx_rtd_theme = "*"
20
  mypy = "*"
21
  black = "==19.10b0"
 
 
 
pytube/__init__.py CHANGED
@@ -9,7 +9,7 @@ __author__ = "Nick Ficano, Harold Martin"
9
  __license__ = "MIT License"
10
  __copyright__ = "Copyright 2019 Nick Ficano"
11
 
12
- from pytube.logging import create_logger
13
  from pytube.query import CaptionQuery
14
  from pytube.query import StreamQuery
15
  from pytube.streams import Stream
 
9
  __license__ = "MIT License"
10
  __copyright__ = "Copyright 2019 Nick Ficano"
11
 
12
+ from pytube.helpers import create_logger
13
  from pytube.query import CaptionQuery
14
  from pytube.query import StreamQuery
15
  from pytube.streams import Stream
pytube/helpers.py CHANGED
@@ -133,3 +133,23 @@ def safe_filename(s, max_length=255):
133
  regex = re.compile(pattern, re.UNICODE)
134
  filename = regex.sub("", s)
135
  return filename[:max_length].rsplit(" ", 0)[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  regex = re.compile(pattern, re.UNICODE)
134
  filename = regex.sub("", s)
135
  return filename[:max_length].rsplit(" ", 0)[0]
136
+
137
+
138
+ def create_logger(level=logging.ERROR):
139
+ """Create a configured instance of logger.
140
+
141
+ :param int level:
142
+ Describe the severity level of the logs to handle.
143
+ """
144
+ fmt = "[%(asctime)s] %(levelname)s in %(module)s: %(message)s"
145
+ date_fmt = "%H:%M:%S"
146
+ formatter = logging.Formatter(fmt, datefmt=date_fmt)
147
+
148
+ handler = logging.StreamHandler()
149
+ handler.setFormatter(formatter)
150
+
151
+ # https://github.com/nficano/pytube/issues/163
152
+ logger = logging.getLogger("pytube")
153
+ logger.addHandler(handler)
154
+ logger.setLevel(level)
155
+ return logger
pytube/logging.py DELETED
@@ -1,24 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """This module implements a log factory."""
3
-
4
- import logging
5
-
6
-
7
- def create_logger(level=logging.ERROR):
8
- """Create a configured instance of logger.
9
-
10
- :param int level:
11
- Describe the severity level of the logs to handle.
12
- """
13
- fmt = "[%(asctime)s] %(levelname)s in %(module)s: %(message)s"
14
- date_fmt = "%H:%M:%S"
15
- formatter = logging.Formatter(fmt, datefmt=date_fmt)
16
-
17
- handler = logging.StreamHandler()
18
- handler.setFormatter(formatter)
19
-
20
- # https://github.com/nficano/pytube/issues/163
21
- logger = logging.getLogger("pytube")
22
- logger.addHandler(handler)
23
- logger.setLevel(level)
24
- return logger
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pytube/version.py CHANGED
@@ -1 +1,4 @@
1
  __version__ = "9.5.6"
 
 
 
 
1
  __version__ = "9.5.6"
2
+
3
+ if __name__ == "__main__":
4
+ print(__version__)