29 Commits

Author SHA1 Message Date
Nikolaus Waxweiler
d584daa8fd Blacken code 2022-12-13 11:26:36 +00:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Chris Simpkins
7abf2e4c75
transition basestring to str
https://github.com/fonttools/fonttools/issues/2232
2021-03-27 10:23:29 -04:00
Simon Cozens
775dc6074e
fontTools.misc.* documentation, part 2 (#1981)
* Document misc.filenames
* Document misc.fixedTools
* Document misc.intTools
* Document misc.loggingTools
* Document misc.macCreatorType
* Document misc.macRes
* Document misc.plistlib
2020-06-08 15:53:48 +01:00
Simon Cozens
f52eabeefe Fix typo in loggingTools variable name 2020-05-07 21:18:29 +01:00
Nikolaus Waxweiler
969df8303b Remove some Python 2 era import gaming 2019-10-11 22:36:33 +01:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
160a9cb238
fix doctest calling configLogger causing flakiness of other tests
since we use pytest-randomly to randomize the test execution, depending on when
this specific test is executed, it may have the side effect of configuring
the global logging configuration, causing other tests that capture logging
messages to fail.

E.g. see https://travis-ci.org/fonttools/fonttools/jobs/545680550
2019-06-14 11:50:07 +01:00
Cosimo Lupo
1fc1d2f529
[loggingTools] remove unused backport of LastResortLogger
we are not in the business of logging.
2019-06-11 13:39:59 +01:00
Cosimo Lupo
9557c6a229
fix deprecation warnings when using ABC from collections module 2018-10-18 18:12:43 +01:00
Cosimo Lupo
0245f2c55a
loggingTools: add msg=None argument to CapturingLogHandler.assertRegex
like all the rest of unittest.TestCase assertSomething
2018-09-28 19:10:50 +01:00
Cosimo Lupo
248ae41e9d
loggingTools: fix CapturingLogHandler to work with py37
we can't set the logger.level directly because in py37 the logger has a _cache
attribute and that needs to be invalidated by calling setLevel method.

also, I noticed we weren't restoring the original 'disabled' attribute value...

And we need to also set/restore the 'propagate' attribute.
2018-07-24 12:17:59 +01:00
Cosimo Lupo
d9d30c819a
loggingTools: move here the LastResortLogger from py23
and add a small test
2018-06-19 16:54:50 +01:00
Cosimo Lupo
fbab1227ce
loggingTools: memoize 'log' property of LogMixin
the logger name is constant (based on the user class's name and module)
so we can cache it.

(this means the LogMixin will only work on regular dict-based classes,
not on 'slotted' classes. But that's ok
2018-06-07 11:40:33 +01:00
Cosimo Lupo
60f2c741c3
CapturingLogHandler: match the fully formatted log message in assertRegex
and not the raw 'msg' attribute which still has the '%' formatting placeholders
2018-01-15 18:38:27 +00:00
Cosimo Lupo
1e31e55682
[loggingTools] add docstring to exemplify usage of LogMixin 2017-04-12 11:20:42 +01:00
Cosimo Lupo
cca1d20b0e
[loggingTools] added LogMixin class
This is useful to quickly add logging functionality to classes, and
to reduce boilerplate.

It adds a 'log' property to the class inheriting from it, which uses
logging.getLogger to get a logging.Logger (sigleton) object named after
<module>.<class> of self.
2017-04-11 18:40:52 +01:00
Cosimo Lupo
fab26fd5c1
[loggingTools] rename 'match' to 'assertRegex'
https://github.com/fonttools/fonttools/pull/913#discussion_r110820088

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRegex
2017-04-11 09:34:39 +01:00
Cosimo Lupo
9528717f6e
[loggingTools] add 'match' method to CapturingLogHandler
Can be useful for writing tests:

>>> with CapturingLogHandler(log, "WARNING") as captor:
...     # do something with logging
>>> assert captor.match('some .* pattern')
2017-04-10 19:47:48 +01:00
Cosimo Lupo
ab395ff0e2 move CapturingLogHandler class from subset to loggingTools module 2016-10-04 14:31:30 +01:00
Rod Sheeter
74e7400097 Minimal change to allow Google Fonts to easily capture subset timings serverside via log handler. 2016-05-11 12:59:37 -07:00
Behdad Esfahbod
2a0359af4d Always import * from py23
Since py23 modifies some essential builtins, it's safe to import
everything all the time.  At least, that's how it was designed.
It's a bug if importing * breaks some code.
2016-04-06 18:15:43 -07:00
Cosimo Lupo
16f29ffd6d [loggingTools] use ellipsis for doctests when printing time
appveyor can be *very* slow

https://ci.appveyor.com/project/anthrotype/fonttools/build/job/pdrl7o5ggan7qlej
2016-02-07 01:19:45 +00:00
Cosimo Lupo
f65a6ec346 [loggingTools] remove _StderrHandler and Logger classes (moved to py23) 2016-02-01 13:18:06 +00:00
Cosimo Lupo
f3116ad4d0 [loggingTools] add Logger class with support for 'lastResort' stderr handler
Both _StderrHandler and Logger.callHandlers included here are taken from Python 3.5's
logging.py source.

I only set logging.lastResort if it's not already set (i.e. for Python < 3.2).
2016-01-29 18:36:21 +00:00
Cosimo Lupo
141cc7b6c2 [loggingTools] typo 2016-01-29 17:28:53 +00:00
Cosimo Lupo
3664462a63 [loggingTools] use ellipsis for elapsed time in doctestes to fix AppVeyor build
https://ci.appveyor.com/project/anthrotype/fonttools/build/1.0.53/job/2p08d9sbcfelvwx6
2016-01-27 19:05:05 +00:00
Cosimo Lupo
e8edfad59a [loggingTools] on Windows, warnings.warn doesn't like category=None, set it to UserWarning (which is the default) 2016-01-27 19:05:05 +00:00
Cosimo Lupo
317d653125 [loggingTools] module containing tools for adapting the Python logging package to fontTools (and viceversa) 2016-01-27 19:01:12 +00:00