Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 2øªjPCã@sddlZddlZddlZddlmZddlmZmZddlZddlm Z ej Z ddddœZ Gdd „d ej ƒZd d „Zdd d„ZGdd„deƒZGdd„dejƒZGdd„dejƒZGdd„deƒZefdd„Zefdd„Zedk�rddlZejejejd�j ƒdS)éN)Úwraps)ÚMappingÚCallable)Ú PercentStylez%(levelname)s: %(message)sz %(message)s)Ú*ÚINFOÚDEBUGcs.eZdZdZd‡fdd„ Z‡fdd„Z‡ZS) ÚLevelFormatterayLog formatter with level-specific formatting. Formatter class which optionally takes a dict of logging levels to format strings, allowing to customise the log records appearance for specific levels. Attributes: fmt: A dictionary mapping logging levels to format strings. The ``*`` key identifies the default format string. datefmt: As per py:class:`logging.Formatter` style: As per py:class:`logging.Formatter` >>> import sys >>> handler = logging.StreamHandler(sys.stdout) >>> formatter = LevelFormatter( ... fmt={ ... '*': '[%(levelname)s] %(message)s', ... 'DEBUG': '%(name)s [%(levelname)s] %(message)s', ... 'INFO': '%(message)s', ... }) >>> handler.setFormatter(formatter) >>> log = logging.getLogger('test') >>> log.setLevel(logging.DEBUG) >>> log.addHandler(handler) >>> log.debug('this uses a custom format string') test [DEBUG] this uses a custom format string >>> log.info('this also uses a custom format string') this also uses a custom format string >>> log.warning("this one uses the default format string") [WARNING] this one uses the default format string Nú%csª|dkrtdƒ‚|dkrt}t|tƒr0|}i}n,t|tƒrPt|ƒ}|jddƒ}n td|ƒ‚tt |ƒj ||ƒ|j |_ i|_ x(|jƒD]\}}tj|ƒ}||j |<q†WdS)Nr z:only '%' percent style is supported in both python 2 and 3rz&fmt must be a str or a dict of str: %r)Ú ValueErrorÚDEFAULT_FORMATSÚ isinstanceÚstrrÚdictÚpopÚ TypeErrorÚsuperr Ú__init__Ú_fmtÚdefault_formatÚcustom_formatsÚitemsÚloggingÚ _checkLevel)ÚselfÚfmtÚdatefmtÚstylerrÚlevel)Ú __class__©ú@/tmp/pip-build-_d5lkt3n/fonttools/fontTools/misc/loggingTools.pyr8s$    zLevelFormatter.__init__csF|jr6|jj|j|jƒ}|j|kr6||_tr6t|ƒ|_tt|ƒj |ƒS)N) rÚgetÚlevelnorrrÚ_stylerr Úformat)rÚrecordr)rr r!r%Ms  zLevelFormatter.format)NNr )Ú__name__Ú __module__Ú __qualname__Ú__doc__rr%Ú __classcell__r r )rr!r s r cKs²|jddƒ}|dkr.d|krFd|krFtdƒ‚nd|ks>d|krFtdƒ‚|dkr”|jddƒ}|jddƒ}|rxtj||ƒ}n|jddƒ}tj|ƒ}|g}|jd d ƒ}| s°t|tƒrºtj|ƒ}t|j d �|jd dƒ}|jd dƒ}|jddƒ} t ||| ƒ} |jdgƒ} xP|D]H}|j dk�r"|j | ƒ|j �sDx| D]} |j| ƒ�q0W|j|ƒ�qW|j dk�rn|jddƒ|_|jddƒ} | dk �rŽ|j| ƒ|�r®dj|jƒƒ}td|ƒ‚dS)aåA more sophisticated logging system configuation manager. This is more or less the same as :py:func:`logging.basicConfig`, with some additional options and defaults. The default behaviour is to create a ``StreamHandler`` which writes to sys.stderr, set a formatter using the ``DEFAULT_FORMATS`` strings, and add the handler to the top-level library logger ("fontTools"). A number of optional keyword arguments may be specified, which can alter the default behaviour. Args: logger: Specifies the logger name or a Logger instance to be configured. (Defaults to "fontTools" logger). Unlike ``basicConfig``, this function can be called multiple times to reconfigure a logger. If the logger or any of its children already exists before the call is made, they will be reset before the new configuration is applied. filename: Specifies that a ``FileHandler`` be created, using the specified filename, rather than a ``StreamHandler``. filemode: Specifies the mode to open the file, if filename is specified. (If filemode is unspecified, it defaults to ``a``). format: Use the specified format string for the handler. This argument also accepts a dictionary of format strings keyed by level name, to allow customising the records appearance for specific levels. The special ``'*'`` key is for 'any other' level. datefmt: Use the specified date/time format. level: Set the logger level to the specified level. stream: Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with ``filename`` - if both are present, ``stream`` is ignored. handlers: If specified, this should be an iterable of already created handlers, which will be added to the logger. Any handler in the list which does not have a formatter assigned will be assigned the formatter created in this function. filters: If specified, this should be an iterable of already created filters. If the ``handlers`` do not already have filters assigned, these filters will be added to them. propagate: All loggers have a ``propagate`` attribute which determines whether to continue searching for handlers up the logging hierarchy. If not provided, the "propagate" attribute will be set to ``False``. ÚhandlersNÚstreamÚfilenamez8'stream' and 'filename' should not be specified togetherzG'stream' or 'filename' should not be specified together with 'handlers'ÚfilemodeÚaÚloggerZ fontTools)Úparentr%rrr ÚfiltersÚrootÚ propagateFrz, zUnrecognised argument(s): %s)rr rÚ FileHandlerÚ StreamHandlerr rÚ getLoggerÚ_resetExistingLoggersÚnamer Ú formatterÚ setFormatterr3Ú addFilterÚ addHandlerr5ÚsetLevelÚjoinÚkeys)Úkwargsr,r.ÚmodeÚhr-r1ÚfsÚdfsrrr3ÚfrrAr r r!Ú configLoggerXsL-                      rHr4c CsBtj}t|jjjƒƒ}|dkr*|g|}nx||kr6dS||kr¢|g}|j|ƒd}|d}t|ƒ}t|ƒ}x6||kr ||d|…|kr–|j||ƒ|d7}qlWxš|D]’}|dk�r|j tj ƒx |j dd…D]} |j | ƒqÒWx |j dd…D]} |j| ƒqôWd|_q¨|jj|} tj| _g| _ g| _ d| _d| _q¨WdS)z„ Reset the logger named 'parent' and all its children to their initial state, if they already exist in the current configuration. r4NéÚ.FT)rr4ÚsortedÚmanagerÚ loggerDictrAÚindexÚlenÚappendr?ÚWARNINGr,Ú removeHandlerr3Z removeFiltersÚdisabledÚNOTSETrr5) r2r4ÚexistingZloggers_to_resetÚiÚprefixedÚpflenÚ num_existingr:rDrGr1r r r!r9¸s<       r9c@s|eZdZdZejZdZdZddd„Z ddd„Z d d „Z d d „Z d d„Z dd„Zdd„Zddd„Zdd„Zdd„Zdd„ZdS)ÚTimeraÓ Keeps track of overall time and split/lap times. >>> import time >>> timer = Timer() >>> time.sleep(0.01) >>> print("First lap:", timer.split()) First lap: ... >>> time.sleep(0.02) >>> print("Second lap:", timer.split()) Second lap: ... >>> print("Overall time:", timer.time()) Overall time: ... Can be used as a context manager inside with-statements. >>> with Timer() as t: ... time.sleep(0.01) >>> print("%0.3f seconds" % t.elapsed) 0... seconds If initialised with a logger, it can log the elapsed time automatically upon exiting the with-statement. >>> import logging >>> log = logging.getLogger("my-fancy-timer-logger") >>> configLogger(logger=log, level="DEBUG", format="%(message)s", stream=sys.stdout) >>> with Timer(log, 'do something'): ... time.sleep(0.01) Took ... to do something The same Timer instance, holding a reference to a logger, can be reused in multiple with-statements, optionally with different messages or levels. >>> timer = Timer(log) >>> with timer(): ... time.sleep(0.01) elapsed time: ...s >>> with timer('redo it', level=logging.INFO): ... time.sleep(0.02) Took ... to redo it It can also be used as a function decorator to log the time elapsed to run the decorated function. >>> @timer() ... def test1(): ... time.sleep(0.01) >>> @timer('run test 2', level=logging.INFO) ... def test2(): ... time.sleep(0.02) >>> test1() Took ... to run 'test1' >>> test2() Took ... to run test 2 zelapsed time: %(time).3fszTook %(time).3fs to %(msg)sNcCs^|j|ƒ|dkrszTimer.formatTimecCs|jƒ|_d|_|S)z Start a new lap g)rarbrc)rr r r!Ú __enter__Os zTimer.__enter__cCsJ|jƒ}|jdks|rdS|j|j|ƒ}|j|dœ}|jj|j||ƒdS)z� End the current lap. If timer has a logger, log the time elapsed, using the format string in self.msg (or the default one). N)r[rd)rfr1rjr[Úlogr)rÚexc_typeÚ exc_valueÚ tracebackrdÚmessageZ msg_partsr r r!Ú__exit__Us  zTimer.__exit__c sjt|tƒr:|‰ˆjs dˆjˆ_tˆƒ‡‡fdd„ƒ}|S|pF|jdƒ}|jdˆjƒ}ˆjˆj||ƒSdS)a9 If the first argument is a function, return a decorator which runs the wrapped function inside Timer's context manager. Otherwise, treat the first argument as a 'msg' string and return an updated Timer instance, referencing the same logger. A 'level' keyword can also be passed to override self.level. zrun '%s'c sˆ� ˆ||ŽSQRXdS)Nr )ÚargsÚkwds)Úfuncrr r!ÚwrapperqszTimer.__call__..wrapperr[rN) r rr[r'rr"rrr1)rZ func_or_msgrBrur[rr )rtrr!Ú__call__ds  zTimer.__call__cCs|jS)N)rc)rr r r!Ú __float__{szTimer.__float__cCs t|jƒS)N)Úintrc)rr r r!Ú__int__~sz Timer.__int__cCs d|jS)Nz%.3f)rc)rr r r!Ú__str__�sz Timer.__str__)NNNN)N)N)r'r(r)r*ÚtimeitZ default_timerrargrrr\rdrfrjrkrqrvrwryrzr r r r!rZás7  rZc@s eZdZdZdd„Zdd„ZdS)ÚChannelsFilteraProvides a hierarchical filter for log entries based on channel names. Filters out records emitted from a list of enabled channel names, including their children. It works the same as the ``logging.Filter`` class, but allows the user to specify multiple channel names. >>> import sys >>> handler = logging.StreamHandler(sys.stdout) >>> handler.setFormatter(logging.Formatter("%(message)s")) >>> filter = ChannelsFilter("A.B", "C.D") >>> handler.addFilter(filter) >>> root = logging.getLogger() >>> root.addHandler(handler) >>> root.setLevel(level=logging.DEBUG) >>> logging.getLogger('A.B').debug('this record passes through') this record passes through >>> logging.getLogger('A.B.C').debug('records from children also pass') records from children also pass >>> logging.getLogger('C.D').debug('this one as well') this one as well >>> logging.getLogger('A.B.').debug('also this one') also this one >>> logging.getLogger('A.F').debug('but this one does not!') >>> logging.getLogger('C.DE').debug('neither this one!') cGs$||_t|ƒ|_dd„|Dƒ|_dS)NcSsi|]}t|ƒ|“qSr )rO)Ú.0Únr r r!ú £sz+ChannelsFilter.__init__..)ÚnamesrOÚnumÚlengths)rr€r r r!r s zChannelsFilter.__init__cCs`|jdkrdSxL|jD]B}|j|}||jkr2dS|jj|d|ƒdkr|j|dkrdSqWdS)NrTrJF)r�r€r‚r:rh)rr&r:Únlenr r r!Úfilter¥s    zChannelsFilter.filterN)r'r(r)r*rr„r r r r!r|…sr|cs>eZdZ‡fdd„Zdd„Zdd„Zdd„Zd d d „Z‡ZS) ÚCapturingLogHandlercs:tt|ƒj|d�g|_t|tƒr0tj|ƒ|_n||_dS)N)r) rr…rÚrecordsr rrr8r1)rr1r)rr r!r³s  zCapturingLogHandler.__init__cCsL|jj|_|jj|_|jj|_|jj|ƒ|jj|jƒd|j_d|j_|S)NF) r1rSÚoriginal_disabledrÚoriginal_levelr5Úoriginal_propagater>r?)rr r r!rk»s    zCapturingLogHandler.__enter__cCs2|jj|ƒ|jj|jƒ|j|j_|j|j_|S)N)r1rRr?rˆr‡rSr‰r5)rÚtypeÚvalueror r r!rqÇs    zCapturingLogHandler.__exit__cCs|jj|ƒdS)N)r†rP)rr&r r r!ÚemitÏszCapturingLogHandler.emitNcCsTddl}|j|ƒ}x |jD]}|j|jƒƒrdSqW|dkrDd|}dsPt|ƒ‚dS)NrTz(Pattern '%s' not found in logger records)ÚreÚcompiler†ÚsearchÚ getMessageÚAssertionError)rÚregexpr[r�ÚpatternÚrr r r!Ú assertRegexÒs  zCapturingLogHandler.assertRegex)N) r'r(r)rrkrqrŒr•r+r r )rr!r…²s   r…c@seZdZdZedd„ƒZdS)ÚLogMixinañ Mixin class that adds logging functionality to another class. You can define a new class that subclasses from ``LogMixin`` as well as other base classes through multiple inheritance. All instances of that class will have a ``log`` property that returns a ``logging.Logger`` named after their respective ``.``. For example: >>> class BaseClass(object): ... pass >>> class MyClass(LogMixin, BaseClass): ... pass >>> a = MyClass() >>> isinstance(a.log, logging.Logger) True >>> print(a.log.name) fontTools.misc.loggingTools.MyClass >>> class AnotherClass(MyClass): ... pass >>> b = AnotherClass() >>> isinstance(b.log, logging.Logger) True >>> print(b.log.name) fontTools.misc.loggingTools.AnotherClass cCs2t|dƒs,dj|jj|jjfƒ}tj|ƒ|_|jS)NÚ_logrJ)Úhasattrr@rr(r'rr8r—)rr:r r r!rlùs   z LogMixin.logN)r'r(r)r*Úpropertyrlr r r r!r–Ýsr–cCstjd||f|dd�dS)z< Raise a warning about deprecated function argument 'name'. z%r is deprecated; %sé)ÚcategoryÚ stacklevelN)ÚwarningsÚwarn)r:r[r›r r r!ÚdeprecateArgumentsrŸcs‡‡fdd„}|S)zD Decorator to raise a warning when a deprecated function is called. cstˆƒ‡‡‡fdd„ƒ}|S)Ncs$tjdˆjˆfˆdd�ˆ||ŽS)Nz%r is deprecated; %sé)r›rœ)r�ržr')rrrB)r›rtr[r r!ru s  z5deprecateFunction..decorator..wrapper)r)rtru)r›r[)rtr!Ú decorator sz$deprecateFunction..decoratorr )r[r›r¡r )r›r[r!ÚdeprecateFunction sr¢Ú__main__)Z optionflags)r4)!Úsysrr{Ú functoolsrÚcollections.abcrrr�rrr^r Ú Formatterr rHr9ÚobjectrZÚFilterr|ÚHandlerr…r–Ú UserWarningrŸr¢r'ÚdoctestÚexitÚtestmodÚELLIPSISÚfailedr r r r!Ús.  B` )%-+&