ok
Direktori : /lib/python3.6/site-packages/dateutil/__pycache__/ |
Current File : //lib/python3.6/site-packages/dateutil/__pycache__/parser.cpython-36.pyc |
3 6�cY�� � @ s d Z ddlmZ ddlZddlZddlZddlZddlZddlm Z ddl mZ ddlm Z mZmZ ddlmZ dd lmZ d dgZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Ze� Zddd �ZG dd� de�Ze� Zdd� Zdd� Z dS )a� This module offers a generic date/time string parser which is able to parse most known formats to represent a date and/or time. This module attempts to be forgiving with regards to unlikely input formats, returning a datetime object even for dates which are ambiguous. If an element of a date/time stamp is omitted, the following rules are applied: - If AM or PM is left unspecified, a 24-hour clock is assumed, however, an hour on a 12-hour clock (``0 <= hour <= 12``) *must* be specified if AM or PM is specified. - If a time zone is omitted, a timezone-naive datetime is returned. If any other elements are missing, they are taken from the :class:`datetime.datetime` object passed to the parameter ``default``. If this results in a day number exceeding the valid number of days per month, the value falls back to the end of the month. Additional resources about date/time string formats can be found below: - `A summary of the international standard date and time notation <http://www.cl.cam.ac.uk/~mgk25/iso-time.html>`_ - `W3C Date and Time Formats <http://www.w3.org/TR/NOTE-datetime>`_ - `Time Formats (Planetary Rings Node) <http://pds-rings.seti.org/tools/time_formats.html>`_ - `CPAN ParseDate module <http://search.cpan.org/~muir/Time-modules-2013.0912/lib/Time/ParseDate.pm>`_ - `Java SimpleDateFormat Class <https://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>`_ � )�unicode_literalsN)�StringIO)� monthrange)� text_type�binary_type� integer_types� )� relativedelta)�tz�parse� parserinfoc @ sn e Zd Zejd�Zdd� Zdd� Zdd� Zdd � Z d d� Z edd � �Zedd� �Z edd� �Zedd� �ZdS )�_timelexz([.,])c C sd t |t�r|j� }t |t�r$t|�}t|dd �d krHtdj|jj d���|| _ g | _g | _d| _ d S )N�readz8Parser must be a string or character stream, not {itype})ZitypeF)� isinstancer �decoder r �getattr� TypeError�format� __class__�__name__�instream� charstack� tokenstack�eof)�selfr � r �/usr/lib/python3.6/parser.py�__init__4 s z_timelex.__init__c C s� | j r| j jd�S d}d}d}�x�| j�s| jr>| jjd�}n&| jjd�}x|dkrb| jjd�}qLW |srd| _P q"|s�|}| j|�r�d}n$| j|�r�d}n| j|�r�d }P nP q"|dk� r�d}| j|�r�||7 }n$|d kr�||7 }d}n| jj |� P q"|dk�rX| j|��r||7 }n>|d k�s:|dk�rHt |�d k�rH||7 }d}n| jj |� P q"|dk�r�d}|d k�s|| j|��r�||7 }n6| j|��r�|d d k�r�||7 }d}n| jj |� P q"|dkr"|d k�s�| j|��r�||7 }q"| j|��r|d d k�r||7 }d}q"| jj |� P q"W |dk�r�|�sN|jd �dk�sN|d dk�r�| jj |�}|d }x(|dd� D ]}|�rp| j j |� �qpW |dk�r�|jd �dk�r�|jdd �}|S )a� This function breaks the time string into lexical units (tokens), which can be parsed by the parser. Lexical units are demarcated by changes in the character set, so any continuous string of letters is considered one unit, any continuous string of numbers is considered one unit. The main complication arises from the fact that dots ('.') can be used both as separators (e.g. "Sep.20.2009") or decimal points (e.g. "4:30:21.447"). As such, it is necessary to read the full context of any dot-separated strings before breaking it into tokens; as such, this function maintains a "token stack", for when the ambiguous context demands that multiple tokens be parsed at once. r FNr � T�a�0� �.�a.�,� �0.z.,���r'