mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-04-22 02:28:47 +00:00
commit
fc1d05389b
251 changed files with 23752 additions and 16877 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
*.pyo
|
||||
__local__/
|
||||
machine_guid
|
||||
/resources/media/Thumbs.db
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Thanks you for contributing to Emby for Kodi!
|
||||
|
||||
* Make pull requests towards the **develop** branch;
|
||||
* Make pull requests towards the **master** branch;
|
||||
* Keep the maximum line length shorter than 100 characters to keep things clean and readable;
|
||||
* Follow pep8 style as closely as possible: https://www.python.org/dev/peps/pep-0008/
|
||||
* Add comments if necessary.
|
||||
|
|
340
LICENSE
340
LICENSE
|
@ -1,340 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
|
853
LICENSE.txt
853
LICENSE.txt
|
@ -1,283 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
0. Definitions.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
1. Source Code.
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
14. Revised Versions of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
NO WARRANTY
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
-------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
18
README.md
18
README.md
|
@ -5,7 +5,7 @@
|
|||
[](https://github.com/MediaBrowser/plugin.video.emby/wiki)
|
||||
[](https://emby.media/community/index.php?/forum/99-kodi/)
|
||||
[](https://ko-fi.com/A5354BI)
|
||||
[](https://emby.media/)
|
||||
[](https://emby.media/)
|
||||
___
|
||||
**A whole new way to manage and view your media library.**
|
||||
|
||||
|
@ -25,7 +25,6 @@ The add-on supports a hybrid approach. You can decide which Emby libraries to sy
|
|||
- Other features supported:
|
||||
+ Simple Live TV presentation
|
||||
+ Home Videos & photos
|
||||
+ Audiobooks
|
||||
+ Playlists
|
||||
+ Theme media
|
||||
- Direct play and transcode
|
||||
|
@ -36,19 +35,8 @@ The add-on supports a hybrid approach. You can decide which Emby libraries to sy
|
|||
- Backup your emby kodi profile. See the [Emby backup option](https://github.com/MediaBrowser/plugin.video.emby/wiki/Create-and-restore-from-backup)
|
||||
- and more...
|
||||
|
||||
### Download and installation
|
||||
**Important notes**
|
||||
- To achieve direct play, you will need to ensure your Emby library paths point to network paths (e.g: "\\\\server\Media\Movies"). See the [Emby wiki](https://github.com/MediaBrowser/Wiki/wiki/Path%20Substitution) for additional information.
|
||||
- **The addon is not (and will not be) compatible with the MySQL database replacement in Kodi.** In fact, Emby takes over the point of having a MySQL database because it acts as a "man in the middle" for your entire media library.
|
||||
- Emby for Kodi is not currently compatible with Kodi's Video Extras addon unless native playback mode is used. **Deactivate Video Extras if content start randomly playing.**
|
||||
|
||||
View this short [Youtube video](https://youtu.be/IaecDPcXI3I?t=119) to give you a better idea of the general process.
|
||||
|
||||
1. Install the Emby for Kodi repository, from the repo install the Emby addon.
|
||||
2. Within a few seconds you should be prompted for your server-details.
|
||||
3. Once you're succesfully authenticated with your Emby server, the initial sync will start.
|
||||
4. The first sync of the Emby server to the local Kodi database may take some time depending on your device and library size.
|
||||
5. Once the full sync is done, you can browse your media in Kodi, and syncs will be done automatically in the background.
|
||||
### Install Emby for Kodi
|
||||
Get started with the [wiki guide](https://github.com/MediaBrowser/plugin.video.emby/wiki)
|
||||
|
||||
### Known limitations
|
||||
- Chapter images are missing unless native playback mode is used.
|
||||
|
|
15
addon.xml
15
addon.xml
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.video.emby"
|
||||
name="Emby"
|
||||
version="3.1.35a"
|
||||
version="4.0.3"
|
||||
provider-name="angelblue05">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.25.0"/>
|
||||
<import addon="plugin.video.emby.movies" version="0.13" />
|
||||
<import addon="plugin.video.emby.tvshows" version="0.13" />
|
||||
<import addon="plugin.video.emby.musicvideos" version="0.13" />
|
||||
<import addon="plugin.video.emby.movies" version="0.14" />
|
||||
<import addon="plugin.video.emby.tvshows" version="0.14" />
|
||||
<import addon="plugin.video.emby.musicvideos" version="0.14" />
|
||||
</requires>
|
||||
<extension point="xbmc.python.pluginsource"
|
||||
library="default.py">
|
||||
|
@ -37,7 +37,12 @@
|
|||
<summary lang="en"></summary>
|
||||
<description lang="en">Welcome to Emby for Kodi A whole new way to manage and view your media library. The Emby addon for Kodi combines the best of Kodi - ultra smooth navigation, beautiful UIs and playback of any file under the sun, and Emby - the most powerful fully open source multi-client media metadata indexer and server. Emby for Kodi is the absolute best way to enjoy the incredible Kodi playback engine combined with the power of Emby's centralized database. Features: Direct integration with the Kodi library for native Kodi speed Instant synchronization with the Emby server Full support for Movie, TV and Music collections Emby Server direct stream and transcoding support - use Kodi when you are away from home!</description>
|
||||
<news>
|
||||
- Many fixes, however still chasing the slowness issue.
|
||||
New stable release
|
||||
The wiki has been updated, PLEASE READ: https://github.com/MediaBrowser/plugin.video.emby/wiki
|
||||
Fix playback for Kodi Leia
|
||||
Fix masterlock
|
||||
Home videos and pictures now show under videos and picture add-ons
|
||||
Dependencies were updated to 0.14!
|
||||
</news>
|
||||
</extension>
|
||||
</addon>
|
||||
|
|
781
changelog.txt
781
changelog.txt
|
@ -1,781 +0,0 @@
|
|||
version 2.3.57
|
||||
- Close dialog after syncing collections
|
||||
- Update Leia support
|
||||
- Fix trakt/watched status issues caused by tvshows being assigned their imdb id instead of tvdb. You'll need to reset your database to fix this (or a repair might do the trick too)
|
||||
- Update photod (well now home videos and photos) library to properly display.
|
||||
- Few other fixes.
|
||||
|
||||
version 2.3.56
|
||||
- Fixed connection not falling back to external when local is unavailable
|
||||
- Support server address without a port number
|
||||
- Add refresh boxsets (launch the emby add-on > Refresh Boxsets). It should not be necessary, but just in case.
|
||||
|
||||
version 2.3.51
|
||||
- Temporarily disabled series pooling for non-admin users. A future server update + a manual sync will correct this. I'll make a quick announcement.
|
||||
|
||||
version 2.3.50
|
||||
- Fixed Series pooling (requires a reset of database + a manual sync to apply)
|
||||
- Add PlayPause server event
|
||||
|
||||
version 2.3.49
|
||||
- Update the websocket url for reverse proxy. wss://{server}/embywebsocket?api..
|
||||
- Fix music support for multiple Emby music libraries
|
||||
- Fix music direct stream to use the original file container rather than defaulting to mp3
|
||||
- Fix subtitles to use original file container rather than defaulting to srt
|
||||
- Fix network credentials using backslash for domain in their username
|
||||
- Fix playback report to your Emby dashboard
|
||||
- Add Polish translation
|
||||
|
||||
version 2.3.47
|
||||
- Fix encoding error in context menu for non-ascii characters
|
||||
- Fix playback reporting monitor for Kodi 17
|
||||
|
||||
version 2.3.35
|
||||
- DB connection management revamped
|
||||
- Emby video nodes now have their own parent node
|
||||
- Kodi 17 Ratings
|
||||
- Thread pool system for Emby data loading
|
||||
- A lot of small bug fixes
|
||||
- Some code refactoring
|
||||
|
||||
version 2.3.25
|
||||
- Fix on-wake sync
|
||||
|
||||
version 2.3.24
|
||||
- Fix bug in the manual sync
|
||||
- Add Italian translation
|
||||
|
||||
version 2.3.23
|
||||
- Adjustments to the download throttle. See github wiki docs.
|
||||
- Fix the fast sync
|
||||
- Fix the emby backup
|
||||
- other minor fixes
|
||||
|
||||
version 2.3.12
|
||||
- Fix virtual episodes being processed
|
||||
- Return offline items so they don't get removed in kodi
|
||||
- other minor fixes
|
||||
|
||||
version 2.3.8
|
||||
- Fix database connection
|
||||
- other minor fixes
|
||||
|
||||
version 2.3.6
|
||||
- Update French translation
|
||||
- Fix screensaver bug
|
||||
|
||||
version 2.3.4
|
||||
- add throttling for error event logging
|
||||
|
||||
version 2.3.3
|
||||
- minor fix to exception handling
|
||||
|
||||
version 2.3.1
|
||||
- minor fixes
|
||||
|
||||
version 2.3.0
|
||||
- New stable version
|
||||
|
||||
version 2.2.57
|
||||
- Fix for external subtitles while using HTTP playback
|
||||
- Minor bug fixes
|
||||
|
||||
version 2.2.52-54
|
||||
- Fix bugs that slipped in the few previous builds
|
||||
|
||||
version 2.2.51
|
||||
- Rework manual sync
|
||||
- Review OS
|
||||
- Review view removal
|
||||
|
||||
version 2.2.50
|
||||
- Add Kodi version to logging
|
||||
|
||||
version 2.2.49
|
||||
- Add OS, Resolution and Lang to logging
|
||||
|
||||
version 2.2.47
|
||||
- Small fix for logging
|
||||
|
||||
version 2.2.46
|
||||
- Error logging improvments
|
||||
|
||||
version 2.2.43
|
||||
- Review music
|
||||
- Clean up syncing code
|
||||
|
||||
version 2.2.41
|
||||
- Emergency update
|
||||
|
||||
version 2.2.40
|
||||
- Review throttle
|
||||
- Fix user migration for the new login method added after 2.2.19 (stable)
|
||||
- Clean up code
|
||||
|
||||
version 2.2.39
|
||||
- Update German translation
|
||||
- Fix issue with throttle
|
||||
- Fix server detection
|
||||
|
||||
version 2.2.38
|
||||
- Fix series pooling
|
||||
|
||||
version 2.2.37
|
||||
- Support favorite episodes
|
||||
- Update Dutch translation
|
||||
- Fix specials -1 bug
|
||||
- minor fixes
|
||||
|
||||
version 2.2.34
|
||||
- Repair sync can now be filtered by content type
|
||||
- Automatically download external subs with language tag
|
||||
- Fix broken music artwork
|
||||
- Fix to music direct stream
|
||||
|
||||
version 2.2.33
|
||||
- Fix manual sync crashing
|
||||
- Update Portuguese translation
|
||||
- Add support for German MPAA rating. You will need to reset your local database to apply the change.
|
||||
- Add a backup option. Find out more: https://github.com/MediaBrowser/plugin.video.emby/wiki/Create-and-restore-from-backup
|
||||
|
||||
version 2.2.32
|
||||
- Update the emby context menu
|
||||
- Add option to disable the context menu in the add-on settings > extras tab
|
||||
|
||||
version 2.2.31
|
||||
- Support series pooling. Will require to reset local database. Once content is resynced, proceed with a manual sync to apply the series pooling.
|
||||
- Fix emby connect websocket issue, will also require updating server to beta 3.1.150 or higher
|
||||
- Fix initial sync artwork dialog for Isengard
|
||||
|
||||
version 2.2.30
|
||||
- Update German translation
|
||||
- minor fixes
|
||||
|
||||
version 2.2.28
|
||||
- Fix user selection when all users are hidden
|
||||
|
||||
version 2.2.24
|
||||
- Filter music from fast sync response if music is disabled in the Kodi profile
|
||||
- Fix restart server behavior in the add-on to fix post capabilities
|
||||
- Fix ubuntu importerror crash
|
||||
- Update Russian translation
|
||||
|
||||
version 2.2.23
|
||||
- NEW! Emby connect integration. Find out more on the emby.media forums
|
||||
- Sync season name for Jarvis and higher
|
||||
- Expand video quality selection (25/30/35 Mpbs)
|
||||
- Move deviceId to a permanent location to outlive reinstalls of the add-on
|
||||
- Fix virtual episodes crashing sync
|
||||
- Fix plugin listing such as home videos not loading
|
||||
- Fix platform detection
|
||||
|
||||
version 2.2.21
|
||||
- Fix new external subtitles from preventing playback in the event the subtitles had no language tag
|
||||
|
||||
version 2.2.20
|
||||
- NEW: Default to HTTP playback when using add-on playback mode out of the box.
|
||||
- Add string translation (German, French and Portuguese)
|
||||
- Add option to download external subtitles when playing from HTTP (add-on settings > playback)
|
||||
- Fix navigation not waking up display
|
||||
- Fix fast sync being used to save update times when plugin is not installed
|
||||
- Fix tv show detection when verifying if file exists.
|
||||
|
||||
version 2.2.19
|
||||
- Fix transcode (logging error)
|
||||
|
||||
version 2.2.18
|
||||
- Fix logging
|
||||
|
||||
version 2.2.17
|
||||
- Fix crash when device wakes up
|
||||
- Add option to disable external subs for direct stream - under add-on settings > playback
|
||||
|
||||
version 2.2.16
|
||||
- Fix strptime error
|
||||
- Temporary fix for database being locked
|
||||
- Fix watched status failing to update if offer delete after playing is enabled but skipped
|
||||
|
||||
version 2.2.14
|
||||
- Progress dialog always shows for full sync
|
||||
- Add (if item count greater than) to options for inc sync progress dialog display
|
||||
- Limit artwork loading to 25 threads by default
|
||||
- Fix delete option
|
||||
- Fix music log error
|
||||
- Add string translation (Spanish)
|
||||
|
||||
version 2.2.12
|
||||
- Preparation for Emby connect
|
||||
- Add string translation (Dutch, Russian and Swedish)
|
||||
- Various bug fixes
|
||||
|
||||
version 2.2.11
|
||||
- Preparation for feature requests
|
||||
- Add option to refresh Emby items via context menu
|
||||
- Minor fixes
|
||||
|
||||
version 2.2.10
|
||||
- Add keymap action for delete content: RunPlugin(plugin://plugin.video.emby?mode=delete)
|
||||
- Fix various bugs
|
||||
|
||||
version 2.2.9
|
||||
- Fix extrafanart
|
||||
|
||||
version 2.2.8
|
||||
- Fix to photos not displaying directories without picutres.
|
||||
- Fix to grouped views causing crash
|
||||
|
||||
version 2.2.7
|
||||
- Prevent Kodi screensaver during the initial sync
|
||||
|
||||
version 2.2.6
|
||||
- Fix unicode error
|
||||
- Fix grouped folders error
|
||||
|
||||
version 2.2.5
|
||||
- Add generate a new device Id option, found in the add-on settings > advanced.
|
||||
- Offer to delete cached thumbnails upon database reset.
|
||||
- Breaking fix for views. You will notice duplicates in your video nodes. When you have a moment to spare, run the refresh playlists/nodes action found by launching the emby add-on (this is not reversible). Your homescreen shortcuts actions will need to be redirected to the new playlists/nodes.
|
||||
- Fix pictures, the shortcut should now appear under photo add-ons > emby.
|
||||
- Fix view shortcuts to follow emby ordering. This changes the Emby.nodes.X ordering (automatically created shortcuts and via launching the emby add-on). This does not change the video nodes ordering.
|
||||
- Fix ssl client certificate verification
|
||||
- Fix resume
|
||||
- Prevent artwork deletion from crashing the add-on
|
||||
- Fix to import virtual season artwork
|
||||
|
||||
version 2.2.4
|
||||
- Fix external subs being appended to direct play (via add-on playback)
|
||||
- First attempt at keeping Kodi awake during the initial sync
|
||||
|
||||
version 2.2.3
|
||||
- Fix resume
|
||||
|
||||
version 2.2.2
|
||||
- Fix dialog crash in the manual sync
|
||||
- Fix view duplicate views appearing via launching the emby add-on, when grouping views in emby
|
||||
|
||||
version 2.2.1
|
||||
- Fix artist/album link for music videos
|
||||
- Fix progress dialog when the manual sync runs at start up
|
||||
- Fix encoding error for special characters in emby username
|
||||
- Offer delete dialog after playback now times out after 2 mins
|
||||
|
||||
version 2.1.4
|
||||
- Removed Emby delete via the Kodi context menu. It is exclusively offered via the extended emby context menu which is available for Isengard or higher. This change was necessary, because there was a risk of wiping the entire library if Kodi decides to run a clean database task and paths were set as plugin paths.
|
||||
|
||||
version 2.1.3
|
||||
- Fix Live TV to terminate ffmpeg processes.
|
||||
|
||||
version 2.1.2
|
||||
- Fix to repair entries if they are deleted by Kodi, but still exists in the Emby database.
|
||||
|
||||
version 2.1.1
|
||||
- Update setting - skip emby delete confirmation, it is now under the extras tab.
|
||||
- Update setting - new content notification, it's now disables the notification if the time is set to 0.
|
||||
- Prevent manual sync from running if the add-on is not yet connected to the emby server.
|
||||
|
||||
version 2.1.0
|
||||
- Add a throttle (automatically adjust the number of items requested at once) to prevent crashing during the initial sync
|
||||
- Do not update the video library when there's a music-only update
|
||||
|
||||
version 2.0.3
|
||||
- Add new retention time option that the latest server Sync plugin uses to help determine if full sync or inc sync should be used.
|
||||
- Add control over new content pop up display time. You will find the settings under Extras > Enable new content notification
|
||||
- Change to the transcode H265 setting. You will need to re-select the proper resolution, if you had the setting enabled.
|
||||
- Change to the paths added to sources.xml
|
||||
- Fix to the manual sync for the music library
|
||||
- Fix resume when launching playback via the web client
|
||||
|
||||
version 1.1.81
|
||||
- Fix missing deviceId
|
||||
- Fix to newly added album/songs (if you experienced the bug, you will need to reset to fix it. Know that moving forward, it is corrected.)
|
||||
|
||||
version 1.1.80
|
||||
- Add refresh for video nodes
|
||||
- Fix for home videos (being unable to back out of the menu). Running refresh playlists/nodes will fix this.
|
||||
- Fix to music, causing sync to crash
|
||||
|
||||
version 1.1.76
|
||||
- Add music rating system
|
||||
- Add home videos as a dynamic plugin entry (requires a reset)
|
||||
- Add photo library
|
||||
- Add/Fix force transcode setting for 720p-1080p/HEVC-H265 formats
|
||||
- Fix to incremental sync, caused by the server restarting
|
||||
- Fix for image caching during the initial sync on rpi devices
|
||||
- Fix to audio/subtitles tracks (requires a repair, or reset)
|
||||
|
||||
version 1.1.72
|
||||
- Fix to extrafanart
|
||||
- Fix for artists deletion
|
||||
- Fix for views
|
||||
|
||||
version 1.1.70
|
||||
- Include AirsAfterSeason for special episodes ordering
|
||||
- Cover art settings - label adjusted. A reset or repair will be required if you change the settings value.
|
||||
- Fix duplicate views being created (reset will be required)
|
||||
- Fix albums merge when they had the same name (reset will be required)
|
||||
- Minor fix to songs
|
||||
|
||||
version 1.1.69
|
||||
- Fix unicode error for video nodes
|
||||
- Fix special episode ordering (repair sync can be run)
|
||||
- Fix deletion via context menu
|
||||
- Fix music add/update breaking incremental sync
|
||||
|
||||
version 1.1.68
|
||||
- Minor fixes
|
||||
|
||||
version 1.1.67
|
||||
- Add option to limit items requested at once from server
|
||||
- Fix artwork cache
|
||||
- Fix dialog crash
|
||||
|
||||
version 1.1.66
|
||||
- Add manual refresh for playlists
|
||||
- Fix fanart
|
||||
- Fix H265 transcode
|
||||
- Fix boxsets
|
||||
- Fix people
|
||||
- First attempt to fix next episode
|
||||
|
||||
version 1.1.65
|
||||
- Fix aspect ratio error
|
||||
|
||||
version 1.1.64
|
||||
- Fix trailer causing initial sync to crash
|
||||
|
||||
version 1.1.63
|
||||
- Code refactoring of the add-on
|
||||
|
||||
version 1.1.62
|
||||
- Fix connection to database staying open
|
||||
- Fix artwork cache delete
|
||||
- Add option to force transcode 1080P/H265
|
||||
|
||||
version 1.1.57
|
||||
- Fix for music videos directors
|
||||
|
||||
version 1.1.55
|
||||
- Fix to incremental sync - database locked error
|
||||
- Fix to music multi disc tracks ordering
|
||||
- Fix to prioritize album artists and fall back to song artists if missing.
|
||||
|
||||
version 1.1.53
|
||||
- Add visual warning when kodi version is incompatible
|
||||
- Add ask to play trailers option
|
||||
- Fix music singles
|
||||
- Fix direct path not working during the initial setup
|
||||
- Fix music videos missing artist link
|
||||
|
||||
version 1.1.52
|
||||
- Report playback for music
|
||||
- Support Emby tags for music videos
|
||||
- Fix studio icon for movies
|
||||
- FORCE RESET LOCAL DATABASE IN PLACE
|
||||
|
||||
version 1.1.50
|
||||
- Ignore channels from syncing process
|
||||
- Date added can now be updated
|
||||
- Disable ssl warning
|
||||
- Fix playlist when play command is issued outside of Kodi.
|
||||
|
||||
version 1.1.48
|
||||
- Support Emby tags
|
||||
- Respect emby "My views" settings
|
||||
- Rework artwork api
|
||||
- Rework playback (trailers, dvds)
|
||||
- Fix mark as watched being reported twice (affected Trakt)
|
||||
- Fix offer deletion
|
||||
- Add direct path option to install wizard
|
||||
|
||||
version 1.1.44
|
||||
- Play strm files regardless of playback method.
|
||||
- Stack method for multi part, including trailers.
|
||||
- Revise transcoding properties
|
||||
- Fix channels name to display properly in Kodi.
|
||||
- Fix DTS-HD MA display
|
||||
- Fix profiles that were leaving threads running after loading a new profile in Kodi.
|
||||
|
||||
version 1.1.43
|
||||
- Fix loop that was happening if you had intros and play next automatically enabled.
|
||||
|
||||
version 1.1.42
|
||||
- Fix for cinema mode playback
|
||||
- New skinhelper properties
|
||||
|
||||
version 1.1.35
|
||||
- Added option to direct stream music library - useful for out of network playback.
|
||||
- Fix error in reporting to the server, when playing music.
|
||||
- Added external subtitles as selectable tracks for direct play and direct stream.
|
||||
- Added extra setup dialog for the new music option.
|
||||
|
||||
version 1.1.34
|
||||
- Fix for userdata causing the incremental sync to hang when user doesn't have music enabled.
|
||||
|
||||
version 1.1.33
|
||||
- Implemented userdata update only
|
||||
- Added progress dialog for incremental sync.
|
||||
- Added the option to start Kodi session with permanent additional users.
|
||||
|
||||
version 1.1.31
|
||||
- Added user image home property.
|
||||
|
||||
version 1.1.30
|
||||
- Fix aspect ratio. Take into account metadata aspect ratio.
|
||||
- Fix flag for NR
|
||||
- Improve logging for transcoding playback
|
||||
|
||||
version 1.1.29
|
||||
- Fix playback error
|
||||
- added full changelog
|
||||
- added description to the addon
|
||||
|
||||
version 1.1.28
|
||||
- Fix playback for widgets
|
||||
|
||||
version 1.1.27
|
||||
- Fix for nextup episodes
|
||||
- Fix for transcoding not properly ending the ffmpeg process
|
||||
- Added webclient remote control command to select the audio stream and subtitles
|
||||
- You can now pre-select the audio and subtitles track when transcoding
|
||||
|
||||
version 1.1.26
|
||||
- Moved the Date string from the path to a param for the Get Change list API endpoint.
|
||||
- Season fanart is added
|
||||
- Last date added is fixed for albums (will require a resync to correct your current listing)
|
||||
- Server restarting message has been added. Enable it under the advanced tab of the add-on settings.
|
||||
|
||||
version 1.1.25
|
||||
This contains a fix for music.
|
||||
More info:
|
||||
- We are now processing your music in batch of 200 items. You might see the scan get stuck at one point, it's very normal since the add-on is pulling all the data from your server for the next section to process. For music, we process the sections in the following order after boxsets: Artists, Albums, Songs.
|
||||
For example, the scan gets stuck at 98% for Albums, it is currently pulling all your songs from your server. If you have a large amount of items for the songs section, it will take longer and might give the impression the scan is stuck, when it's not. :) Hopefully we will be able to improve the visual logging the reflect this in the future.
|
||||
Please, let us know if you still see mentions of read timeout in your logs when scanning your music library in or if the scan still doesn't complete
|
||||
|
||||
version 1.1.24
|
||||
- Sorry for the many updates in a row! Fix for video nodes not showing up.
|
||||
|
||||
version 1.1.23
|
||||
- Fix a url encoding issue with time stamps of the new changes endpoint.
|
||||
|
||||
version 1.1.22
|
||||
- Fixed a bug that was introduced in the last build.
|
||||
|
||||
version 1.1.21
|
||||
- Fixed video node and source creation when using the new fast startup sync
|
||||
|
||||
version 1.1.20
|
||||
- Added new fast startup sync feature. check out http://emby.media/community/index.php?/topic/23971-fast-startup-sync-server-plugin/
|
||||
|
||||
version 1.1.19
|
||||
- This version fixes the missing duration from home widgets
|
||||
|
||||
version 1.1.18
|
||||
- We should be back on track with this build. The initial sync should complete once again. To make sure everything goes smoothly, you will need to reset and resync your library after updating to 1.1.18. Music also received a much needed update, thank you @marcelveldt.
|
||||
|
||||
version 1.1.17
|
||||
- This version has support for Kodi 16 (aka Jarvis) - full rebuild needed. Allows video themes to be excluded when syncing theme media, contains a fix for non persistent settings and for local media flags
|
||||
|
||||
version 1.1.16
|
||||
- Fix for the issue causing the initial sync to fail with 1.1.15.
|
||||
|
||||
version 1.1.15
|
||||
Features:
|
||||
- Added the option to delete movies after playback
|
||||
- Resume jumpback (in seconds)
|
||||
Fixes:
|
||||
- Precise resume points
|
||||
- Theme media - direct stream syncing
|
||||
- Cast order should be the same as Emby's for Kodi Helix and Isengard
|
||||
- Genres - Clean up genres if modified, as well as correctly display Genres for TV shows.
|
||||
- Masterlock - We now create sources during the first initial sync. This means your library should now display when using Masterlock.
|
||||
- Error during login - due to Emby "disable access user preferences" setting.
|
||||
- Plugin paths now support mediaflags (bluray, 3D, etc) and should properly reflect this when navigating your Kodi library (MQ cases, etc.).
|
||||
- Kodi audio and subtitles track should now be remembered after being changed.
|
||||
- Make report progress to Emby more accurate
|
||||
- Remote command should now be accepted during the first minute of playback.
|
||||
Changes:
|
||||
- The library syncing process was moved to it's on thread. In general, the add-on should perform faster and be more responsive. Especially at startup.
|
||||
- Improved information logging (1) so you are able to see the exact content being processed.
|
||||
|
||||
version 1.1.14
|
||||
- This version contains a fix for the cast order presented on the video info screens. It is restricted to Kodi 15 and onwards.
|
||||
- A complete resync of the database will be needed to pick up the changes
|
||||
|
||||
version 1.1.13
|
||||
Fix:
|
||||
- If you were unable to launch scripts from the Emby add-on launch menu, this is now resolved.
|
||||
Features:
|
||||
- Cover art - Fix for cut off cover art
|
||||
- Local/remote access from same Kodi profile ** This is not Emby connect **
|
||||
Cover art:
|
||||
- Add-on settings > Extras > Force CoverArt ratio
|
||||
If your poster CoverArt is cut off, you can enable this option to force the artwork to fit the standard Kodi image aspect ratio (image will be slightly distorted). Since images are cached in Kodi, you will need to reset/resync your library to see your artwork change. ** You should still request to fix the aspect ratio issue by posting in the appropriate thread to contact the skin creator. Using the Confluence skin, for example, displays Cover art correctly, without distorting the image. **
|
||||
Local/remote access:
|
||||
- Add-on settings > Emby > Use alternate address / Secondary Server Address
|
||||
This feature is useful in the event you are on the move. You simply enable the option and enter your external server address, restart Kodi and it should now load your profile using your external address instead. This way you can enable Play from HTTP and stream/transcode while away from home! To recap, the secondary server address is only to reach the same server as the primary server address
|
||||
|
||||
|
||||
|
||||
version 1.1.0
|
||||
- stable release
|
||||
- Note that the secondary IP address support in this release is still a BETA feature.
|
||||
- Note that the beta is likely to go more unstable for a bit - so if you are using Beta - you might disable auto update, or switch to stable.
|
||||
|
||||
|
||||
version 1.0.15
|
||||
- If having the auto caching images setting enabled was causing an issue while syncing, this should now be resolved. Other improvements have been made regarding widgets refresh rate for new content, theme media and direct paths.
|
||||
|
||||
version 1.0.14
|
||||
- The last version assured a show/movie would have either a theme video or theme music as this was what the nfo format supported (which tvtunes reads and we create). However this was restrictive so a change has been made to include all theme media and with the help of the upcoming tvtunes version (5.0.2 onwards) it has options to prefer theme videos etc.
|
||||
|
||||
version 1.0.13
|
||||
- The only difference to the previous version is a possible fix for theme music import with strange characters in the filename
|
||||
|
||||
version 1.0.12
|
||||
- This version adds theme videos to the theme media sync, for people using theme videos you will need to run the option to "sync emby theme media to kodi" again
|
||||
|
||||
version 1.0.10
|
||||
Important:
|
||||
- We reverted the database detection method from previous version (1.0.09) back to a static method. This means we currently support Helix 14.2 (MyVideos90.db) and Isengard Beta 2 (MyVideos93.db).
|
||||
Fix:
|
||||
- Illegal characters in file name for Theme music (should now be finally fixed!)
|
||||
Optimization:
|
||||
- Season posters should now reflect instantly when changed in Emby
|
||||
- Fanart backdrops should now reflect correctly when changed in Emby - give several seconds to see the new backdrop appear.
|
||||
- Added Series poster as All Season poster. - you will need to reset - resync library for them to show for already established Series.
|
||||
- Watched status should now be instant. Please test and report any issues.
|
||||
|
||||
version 1.0.09
|
||||
- Important database detection change: We are trying something new. The famous error "can't find table id Path" or similar, when starting the sync happens in the event the add-on is unable to locate your Kodi database file. We are trying a more dynamic way of getting this information in order to eradicate this error. So keep your eyes peeled in the event the database is not found and report ASAP with logs as we are unsure of this change. It is really appreciated!
|
||||
TV Tunes, Theme music:
|
||||
- Fix for invalid characters in filename **Still needs work**
|
||||
- Fix for special characters.
|
||||
- Automatically set the custom path in your TV Tunes settings, so you don't have to (this allows TV Tunes to find your Emby themes). This means your themes will start working instantly. Make sure TV Tunes is enabled for the skin you are using!
|
||||
- The feature should now be compatible with OpenElec.
|
||||
- Video backdrops are coming soon!
|
||||
Youtube trailers:
|
||||
- Youtube Trailers should now work and be launched using the youtube add-on. However, it will require a reset - resync of your database.
|
||||
|
||||
version 1.0.08
|
||||
- Attempt at supporting Isengard Beta 2
|
||||
- Caused error with special chars
|
||||
- Disable audio-subs pref
|
||||
- increase logging verbosity for WebSocket message errors
|
||||
- with direct paths make sure a path was returned
|
||||
|
||||
version 1.0.07
|
||||
- added stream language and subtitle language to stream details
|
||||
- prevent errors on empty results
|
||||
- Re-add connection message
|
||||
- Support multiple theme songs
|
||||
|
||||
version 1.0.06
|
||||
- bug fix
|
||||
|
||||
version 1.0.05
|
||||
Fix:
|
||||
- Error that was preventing the initial sync from running the first time around on fresh installs.
|
||||
Highlight:
|
||||
- As you know, using plugin paths, the Kodi's custom video settings were not sticking (audio and subtitles). We've implement an internal logic that will pick the correct setting automatically according to your Emby user preferences. It works with every type of playback: Direct Play, Direct Stream, Transcoding and Direct Paths. You will also find an additional option under the Playback tab in settings to "Always enable subtitles". With this change, there's no more need for Kodi's custom video settings
|
||||
|
||||
version 1.0.04
|
||||
- Texture Cache now included in the addon. You can set an option to scan the images to the texture cache on setup or when new data is added. The Cinema Mode and User preferences mentioned in 1.0.02 are back.
|
||||
- Please note that Cinema mode is not currently compatible with Kodi's option: Play next video automatically.
|
||||
|
||||
version 1.0.02
|
||||
- This version now supports Cinema Mode/Intros and has the start of support for some user preferences. Currently the only setting is cinema mode, but we will extend this to support the audio language and maybe other settings in the future.
|
||||
|
||||
version 1.0.1
|
||||
- In this version the netflix style next up functionality has been removed from the addon and placed into a separate addon. If you would still like to use this functionality install the nextup service from the beta repo
|
||||
- also stable release
|
||||
|
||||
version 1.0.0
|
||||
- Stable release
|
||||
|
||||
version 0.1.94
|
||||
- Fix for TV episode info not showing when using direct paths on a password protected network
|
||||
|
||||
|
||||
version 0.1.93
|
||||
- Bug fix for NON-direct path mode. Sorry - made a copy/paste error :( This will have caused missing music videos/TV shows, and bad syncing of states for music videos/TV Shows
|
||||
|
||||
version 0.1.92
|
||||
- New option to point directly to files instead of going through the addon for playback. This will speed up playback on low end devices, and allow addons like TV Tunes to work - but at the cost of losing remote playback, transcoding support and parental control. Once turned on, you must reset your DB to use
|
||||
- Fix for slow syncing after wakeup. However if using OpenElec I suggest a restart on wake as described here: http://openelec.tv/f...start=15#101953 (using kodi instead of xbmc though)
|
||||
- Option to ignore specials in NextUp
|
||||
- Added votes and taglines for movies
|
||||
- Fix for 'Start from beginning'
|
||||
- Getting REALLY close to our 1.0 releas
|
||||
|
||||
version 0.1.9/91
|
||||
- Temporary removal of the service monitor, until it can be implemented without interfering with other functions. This means if you had trouble playing content because of it, it should be working again.
|
||||
- Fix the delay in marking watched after content has just been watched in Kodi. This should now be reflected instantly.
|
||||
|
||||
version 0.1.89
|
||||
- Alright guys, we are nearing a stable version. It is important you let us know if something is not working correctly for you! The best thing you can do to help us is to start from scratch and let us know if you experience any issues during the process, from start to finish! If everything goes well for everyone, we will release our first Stable version!
|
||||
- If you were unable to get Direct playback when content had special character in the name, this should now be fixed (for real this time).
|
||||
- We have been reviewing the playcount/watch status situation and tweak certain Kodi behaviors to allow for a perfect sync of your playstates between Emby and Kodi. This is a follow up to the previous update. The correct Emby playcount should display now.
|
||||
- As usual, if something doesn't work as intended, please start a new thread and provide a log. Hopefully, you will not. *fingers crossed!*
|
||||
|
||||
version 0.1.86
|
||||
- Clean up empty TV Shows when last episode deleted by web socket
|
||||
- Add option to suppress successful connection message
|
||||
- Fix 'offer delete' bug accidental introduced in previous release
|
||||
|
||||
version 0.1.83/85
|
||||
- The playcount situation should be resolved. If you saw an item be marked as watched before the 90% this should be fixed. As well as rewatching an item, it should now stop marking it as unwatched.
|
||||
- We now support Webclient remote control! It's so much fun
|
||||
|
||||
version 0.1.82
|
||||
- The addon now respects Parental control for access schedules
|
||||
- Adding a new series (that was never imported to Kodi during initial sync) and changing boxsets should be picked up instantly on event
|
||||
|
||||
version 0.1.81
|
||||
- Officially fixes playback for files containing special characters.
|
||||
|
||||
version 0.1.8
|
||||
We now support:
|
||||
- split videos - if you do have them, please let us know if it works correctly.
|
||||
- You can now send messages from the web client to Kodi
|
||||
- Final touches for music support
|
||||
- Added Genres and sets to video nodes and sublevels
|
||||
Fixes:
|
||||
- TV Shows: Recently added, in progress nodes are now filtered by the parent folder to show the appropriate content
|
||||
- Fix for path containing special characters failing to playback
|
||||
- Speed improvement when using Kodi Isengard
|
||||
- EDIT: Emby for Kodi should behave if you also have tvtunes and videoextras addon enabled.
|
||||
|
||||
version 0.1.6
|
||||
- fixes an error with playback
|
||||
|
||||
version 0.1.5
|
||||
- Adds dialog to delete episodes for realz when hitting the delete key
|
||||
- Adds option to offer delete when playback is >80%
|
||||
- Fixes widget playback
|
||||
|
||||
version 0.1.4
|
||||
New feature:
|
||||
- Thanks to @marcelveldt we are now able to support your Emby music library. It is an optional feature. Please try it out and report back as it is experimental at this stage. You can find the option in your addon settings under Sync Options. After you have enabled the option, you will need to restart Kodi.
|
||||
Noteworthy:
|
||||
- New content is now added during playback instead of at the end of it. We thought "almost instant" was not good enough, we opted for instant instead! :)
|
||||
- The playback went through a major rework. Local paths are now supported (this means you are no longer forced to use UNC path to view content available on the same device). We made the playback smart. Now, instead of failing on one method (let's say Direct play), it will try to play via Direct Stream and then Transcoding before giving you an error. It will still let you know if it failed to launch via direct play, so you are not in the dark.
|
||||
Fix:
|
||||
- video nodes not being created when you were switching Kodi profiles
|
||||
- "Year" format for seasons are now supported
|
||||
- Missing seasons (hopefully?...let us know!)
|
||||
- Online server check offline even if server was online
|
||||
- We forgot to mention that boxsets should be fixed, since the previous version. This should cover add/remove content from boxsets and displaying the correct boxset cover.
|
||||
- Other minor fixes....
|
||||
|
||||
version 0.1.2/3
|
||||
- Playcount fix for unwatched count
|
||||
- Video Nodes now working for multi-profiles
|
||||
- Convenient listing for everything Emby when you launch the Emby for Kodi add-on (like it is with the Mediabrowser add-on).
|
||||
- Add and Remove users from the viewing session (read below for everything you know about this feature!)
|
||||
|
||||
version 0.1.0
|
||||
- Uses a new approach to interact with Kodi DB (Direct Access) You will need to do a Kodi DB reset for this new update
|
||||
- In the Emby Addon settings under Advanced select "Reset Local Kodi DB"
|
||||
- 10x+ speed improvement
|
||||
- Sync reliability improvements
|
||||
- Works fine on RaspPi 1 now
|
||||
- Seamless switching from SMB to HTTP
|
||||
- Box set art fixed
|
||||
- Sync after resume fixed
|
||||
- Disable coverart option added
|
||||
- Transcoding options added
|
||||
- Video nodes to mimic Emby nodes added
|
||||
- Date created fix
|
||||
- Native support for 'extra fanart'
|
||||
- Dashboard viewing bug fixes
|
||||
- 3D stream support
|
||||
- New eTag server feature for stale data implemented
|
||||
- 'Watched' fixes
|
||||
|
||||
In short - if you tried this addon and thought it was slow/inaccurate, please give it another go.
|
||||
|
||||
Reminder: You need to reset your DB for this release - but it is MUCH faster on initial sync, and follow up syncs are almost instant
|
||||
|
||||
version 0.0.33
|
||||
- Playcount fix
|
||||
- Playback report/resume fix.
|
||||
|
||||
|
||||
version 0.0.31/32
|
||||
- Emby for Kodi can now support HTTPS fully. This works the same as it would in a browser. You can enable/disable Host certificate verification and if you use a custom ssl certificate for your Emby server, you also have the option to add a client-side ssl certificate(.pem). By default, only enabling the HTTPS option should work for most HTTPS connection (self-signed certificates).
|
||||
- Minor fixes that affects the initial sync and sending a remote stream to Kodi.
|
||||
|
||||
|
||||
version 0.0.30
|
||||
- New download system implemented - hopefully this will make the syncing process less lengthy.
|
||||
- Special character fix for Emby username.
|
||||
|
||||
|
||||
version 0.0.29
|
||||
- Fixed a lockup issue with sync when syncing episodes with no season
|
||||
|
||||
version 0.0.28
|
||||
- Fix updates during playback
|
||||
- Fix issues with deletes
|
||||
- Images fixes
|
||||
|
||||
version 0.0.27
|
||||
- Fix for images not showing up
|
||||
- Fix for "NEW" Tv Shows being added with event driven triggers fixed
|
||||
- Fix for episodes that have their season or episode index number change not being updated
|
||||
- Force / in paths to fix a local path comparison issue
|
||||
- Fix episode specials showing up in all seasons
|
||||
|
||||
version 0.0.25
|
||||
- Fixed the option to reset your database, it should now work on every platform. You will be offered with the option to delete your database, followed by the option to erase your saved user information. Yay!
|
||||
- HTTPS is now fully implemented. (custom certificate not yet accepted - server self signed should work)
|
||||
- Custom settings for transcoding are now added in the add-on settings.
|
||||
- Fixed Kodi "hanging" when shutting down.
|
||||
|
||||
|
||||
version 0.0.24
|
||||
- This version has a major change: at startup, a full sync is performed, however after that ALL syncing is done using websocket messages from the server. This results in much faster updating, and way less CPU use
|
||||
- ALSO - there is a big change to the "plot" support - so the first time you run it is going to take a while to get the plots all fixed up.
|
||||
|
||||
version 0.0.23
|
||||
- changed the AutoPlay function a little bit. What it now does is popup in the last 20 seconds of play and gives the option to cancel viewing the next episode. This repeats at the end of each episode rather than how it was before where it added the full list of remaining episodes to play
|
||||
- This version also adds back the 'play from HTTP' option. In a clean build it will ask you if you want to play from HTTP. Otherwise change it in settings and your database will slowly change over to point to the HTTP path
|
||||
|
||||
version 0.0.22
|
||||
- added support for Kodi Isengard
|
||||
- fixed ratings for all media types
|
||||
- fixed episode thumbnails
|
||||
- some code cleanup and small typos fixed
|
||||
- Multiple profiles/users now working. You can setup each Kodi profile with a different Emby user.
|
||||
|
||||
version 0.0.21
|
||||
- Now can use the "Easy Pin" option on local networks for signing in thanks to @Angelblue05
|
||||
- For those who like to binge watch series I added an option to "AutoPlay" the remaining episodes in a Season. This works with the "Ongoing Episodes/Next UP" widgets found on many home screens and attempts to sort of emulate the way it is done with Netflix. If you have enabled the option in the settings after playback has ended a dialog will popup asking if you want to carry on watching the remaining episodes...this dialog will auto time out after 10 seconds and if nothing is done proceeds to add the remaining episodes to a playlist which is then played
|
||||
|
||||
version 0.0.16
|
||||
- More speedups!
|
||||
- Fixed TV tags
|
||||
- If you don't specify the type of a collection, we now assume it is movies (but you should specify..)
|
||||
|
||||
version 0.0.15
|
||||
- New version has much, much, much faster initial import - plus support for TV collections
|
||||
|
||||
version 0.0.14
|
||||
- some HUGE speed improvements with the initial sync time
|
||||
|
||||
version 0.0.13
|
||||
- reduces the initial sync time for new installs but provides no additional changes for current users
|
||||
|
||||
version 0.0.12
|
||||
- alter reset so that addon data dir is always removed when video db
|
||||
- box set sync no longer an option
|
||||
- solve encoding issue with playurl
|
||||
|
||||
version 0.0.10
|
||||
- For those where the reset fails you now only need to delete the video database manually ""userdata/Database/MyVideo90.db"" (note version may differ if not running a Helix version of Kodi)
|
||||
|
||||
version 0.0.9
|
||||
- This version changes a lot under the hood and needs a clean start to proceed. We have provided a reset option in the addon under advanced settings for this
|
||||
|
||||
version 0.0.1
|
||||
- initital alpha version
|
|
@ -13,11 +13,13 @@ import xbmcaddon
|
|||
|
||||
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
|
||||
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
|
||||
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
|
||||
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
|
||||
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
|
||||
|
||||
sys.path.insert(0, __cache__)
|
||||
sys.path.insert(0, __pcache__)
|
||||
sys.path.insert(0, __libraries__)
|
||||
sys.path.append(__base__)
|
||||
|
||||
#################################################################################################
|
||||
|
|
|
@ -13,11 +13,13 @@ import xbmcaddon
|
|||
|
||||
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
|
||||
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
|
||||
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
|
||||
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
|
||||
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
|
||||
|
||||
sys.path.insert(0, __cache__)
|
||||
sys.path.insert(0, __pcache__)
|
||||
sys.path.insert(0, __libraries__)
|
||||
sys.path.append(__base__)
|
||||
|
||||
#################################################################################################
|
||||
|
|
|
@ -13,11 +13,13 @@ import xbmcaddon
|
|||
|
||||
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
|
||||
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
|
||||
__libraries__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'libraries')).decode('utf-8')
|
||||
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
|
||||
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
|
||||
|
||||
sys.path.insert(0, __cache__)
|
||||
sys.path.insert(0, __pcache__)
|
||||
sys.path.insert(0, __libraries__)
|
||||
sys.path.append(__base__)
|
||||
|
||||
#################################################################################################
|
||||
|
|
54
libraries/dateutil/LICENSE
Normal file
54
libraries/dateutil/LICENSE
Normal file
|
@ -0,0 +1,54 @@
|
|||
Copyright 2017- Paul Ganssle <paul@ganssle.io>
|
||||
Copyright 2017- dateutil contributors (see AUTHORS file)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
The above license applies to all contributions after 2017-12-01, as well as
|
||||
all contributions that have been re-licensed (see AUTHORS file for the list of
|
||||
contributors who have re-licensed their code).
|
||||
--------------------------------------------------------------------------------
|
||||
dateutil - Extensions to the standard Python datetime module.
|
||||
|
||||
Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
|
||||
Copyright (c) 2012-2014 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
|
||||
Copyright (c) 2014-2016 - Yaron de Leeuw <me@jarondl.net>
|
||||
Copyright (c) 2015- - Paul Ganssle <paul@ganssle.io>
|
||||
Copyright (c) 2015- - dateutil contributors (see AUTHORS file)
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The above BSD License Applies to all code, even that also covered by Apache 2.0.
|
701
libraries/dateutil/NEWS
Normal file
701
libraries/dateutil/NEWS
Normal file
|
@ -0,0 +1,701 @@
|
|||
Version 2.7.3 (2018-05-09)
|
||||
==========================
|
||||
|
||||
Data updates
|
||||
------------
|
||||
|
||||
- Update tzdata to 2018e. (gh pr #710)
|
||||
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Fixed an issue where decimal.Decimal would cast `NaN` or infinite value in a
|
||||
parser.parse, which will raise decimal.Decimal-specific errors. Reported and
|
||||
fixed by @amureki (gh issue #662, gh pr #679).
|
||||
- Fixed a ValueError being thrown if tzinfos call explicity returns ``None``.
|
||||
Reported by @pganssle (gh issue #661) Fixed by @parsethis (gh pr #681)
|
||||
- Fixed incorrect parsing of certain dates earlier than 100 AD when repesented
|
||||
in the form "%B.%Y.%d", e.g. "December.0031.30". (gh issue #687, pr #700)
|
||||
- Fixed a bug where automatically generated DTSTART was naive even if a
|
||||
specified UNTIL had a time zone. Automatically generated DTSTART will now
|
||||
take on the timezone of an UNTIL date, if provided. Reported by @href (gh
|
||||
issue #652). Fixed by @absreim (gh pr #693).
|
||||
|
||||
|
||||
Documentation changes
|
||||
---------------------
|
||||
|
||||
- Corrected link syntax and updated URL to https for ISO year week number
|
||||
notation in relativedelta examples. (gh issue #670, pr #711)
|
||||
- Add doctest examples to tzfile documentation. Done by @weatherpattern and
|
||||
@pganssle (gh pr #671)
|
||||
- Updated the documentation for relativedelta. Removed references to tuple
|
||||
arguments for weekday, explained effect of weekday(_, 1) and better explained
|
||||
the order of operations that relativedelta applies. Fixed by @kvn219
|
||||
@huangy22 and @ElliotJH (gh pr #673)
|
||||
- Added changelog to documentation. (gh issue #692, gh pr #707)
|
||||
- Changed order of keywords in rrule docstring. Reported and fixed by
|
||||
@rmahajan14 (gh issue #686, gh pr #695).
|
||||
- Added documentation for ``dateutil.tz.gettz``. Reported by @pganssle (gh
|
||||
issue #647). Fixed by @weatherpattern (gh pr #704)
|
||||
- Cleaned up malformed RST in the ``tz`` documentation. (gh issue #702, gh pr
|
||||
#706)
|
||||
- Changed the default theme to sphinx_rtd_theme, and changed the sphinx
|
||||
configuration to go along with that. (gh pr #707)
|
||||
- Reorganized ``dateutil.tz`` documentation and fixed issue with the
|
||||
``dateutil.tz`` docstring. (gh pr #714)
|
||||
|
||||
|
||||
Misc
|
||||
----
|
||||
|
||||
- GH #674, GH #688, GH #699
|
||||
|
||||
|
||||
Version 2.7.2 (2018-03-26)
|
||||
==========================
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Fixed an issue with the setup script running in non-UTF-8 environment.
|
||||
Reported and fixed by @gergondet (gh pr #651)
|
||||
|
||||
|
||||
Misc
|
||||
----
|
||||
|
||||
- GH #655
|
||||
|
||||
|
||||
Version 2.7.1 (2018-03-24)
|
||||
===========================
|
||||
|
||||
Data updates
|
||||
------------
|
||||
|
||||
- Updated tzdata version to 2018d.
|
||||
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Fixed issue where parser.parse would occasionally raise
|
||||
decimal.Decimal-specific error types rather than ValueError. Reported by
|
||||
@amureki (gh issue #632). Fixed by @pganssle (gh pr #636).
|
||||
- Improve error message when rrule's dtstart and until are not both naive or
|
||||
both aware. Reported and fixed by @ryanpetrello (gh issue #633, gh pr #634)
|
||||
|
||||
|
||||
Misc
|
||||
----
|
||||
|
||||
- GH #644, GH #648
|
||||
|
||||
|
||||
Version 2.7.0
|
||||
=============
|
||||
- Dropped support for Python 2.6 (gh pr #362 by @jdufresne)
|
||||
- Dropped support for Python 3.2 (gh pr #626)
|
||||
- Updated zoneinfo file to 2018c (gh pr #616)
|
||||
- Changed licensing scheme so all new contributions are dual licensed under
|
||||
Apache 2.0 and BSD. (gh pr #542, issue #496)
|
||||
- Added __all__ variable to the root package. Reported by @tebriel
|
||||
(gh issue #406), fixed by @mariocj89 (gh pr #494)
|
||||
- Added python_requires to setup.py so that pip will distribute the right
|
||||
version of dateutil. Fixed by @jakec-github (gh issue #537, pr #552)
|
||||
- Added the utils submodule, for miscellaneous utilities.
|
||||
- Added within_delta function to utils - added by @justanr (gh issue #432,
|
||||
gh pr #437)
|
||||
- Added today function to utils (gh pr #474)
|
||||
- Added default_tzinfo function to utils (gh pr #475), solving an issue
|
||||
reported by @nealmcb (gh issue #94)
|
||||
- Added dedicated ISO 8601 parsing function isoparse (gh issue #424).
|
||||
Initial implementation by @pganssle in gh pr #489 and #622, with a
|
||||
pre-release fix by @kirit93 (gh issue #546, gh pr #573).
|
||||
- Moved parser module into parser/_parser.py and officially deprecated the use
|
||||
of several private functions and classes from that module. (gh pr #501, #515)
|
||||
- Tweaked parser error message to include rejected string format, added by
|
||||
@pbiering (gh pr #300)
|
||||
- Add support for parsing bytesarray, reported by @uckelman (gh issue #417) and
|
||||
fixed by @uckelman and @pganssle (gh pr #514)
|
||||
- Started raising a warning when the parser finds a timezone string that it
|
||||
cannot construct a tzinfo instance for (rather than succeeding with no
|
||||
indication of an error). Reported and fixed by @jbrockmendel (gh pr #540)
|
||||
- Dropped the use of assert in the parser. Fixed by @jbrockmendel (gh pr #502)
|
||||
- Fixed to assertion logic in parser to support dates like '2015-15-May',
|
||||
reported and fixed by @jbrockmendel (gh pr #409)
|
||||
- Fixed IndexError in parser on dates with trailing colons, reported and fixed
|
||||
by @jbrockmendel (gh pr #420)
|
||||
- Fixed bug where hours were not validated, leading to improper parse. Reported
|
||||
by @heappro (gh pr #353), fixed by @jbrockmendel (gh pr #482)
|
||||
- Fixed problem parsing strings in %b-%Y-%d format. Reported and fixed by
|
||||
@jbrockmendel (gh pr #481)
|
||||
- Fixed problem parsing strings in the %d%B%y format. Reported by @asishm
|
||||
(gh issue #360), fixed by @jbrockmendel (gh pr #483)
|
||||
- Fixed problem parsing certain unambiguous strings when year <99 (gh pr #510).
|
||||
Reported by @alexwlchan (gh issue #293).
|
||||
- Fixed issue with parsing an unambiguous string representation of an ambiguous
|
||||
datetime such that if possible the correct value for fold is set. Fixes
|
||||
issue reported by @JordonPhillips and @pganssle (gh issue #318, #320,
|
||||
gh pr #517)
|
||||
- Fixed issue with improper rounding of fractional components. Reported by
|
||||
@dddmello (gh issue #427), fixed by @m-dz (gh pr #570)
|
||||
- Performance improvement to parser from removing certain min() calls. Reported
|
||||
and fixed by @jbrockmendel (gh pr #589)
|
||||
- Significantly refactored parser code by @jbrockmendel (gh prs #419, #436,
|
||||
#490, #498, #539) and @pganssle (gh prs #435, #468)
|
||||
- Implementated of __hash__ for relativedelta and weekday, reported and fixed
|
||||
by @mrigor (gh pr #389)
|
||||
- Implemented __abs__ for relativedelta. Reported by @binnisb and @pferreir
|
||||
(gh issue #350, pr #472)
|
||||
- Fixed relativedelta.weeks property getter and setter to work for both
|
||||
negative and positive values. Reported and fixed by @souliane (gh issue #459,
|
||||
pr #460)
|
||||
- Fixed issue where passing whole number floats to the months or years
|
||||
arguments of the relativedelta constructor would lead to errors during
|
||||
addition. Reported by @arouanet (gh pr #411), fixed by @lkollar (gh pr #553)
|
||||
- Added a pre-built tz.UTC object representing UTC (gh pr #497)
|
||||
- Added a cache to tz.gettz so that by default it will return the same object
|
||||
for identical inputs. This will change the semantics of certain operations
|
||||
between datetimes constructed with tzinfo=tz.gettz(...). (gh pr #628)
|
||||
- Changed the behavior of tz.tzutc to return a singleton (gh pr #497, #504)
|
||||
- Changed the behavior of tz.tzoffset to return the same object when passed the
|
||||
same inputs, with a corresponding performance improvement (gh pr #504)
|
||||
- Changed the behavior of tz.tzstr to return the same object when passed the
|
||||
same inputs. (gh pr #628)
|
||||
- Added .instance alternate constructors for tz.tzoffset and tz.tzstr, to
|
||||
allow the construction of a new instance if desired. (gh pr #628)
|
||||
- Added the tz.gettz.nocache function to allow explicit retrieval of a new
|
||||
instance of the relevant tzinfo. (gh pr #628)
|
||||
- Expand definition of tz.tzlocal equality so that the local zone is allow
|
||||
equality with tzoffset and tzutc. (gh pr #598)
|
||||
- Deprecated the idiosyncratic tzstr format mentioned in several examples but
|
||||
evidently designed exclusively for dateutil, and very likely not used by
|
||||
any current users. (gh issue #595, gh pr #606)
|
||||
- Added the tz.resolve_imaginary function, which generates a real date from
|
||||
an imaginary one, if necessary. Implemented by @Cheukting (gh issue #339,
|
||||
gh pr #607)
|
||||
- Fixed issue where the tz.tzstr constructor would erroneously succeed if
|
||||
passed an invalid value for tzstr. Fixed by @pablogsal (gh issue #259,
|
||||
gh pr #581)
|
||||
- Fixed issue with tz.gettz for TZ variables that start with a colon. Reported
|
||||
and fixed by @lapointexavier (gh pr #601)
|
||||
- Added a lock to tz.tzical's cache. Reported and fixed by @Unrud (gh pr #430)
|
||||
- Fixed an issue with fold support on certain Python 3 implementations that
|
||||
used the pre-3.6 pure Python implementation of datetime.replace, most
|
||||
notably pypy3 (gh pr #446).
|
||||
- Added support for VALUE=DATE-TIME for DTSTART in rrulestr. Reported by @potuz
|
||||
(gh issue #401) and fixed by @Unrud (gh pr #429)
|
||||
- Started enforcing that within VTIMEZONE, the VALUE parameter can only be
|
||||
omitted or DATE-TIME, per RFC 5545. Reported by @Unrud (gh pr #439)
|
||||
- Added support for TZID parameter for DTSTART in rrulestr. Reported and
|
||||
fixed by @ryanpetrello (gh issue #614, gh pr #624)
|
||||
- Added 'RRULE:' prefix to rrule strings generated by rrule.__str__, in
|
||||
compliance with the RFC. Reported by @AndrewPashkin (gh issue #86), fixed by
|
||||
@jarondl and @mlorant (gh pr #450)
|
||||
- Switched to setuptools_scm for version management, automatically calculating
|
||||
a version number from the git metadata. Reported by @jreback (gh issue #511),
|
||||
implemented by @Sulley38 (gh pr #564)
|
||||
- Switched setup.py to use find_packages, and started testing against pip
|
||||
installed versions of dateutil in CI. Fixed issue with parser import
|
||||
discovered by @jreback in pandas-dev/pandas#18141. (gh issue #507, pr #509)
|
||||
- Switched test suite to using pytest (gh pr #495)
|
||||
- Switched CI over to use tox. Fixed by @gaborbernat (gh pr #549)
|
||||
- Added a test-only dependency on freezegun. (gh pr #474)
|
||||
- Reduced number of CI builds on Appveyor. Fixed by @kirit93 (gh issue #529,
|
||||
gh pr #579)
|
||||
- Made xfails strict by default, so that an xpass is a failure. (gh pr #567)
|
||||
- Added a documentation generation stage to tox and CI. (gh pr #568)
|
||||
- Added an explicit warning when running python setup.py explaining how to run
|
||||
the test suites with pytest. Fixed by @lkollar. (gh issue #544, gh pr #548)
|
||||
- Added requirements-dev.txt for test dependency management (gh pr #499, #516)
|
||||
- Fixed code coverage metrics to account for Windows builds (gh pr #526)
|
||||
- Fixed code coverage metrics to NOT count xfails. Fixed by @gaborbernat
|
||||
(gh issue #519, gh pr #563)
|
||||
- Style improvement to zoneinfo.tzfile that was confusing to static type
|
||||
checkers. Reported and fixed by @quodlibetor (gh pr #485)
|
||||
- Several unused imports were removed by @jdufresne. (gh pr #486)
|
||||
- Switched ``isinstance(*, collections.Callable)`` to callable, which is available
|
||||
on all supported Python versions. Implemented by @jdufresne (gh pr #612)
|
||||
- Added CONTRIBUTING.md (gh pr #533)
|
||||
- Added AUTHORS.md (gh pr #542)
|
||||
- Corrected setup.py metadata to reflect author vs. maintainer, (gh issue #477,
|
||||
gh pr #538)
|
||||
- Corrected README to reflect that tests are now run in pytest. Reported and
|
||||
fixed by @m-dz (gh issue #556, gh pr #557)
|
||||
- Updated all references to RFC 2445 (iCalendar) to point to RFC 5545. Fixed
|
||||
by @mariocj89 (gh issue #543, gh pr #555)
|
||||
- Corrected parse documentation to reflect proper integer offset units,
|
||||
reported and fixed by @abrugh (gh pr #458)
|
||||
- Fixed dangling parenthesis in tzoffset documentation (gh pr #461)
|
||||
- Started including the license file in wheels. Reported and fixed by
|
||||
@jdufresne (gh pr #476)
|
||||
- Indendation fixes to parser docstring by @jbrockmendel (gh pr #492)
|
||||
- Moved many examples from the "examples" documentation into their appropriate
|
||||
module documentation pages. Fixed by @Tomasz-Kluczkowski and @jakec-github
|
||||
(gh pr #558, #561)
|
||||
- Fixed documentation so that the parser.isoparse documentation displays.
|
||||
Fixed by @alexchamberlain (gh issue #545, gh pr #560)
|
||||
- Refactored build and release sections and added setup instructions to
|
||||
CONTRIBUTING. Reported and fixed by @kynan (gh pr #562)
|
||||
- Cleaned up various dead links in the documentation. (gh pr #602, #608, #618)
|
||||
|
||||
Version 2.6.1
|
||||
=============
|
||||
- Updated zoneinfo file to 2017b. (gh pr #395)
|
||||
- Added Python 3.6 to CI testing (gh pr #365)
|
||||
- Removed duplicate test name that was preventing a test from being run.
|
||||
Reported and fixed by @jdufresne (gh pr #371)
|
||||
- Fixed testing of folds and gaps, particularly on Windows (gh pr #392)
|
||||
- Fixed deprecated escape characters in regular expressions. Reported by
|
||||
@nascheme and @thierryba (gh issue #361), fixed by @thierryba (gh pr #358)
|
||||
- Many PEP8 style violations and other code smells were fixed by @jdufresne
|
||||
(gh prs #358, #363, #364, #366, #367, #368, #372, #374, #379, #380, #398)
|
||||
- Improved performance of tzutc and tzoffset objects. (gh pr #391)
|
||||
- Fixed issue with several time zone classes around DST transitions in any
|
||||
zones with +0 standard offset (e.g. Europe/London) (gh issue #321, pr #390)
|
||||
- Fixed issue with fuzzy parsing where tokens similar to AM/PM that are in the
|
||||
end skipped were dropped in the fuzzy_with_tokens list. Reported and fixed
|
||||
by @jbrockmendel (gh pr #332).
|
||||
- Fixed issue with parsing dates of the form X m YY. Reported by @jbrockmendel.
|
||||
(gh issue #333, pr #393)
|
||||
- Added support for parser weekdays with less than 3 characters. Reported by
|
||||
@arcadefoam (gh issue #343), fixed by @jonemo (gh pr #382)
|
||||
- Fixed issue with the addition and subtraction of certain relativedeltas.
|
||||
Reported and fixed by @kootenpv (gh issue #346, pr #347)
|
||||
- Fixed issue where the COUNT parameter of rrules was ignored if 0. Fixed by
|
||||
@mshenfield (gh pr #330), reported by @vaultah (gh issue #329).
|
||||
- Updated documentation to include the new tz methods. (gh pr #324)
|
||||
- Update documentation to reflect that the parser can raise TypeError, reported
|
||||
and fixed by @tomchuk (gh issue #336, pr #337)
|
||||
- Fixed an incorrect year in a parser doctest. Fixed by @xlotlu (gh pr #357)
|
||||
- Moved version information into _version.py and set up the versions more
|
||||
granularly.
|
||||
|
||||
Version 2.6.0
|
||||
=============
|
||||
- Added PEP-495-compatible methods to address ambiguous and imaginary dates in
|
||||
time zones in a backwards-compatible way. Ambiguous dates and times can now
|
||||
be safely represented by all dateutil time zones. Many thanks to Alexander
|
||||
Belopolski (@abalkin) and Tim Peters @tim-one for their inputs on how to
|
||||
address this. Original issues reported by Yupeng and @zed (lP: 1390262,
|
||||
gh issues #57, #112, #249, #284, #286, prs #127, #225, #248, #264, #302).
|
||||
- Added new methods for working with ambiguous and imaginary dates to the tz
|
||||
module. datetime_ambiguous() determines if a datetime is ambiguous for a given
|
||||
zone and datetime_exists() determines if a datetime exists in a given zone.
|
||||
This works for all fold-aware datetimes, not just those provided by dateutil.
|
||||
(gh issue #253, gh pr #302)
|
||||
- Fixed an issue where dst() in Portugal in 1996 was returning the wrong value
|
||||
in tz.tzfile objects. Reported by @abalkin (gh issue #128, pr #225)
|
||||
- Fixed an issue where zoneinfo.ZoneInfoFile errors were not being properly
|
||||
deep-copied. (gh issue #226, pr #225)
|
||||
- Refactored tzwin and tzrange as a subclass of a common class, tzrangebase, as
|
||||
there was substantial overlapping functionality. As part of this change,
|
||||
tzrange and tzstr now expose a transitions() function, which returns the
|
||||
DST on and off transitions for a given year. (gh issue #260, pr #302)
|
||||
- Deprecated zoneinfo.gettz() due to confusion with tz.gettz(), in favor of
|
||||
get() method of zoneinfo.ZoneInfoFile objects. (gh issue #11, pr #310)
|
||||
- For non-character, non-stream arguments, parser.parse now raises TypeError
|
||||
instead of AttributeError. (gh issues #171, #269, pr #247)
|
||||
- Fixed an issue where tzfile objects were not properly handling dst() and
|
||||
tzname() when attached to datetime.time objects. Reported by @ovacephaloid.
|
||||
(gh issue #292, pr #309)
|
||||
- /usr/share/lib/zoneinfo was added to TZPATHS for compatibility with Solaris
|
||||
systems. Reported by @dhduvall (gh issue #276, pr #307)
|
||||
- tzoffset and tzrange objects now accept either a number of seconds or a
|
||||
datetime.timedelta() object wherever previously only a number of seconds was
|
||||
allowed. (gh pr #264, #277)
|
||||
- datetime.timedelta objects can now be added to relativedelta objects. Reported
|
||||
and added by Alec Nikolas Reiter (@justanr) (gh issue #282, pr #283
|
||||
- Refactored relativedelta.weekday and rrule.weekday into a common base class
|
||||
to reduce code duplication. (gh issue #140, pr #311)
|
||||
- An issue where the WKST parameter was improperly rendering in str(rrule) was
|
||||
reported and fixed by Daniel LePage (@dplepage). (gh issue #262, pr #263)
|
||||
- A replace() method has been added to rrule objects by @jendas1, which creates
|
||||
new rrule with modified attributes, analogous to datetime.replace (gh pr #167)
|
||||
- Made some significant performance improvements to rrule objects in Python 2.x
|
||||
(gh pr #245)
|
||||
- All classes defining equality functions now return NotImplemented when
|
||||
compared to unsupported classes, rather than raising TypeError, to allow other
|
||||
classes to provide fallback support. (gh pr #236)
|
||||
- Several classes have been marked as explicitly unhashable to maintain
|
||||
identical behavior between Python 2 and 3. Submitted by Roy Williams
|
||||
(@rowillia) (gh pr #296)
|
||||
- Trailing whitespace in easter.py has been removed. Submitted by @OmgImAlexis
|
||||
(gh pr #299)
|
||||
- Windows-only batch files in build scripts had line endings switched to CRLF.
|
||||
(gh pr #237)
|
||||
- @adamchainz updated the documentation links to reflect that the canonical
|
||||
location for readthedocs links is now at .io, not .org. (gh pr #272)
|
||||
- Made some changes to the CI and codecov to test against newer versions of
|
||||
Python and pypy, and to adjust the code coverage requirements. For the moment,
|
||||
full pypy3 compatibility is not supported until a new release is available,
|
||||
due to upstream bugs in the old version affecting PEP-495 support.
|
||||
(gh prs #265, #266, #304, #308)
|
||||
- The full PGP signing key fingerprint was added to the README.md in favor of
|
||||
the previously used long-id. Reported by @valholl (gh issue #287, pr #304)
|
||||
- Updated zoneinfo to 2016i. (gh issue #298, gh pr #306)
|
||||
|
||||
|
||||
Version 2.5.3
|
||||
=============
|
||||
- Updated zoneinfo to 2016d
|
||||
- Fixed parser bug where unambiguous datetimes fail to parse when dayfirst is
|
||||
set to true. (gh issue #233, pr #234)
|
||||
- Bug in zoneinfo file on platforms such as Google App Engine which do not
|
||||
do not allow importing of subprocess.check_call was reported and fixed by
|
||||
@savraj (gh issue #239, gh pr #240)
|
||||
- Fixed incorrect version in documentation (gh issue #235, pr #243)
|
||||
|
||||
Version 2.5.2
|
||||
=============
|
||||
- Updated zoneinfo to 2016c
|
||||
- Fixed parser bug where yearfirst and dayfirst parameters were not being
|
||||
respected when no separator was present. (gh issue #81 and #217, pr #229)
|
||||
|
||||
Version 2.5.1
|
||||
=============
|
||||
- Updated zoneinfo to 2016b
|
||||
- Changed MANIFEST.in to explicitly include test suite in source distributions,
|
||||
with help from @koobs (gh issue #193, pr #194, #201, #221)
|
||||
- Explicitly set all line-endings to LF, except for the NEWS file, on a
|
||||
per-repository basis (gh pr #218)
|
||||
- Fixed an issue with improper caching behavior in rruleset objects (gh issue
|
||||
#104, pr #207)
|
||||
- Changed to an explicit error when rrulestr strings contain a missing BYDAY
|
||||
(gh issue #162, pr #211)
|
||||
- tzfile now correctly handles files containing leapcnt (although the leapcnt
|
||||
information is not actually used). Contributed by @hjoukl (gh issue #146, pr
|
||||
#147)
|
||||
- Fixed recursive import issue with tz module (gh pr #204)
|
||||
- Added compatibility between tzwin objects and datetime.time objects (gh issue
|
||||
#216, gh pr #219)
|
||||
- Refactored monolithic test suite by module (gh issue #61, pr #200 and #206)
|
||||
- Improved test coverage in the relativedelta module (gh pr #215)
|
||||
- Adjusted documentation to reflect possibly counter-intuitive properties of
|
||||
RFC-5545-compliant rrules, and other documentation improvements in the rrule
|
||||
module (gh issue #105, gh issue #149 - pointer to the solution by @phep,
|
||||
pr #213).
|
||||
|
||||
|
||||
Version 2.5.0
|
||||
=============
|
||||
- Updated zoneinfo to 2016a
|
||||
- zoneinfo_metadata file version increased to 2.0 - the updated updatezinfo.py
|
||||
script will work with older zoneinfo_metadata.json files, but new metadata
|
||||
files will not work with older updatezinfo.py versions. Additionally, we have
|
||||
started hosting our own mirror of the Olson databases on a github pages
|
||||
site (https://dateutil.github.io/tzdata/) (gh pr #183)
|
||||
- dateutil zoneinfo tarballs now contain the full zoneinfo_metadata file used
|
||||
to generate them. (gh issue #27, gh pr #85)
|
||||
- relativedelta can now be safely subclassed without derived objects reverting
|
||||
to base relativedelta objects as a result of arithmetic operations.
|
||||
(lp:1010199, gh issue #44, pr #49)
|
||||
- relativedelta 'weeks' parameter can now be set and retrieved as a property of
|
||||
relativedelta instances. (lp: 727525, gh issue #45, pr #49)
|
||||
- relativedelta now explicitly supports fractional relative weeks, days, hours,
|
||||
minutes and seconds. Fractional values in absolute parameters (year, day, etc)
|
||||
are now deprecated. (gh issue #40, pr #190)
|
||||
- relativedelta objects previously did not use microseconds to determine of two
|
||||
relativedelta objects were equal. This oversight has been corrected.
|
||||
Contributed by @elprans (gh pr #113)
|
||||
- rrule now has an xafter() method for retrieving multiple recurrences after a
|
||||
specified date. (gh pr #38)
|
||||
- str(rrule) now returns an RFC2445-compliant rrule string, contributed by
|
||||
@schinckel and @armicron (lp:1406305, gh issue #47, prs #50, #62 and #160)
|
||||
- rrule performance under certain conditions has been significantly improved
|
||||
thanks to a patch contributed by @dekoza, based on an article by Brian Beck
|
||||
(@exogen) (gh pr #136)
|
||||
- The use of both the 'until' and 'count' parameters is now deprecated as
|
||||
inconsistent with RFC2445 (gh pr #62, #185)
|
||||
- Parsing an empty string will now raise a ValueError, rather than returning the
|
||||
datetime passed to the 'default' parameter. (gh issue #78, pr #187)
|
||||
- tzwinlocal objects now have a meaningful repr() and str() implementation
|
||||
(gh issue #148, prs #184 and #186)
|
||||
- Added equality logic for tzwin and tzwinlocal objects. (gh issue #151,
|
||||
pr #180, #184)
|
||||
- Added some flexibility in subclassing timelex, and switched the default
|
||||
behavior over to using string methods rather than comparing against a fixed
|
||||
list. (gh pr #122, #139)
|
||||
- An issue causing tzstr() to crash on Python 2.x was fixed. (lp: 1331576,
|
||||
gh issue #51, pr #55)
|
||||
- An issue with string encoding causing exceptions under certain circumstances
|
||||
when tzname() is called was fixed. (gh issue #60, #74, pr #75)
|
||||
- Parser issue where calling parse() on dates with no day specified when the
|
||||
day of the month in the default datetime (which is "today" if unspecified) is
|
||||
greater than the number of days in the parsed month was fixed (this issue
|
||||
tended to crop up between the 29th and 31st of the month, for obvious reasons)
|
||||
(canonical gh issue #25, pr #30, #191)
|
||||
- Fixed parser issue causing fuzzy_with_tokens to raise an unexpected exception
|
||||
in certain circumstances. Contributed by @MichaelAquilina (gh pr #91)
|
||||
- Fixed parser issue where years > 100 AD were incorrectly parsed. Contributed
|
||||
by @Bachmann1234 (gh pr #130)
|
||||
- Fixed parser issue where commas were not a valid separator between seconds
|
||||
and microseconds, preventing parsing of ISO 8601 dates. Contributed by
|
||||
@ryanss (gh issue #28, pr #106)
|
||||
- Fixed issue with tzwin encoding in locales with non-Latin alphabets
|
||||
(gh issue #92, pr #98)
|
||||
- Fixed an issue where tzwin was not being properly imported on Windows.
|
||||
Contributed by @labrys. (gh pr #134)
|
||||
- Fixed a problem causing issues importing zoneinfo in certain circumstances.
|
||||
Issue and solution contributed by @alexxv (gh issue #97, pr #99)
|
||||
- Fixed an issue where dateutil timezones were not compatible with basic time
|
||||
objects. One of many, many timezone related issues contributed and tested by
|
||||
@labrys. (gh issue #132, pr #181)
|
||||
- Fixed issue where tzwinlocal had an invalid utcoffset. (gh issue #135,
|
||||
pr #141, #142)
|
||||
- Fixed issue with tzwin and tzwinlocal where DST transitions were incorrectly
|
||||
parsed from the registry. (gh issue #143, pr #178)
|
||||
- updatezinfo.py no longer suppresses certain OSErrors. Contributed by @bjamesv
|
||||
(gh pr #164)
|
||||
- An issue that arose when timezone locale changes during runtime has been
|
||||
fixed by @carlosxl and @mjschultz (gh issue #100, prs #107, #109)
|
||||
- Python 3.5 was added to the supported platforms in the metadata (@tacaswell
|
||||
gh pr #159) and the test suites (@moreati gh pr #117).
|
||||
- An issue with tox failing without unittest2 installed in Python 2.6 was fixed
|
||||
by @moreati (gh pr #115)
|
||||
- Several deprecated functions were replaced in the tests by @moreati
|
||||
(gh pr #116)
|
||||
- Improved the logic in Travis and Appveyor to alleviate issues where builds
|
||||
were failing due to connection issues when downloading the IANA timezone
|
||||
files. In addition to adding our own mirror for the files (gh pr #183), the
|
||||
download is now retried a number of times (with a delay) (gh pr #177)
|
||||
- Many failing doctests were fixed by @moreati. (gh pr #120)
|
||||
- Many fixes to the documentation (gh pr #103, gh pr #87 from @radarhere,
|
||||
gh pr #154 from @gpoesia, gh pr #156 from @awsum, gh pr #168 from @ja8zyjits)
|
||||
- Added a code coverage tool to the CI to help improve the library. (gh pr #182)
|
||||
- We now have a mailing list - dateutil@python.org, graciously hosted by
|
||||
Python.org.
|
||||
|
||||
|
||||
Version 2.4.2
|
||||
=============
|
||||
- Updated zoneinfo to 2015b.
|
||||
- Fixed issue with parsing of tzstr on Python 2.7.x; tzstr will now be decoded
|
||||
if not a unicode type. gh #51 (lp:1331576), gh pr #55.
|
||||
- Fix a parser issue where AM and PM tokens were showing up in fuzzy date
|
||||
stamps, triggering inappropriate errors. gh #56 (lp: 1428895), gh pr #63.
|
||||
- Missing function "setcachesize" removed from zoneinfo __all__ list by @ryanss,
|
||||
fixing an issue with wildcard imports of dateutil.zoneinfo. (gh pr #66).
|
||||
- (PyPI only) Fix an issue with source distributions not including the test
|
||||
suite.
|
||||
|
||||
|
||||
Version 2.4.1
|
||||
=============
|
||||
|
||||
- Added explicit check for valid hours if AM/PM is specified in parser.
|
||||
(gh pr #22, issue #21)
|
||||
- Fix bug in rrule introduced in 2.4.0 where byweekday parameter was not
|
||||
handled properly. (gh pr #35, issue #34)
|
||||
- Fix error where parser allowed some invalid dates, overwriting existing hours
|
||||
with the last 2-digit number in the string. (gh pr #32, issue #31)
|
||||
- Fix and add test for Python 2.x compatibility with boolean checking of
|
||||
relativedelta objects. Implemented by @nimasmi (gh pr #43) and Cédric Krier
|
||||
(lp: 1035038)
|
||||
- Replaced parse() calls with explicit datetime objects in unit tests unrelated
|
||||
to parser. (gh pr #36)
|
||||
- Changed private _byxxx from sets to sorted tuples and fixed one currently
|
||||
unreachable bug in _construct_byset. (gh pr #54)
|
||||
- Additional documentation for parser (gh pr #29, #33, #41) and rrule.
|
||||
- Formatting fixes to documentation of rrule and README.rst.
|
||||
- Updated zoneinfo to 2015a.
|
||||
|
||||
Version 2.4.0
|
||||
=============
|
||||
|
||||
- Fix an issue with relativedelta and freezegun (lp:1374022)
|
||||
- Fix tzinfo in windows for timezones without dst (lp:1010050, gh #2)
|
||||
- Ignore missing timezones in windows like in POSIX
|
||||
- Fix minimal version requirement for six (gh #6)
|
||||
- Many rrule changes and fixes by @pganssle (gh pull requests #13 #14 #17),
|
||||
including defusing some infinite loops (gh #4)
|
||||
|
||||
Version 2.3
|
||||
===========
|
||||
|
||||
- Cleanup directory structure, moved test.py to dateutil/tests/test.py
|
||||
|
||||
- Changed many aspects of dealing with the zone info file. Instead of a cache,
|
||||
all the zones are loaded to memory, but symbolic links are loaded only once,
|
||||
so not much memory is used.
|
||||
|
||||
- The package is now zip-safe, and universal-wheelable, thanks to changes in
|
||||
the handling of the zoneinfo file.
|
||||
|
||||
- Fixed tzwin silently not imported on windows python2
|
||||
|
||||
- New maintainer, together with new hosting: GitHub, Travis, Read-The-Docs
|
||||
|
||||
Version 2.2
|
||||
===========
|
||||
|
||||
- Updated zoneinfo to 2013h
|
||||
|
||||
- fuzzy_with_tokens parse addon from Christopher Corley
|
||||
|
||||
- Bug with LANG=C fixed by Mike Gilbert
|
||||
|
||||
Version 2.1
|
||||
===========
|
||||
|
||||
- New maintainer
|
||||
|
||||
- Dateutil now works on Python 2.6, 2.7 and 3.2 from same codebase (with six)
|
||||
|
||||
- #704047: Ismael Carnales' patch for a new time format
|
||||
|
||||
- Small bug fixes, thanks for reporters!
|
||||
|
||||
|
||||
Version 2.0
|
||||
===========
|
||||
|
||||
- Ported to Python 3, by Brian Jones. If you need dateutil for Python 2.X,
|
||||
please continue using the 1.X series.
|
||||
|
||||
- There's no such thing as a "PSF License". This source code is now
|
||||
made available under the Simplified BSD license. See LICENSE for
|
||||
details.
|
||||
|
||||
Version 1.5
|
||||
===========
|
||||
|
||||
- As reported by Mathieu Bridon, rrules were matching the bysecond rules
|
||||
incorrectly against byminute in some circumstances when the SECONDLY
|
||||
frequency was in use, due to a copy & paste bug. The problem has been
|
||||
unittested and corrected.
|
||||
|
||||
- Adam Ryan reported a problem in the relativedelta implementation which
|
||||
affected the yearday parameter in the month of January specifically.
|
||||
This has been unittested and fixed.
|
||||
|
||||
- Updated timezone information.
|
||||
|
||||
|
||||
Version 1.4.1
|
||||
=============
|
||||
|
||||
- Updated timezone information.
|
||||
|
||||
|
||||
Version 1.4
|
||||
===========
|
||||
|
||||
- Fixed another parser precision problem on conversion of decimal seconds
|
||||
to microseconds, as reported by Erik Brown. Now these issues are gone
|
||||
for real since it's not using floating point arithmetic anymore.
|
||||
|
||||
- Fixed case where tzrange.utcoffset and tzrange.dst() might fail due
|
||||
to a date being used where a datetime was expected (reported and fixed
|
||||
by Lennart Regebro).
|
||||
|
||||
- Prevent tzstr from introducing daylight timings in strings that didn't
|
||||
specify them (reported by Lennart Regebro).
|
||||
|
||||
- Calls like gettz("GMT+3") and gettz("UTC-2") will now return the
|
||||
expected values, instead of the TZ variable behavior.
|
||||
|
||||
- Fixed DST signal handling in zoneinfo files. Reported by
|
||||
Nicholas F. Fabry and John-Mark Gurney.
|
||||
|
||||
|
||||
Version 1.3
|
||||
===========
|
||||
|
||||
- Fixed precision problem on conversion of decimal seconds to
|
||||
microseconds, as reported by Skip Montanaro.
|
||||
|
||||
- Fixed bug in constructor of parser, and converted parser classes to
|
||||
new-style classes. Original report and patch by Michael Elsdörfer.
|
||||
|
||||
- Initialize tzid and comps in tz.py, to prevent the code from ever
|
||||
raising a NameError (even with broken files). Johan Dahlin suggested
|
||||
the fix after a pyflakes run.
|
||||
|
||||
- Version is now published in dateutil.__version__, as requested
|
||||
by Darren Dale.
|
||||
|
||||
- All code is compatible with new-style division.
|
||||
|
||||
|
||||
Version 1.2
|
||||
===========
|
||||
|
||||
- Now tzfile will round timezones to full-minutes if necessary,
|
||||
since Python's datetime doesn't support sub-minute offsets.
|
||||
Thanks to Ilpo Nyyssönen for reporting the issue.
|
||||
|
||||
- Removed bare string exceptions, as reported and fixed by
|
||||
Wilfredo Sánchez Vega.
|
||||
|
||||
- Fix bug in leap count parsing (reported and fixed by Eugene Oden).
|
||||
|
||||
|
||||
Version 1.1
|
||||
===========
|
||||
|
||||
- Fixed rrule byyearday handling. Abramo Bagnara pointed out that
|
||||
RFC2445 allows negative numbers.
|
||||
|
||||
- Fixed --prefix handling in setup.py (by Sidnei da Silva).
|
||||
|
||||
- Now tz.gettz() returns a tzlocal instance when not given any
|
||||
arguments and no other timezone information is found.
|
||||
|
||||
- Updating timezone information to version 2005q.
|
||||
|
||||
|
||||
Version 1.0
|
||||
===========
|
||||
|
||||
- Fixed parsing of XXhXXm formatted time after day/month/year
|
||||
has been parsed.
|
||||
|
||||
- Added patch by Jeffrey Harris optimizing rrule.__contains__.
|
||||
|
||||
|
||||
Version 0.9
|
||||
===========
|
||||
|
||||
- Fixed pickling of timezone types, as reported by
|
||||
Andreas Köhler.
|
||||
|
||||
- Implemented internal timezone information with binary
|
||||
timezone files. datautil.tz.gettz() function will now
|
||||
try to use the system timezone files, and fallback to
|
||||
the internal versions. It's also possible to ask for
|
||||
the internal versions directly by using
|
||||
dateutil.zoneinfo.gettz().
|
||||
|
||||
- New tzwin timezone type, allowing access to Windows
|
||||
internal timezones (contributed by Jeffrey Harris).
|
||||
|
||||
- Fixed parsing of unicode date strings.
|
||||
|
||||
- Accept parserinfo instances as the parser constructor
|
||||
parameter, besides parserinfo (sub)classes.
|
||||
|
||||
- Changed weekday to spell the not-set n value as None
|
||||
instead of 0.
|
||||
|
||||
- Fixed other reported bugs.
|
||||
|
||||
|
||||
Version 0.5
|
||||
===========
|
||||
|
||||
- Removed ``FREQ_`` prefix from rrule frequency constants
|
||||
WARNING: this breaks compatibility with previous versions.
|
||||
|
||||
- Fixed rrule.between() for cases where "after" is achieved
|
||||
before even starting, as reported by Andreas Köhler.
|
||||
|
||||
- Fixed two digit zero-year parsing (such as 31-Dec-00), as
|
||||
reported by Jim Abramson, and included test case for this.
|
||||
|
||||
- Sort exdate and rdate before iterating over them, so that
|
||||
it's not necessary to sort them before adding to the rruleset,
|
||||
as reported by Nicholas Piper.
|
158
libraries/dateutil/README.rst
Normal file
158
libraries/dateutil/README.rst
Normal file
|
@ -0,0 +1,158 @@
|
|||
dateutil - powerful extensions to datetime
|
||||
==========================================
|
||||
|
||||
|pypi| |support| |licence|
|
||||
|
||||
|gitter| |readthedocs|
|
||||
|
||||
|travis| |appveyor| |coverage|
|
||||
|
||||
.. |pypi| image:: https://img.shields.io/pypi/v/python-dateutil.svg?style=flat-square
|
||||
:target: https://pypi.org/project/python-dateutil/
|
||||
:alt: pypi version
|
||||
|
||||
.. |support| image:: https://img.shields.io/pypi/pyversions/python-dateutil.svg?style=flat-square
|
||||
:target: https://pypi.org/project/python-dateutil/
|
||||
:alt: supported Python version
|
||||
|
||||
.. |travis| image:: https://img.shields.io/travis/dateutil/dateutil/master.svg?style=flat-square&label=Travis%20Build
|
||||
:target: https://travis-ci.org/dateutil/dateutil
|
||||
:alt: travis build status
|
||||
|
||||
.. |appveyor| image:: https://img.shields.io/appveyor/ci/dateutil/dateutil/master.svg?style=flat-square&logo=appveyor
|
||||
:target: https://ci.appveyor.com/project/dateutil/dateutil
|
||||
:alt: appveyor build status
|
||||
|
||||
.. |coverage| image:: https://codecov.io/github/dateutil/dateutil/coverage.svg?branch=master
|
||||
:target: https://codecov.io/github/dateutil/dateutil?branch=master
|
||||
:alt: Code coverage
|
||||
|
||||
.. |gitter| image:: https://badges.gitter.im/dateutil/dateutil.svg
|
||||
:alt: Join the chat at https://gitter.im/dateutil/dateutil
|
||||
:target: https://gitter.im/dateutil/dateutil
|
||||
|
||||
.. |licence| image:: https://img.shields.io/pypi/l/python-dateutil.svg?style=flat-square
|
||||
:target: https://pypi.org/project/python-dateutil/
|
||||
:alt: licence
|
||||
|
||||
.. |readthedocs| image:: https://img.shields.io/readthedocs/dateutil/latest.svg?style=flat-square&label=Read%20the%20Docs
|
||||
:alt: Read the documentation at https://dateutil.readthedocs.io/en/latest/
|
||||
:target: https://dateutil.readthedocs.io/en/latest/
|
||||
|
||||
The `dateutil` module provides powerful extensions to
|
||||
the standard `datetime` module, available in Python.
|
||||
|
||||
|
||||
Download
|
||||
========
|
||||
dateutil is available on PyPI
|
||||
https://pypi.org/project/python-dateutil/
|
||||
|
||||
The documentation is hosted at:
|
||||
https://dateutil.readthedocs.io/en/stable/
|
||||
|
||||
Code
|
||||
====
|
||||
The code and issue tracker are hosted on Github:
|
||||
https://github.com/dateutil/dateutil/
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
* Computing of relative deltas (next month, next year,
|
||||
next monday, last week of month, etc);
|
||||
* Computing of relative deltas between two given
|
||||
date and/or datetime objects;
|
||||
* Computing of dates based on very flexible recurrence rules,
|
||||
using a superset of the `iCalendar <https://www.ietf.org/rfc/rfc2445.txt>`_
|
||||
specification. Parsing of RFC strings is supported as well.
|
||||
* Generic parsing of dates in almost any string format;
|
||||
* Timezone (tzinfo) implementations for tzfile(5) format
|
||||
files (/etc/localtime, /usr/share/zoneinfo, etc), TZ
|
||||
environment string (in all known formats), iCalendar
|
||||
format files, given ranges (with help from relative deltas),
|
||||
local machine timezone, fixed offset timezone, UTC timezone,
|
||||
and Windows registry-based time zones.
|
||||
* Internal up-to-date world timezone information based on
|
||||
Olson's database.
|
||||
* Computing of Easter Sunday dates for any given year,
|
||||
using Western, Orthodox or Julian algorithms;
|
||||
* A comprehensive test suite.
|
||||
|
||||
Quick example
|
||||
=============
|
||||
Here's a snapshot, just to give an idea about the power of the
|
||||
package. For more examples, look at the documentation.
|
||||
|
||||
Suppose you want to know how much time is left, in
|
||||
years/months/days/etc, before the next easter happening on a
|
||||
year with a Friday 13th in August, and you want to get today's
|
||||
date out of the "date" unix system command. Here is the code:
|
||||
|
||||
.. doctest:: readmeexample
|
||||
|
||||
>>> from dateutil.relativedelta import *
|
||||
>>> from dateutil.easter import *
|
||||
>>> from dateutil.rrule import *
|
||||
>>> from dateutil.parser import *
|
||||
>>> from datetime import *
|
||||
>>> now = parse("Sat Oct 11 17:13:46 UTC 2003")
|
||||
>>> today = now.date()
|
||||
>>> year = rrule(YEARLY,dtstart=now,bymonth=8,bymonthday=13,byweekday=FR)[0].year
|
||||
>>> rdelta = relativedelta(easter(year), today)
|
||||
>>> print("Today is: %s" % today)
|
||||
Today is: 2003-10-11
|
||||
>>> print("Year with next Aug 13th on a Friday is: %s" % year)
|
||||
Year with next Aug 13th on a Friday is: 2004
|
||||
>>> print("How far is the Easter of that year: %s" % rdelta)
|
||||
How far is the Easter of that year: relativedelta(months=+6)
|
||||
>>> print("And the Easter of that year is: %s" % (today+rdelta))
|
||||
And the Easter of that year is: 2004-04-11
|
||||
|
||||
Being exactly 6 months ahead was **really** a coincidence :)
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
||||
We welcome many types of contributions - bug reports, pull requests (code, infrastructure or documentation fixes). For more information about how to contribute to the project, see the ``CONTRIBUTING.md`` file in the repository.
|
||||
|
||||
|
||||
Author
|
||||
======
|
||||
The dateutil module was written by Gustavo Niemeyer <gustavo@niemeyer.net>
|
||||
in 2003.
|
||||
|
||||
It is maintained by:
|
||||
|
||||
* Gustavo Niemeyer <gustavo@niemeyer.net> 2003-2011
|
||||
* Tomi Pieviläinen <tomi.pievilainen@iki.fi> 2012-2014
|
||||
* Yaron de Leeuw <me@jarondl.net> 2014-2016
|
||||
* Paul Ganssle <paul@ganssle.io> 2015-
|
||||
|
||||
Starting with version 2.4.1, all source and binary distributions will be signed
|
||||
by a PGP key that has, at the very least, been signed by the key which made the
|
||||
previous release. A table of release signing keys can be found below:
|
||||
|
||||
=========== ============================
|
||||
Releases Signing key fingerprint
|
||||
=========== ============================
|
||||
2.4.1- `6B49 ACBA DCF6 BD1C A206 67AB CD54 FCE3 D964 BEFB`_ (|pgp_mirror|_)
|
||||
=========== ============================
|
||||
|
||||
|
||||
Contact
|
||||
=======
|
||||
Our mailing list is available at `dateutil@python.org <https://mail.python.org/mailman/listinfo/dateutil>`_. As it is hosted by the PSF, it is subject to the `PSF code of
|
||||
conduct <https://www.python.org/psf/codeofconduct/>`_.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
All contributions after December 1, 2017 released under dual license - either `Apache 2.0 License <https://www.apache.org/licenses/LICENSE-2.0>`_ or the `BSD 3-Clause License <https://opensource.org/licenses/BSD-3-Clause>`_. Contributions before December 1, 2017 - except those those explicitly relicensed - are released only under the BSD 3-Clause License.
|
||||
|
||||
|
||||
.. _6B49 ACBA DCF6 BD1C A206 67AB CD54 FCE3 D964 BEFB:
|
||||
https://pgp.mit.edu/pks/lookup?op=vindex&search=0xCD54FCE3D964BEFB
|
||||
|
||||
.. |pgp_mirror| replace:: mirror
|
||||
.. _pgp_mirror: https://sks-keyservers.net/pks/lookup?op=vindex&search=0xCD54FCE3D964BEFB
|
8
libraries/dateutil/__init__.py
Normal file
8
libraries/dateutil/__init__.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
try:
|
||||
from _version import version as __version__
|
||||
except ImportError:
|
||||
__version__ = 'unknown'
|
||||
|
||||
__all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz',
|
||||
'utils', 'zoneinfo', 'six']
|
43
libraries/dateutil/_common.py
Normal file
43
libraries/dateutil/_common.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
"""
|
||||
Common code used in multiple modules.
|
||||
"""
|
||||
|
||||
|
||||
class weekday(object):
|
||||
__slots__ = ["weekday", "n"]
|
||||
|
||||
def __init__(self, weekday, n=None):
|
||||
self.weekday = weekday
|
||||
self.n = n
|
||||
|
||||
def __call__(self, n):
|
||||
if n == self.n:
|
||||
return self
|
||||
else:
|
||||
return self.__class__(self.weekday, n)
|
||||
|
||||
def __eq__(self, other):
|
||||
try:
|
||||
if self.weekday != other.weekday or self.n != other.n:
|
||||
return False
|
||||
except AttributeError:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __hash__(self):
|
||||
return hash((
|
||||
self.weekday,
|
||||
self.n,
|
||||
))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
def __repr__(self):
|
||||
s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday]
|
||||
if not self.n:
|
||||
return s
|
||||
else:
|
||||
return "%s(%+d)" % (s, self.n)
|
||||
|
||||
# vim:ts=4:sw=4:et
|
89
libraries/dateutil/easter.py
Normal file
89
libraries/dateutil/easter.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module offers a generic easter computing method for any given year, using
|
||||
Western, Orthodox or Julian algorithms.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
|
||||
__all__ = ["easter", "EASTER_JULIAN", "EASTER_ORTHODOX", "EASTER_WESTERN"]
|
||||
|
||||
EASTER_JULIAN = 1
|
||||
EASTER_ORTHODOX = 2
|
||||
EASTER_WESTERN = 3
|
||||
|
||||
|
||||
def easter(year, method=EASTER_WESTERN):
|
||||
"""
|
||||
This method was ported from the work done by GM Arts,
|
||||
on top of the algorithm by Claus Tondering, which was
|
||||
based in part on the algorithm of Ouding (1940), as
|
||||
quoted in "Explanatory Supplement to the Astronomical
|
||||
Almanac", P. Kenneth Seidelmann, editor.
|
||||
|
||||
This algorithm implements three different easter
|
||||
calculation methods:
|
||||
|
||||
1 - Original calculation in Julian calendar, valid in
|
||||
dates after 326 AD
|
||||
2 - Original method, with date converted to Gregorian
|
||||
calendar, valid in years 1583 to 4099
|
||||
3 - Revised method, in Gregorian calendar, valid in
|
||||
years 1583 to 4099 as well
|
||||
|
||||
These methods are represented by the constants:
|
||||
|
||||
* ``EASTER_JULIAN = 1``
|
||||
* ``EASTER_ORTHODOX = 2``
|
||||
* ``EASTER_WESTERN = 3``
|
||||
|
||||
The default method is method 3.
|
||||
|
||||
More about the algorithm may be found at:
|
||||
|
||||
`GM Arts: Easter Algorithms <http://www.gmarts.org/index.php?go=415>`_
|
||||
|
||||
and
|
||||
|
||||
`The Calendar FAQ: Easter <https://www.tondering.dk/claus/cal/easter.php>`_
|
||||
|
||||
"""
|
||||
|
||||
if not (1 <= method <= 3):
|
||||
raise ValueError("invalid method")
|
||||
|
||||
# g - Golden year - 1
|
||||
# c - Century
|
||||
# h - (23 - Epact) mod 30
|
||||
# i - Number of days from March 21 to Paschal Full Moon
|
||||
# j - Weekday for PFM (0=Sunday, etc)
|
||||
# p - Number of days from March 21 to Sunday on or before PFM
|
||||
# (-6 to 28 methods 1 & 3, to 56 for method 2)
|
||||
# e - Extra days to add for method 2 (converting Julian
|
||||
# date to Gregorian date)
|
||||
|
||||
y = year
|
||||
g = y % 19
|
||||
e = 0
|
||||
if method < 3:
|
||||
# Old method
|
||||
i = (19*g + 15) % 30
|
||||
j = (y + y//4 + i) % 7
|
||||
if method == 2:
|
||||
# Extra dates to convert Julian to Gregorian date
|
||||
e = 10
|
||||
if y > 1600:
|
||||
e = e + y//100 - 16 - (y//100 - 16)//4
|
||||
else:
|
||||
# New method
|
||||
c = y//100
|
||||
h = (c - c//4 - (8*c + 13)//25 + 19*g + 15) % 30
|
||||
i = h - (h//28)*(1 - (h//28)*(29//(h + 1))*((21 - g)//11))
|
||||
j = (y + y//4 + i + 2 - c + c//4) % 7
|
||||
|
||||
# p can be from -6 to 56 corresponding to dates 22 March to 23 May
|
||||
# (later dates apply to method 2, although 23 May never actually occurs)
|
||||
p = i - j + e
|
||||
d = 1 + (p + 27 + (p + 6)//40) % 31
|
||||
m = 3 + (p + 26)//30
|
||||
return datetime.date(int(y), int(m), int(d))
|
60
libraries/dateutil/parser/__init__.py
Normal file
60
libraries/dateutil/parser/__init__.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from _parser import parse, parser, parserinfo
|
||||
from _parser import DEFAULTPARSER, DEFAULTTZPARSER
|
||||
from _parser import UnknownTimezoneWarning
|
||||
|
||||
from _parser import __doc__
|
||||
|
||||
from isoparser import isoparser, isoparse
|
||||
|
||||
__all__ = ['parse', 'parser', 'parserinfo',
|
||||
'isoparse', 'isoparser',
|
||||
'UnknownTimezoneWarning']
|
||||
|
||||
|
||||
###
|
||||
# Deprecate portions of the private interface so that downstream code that
|
||||
# is improperly relying on it is given *some* notice.
|
||||
|
||||
|
||||
def __deprecated_private_func(f):
|
||||
from functools import wraps
|
||||
import warnings
|
||||
|
||||
msg = ('{name} is a private function and may break without warning, '
|
||||
'it will be moved and or renamed in future versions.')
|
||||
msg = msg.format(name=f.__name__)
|
||||
|
||||
@wraps(f)
|
||||
def deprecated_func(*args, **kwargs):
|
||||
warnings.warn(msg, DeprecationWarning)
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return deprecated_func
|
||||
|
||||
def __deprecate_private_class(c):
|
||||
import warnings
|
||||
|
||||
msg = ('{name} is a private class and may break without warning, '
|
||||
'it will be moved and or renamed in future versions.')
|
||||
msg = msg.format(name=c.__name__)
|
||||
|
||||
class private_class(c):
|
||||
__doc__ = c.__doc__
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn(msg, DeprecationWarning)
|
||||
super(private_class, self).__init__(*args, **kwargs)
|
||||
|
||||
private_class.__name__ = c.__name__
|
||||
|
||||
return private_class
|
||||
|
||||
|
||||
from ._parser import _timelex, _resultbase
|
||||
from ._parser import _tzparser, _parsetz
|
||||
|
||||
_timelex = __deprecate_private_class(_timelex)
|
||||
_tzparser = __deprecate_private_class(_tzparser)
|
||||
_resultbase = __deprecate_private_class(_resultbase)
|
||||
_parsetz = __deprecated_private_func(_parsetz)
|
1578
libraries/dateutil/parser/_parser.py
Normal file
1578
libraries/dateutil/parser/_parser.py
Normal file
File diff suppressed because it is too large
Load diff
406
libraries/dateutil/parser/isoparser.py
Normal file
406
libraries/dateutil/parser/isoparser.py
Normal file
|
@ -0,0 +1,406 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module offers a parser for ISO-8601 strings
|
||||
|
||||
It is intended to support all valid date, time and datetime formats per the
|
||||
ISO-8601 specification.
|
||||
|
||||
..versionadded:: 2.7.0
|
||||
"""
|
||||
from datetime import datetime, timedelta, time, date
|
||||
import calendar
|
||||
from dateutil import tz
|
||||
|
||||
from functools import wraps
|
||||
|
||||
import re
|
||||
import six
|
||||
|
||||
__all__ = ["isoparse", "isoparser"]
|
||||
|
||||
|
||||
def _takes_ascii(f):
|
||||
@wraps(f)
|
||||
def func(self, str_in, *args, **kwargs):
|
||||
# If it's a stream, read the whole thing
|
||||
str_in = getattr(str_in, 'read', lambda: str_in)()
|
||||
|
||||
# If it's unicode, turn it into bytes, since ISO-8601 only covers ASCII
|
||||
if isinstance(str_in, six.text_type):
|
||||
# ASCII is the same in UTF-8
|
||||
try:
|
||||
str_in = str_in.encode('ascii')
|
||||
except UnicodeEncodeError as e:
|
||||
msg = 'ISO-8601 strings should contain only ASCII characters'
|
||||
six.raise_from(ValueError(msg), e)
|
||||
|
||||
return f(self, str_in, *args, **kwargs)
|
||||
|
||||
return func
|
||||
|
||||
|
||||
class isoparser(object):
|
||||
def __init__(self, sep=None):
|
||||
"""
|
||||
:param sep:
|
||||
A single character that separates date and time portions. If
|
||||
``None``, the parser will accept any single character.
|
||||
For strict ISO-8601 adherence, pass ``'T'``.
|
||||
"""
|
||||
if sep is not None:
|
||||
if (len(sep) != 1 or ord(sep) >= 128 or sep in '0123456789'):
|
||||
raise ValueError('Separator must be a single, non-numeric ' +
|
||||
'ASCII character')
|
||||
|
||||
sep = sep.encode('ascii')
|
||||
|
||||
self._sep = sep
|
||||
|
||||
@_takes_ascii
|
||||
def isoparse(self, dt_str):
|
||||
"""
|
||||
Parse an ISO-8601 datetime string into a :class:`datetime.datetime`.
|
||||
|
||||
An ISO-8601 datetime string consists of a date portion, followed
|
||||
optionally by a time portion - the date and time portions are separated
|
||||
by a single character separator, which is ``T`` in the official
|
||||
standard. Incomplete date formats (such as ``YYYY-MM``) may *not* be
|
||||
combined with a time portion.
|
||||
|
||||
Supported date formats are:
|
||||
|
||||
Common:
|
||||
|
||||
- ``YYYY``
|
||||
- ``YYYY-MM`` or ``YYYYMM``
|
||||
- ``YYYY-MM-DD`` or ``YYYYMMDD``
|
||||
|
||||
Uncommon:
|
||||
|
||||
- ``YYYY-Www`` or ``YYYYWww`` - ISO week (day defaults to 0)
|
||||
- ``YYYY-Www-D`` or ``YYYYWwwD`` - ISO week and day
|
||||
|
||||
The ISO week and day numbering follows the same logic as
|
||||
:func:`datetime.date.isocalendar`.
|
||||
|
||||
Supported time formats are:
|
||||
|
||||
- ``hh``
|
||||
- ``hh:mm`` or ``hhmm``
|
||||
- ``hh:mm:ss`` or ``hhmmss``
|
||||
- ``hh:mm:ss.sss`` or ``hh:mm:ss.ssssss`` (3-6 sub-second digits)
|
||||
|
||||
Midnight is a special case for `hh`, as the standard supports both
|
||||
00:00 and 24:00 as a representation.
|
||||
|
||||
.. caution::
|
||||
|
||||
Support for fractional components other than seconds is part of the
|
||||
ISO-8601 standard, but is not currently implemented in this parser.
|
||||
|
||||
Supported time zone offset formats are:
|
||||
|
||||
- `Z` (UTC)
|
||||
- `±HH:MM`
|
||||
- `±HHMM`
|
||||
- `±HH`
|
||||
|
||||
Offsets will be represented as :class:`dateutil.tz.tzoffset` objects,
|
||||
with the exception of UTC, which will be represented as
|
||||
:class:`dateutil.tz.tzutc`. Time zone offsets equivalent to UTC (such
|
||||
as `+00:00`) will also be represented as :class:`dateutil.tz.tzutc`.
|
||||
|
||||
:param dt_str:
|
||||
A string or stream containing only an ISO-8601 datetime string
|
||||
|
||||
:return:
|
||||
Returns a :class:`datetime.datetime` representing the string.
|
||||
Unspecified components default to their lowest value.
|
||||
|
||||
.. warning::
|
||||
|
||||
As of version 2.7.0, the strictness of the parser should not be
|
||||
considered a stable part of the contract. Any valid ISO-8601 string
|
||||
that parses correctly with the default settings will continue to
|
||||
parse correctly in future versions, but invalid strings that
|
||||
currently fail (e.g. ``2017-01-01T00:00+00:00:00``) are not
|
||||
guaranteed to continue failing in future versions if they encode
|
||||
a valid date.
|
||||
|
||||
.. versionadded:: 2.7.0
|
||||
"""
|
||||
components, pos = self._parse_isodate(dt_str)
|
||||
|
||||
if len(dt_str) > pos:
|
||||
if self._sep is None or dt_str[pos:pos + 1] == self._sep:
|
||||
components += self._parse_isotime(dt_str[pos + 1:])
|
||||
else:
|
||||
raise ValueError('String contains unknown ISO components')
|
||||
|
||||
return datetime(*components)
|
||||
|
||||
@_takes_ascii
|
||||
def parse_isodate(self, datestr):
|
||||
"""
|
||||
Parse the date portion of an ISO string.
|
||||
|
||||
:param datestr:
|
||||
The string portion of an ISO string, without a separator
|
||||
|
||||
:return:
|
||||
Returns a :class:`datetime.date` object
|
||||
"""
|
||||
components, pos = self._parse_isodate(datestr)
|
||||
if pos < len(datestr):
|
||||
raise ValueError('String contains unknown ISO ' +
|
||||
'components: {}'.format(datestr))
|
||||
return date(*components)
|
||||
|
||||
@_takes_ascii
|
||||
def parse_isotime(self, timestr):
|
||||
"""
|
||||
Parse the time portion of an ISO string.
|
||||
|
||||
:param timestr:
|
||||
The time portion of an ISO string, without a separator
|
||||
|
||||
:return:
|
||||
Returns a :class:`datetime.time` object
|
||||
"""
|
||||
return time(*self._parse_isotime(timestr))
|
||||
|
||||
@_takes_ascii
|
||||
def parse_tzstr(self, tzstr, zero_as_utc=True):
|
||||
"""
|
||||
Parse a valid ISO time zone string.
|
||||
|
||||
See :func:`isoparser.isoparse` for details on supported formats.
|
||||
|
||||
:param tzstr:
|
||||
A string representing an ISO time zone offset
|
||||
|
||||
:param zero_as_utc:
|
||||
Whether to return :class:`dateutil.tz.tzutc` for zero-offset zones
|
||||
|
||||
:return:
|
||||
Returns :class:`dateutil.tz.tzoffset` for offsets and
|
||||
:class:`dateutil.tz.tzutc` for ``Z`` and (if ``zero_as_utc`` is
|
||||
specified) offsets equivalent to UTC.
|
||||
"""
|
||||
return self._parse_tzstr(tzstr, zero_as_utc=zero_as_utc)
|
||||
|
||||
# Constants
|
||||
_MICROSECOND_END_REGEX = re.compile(b'[-+Z]+')
|
||||
_DATE_SEP = b'-'
|
||||
_TIME_SEP = b':'
|
||||
_MICRO_SEP = b'.'
|
||||
|
||||
def _parse_isodate(self, dt_str):
|
||||
try:
|
||||
return self._parse_isodate_common(dt_str)
|
||||
except ValueError:
|
||||
return self._parse_isodate_uncommon(dt_str)
|
||||
|
||||
def _parse_isodate_common(self, dt_str):
|
||||
len_str = len(dt_str)
|
||||
components = [1, 1, 1]
|
||||
|
||||
if len_str < 4:
|
||||
raise ValueError('ISO string too short')
|
||||
|
||||
# Year
|
||||
components[0] = int(dt_str[0:4])
|
||||
pos = 4
|
||||
if pos >= len_str:
|
||||
return components, pos
|
||||
|
||||
has_sep = dt_str[pos:pos + 1] == self._DATE_SEP
|
||||
if has_sep:
|
||||
pos += 1
|
||||
|
||||
# Month
|
||||
if len_str - pos < 2:
|
||||
raise ValueError('Invalid common month')
|
||||
|
||||
components[1] = int(dt_str[pos:pos + 2])
|
||||
pos += 2
|
||||
|
||||
if pos >= len_str:
|
||||
if has_sep:
|
||||
return components, pos
|
||||
else:
|
||||
raise ValueError('Invalid ISO format')
|
||||
|
||||
if has_sep:
|
||||
if dt_str[pos:pos + 1] != self._DATE_SEP:
|
||||
raise ValueError('Invalid separator in ISO string')
|
||||
pos += 1
|
||||
|
||||
# Day
|
||||
if len_str - pos < 2:
|
||||
raise ValueError('Invalid common day')
|
||||
components[2] = int(dt_str[pos:pos + 2])
|
||||
return components, pos + 2
|
||||
|
||||
def _parse_isodate_uncommon(self, dt_str):
|
||||
if len(dt_str) < 4:
|
||||
raise ValueError('ISO string too short')
|
||||
|
||||
# All ISO formats start with the year
|
||||
year = int(dt_str[0:4])
|
||||
|
||||
has_sep = dt_str[4:5] == self._DATE_SEP
|
||||
|
||||
pos = 4 + has_sep # Skip '-' if it's there
|
||||
if dt_str[pos:pos + 1] == b'W':
|
||||
# YYYY-?Www-?D?
|
||||
pos += 1
|
||||
weekno = int(dt_str[pos:pos + 2])
|
||||
pos += 2
|
||||
|
||||
dayno = 1
|
||||
if len(dt_str) > pos:
|
||||
if (dt_str[pos:pos + 1] == self._DATE_SEP) != has_sep:
|
||||
raise ValueError('Inconsistent use of dash separator')
|
||||
|
||||
pos += has_sep
|
||||
|
||||
dayno = int(dt_str[pos:pos + 1])
|
||||
pos += 1
|
||||
|
||||
base_date = self._calculate_weekdate(year, weekno, dayno)
|
||||
else:
|
||||
# YYYYDDD or YYYY-DDD
|
||||
if len(dt_str) - pos < 3:
|
||||
raise ValueError('Invalid ordinal day')
|
||||
|
||||
ordinal_day = int(dt_str[pos:pos + 3])
|
||||
pos += 3
|
||||
|
||||
if ordinal_day < 1 or ordinal_day > (365 + calendar.isleap(year)):
|
||||
raise ValueError('Invalid ordinal day' +
|
||||
' {} for year {}'.format(ordinal_day, year))
|
||||
|
||||
base_date = date(year, 1, 1) + timedelta(days=ordinal_day - 1)
|
||||
|
||||
components = [base_date.year, base_date.month, base_date.day]
|
||||
return components, pos
|
||||
|
||||
def _calculate_weekdate(self, year, week, day):
|
||||
"""
|
||||
Calculate the day of corresponding to the ISO year-week-day calendar.
|
||||
|
||||
This function is effectively the inverse of
|
||||
:func:`datetime.date.isocalendar`.
|
||||
|
||||
:param year:
|
||||
The year in the ISO calendar
|
||||
|
||||
:param week:
|
||||
The week in the ISO calendar - range is [1, 53]
|
||||
|
||||
:param day:
|
||||
The day in the ISO calendar - range is [1 (MON), 7 (SUN)]
|
||||
|
||||
:return:
|
||||
Returns a :class:`datetime.date`
|
||||
"""
|
||||
if not 0 < week < 54:
|
||||
raise ValueError('Invalid week: {}'.format(week))
|
||||
|
||||
if not 0 < day < 8: # Range is 1-7
|
||||
raise ValueError('Invalid weekday: {}'.format(day))
|
||||
|
||||
# Get week 1 for the specific year:
|
||||
jan_4 = date(year, 1, 4) # Week 1 always has January 4th in it
|
||||
week_1 = jan_4 - timedelta(days=jan_4.isocalendar()[2] - 1)
|
||||
|
||||
# Now add the specific number of weeks and days to get what we want
|
||||
week_offset = (week - 1) * 7 + (day - 1)
|
||||
return week_1 + timedelta(days=week_offset)
|
||||
|
||||
def _parse_isotime(self, timestr):
|
||||
len_str = len(timestr)
|
||||
components = [0, 0, 0, 0, None]
|
||||
pos = 0
|
||||
comp = -1
|
||||
|
||||
if len(timestr) < 2:
|
||||
raise ValueError('ISO time too short')
|
||||
|
||||
has_sep = len_str >= 3 and timestr[2:3] == self._TIME_SEP
|
||||
|
||||
while pos < len_str and comp < 5:
|
||||
comp += 1
|
||||
|
||||
if timestr[pos:pos + 1] in b'-+Z':
|
||||
# Detect time zone boundary
|
||||
components[-1] = self._parse_tzstr(timestr[pos:])
|
||||
pos = len_str
|
||||
break
|
||||
|
||||
if comp < 3:
|
||||
# Hour, minute, second
|
||||
components[comp] = int(timestr[pos:pos + 2])
|
||||
pos += 2
|
||||
if (has_sep and pos < len_str and
|
||||
timestr[pos:pos + 1] == self._TIME_SEP):
|
||||
pos += 1
|
||||
|
||||
if comp == 3:
|
||||
# Microsecond
|
||||
if timestr[pos:pos + 1] != self._MICRO_SEP:
|
||||
continue
|
||||
|
||||
pos += 1
|
||||
us_str = self._MICROSECOND_END_REGEX.split(timestr[pos:pos + 6],
|
||||
1)[0]
|
||||
|
||||
components[comp] = int(us_str) * 10**(6 - len(us_str))
|
||||
pos += len(us_str)
|
||||
|
||||
if pos < len_str:
|
||||
raise ValueError('Unused components in ISO string')
|
||||
|
||||
if components[0] == 24:
|
||||
# Standard supports 00:00 and 24:00 as representations of midnight
|
||||
if any(component != 0 for component in components[1:4]):
|
||||
raise ValueError('Hour may only be 24 at 24:00:00.000')
|
||||
components[0] = 0
|
||||
|
||||
return components
|
||||
|
||||
def _parse_tzstr(self, tzstr, zero_as_utc=True):
|
||||
if tzstr == b'Z':
|
||||
return tz.tzutc()
|
||||
|
||||
if len(tzstr) not in {3, 5, 6}:
|
||||
raise ValueError('Time zone offset must be 1, 3, 5 or 6 characters')
|
||||
|
||||
if tzstr[0:1] == b'-':
|
||||
mult = -1
|
||||
elif tzstr[0:1] == b'+':
|
||||
mult = 1
|
||||
else:
|
||||
raise ValueError('Time zone offset requires sign')
|
||||
|
||||
hours = int(tzstr[1:3])
|
||||
if len(tzstr) == 3:
|
||||
minutes = 0
|
||||
else:
|
||||
minutes = int(tzstr[(4 if tzstr[3:4] == self._TIME_SEP else 3):])
|
||||
|
||||
if zero_as_utc and hours == 0 and minutes == 0:
|
||||
return tz.tzutc()
|
||||
else:
|
||||
if minutes > 59:
|
||||
raise ValueError('Invalid minutes in time zone offset')
|
||||
|
||||
if hours > 23:
|
||||
raise ValueError('Invalid hours in time zone offset')
|
||||
|
||||
return tz.tzoffset(None, mult * (hours * 60 + minutes) * 60)
|
||||
|
||||
|
||||
DEFAULT_ISOPARSER = isoparser()
|
||||
isoparse = DEFAULT_ISOPARSER.isoparse
|
590
libraries/dateutil/relativedelta.py
Normal file
590
libraries/dateutil/relativedelta.py
Normal file
|
@ -0,0 +1,590 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import calendar
|
||||
|
||||
import operator
|
||||
from math import copysign
|
||||
|
||||
from six import integer_types
|
||||
from warnings import warn
|
||||
|
||||
from ._common import weekday
|
||||
|
||||
MO, TU, WE, TH, FR, SA, SU = weekdays = tuple(weekday(x) for x in range(7))
|
||||
|
||||
__all__ = ["relativedelta", "MO", "TU", "WE", "TH", "FR", "SA", "SU"]
|
||||
|
||||
|
||||
class relativedelta(object):
|
||||
"""
|
||||
The relativedelta type is based on the specification of the excellent
|
||||
work done by M.-A. Lemburg in his
|
||||
`mx.DateTime <https://www.egenix.com/products/python/mxBase/mxDateTime/>`_ extension.
|
||||
However, notice that this type does *NOT* implement the same algorithm as
|
||||
his work. Do *NOT* expect it to behave like mx.DateTime's counterpart.
|
||||
|
||||
There are two different ways to build a relativedelta instance. The
|
||||
first one is passing it two date/datetime classes::
|
||||
|
||||
relativedelta(datetime1, datetime2)
|
||||
|
||||
The second one is passing it any number of the following keyword arguments::
|
||||
|
||||
relativedelta(arg1=x,arg2=y,arg3=z...)
|
||||
|
||||
year, month, day, hour, minute, second, microsecond:
|
||||
Absolute information (argument is singular); adding or subtracting a
|
||||
relativedelta with absolute information does not perform an arithmetic
|
||||
operation, but rather REPLACES the corresponding value in the
|
||||
original datetime with the value(s) in relativedelta.
|
||||
|
||||
years, months, weeks, days, hours, minutes, seconds, microseconds:
|
||||
Relative information, may be negative (argument is plural); adding
|
||||
or subtracting a relativedelta with relative information performs
|
||||
the corresponding aritmetic operation on the original datetime value
|
||||
with the information in the relativedelta.
|
||||
|
||||
weekday:
|
||||
One of the weekday instances (MO, TU, etc). These
|
||||
instances may receive a parameter N, specifying the Nth
|
||||
weekday, which could be positive or negative (like MO(+1)
|
||||
or MO(-2). Not specifying it is the same as specifying
|
||||
+1. You can also use an integer, where 0=MO. Notice that
|
||||
if the calculated date is already Monday, for example,
|
||||
using MO(1) or MO(-1) won't change the day.
|
||||
|
||||
leapdays:
|
||||
Will add given days to the date found, if year is a leap
|
||||
year, and the date found is post 28 of february.
|
||||
|
||||
yearday, nlyearday:
|
||||
Set the yearday or the non-leap year day (jump leap days).
|
||||
These are converted to day/month/leapdays information.
|
||||
|
||||
There are relative and absolute forms of the keyword
|
||||
arguments. The plural is relative, and the singular is
|
||||
absolute. For each argument in the order below, the absolute form
|
||||
is applied first (by setting each attribute to that value) and
|
||||
then the relative form (by adding the value to the attribute).
|
||||
|
||||
The order of attributes considered when this relativedelta is
|
||||
added to a datetime is:
|
||||
|
||||
1. Year
|
||||
2. Month
|
||||
3. Day
|
||||
4. Hours
|
||||
5. Minutes
|
||||
6. Seconds
|
||||
7. Microseconds
|
||||
|
||||
Finally, weekday is applied, using the rule described above.
|
||||
|
||||
For example
|
||||
|
||||
>>> dt = datetime(2018, 4, 9, 13, 37, 0)
|
||||
>>> delta = relativedelta(hours=25, day=1, weekday=MO(1))
|
||||
datetime(2018, 4, 2, 14, 37, 0)
|
||||
|
||||
First, the day is set to 1 (the first of the month), then 25 hours
|
||||
are added, to get to the 2nd day and 14th hour, finally the
|
||||
weekday is applied, but since the 2nd is already a Monday there is
|
||||
no effect.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, dt1=None, dt2=None,
|
||||
years=0, months=0, days=0, leapdays=0, weeks=0,
|
||||
hours=0, minutes=0, seconds=0, microseconds=0,
|
||||
year=None, month=None, day=None, weekday=None,
|
||||
yearday=None, nlyearday=None,
|
||||
hour=None, minute=None, second=None, microsecond=None):
|
||||
|
||||
if dt1 and dt2:
|
||||
# datetime is a subclass of date. So both must be date
|
||||
if not (isinstance(dt1, datetime.date) and
|
||||
isinstance(dt2, datetime.date)):
|
||||
raise TypeError("relativedelta only diffs datetime/date")
|
||||
|
||||
# We allow two dates, or two datetimes, so we coerce them to be
|
||||
# of the same type
|
||||
if (isinstance(dt1, datetime.datetime) !=
|
||||
isinstance(dt2, datetime.datetime)):
|
||||
if not isinstance(dt1, datetime.datetime):
|
||||
dt1 = datetime.datetime.fromordinal(dt1.toordinal())
|
||||
elif not isinstance(dt2, datetime.datetime):
|
||||
dt2 = datetime.datetime.fromordinal(dt2.toordinal())
|
||||
|
||||
self.years = 0
|
||||
self.months = 0
|
||||
self.days = 0
|
||||
self.leapdays = 0
|
||||
self.hours = 0
|
||||
self.minutes = 0
|
||||
self.seconds = 0
|
||||
self.microseconds = 0
|
||||
self.year = None
|
||||
self.month = None
|
||||
self.day = None
|
||||
self.weekday = None
|
||||
self.hour = None
|
||||
self.minute = None
|
||||
self.second = None
|
||||
self.microsecond = None
|
||||
self._has_time = 0
|
||||
|
||||
# Get year / month delta between the two
|
||||
months = (dt1.year - dt2.year) * 12 + (dt1.month - dt2.month)
|
||||
self._set_months(months)
|
||||
|
||||
# Remove the year/month delta so the timedelta is just well-defined
|
||||
# time units (seconds, days and microseconds)
|
||||
dtm = self.__radd__(dt2)
|
||||
|
||||
# If we've overshot our target, make an adjustment
|
||||
if dt1 < dt2:
|
||||
compare = operator.gt
|
||||
increment = 1
|
||||
else:
|
||||
compare = operator.lt
|
||||
increment = -1
|
||||
|
||||
while compare(dt1, dtm):
|
||||
months += increment
|
||||
self._set_months(months)
|
||||
dtm = self.__radd__(dt2)
|
||||
|
||||
# Get the timedelta between the "months-adjusted" date and dt1
|
||||
delta = dt1 - dtm
|
||||
self.seconds = delta.seconds + delta.days * 86400
|
||||
self.microseconds = delta.microseconds
|
||||
else:
|
||||
# Check for non-integer values in integer-only quantities
|
||||
if any(x is not None and x != int(x) for x in (years, months)):
|
||||
raise ValueError("Non-integer years and months are "
|
||||
"ambiguous and not currently supported.")
|
||||
|
||||
# Relative information
|
||||
self.years = int(years)
|
||||
self.months = int(months)
|
||||
self.days = days + weeks * 7
|
||||
self.leapdays = leapdays
|
||||
self.hours = hours
|
||||
self.minutes = minutes
|
||||
self.seconds = seconds
|
||||
self.microseconds = microseconds
|
||||
|
||||
# Absolute information
|
||||
self.year = year
|
||||
self.month = month
|
||||
self.day = day
|
||||
self.hour = hour
|
||||
self.minute = minute
|
||||
self.second = second
|
||||
self.microsecond = microsecond
|
||||
|
||||
if any(x is not None and int(x) != x
|
||||
for x in (year, month, day, hour,
|
||||
minute, second, microsecond)):
|
||||
# For now we'll deprecate floats - later it'll be an error.
|
||||
warn("Non-integer value passed as absolute information. " +
|
||||
"This is not a well-defined condition and will raise " +
|
||||
"errors in future versions.", DeprecationWarning)
|
||||
|
||||
if isinstance(weekday, integer_types):
|
||||
self.weekday = weekdays[weekday]
|
||||
else:
|
||||
self.weekday = weekday
|
||||
|
||||
yday = 0
|
||||
if nlyearday:
|
||||
yday = nlyearday
|
||||
elif yearday:
|
||||
yday = yearday
|
||||
if yearday > 59:
|
||||
self.leapdays = -1
|
||||
if yday:
|
||||
ydayidx = [31, 59, 90, 120, 151, 181, 212,
|
||||
243, 273, 304, 334, 366]
|
||||
for idx, ydays in enumerate(ydayidx):
|
||||
if yday <= ydays:
|
||||
self.month = idx+1
|
||||
if idx == 0:
|
||||
self.day = yday
|
||||
else:
|
||||
self.day = yday-ydayidx[idx-1]
|
||||
break
|
||||
else:
|
||||
raise ValueError("invalid year day (%d)" % yday)
|
||||
|
||||
self._fix()
|
||||
|
||||
def _fix(self):
|
||||
if abs(self.microseconds) > 999999:
|
||||
s = _sign(self.microseconds)
|
||||
div, mod = divmod(self.microseconds * s, 1000000)
|
||||
self.microseconds = mod * s
|
||||
self.seconds += div * s
|
||||
if abs(self.seconds) > 59:
|
||||
s = _sign(self.seconds)
|
||||
div, mod = divmod(self.seconds * s, 60)
|
||||
self.seconds = mod * s
|
||||
self.minutes += div * s
|
||||
if abs(self.minutes) > 59:
|
||||
s = _sign(self.minutes)
|
||||
div, mod = divmod(self.minutes * s, 60)
|
||||
self.minutes = mod * s
|
||||
self.hours += div * s
|
||||
if abs(self.hours) > 23:
|
||||
s = _sign(self.hours)
|
||||
div, mod = divmod(self.hours * s, 24)
|
||||
self.hours = mod * s
|
||||
self.days += div * s
|
||||
if abs(self.months) > 11:
|
||||
s = _sign(self.months)
|
||||
div, mod = divmod(self.months * s, 12)
|
||||
self.months = mod * s
|
||||
self.years += div * s
|
||||
if (self.hours or self.minutes or self.seconds or self.microseconds
|
||||
or self.hour is not None or self.minute is not None or
|
||||
self.second is not None or self.microsecond is not None):
|
||||
self._has_time = 1
|
||||
else:
|
||||
self._has_time = 0
|
||||
|
||||
@property
|
||||
def weeks(self):
|
||||
return int(self.days / 7.0)
|
||||
|
||||
@weeks.setter
|
||||
def weeks(self, value):
|
||||
self.days = self.days - (self.weeks * 7) + value * 7
|
||||
|
||||
def _set_months(self, months):
|
||||
self.months = months
|
||||
if abs(self.months) > 11:
|
||||
s = _sign(self.months)
|
||||
div, mod = divmod(self.months * s, 12)
|
||||
self.months = mod * s
|
||||
self.years = div * s
|
||||
else:
|
||||
self.years = 0
|
||||
|
||||
def normalized(self):
|
||||
"""
|
||||
Return a version of this object represented entirely using integer
|
||||
values for the relative attributes.
|
||||
|
||||
>>> relativedelta(days=1.5, hours=2).normalized()
|
||||
relativedelta(days=1, hours=14)
|
||||
|
||||
:return:
|
||||
Returns a :class:`dateutil.relativedelta.relativedelta` object.
|
||||
"""
|
||||
# Cascade remainders down (rounding each to roughly nearest microsecond)
|
||||
days = int(self.days)
|
||||
|
||||
hours_f = round(self.hours + 24 * (self.days - days), 11)
|
||||
hours = int(hours_f)
|
||||
|
||||
minutes_f = round(self.minutes + 60 * (hours_f - hours), 10)
|
||||
minutes = int(minutes_f)
|
||||
|
||||
seconds_f = round(self.seconds + 60 * (minutes_f - minutes), 8)
|
||||
seconds = int(seconds_f)
|
||||
|
||||
microseconds = round(self.microseconds + 1e6 * (seconds_f - seconds))
|
||||
|
||||
# Constructor carries overflow back up with call to _fix()
|
||||
return self.__class__(years=self.years, months=self.months,
|
||||
days=days, hours=hours, minutes=minutes,
|
||||
seconds=seconds, microseconds=microseconds,
|
||||
leapdays=self.leapdays, year=self.year,
|
||||
month=self.month, day=self.day,
|
||||
weekday=self.weekday, hour=self.hour,
|
||||
minute=self.minute, second=self.second,
|
||||
microsecond=self.microsecond)
|
||||
|
||||
def __add__(self, other):
|
||||
if isinstance(other, relativedelta):
|
||||
return self.__class__(years=other.years + self.years,
|
||||
months=other.months + self.months,
|
||||
days=other.days + self.days,
|
||||
hours=other.hours + self.hours,
|
||||
minutes=other.minutes + self.minutes,
|
||||
seconds=other.seconds + self.seconds,
|
||||
microseconds=(other.microseconds +
|
||||
self.microseconds),
|
||||
leapdays=other.leapdays or self.leapdays,
|
||||
year=(other.year if other.year is not None
|
||||
else self.year),
|
||||
month=(other.month if other.month is not None
|
||||
else self.month),
|
||||
day=(other.day if other.day is not None
|
||||
else self.day),
|
||||
weekday=(other.weekday if other.weekday is not None
|
||||
else self.weekday),
|
||||
hour=(other.hour if other.hour is not None
|
||||
else self.hour),
|
||||
minute=(other.minute if other.minute is not None
|
||||
else self.minute),
|
||||
second=(other.second if other.second is not None
|
||||
else self.second),
|
||||
microsecond=(other.microsecond if other.microsecond
|
||||
is not None else
|
||||
self.microsecond))
|
||||
if isinstance(other, datetime.timedelta):
|
||||
return self.__class__(years=self.years,
|
||||
months=self.months,
|
||||
days=self.days + other.days,
|
||||
hours=self.hours,
|
||||
minutes=self.minutes,
|
||||
seconds=self.seconds + other.seconds,
|
||||
microseconds=self.microseconds + other.microseconds,
|
||||
leapdays=self.leapdays,
|
||||
year=self.year,
|
||||
month=self.month,
|
||||
day=self.day,
|
||||
weekday=self.weekday,
|
||||
hour=self.hour,
|
||||
minute=self.minute,
|
||||
second=self.second,
|
||||
microsecond=self.microsecond)
|
||||
if not isinstance(other, datetime.date):
|
||||
return NotImplemented
|
||||
elif self._has_time and not isinstance(other, datetime.datetime):
|
||||
other = datetime.datetime.fromordinal(other.toordinal())
|
||||
year = (self.year or other.year)+self.years
|
||||
month = self.month or other.month
|
||||
if self.months:
|
||||
assert 1 <= abs(self.months) <= 12
|
||||
month += self.months
|
||||
if month > 12:
|
||||
year += 1
|
||||
month -= 12
|
||||
elif month < 1:
|
||||
year -= 1
|
||||
month += 12
|
||||
day = min(calendar.monthrange(year, month)[1],
|
||||
self.day or other.day)
|
||||
repl = {"year": year, "month": month, "day": day}
|
||||
for attr in ["hour", "minute", "second", "microsecond"]:
|
||||
value = getattr(self, attr)
|
||||
if value is not None:
|
||||
repl[attr] = value
|
||||
days = self.days
|
||||
if self.leapdays and month > 2 and calendar.isleap(year):
|
||||
days += self.leapdays
|
||||
ret = (other.replace(**repl)
|
||||
+ datetime.timedelta(days=days,
|
||||
hours=self.hours,
|
||||
minutes=self.minutes,
|
||||
seconds=self.seconds,
|
||||
microseconds=self.microseconds))
|
||||
if self.weekday:
|
||||
weekday, nth = self.weekday.weekday, self.weekday.n or 1
|
||||
jumpdays = (abs(nth) - 1) * 7
|
||||
if nth > 0:
|
||||
jumpdays += (7 - ret.weekday() + weekday) % 7
|
||||
else:
|
||||
jumpdays += (ret.weekday() - weekday) % 7
|
||||
jumpdays *= -1
|
||||
ret += datetime.timedelta(days=jumpdays)
|
||||
return ret
|
||||
|
||||
def __radd__(self, other):
|
||||
return self.__add__(other)
|
||||
|
||||
def __rsub__(self, other):
|
||||
return self.__neg__().__radd__(other)
|
||||
|
||||
def __sub__(self, other):
|
||||
if not isinstance(other, relativedelta):
|
||||
return NotImplemented # In case the other object defines __rsub__
|
||||
return self.__class__(years=self.years - other.years,
|
||||
months=self.months - other.months,
|
||||
days=self.days - other.days,
|
||||
hours=self.hours - other.hours,
|
||||
minutes=self.minutes - other.minutes,
|
||||
seconds=self.seconds - other.seconds,
|
||||
microseconds=self.microseconds - other.microseconds,
|
||||
leapdays=self.leapdays or other.leapdays,
|
||||
year=(self.year if self.year is not None
|
||||
else other.year),
|
||||
month=(self.month if self.month is not None else
|
||||
other.month),
|
||||
day=(self.day if self.day is not None else
|
||||
other.day),
|
||||
weekday=(self.weekday if self.weekday is not None else
|
||||
other.weekday),
|
||||
hour=(self.hour if self.hour is not None else
|
||||
other.hour),
|
||||
minute=(self.minute if self.minute is not None else
|
||||
other.minute),
|
||||
second=(self.second if self.second is not None else
|
||||
other.second),
|
||||
microsecond=(self.microsecond if self.microsecond
|
||||
is not None else
|
||||
other.microsecond))
|
||||
|
||||
def __abs__(self):
|
||||
return self.__class__(years=abs(self.years),
|
||||
months=abs(self.months),
|
||||
days=abs(self.days),
|
||||
hours=abs(self.hours),
|
||||
minutes=abs(self.minutes),
|
||||
seconds=abs(self.seconds),
|
||||
microseconds=abs(self.microseconds),
|
||||
leapdays=self.leapdays,
|
||||
year=self.year,
|
||||
month=self.month,
|
||||
day=self.day,
|
||||
weekday=self.weekday,
|
||||
hour=self.hour,
|
||||
minute=self.minute,
|
||||
second=self.second,
|
||||
microsecond=self.microsecond)
|
||||
|
||||
def __neg__(self):
|
||||
return self.__class__(years=-self.years,
|
||||
months=-self.months,
|
||||
days=-self.days,
|
||||
hours=-self.hours,
|
||||
minutes=-self.minutes,
|
||||
seconds=-self.seconds,
|
||||
microseconds=-self.microseconds,
|
||||
leapdays=self.leapdays,
|
||||
year=self.year,
|
||||
month=self.month,
|
||||
day=self.day,
|
||||
weekday=self.weekday,
|
||||
hour=self.hour,
|
||||
minute=self.minute,
|
||||
second=self.second,
|
||||
microsecond=self.microsecond)
|
||||
|
||||
def __bool__(self):
|
||||
return not (not self.years and
|
||||
not self.months and
|
||||
not self.days and
|
||||
not self.hours and
|
||||
not self.minutes and
|
||||
not self.seconds and
|
||||
not self.microseconds and
|
||||
not self.leapdays and
|
||||
self.year is None and
|
||||
self.month is None and
|
||||
self.day is None and
|
||||
self.weekday is None and
|
||||
self.hour is None and
|
||||
self.minute is None and
|
||||
self.second is None and
|
||||
self.microsecond is None)
|
||||
# Compatibility with Python 2.x
|
||||
__nonzero__ = __bool__
|
||||
|
||||
def __mul__(self, other):
|
||||
try:
|
||||
f = float(other)
|
||||
except TypeError:
|
||||
return NotImplemented
|
||||
|
||||
return self.__class__(years=int(self.years * f),
|
||||
months=int(self.months * f),
|
||||
days=int(self.days * f),
|
||||
hours=int(self.hours * f),
|
||||
minutes=int(self.minutes * f),
|
||||
seconds=int(self.seconds * f),
|
||||
microseconds=int(self.microseconds * f),
|
||||
leapdays=self.leapdays,
|
||||
year=self.year,
|
||||
month=self.month,
|
||||
day=self.day,
|
||||
weekday=self.weekday,
|
||||
hour=self.hour,
|
||||
minute=self.minute,
|
||||
second=self.second,
|
||||
microsecond=self.microsecond)
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, relativedelta):
|
||||
return NotImplemented
|
||||
if self.weekday or other.weekday:
|
||||
if not self.weekday or not other.weekday:
|
||||
return False
|
||||
if self.weekday.weekday != other.weekday.weekday:
|
||||
return False
|
||||
n1, n2 = self.weekday.n, other.weekday.n
|
||||
if n1 != n2 and not ((not n1 or n1 == 1) and (not n2 or n2 == 1)):
|
||||
return False
|
||||
return (self.years == other.years and
|
||||
self.months == other.months and
|
||||
self.days == other.days and
|
||||
self.hours == other.hours and
|
||||
self.minutes == other.minutes and
|
||||
self.seconds == other.seconds and
|
||||
self.microseconds == other.microseconds and
|
||||
self.leapdays == other.leapdays and
|
||||
self.year == other.year and
|
||||
self.month == other.month and
|
||||
self.day == other.day and
|
||||
self.hour == other.hour and
|
||||
self.minute == other.minute and
|
||||
self.second == other.second and
|
||||
self.microsecond == other.microsecond)
|
||||
|
||||
def __hash__(self):
|
||||
return hash((
|
||||
self.weekday,
|
||||
self.years,
|
||||
self.months,
|
||||
self.days,
|
||||
self.hours,
|
||||
self.minutes,
|
||||
self.seconds,
|
||||
self.microseconds,
|
||||
self.leapdays,
|
||||
self.year,
|
||||
self.month,
|
||||
self.day,
|
||||
self.hour,
|
||||
self.minute,
|
||||
self.second,
|
||||
self.microsecond,
|
||||
))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __div__(self, other):
|
||||
try:
|
||||
reciprocal = 1 / float(other)
|
||||
except TypeError:
|
||||
return NotImplemented
|
||||
|
||||
return self.__mul__(reciprocal)
|
||||
|
||||
__truediv__ = __div__
|
||||
|
||||
def __repr__(self):
|
||||
l = []
|
||||
for attr in ["years", "months", "days", "leapdays",
|
||||
"hours", "minutes", "seconds", "microseconds"]:
|
||||
value = getattr(self, attr)
|
||||
if value:
|
||||
l.append("{attr}={value:+g}".format(attr=attr, value=value))
|
||||
for attr in ["year", "month", "day", "weekday",
|
||||
"hour", "minute", "second", "microsecond"]:
|
||||
value = getattr(self, attr)
|
||||
if value is not None:
|
||||
l.append("{attr}={value}".format(attr=attr, value=repr(value)))
|
||||
return "{classname}({attrs})".format(classname=self.__class__.__name__,
|
||||
attrs=", ".join(l))
|
||||
|
||||
|
||||
def _sign(x):
|
||||
return int(copysign(1, x))
|
||||
|
||||
# vim:ts=4:sw=4:et
|
1672
libraries/dateutil/rrule.py
Normal file
1672
libraries/dateutil/rrule.py
Normal file
File diff suppressed because it is too large
Load diff
0
libraries/dateutil/test/__init__.py
Normal file
0
libraries/dateutil/test/__init__.py
Normal file
275
libraries/dateutil/test/_common.py
Normal file
275
libraries/dateutil/test/_common.py
Normal file
|
@ -0,0 +1,275 @@
|
|||
from __future__ import unicode_literals
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import warnings
|
||||
import tempfile
|
||||
import pickle
|
||||
|
||||
|
||||
class WarningTestMixin(object):
|
||||
# Based on https://stackoverflow.com/a/12935176/467366
|
||||
class _AssertWarnsContext(warnings.catch_warnings):
|
||||
def __init__(self, expected_warnings, parent, **kwargs):
|
||||
super(WarningTestMixin._AssertWarnsContext, self).__init__(**kwargs)
|
||||
|
||||
self.parent = parent
|
||||
try:
|
||||
self.expected_warnings = list(expected_warnings)
|
||||
except TypeError:
|
||||
self.expected_warnings = [expected_warnings]
|
||||
|
||||
self._warning_log = []
|
||||
|
||||
def __enter__(self, *args, **kwargs):
|
||||
rv = super(WarningTestMixin._AssertWarnsContext, self).__enter__(*args, **kwargs)
|
||||
|
||||
if self._showwarning is not self._module.showwarning:
|
||||
super_showwarning = self._module.showwarning
|
||||
else:
|
||||
super_showwarning = None
|
||||
|
||||
def showwarning(*args, **kwargs):
|
||||
if super_showwarning is not None:
|
||||
super_showwarning(*args, **kwargs)
|
||||
|
||||
self._warning_log.append(warnings.WarningMessage(*args, **kwargs))
|
||||
|
||||
self._module.showwarning = showwarning
|
||||
return rv
|
||||
|
||||
def __exit__(self, *args, **kwargs):
|
||||
super(WarningTestMixin._AssertWarnsContext, self).__exit__(self, *args, **kwargs)
|
||||
|
||||
self.parent.assertTrue(any(issubclass(item.category, warning)
|
||||
for warning in self.expected_warnings
|
||||
for item in self._warning_log))
|
||||
|
||||
def assertWarns(self, warning, callable=None, *args, **kwargs):
|
||||
warnings.simplefilter('always')
|
||||
context = self.__class__._AssertWarnsContext(warning, self)
|
||||
if callable is None:
|
||||
return context
|
||||
else:
|
||||
with context:
|
||||
callable(*args, **kwargs)
|
||||
|
||||
|
||||
class PicklableMixin(object):
|
||||
def _get_nobj_bytes(self, obj, dump_kwargs, load_kwargs):
|
||||
"""
|
||||
Pickle and unpickle an object using ``pickle.dumps`` / ``pickle.loads``
|
||||
"""
|
||||
pkl = pickle.dumps(obj, **dump_kwargs)
|
||||
return pickle.loads(pkl, **load_kwargs)
|
||||
|
||||
def _get_nobj_file(self, obj, dump_kwargs, load_kwargs):
|
||||
"""
|
||||
Pickle and unpickle an object using ``pickle.dump`` / ``pickle.load`` on
|
||||
a temporary file.
|
||||
"""
|
||||
with tempfile.TemporaryFile('w+b') as pkl:
|
||||
pickle.dump(obj, pkl, **dump_kwargs)
|
||||
pkl.seek(0) # Reset the file to the beginning to read it
|
||||
nobj = pickle.load(pkl, **load_kwargs)
|
||||
|
||||
return nobj
|
||||
|
||||
def assertPicklable(self, obj, singleton=False, asfile=False,
|
||||
dump_kwargs=None, load_kwargs=None):
|
||||
"""
|
||||
Assert that an object can be pickled and unpickled. This assertion
|
||||
assumes that the desired behavior is that the unpickled object compares
|
||||
equal to the original object, but is not the same object.
|
||||
"""
|
||||
get_nobj = self._get_nobj_file if asfile else self._get_nobj_bytes
|
||||
dump_kwargs = dump_kwargs or {}
|
||||
load_kwargs = load_kwargs or {}
|
||||
|
||||
nobj = get_nobj(obj, dump_kwargs, load_kwargs)
|
||||
if not singleton:
|
||||
self.assertIsNot(obj, nobj)
|
||||
self.assertEqual(obj, nobj)
|
||||
|
||||
|
||||
class TZContextBase(object):
|
||||
"""
|
||||
Base class for a context manager which allows changing of time zones.
|
||||
|
||||
Subclasses may define a guard variable to either block or or allow time
|
||||
zone changes by redefining ``_guard_var_name`` and ``_guard_allows_change``.
|
||||
The default is that the guard variable must be affirmatively set.
|
||||
|
||||
Subclasses must define ``get_current_tz`` and ``set_current_tz``.
|
||||
"""
|
||||
_guard_var_name = "DATEUTIL_MAY_CHANGE_TZ"
|
||||
_guard_allows_change = True
|
||||
|
||||
def __init__(self, tzval):
|
||||
self.tzval = tzval
|
||||
self._old_tz = None
|
||||
|
||||
@classmethod
|
||||
def tz_change_allowed(cls):
|
||||
"""
|
||||
Class method used to query whether or not this class allows time zone
|
||||
changes.
|
||||
"""
|
||||
guard = bool(os.environ.get(cls._guard_var_name, False))
|
||||
|
||||
# _guard_allows_change gives the "default" behavior - if True, the
|
||||
# guard is overcoming a block. If false, the guard is causing a block.
|
||||
# Whether tz_change is allowed is therefore the XNOR of the two.
|
||||
return guard == cls._guard_allows_change
|
||||
|
||||
@classmethod
|
||||
def tz_change_disallowed_message(cls):
|
||||
""" Generate instructions on how to allow tz changes """
|
||||
msg = ('Changing time zone not allowed. Set {envar} to {gval} '
|
||||
'if you would like to allow this behavior')
|
||||
|
||||
return msg.format(envar=cls._guard_var_name,
|
||||
gval=cls._guard_allows_change)
|
||||
|
||||
def __enter__(self):
|
||||
if not self.tz_change_allowed():
|
||||
raise ValueError(self.tz_change_disallowed_message())
|
||||
|
||||
self._old_tz = self.get_current_tz()
|
||||
self.set_current_tz(self.tzval)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
if self._old_tz is not None:
|
||||
self.set_current_tz(self._old_tz)
|
||||
|
||||
self._old_tz = None
|
||||
|
||||
def get_current_tz(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def set_current_tz(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class TZEnvContext(TZContextBase):
|
||||
"""
|
||||
Context manager that temporarily sets the `TZ` variable (for use on
|
||||
*nix-like systems). Because the effect is local to the shell anyway, this
|
||||
will apply *unless* a guard is set.
|
||||
|
||||
If you do not want the TZ environment variable set, you may set the
|
||||
``DATEUTIL_MAY_NOT_CHANGE_TZ_VAR`` variable to a truthy value.
|
||||
"""
|
||||
_guard_var_name = "DATEUTIL_MAY_NOT_CHANGE_TZ_VAR"
|
||||
_guard_allows_change = False
|
||||
|
||||
def get_current_tz(self):
|
||||
return os.environ.get('TZ', UnsetTz)
|
||||
|
||||
def set_current_tz(self, tzval):
|
||||
if tzval is UnsetTz and 'TZ' in os.environ:
|
||||
del os.environ['TZ']
|
||||
else:
|
||||
os.environ['TZ'] = tzval
|
||||
|
||||
time.tzset()
|
||||
|
||||
|
||||
class TZWinContext(TZContextBase):
|
||||
"""
|
||||
Context manager for changing local time zone on Windows.
|
||||
|
||||
Because the effect of this is system-wide and global, it may have
|
||||
unintended side effect. Set the ``DATEUTIL_MAY_CHANGE_TZ`` environment
|
||||
variable to a truthy value before using this context manager.
|
||||
"""
|
||||
def get_current_tz(self):
|
||||
p = subprocess.Popen(['tzutil', '/g'], stdout=subprocess.PIPE)
|
||||
|
||||
ctzname, err = p.communicate()
|
||||
ctzname = ctzname.decode() # Popen returns
|
||||
|
||||
if p.returncode:
|
||||
raise OSError('Failed to get current time zone: ' + err)
|
||||
|
||||
return ctzname
|
||||
|
||||
def set_current_tz(self, tzname):
|
||||
p = subprocess.Popen('tzutil /s "' + tzname + '"')
|
||||
|
||||
out, err = p.communicate()
|
||||
|
||||
if p.returncode:
|
||||
raise OSError('Failed to set current time zone: ' +
|
||||
(err or 'Unknown error.'))
|
||||
|
||||
|
||||
###
|
||||
# Utility classes
|
||||
class NotAValueClass(object):
|
||||
"""
|
||||
A class analogous to NaN that has operations defined for any type.
|
||||
"""
|
||||
def _op(self, other):
|
||||
return self # Operation with NotAValue returns NotAValue
|
||||
|
||||
def _cmp(self, other):
|
||||
return False
|
||||
|
||||
__add__ = __radd__ = _op
|
||||
__sub__ = __rsub__ = _op
|
||||
__mul__ = __rmul__ = _op
|
||||
__div__ = __rdiv__ = _op
|
||||
__truediv__ = __rtruediv__ = _op
|
||||
__floordiv__ = __rfloordiv__ = _op
|
||||
|
||||
__lt__ = __rlt__ = _op
|
||||
__gt__ = __rgt__ = _op
|
||||
__eq__ = __req__ = _op
|
||||
__le__ = __rle__ = _op
|
||||
__ge__ = __rge__ = _op
|
||||
|
||||
|
||||
NotAValue = NotAValueClass()
|
||||
|
||||
|
||||
class ComparesEqualClass(object):
|
||||
"""
|
||||
A class that is always equal to whatever you compare it to.
|
||||
"""
|
||||
|
||||
def __eq__(self, other):
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
return False
|
||||
|
||||
def __le__(self, other):
|
||||
return True
|
||||
|
||||
def __ge__(self, other):
|
||||
return True
|
||||
|
||||
def __lt__(self, other):
|
||||
return False
|
||||
|
||||
def __gt__(self, other):
|
||||
return False
|
||||
|
||||
__req__ = __eq__
|
||||
__rne__ = __ne__
|
||||
__rle__ = __le__
|
||||
__rge__ = __ge__
|
||||
__rlt__ = __lt__
|
||||
__rgt__ = __gt__
|
||||
|
||||
|
||||
ComparesEqual = ComparesEqualClass()
|
||||
|
||||
|
||||
class UnsetTzClass(object):
|
||||
""" Sentinel class for unset time zone variable """
|
||||
pass
|
||||
|
||||
|
||||
UnsetTz = UnsetTzClass()
|
27
libraries/dateutil/test/property/test_isoparse_prop.py
Normal file
27
libraries/dateutil/test/property/test_isoparse_prop.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from hypothesis import given, assume
|
||||
from hypothesis import strategies as st
|
||||
|
||||
from dateutil import tz
|
||||
from dateutil.parser import isoparse
|
||||
|
||||
import pytest
|
||||
|
||||
# Strategies
|
||||
TIME_ZONE_STRATEGY = st.sampled_from([None, tz.tzutc()] +
|
||||
[tz.gettz(zname) for zname in ('US/Eastern', 'US/Pacific',
|
||||
'Australia/Sydney', 'Europe/London')])
|
||||
ASCII_STRATEGY = st.characters(max_codepoint=127)
|
||||
|
||||
|
||||
@pytest.mark.isoparser
|
||||
@given(dt=st.datetimes(timezones=TIME_ZONE_STRATEGY), sep=ASCII_STRATEGY)
|
||||
def test_timespec_auto(dt, sep):
|
||||
if dt.tzinfo is not None:
|
||||
# Assume offset has no sub-second components
|
||||
assume(dt.utcoffset().total_seconds() % 60 == 0)
|
||||
|
||||
sep = str(sep) # Python 2.7 requires bytes
|
||||
dtstr = dt.isoformat(sep=sep)
|
||||
dt_rt = isoparse(dtstr)
|
||||
|
||||
assert dt_rt == dt
|
22
libraries/dateutil/test/property/test_parser_prop.py
Normal file
22
libraries/dateutil/test/property/test_parser_prop.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from hypothesis.strategies import integers
|
||||
from hypothesis import given
|
||||
|
||||
import pytest
|
||||
|
||||
from dateutil.parser import parserinfo
|
||||
|
||||
|
||||
@pytest.mark.parserinfo
|
||||
@given(integers(min_value=100, max_value=9999))
|
||||
def test_convertyear(n):
|
||||
assert n == parserinfo().convertyear(n)
|
||||
|
||||
|
||||
@pytest.mark.parserinfo
|
||||
@given(integers(min_value=-50,
|
||||
max_value=49))
|
||||
def test_convertyear_no_specified_century(n):
|
||||
p = parserinfo()
|
||||
new_year = p._year + n
|
||||
result = p.convertyear(new_year % 100, century_specified=False)
|
||||
assert result == new_year
|
95
libraries/dateutil/test/test_easter.py
Normal file
95
libraries/dateutil/test/test_easter.py
Normal file
|
@ -0,0 +1,95 @@
|
|||
from dateutil.easter import easter
|
||||
from dateutil.easter import EASTER_WESTERN, EASTER_ORTHODOX, EASTER_JULIAN
|
||||
|
||||
from datetime import date
|
||||
import unittest
|
||||
|
||||
# List of easters between 1990 and 2050
|
||||
western_easter_dates = [
|
||||
date(1990, 4, 15), date(1991, 3, 31), date(1992, 4, 19), date(1993, 4, 11),
|
||||
date(1994, 4, 3), date(1995, 4, 16), date(1996, 4, 7), date(1997, 3, 30),
|
||||
date(1998, 4, 12), date(1999, 4, 4),
|
||||
|
||||
date(2000, 4, 23), date(2001, 4, 15), date(2002, 3, 31), date(2003, 4, 20),
|
||||
date(2004, 4, 11), date(2005, 3, 27), date(2006, 4, 16), date(2007, 4, 8),
|
||||
date(2008, 3, 23), date(2009, 4, 12),
|
||||
|
||||
date(2010, 4, 4), date(2011, 4, 24), date(2012, 4, 8), date(2013, 3, 31),
|
||||
date(2014, 4, 20), date(2015, 4, 5), date(2016, 3, 27), date(2017, 4, 16),
|
||||
date(2018, 4, 1), date(2019, 4, 21),
|
||||
|
||||
date(2020, 4, 12), date(2021, 4, 4), date(2022, 4, 17), date(2023, 4, 9),
|
||||
date(2024, 3, 31), date(2025, 4, 20), date(2026, 4, 5), date(2027, 3, 28),
|
||||
date(2028, 4, 16), date(2029, 4, 1),
|
||||
|
||||
date(2030, 4, 21), date(2031, 4, 13), date(2032, 3, 28), date(2033, 4, 17),
|
||||
date(2034, 4, 9), date(2035, 3, 25), date(2036, 4, 13), date(2037, 4, 5),
|
||||
date(2038, 4, 25), date(2039, 4, 10),
|
||||
|
||||
date(2040, 4, 1), date(2041, 4, 21), date(2042, 4, 6), date(2043, 3, 29),
|
||||
date(2044, 4, 17), date(2045, 4, 9), date(2046, 3, 25), date(2047, 4, 14),
|
||||
date(2048, 4, 5), date(2049, 4, 18), date(2050, 4, 10)
|
||||
]
|
||||
|
||||
orthodox_easter_dates = [
|
||||
date(1990, 4, 15), date(1991, 4, 7), date(1992, 4, 26), date(1993, 4, 18),
|
||||
date(1994, 5, 1), date(1995, 4, 23), date(1996, 4, 14), date(1997, 4, 27),
|
||||
date(1998, 4, 19), date(1999, 4, 11),
|
||||
|
||||
date(2000, 4, 30), date(2001, 4, 15), date(2002, 5, 5), date(2003, 4, 27),
|
||||
date(2004, 4, 11), date(2005, 5, 1), date(2006, 4, 23), date(2007, 4, 8),
|
||||
date(2008, 4, 27), date(2009, 4, 19),
|
||||
|
||||
date(2010, 4, 4), date(2011, 4, 24), date(2012, 4, 15), date(2013, 5, 5),
|
||||
date(2014, 4, 20), date(2015, 4, 12), date(2016, 5, 1), date(2017, 4, 16),
|
||||
date(2018, 4, 8), date(2019, 4, 28),
|
||||
|
||||
date(2020, 4, 19), date(2021, 5, 2), date(2022, 4, 24), date(2023, 4, 16),
|
||||
date(2024, 5, 5), date(2025, 4, 20), date(2026, 4, 12), date(2027, 5, 2),
|
||||
date(2028, 4, 16), date(2029, 4, 8),
|
||||
|
||||
date(2030, 4, 28), date(2031, 4, 13), date(2032, 5, 2), date(2033, 4, 24),
|
||||
date(2034, 4, 9), date(2035, 4, 29), date(2036, 4, 20), date(2037, 4, 5),
|
||||
date(2038, 4, 25), date(2039, 4, 17),
|
||||
|
||||
date(2040, 5, 6), date(2041, 4, 21), date(2042, 4, 13), date(2043, 5, 3),
|
||||
date(2044, 4, 24), date(2045, 4, 9), date(2046, 4, 29), date(2047, 4, 21),
|
||||
date(2048, 4, 5), date(2049, 4, 25), date(2050, 4, 17)
|
||||
]
|
||||
|
||||
# A random smattering of Julian dates.
|
||||
# Pulled values from http://www.kevinlaughery.com/east4099.html
|
||||
julian_easter_dates = [
|
||||
date( 326, 4, 3), date( 375, 4, 5), date( 492, 4, 5), date( 552, 3, 31),
|
||||
date( 562, 4, 9), date( 569, 4, 21), date( 597, 4, 14), date( 621, 4, 19),
|
||||
date( 636, 3, 31), date( 655, 3, 29), date( 700, 4, 11), date( 725, 4, 8),
|
||||
date( 750, 3, 29), date( 782, 4, 7), date( 835, 4, 18), date( 849, 4, 14),
|
||||
date( 867, 3, 30), date( 890, 4, 12), date( 922, 4, 21), date( 934, 4, 6),
|
||||
date(1049, 3, 26), date(1058, 4, 19), date(1113, 4, 6), date(1119, 3, 30),
|
||||
date(1242, 4, 20), date(1255, 3, 28), date(1257, 4, 8), date(1258, 3, 24),
|
||||
date(1261, 4, 24), date(1278, 4, 17), date(1333, 4, 4), date(1351, 4, 17),
|
||||
date(1371, 4, 6), date(1391, 3, 26), date(1402, 3, 26), date(1412, 4, 3),
|
||||
date(1439, 4, 5), date(1445, 3, 28), date(1531, 4, 9), date(1555, 4, 14)
|
||||
]
|
||||
|
||||
|
||||
class EasterTest(unittest.TestCase):
|
||||
def testEasterWestern(self):
|
||||
for easter_date in western_easter_dates:
|
||||
self.assertEqual(easter_date,
|
||||
easter(easter_date.year, EASTER_WESTERN))
|
||||
|
||||
def testEasterOrthodox(self):
|
||||
for easter_date in orthodox_easter_dates:
|
||||
self.assertEqual(easter_date,
|
||||
easter(easter_date.year, EASTER_ORTHODOX))
|
||||
|
||||
def testEasterJulian(self):
|
||||
for easter_date in julian_easter_dates:
|
||||
self.assertEqual(easter_date,
|
||||
easter(easter_date.year, EASTER_JULIAN))
|
||||
|
||||
def testEasterBadMethod(self):
|
||||
# Invalid methods raise ValueError
|
||||
with self.assertRaises(ValueError):
|
||||
easter(1975, 4)
|
33
libraries/dateutil/test/test_import_star.py
Normal file
33
libraries/dateutil/test/test_import_star.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""Test for the "import *" functionality.
|
||||
|
||||
As imort * can be only done at module level, it has been added in a separate file
|
||||
"""
|
||||
import unittest
|
||||
|
||||
prev_locals = list(locals())
|
||||
from dateutil import *
|
||||
new_locals = {name:value for name,value in locals().items()
|
||||
if name not in prev_locals}
|
||||
new_locals.pop('prev_locals')
|
||||
|
||||
class ImportStarTest(unittest.TestCase):
|
||||
""" Test that `from dateutil import *` adds the modules in __all__ locally"""
|
||||
|
||||
def testImportedModules(self):
|
||||
import dateutil.easter
|
||||
import dateutil.parser
|
||||
import dateutil.relativedelta
|
||||
import dateutil.rrule
|
||||
import dateutil.tz
|
||||
import dateutil.utils
|
||||
import dateutil.zoneinfo
|
||||
|
||||
self.assertEquals(dateutil.easter, new_locals.pop("easter"))
|
||||
self.assertEquals(dateutil.parser, new_locals.pop("parser"))
|
||||
self.assertEquals(dateutil.relativedelta, new_locals.pop("relativedelta"))
|
||||
self.assertEquals(dateutil.rrule, new_locals.pop("rrule"))
|
||||
self.assertEquals(dateutil.tz, new_locals.pop("tz"))
|
||||
self.assertEquals(dateutil.utils, new_locals.pop("utils"))
|
||||
self.assertEquals(dateutil.zoneinfo, new_locals.pop("zoneinfo"))
|
||||
|
||||
self.assertFalse(new_locals)
|
166
libraries/dateutil/test/test_imports.py
Normal file
166
libraries/dateutil/test/test_imports.py
Normal file
|
@ -0,0 +1,166 @@
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
class ImportVersionTest(unittest.TestCase):
|
||||
""" Test that dateutil.__version__ can be imported"""
|
||||
|
||||
def testImportVersionStr(self):
|
||||
from dateutil import __version__
|
||||
|
||||
def testImportRoot(self):
|
||||
import dateutil
|
||||
|
||||
self.assertTrue(hasattr(dateutil, '__version__'))
|
||||
|
||||
|
||||
class ImportEasterTest(unittest.TestCase):
|
||||
""" Test that dateutil.easter-related imports work properly """
|
||||
|
||||
def testEasterDirect(self):
|
||||
import dateutil.easter
|
||||
|
||||
def testEasterFrom(self):
|
||||
from dateutil import easter
|
||||
|
||||
def testEasterStar(self):
|
||||
from dateutil.easter import easter
|
||||
|
||||
|
||||
class ImportParserTest(unittest.TestCase):
|
||||
""" Test that dateutil.parser-related imports work properly """
|
||||
def testParserDirect(self):
|
||||
import dateutil.parser
|
||||
|
||||
def testParserFrom(self):
|
||||
from dateutil import parser
|
||||
|
||||
def testParserAll(self):
|
||||
# All interface
|
||||
from dateutil.parser import parse
|
||||
from dateutil.parser import parserinfo
|
||||
|
||||
# Other public classes
|
||||
from dateutil.parser import parser
|
||||
|
||||
for var in (parse, parserinfo, parser):
|
||||
self.assertIsNot(var, None)
|
||||
|
||||
|
||||
class ImportRelativeDeltaTest(unittest.TestCase):
|
||||
""" Test that dateutil.relativedelta-related imports work properly """
|
||||
def testRelativeDeltaDirect(self):
|
||||
import dateutil.relativedelta
|
||||
|
||||
def testRelativeDeltaFrom(self):
|
||||
from dateutil import relativedelta
|
||||
|
||||
def testRelativeDeltaAll(self):
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from dateutil.relativedelta import MO, TU, WE, TH, FR, SA, SU
|
||||
|
||||
for var in (relativedelta, MO, TU, WE, TH, FR, SA, SU):
|
||||
self.assertIsNot(var, None)
|
||||
|
||||
# In the public interface but not in all
|
||||
from dateutil.relativedelta import weekday
|
||||
self.assertIsNot(weekday, None)
|
||||
|
||||
|
||||
class ImportRRuleTest(unittest.TestCase):
|
||||
""" Test that dateutil.rrule related imports work properly """
|
||||
def testRRuleDirect(self):
|
||||
import dateutil.rrule
|
||||
|
||||
def testRRuleFrom(self):
|
||||
from dateutil import rrule
|
||||
|
||||
def testRRuleAll(self):
|
||||
from dateutil.rrule import rrule
|
||||
from dateutil.rrule import rruleset
|
||||
from dateutil.rrule import rrulestr
|
||||
from dateutil.rrule import YEARLY, MONTHLY, WEEKLY, DAILY
|
||||
from dateutil.rrule import HOURLY, MINUTELY, SECONDLY
|
||||
from dateutil.rrule import MO, TU, WE, TH, FR, SA, SU
|
||||
|
||||
rr_all = (rrule, rruleset, rrulestr,
|
||||
YEARLY, MONTHLY, WEEKLY, DAILY,
|
||||
HOURLY, MINUTELY, SECONDLY,
|
||||
MO, TU, WE, TH, FR, SA, SU)
|
||||
|
||||
for var in rr_all:
|
||||
self.assertIsNot(var, None)
|
||||
|
||||
# In the public interface but not in all
|
||||
from dateutil.rrule import weekday
|
||||
self.assertIsNot(weekday, None)
|
||||
|
||||
|
||||
class ImportTZTest(unittest.TestCase):
|
||||
""" Test that dateutil.tz related imports work properly """
|
||||
def testTzDirect(self):
|
||||
import dateutil.tz
|
||||
|
||||
def testTzFrom(self):
|
||||
from dateutil import tz
|
||||
|
||||
def testTzAll(self):
|
||||
from dateutil.tz import tzutc
|
||||
from dateutil.tz import tzoffset
|
||||
from dateutil.tz import tzlocal
|
||||
from dateutil.tz import tzfile
|
||||
from dateutil.tz import tzrange
|
||||
from dateutil.tz import tzstr
|
||||
from dateutil.tz import tzical
|
||||
from dateutil.tz import gettz
|
||||
from dateutil.tz import tzwin
|
||||
from dateutil.tz import tzwinlocal
|
||||
from dateutil.tz import UTC
|
||||
from dateutil.tz import datetime_ambiguous
|
||||
from dateutil.tz import datetime_exists
|
||||
from dateutil.tz import resolve_imaginary
|
||||
|
||||
tz_all = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
|
||||
"tzstr", "tzical", "gettz", "datetime_ambiguous",
|
||||
"datetime_exists", "resolve_imaginary", "UTC"]
|
||||
|
||||
tz_all += ["tzwin", "tzwinlocal"] if sys.platform.startswith("win") else []
|
||||
lvars = locals()
|
||||
|
||||
for var in tz_all:
|
||||
self.assertIsNot(lvars[var], None)
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith('win'), "Requires Windows")
|
||||
class ImportTZWinTest(unittest.TestCase):
|
||||
""" Test that dateutil.tzwin related imports work properly """
|
||||
def testTzwinDirect(self):
|
||||
import dateutil.tzwin
|
||||
|
||||
def testTzwinFrom(self):
|
||||
from dateutil import tzwin
|
||||
|
||||
def testTzwinStar(self):
|
||||
from dateutil.tzwin import tzwin
|
||||
from dateutil.tzwin import tzwinlocal
|
||||
|
||||
tzwin_all = [tzwin, tzwinlocal]
|
||||
|
||||
for var in tzwin_all:
|
||||
self.assertIsNot(var, None)
|
||||
|
||||
|
||||
class ImportZoneInfoTest(unittest.TestCase):
|
||||
def testZoneinfoDirect(self):
|
||||
import dateutil.zoneinfo
|
||||
|
||||
def testZoneinfoFrom(self):
|
||||
from dateutil import zoneinfo
|
||||
|
||||
def testZoneinfoStar(self):
|
||||
from dateutil.zoneinfo import gettz
|
||||
from dateutil.zoneinfo import gettz_db_metadata
|
||||
from dateutil.zoneinfo import rebuild
|
||||
|
||||
zi_all = (gettz, gettz_db_metadata, rebuild)
|
||||
|
||||
for var in zi_all:
|
||||
self.assertIsNot(var, None)
|
95
libraries/dateutil/test/test_internals.py
Normal file
95
libraries/dateutil/test/test_internals.py
Normal file
|
@ -0,0 +1,95 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Tests for implementation details, not necessarily part of the user-facing
|
||||
API.
|
||||
|
||||
The motivating case for these tests is #483, where we want to smoke-test
|
||||
code that may be difficult to reach through the standard API calls.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from dateutil.parser._parser import _ymd
|
||||
from dateutil import tz
|
||||
|
||||
IS_PY32 = sys.version_info[0:2] == (3, 2)
|
||||
|
||||
|
||||
class TestYMD(unittest.TestCase):
|
||||
|
||||
# @pytest.mark.smoke
|
||||
def test_could_be_day(self):
|
||||
ymd = _ymd('foo bar 124 baz')
|
||||
|
||||
ymd.append(2, 'M')
|
||||
assert ymd.has_month
|
||||
assert not ymd.has_year
|
||||
assert ymd.could_be_day(4)
|
||||
assert not ymd.could_be_day(-6)
|
||||
assert not ymd.could_be_day(32)
|
||||
|
||||
# Assumes leapyear
|
||||
assert ymd.could_be_day(29)
|
||||
|
||||
ymd.append(1999)
|
||||
assert ymd.has_year
|
||||
assert not ymd.could_be_day(29)
|
||||
|
||||
ymd.append(16, 'D')
|
||||
assert ymd.has_day
|
||||
assert not ymd.could_be_day(1)
|
||||
|
||||
ymd = _ymd('foo bar 124 baz')
|
||||
ymd.append(1999)
|
||||
assert ymd.could_be_day(31)
|
||||
|
||||
|
||||
###
|
||||
# Test that private interfaces in _parser are deprecated properly
|
||||
@pytest.mark.skipif(IS_PY32, reason='pytest.warns not supported on Python 3.2')
|
||||
def test_parser_private_warns():
|
||||
from dateutil.parser import _timelex, _tzparser
|
||||
from dateutil.parser import _parsetz
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
_tzparser()
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
_timelex('2014-03-03')
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
_parsetz('+05:00')
|
||||
|
||||
|
||||
@pytest.mark.skipif(IS_PY32, reason='pytest.warns not supported on Python 3.2')
|
||||
def test_parser_parser_private_not_warns():
|
||||
from dateutil.parser._parser import _timelex, _tzparser
|
||||
from dateutil.parser._parser import _parsetz
|
||||
|
||||
with pytest.warns(None) as recorder:
|
||||
_tzparser()
|
||||
assert len(recorder) == 0
|
||||
|
||||
with pytest.warns(None) as recorder:
|
||||
_timelex('2014-03-03')
|
||||
|
||||
assert len(recorder) == 0
|
||||
|
||||
with pytest.warns(None) as recorder:
|
||||
_parsetz('+05:00')
|
||||
assert len(recorder) == 0
|
||||
|
||||
|
||||
@pytest.mark.tzstr
|
||||
def test_tzstr_internal_timedeltas():
|
||||
with pytest.warns(tz.DeprecatedTzFormatWarning):
|
||||
tz1 = tz.tzstr("EST5EDT,5,4,0,7200,11,-3,0,7200")
|
||||
|
||||
with pytest.warns(tz.DeprecatedTzFormatWarning):
|
||||
tz2 = tz.tzstr("EST5EDT,4,1,0,7200,10,-1,0,7200")
|
||||
|
||||
assert tz1._start_delta != tz2._start_delta
|
||||
assert tz1._end_delta != tz2._end_delta
|
482
libraries/dateutil/test/test_isoparser.py
Normal file
482
libraries/dateutil/test/test_isoparser.py
Normal file
|
@ -0,0 +1,482 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import datetime, timedelta, date, time
|
||||
import itertools as it
|
||||
|
||||
from dateutil.tz import tz
|
||||
from dateutil.parser import isoparser, isoparse
|
||||
|
||||
import pytest
|
||||
import six
|
||||
|
||||
UTC = tz.tzutc()
|
||||
|
||||
def _generate_tzoffsets(limited):
|
||||
def _mkoffset(hmtuple, fmt):
|
||||
h, m = hmtuple
|
||||
m_td = (-1 if h < 0 else 1) * m
|
||||
|
||||
tzo = tz.tzoffset(None, timedelta(hours=h, minutes=m_td))
|
||||
return tzo, fmt.format(h, m)
|
||||
|
||||
out = []
|
||||
if not limited:
|
||||
# The subset that's just hours
|
||||
hm_out_h = [(h, 0) for h in (-23, -5, 0, 5, 23)]
|
||||
out.extend([_mkoffset(hm, '{:+03d}') for hm in hm_out_h])
|
||||
|
||||
# Ones that have hours and minutes
|
||||
hm_out = [] + hm_out_h
|
||||
hm_out += [(-12, 15), (11, 30), (10, 2), (5, 15), (-5, 30)]
|
||||
else:
|
||||
hm_out = [(-5, -0)]
|
||||
|
||||
fmts = ['{:+03d}:{:02d}', '{:+03d}{:02d}']
|
||||
out += [_mkoffset(hm, fmt) for hm in hm_out for fmt in fmts]
|
||||
|
||||
# Also add in UTC and naive
|
||||
out.append((tz.tzutc(), 'Z'))
|
||||
out.append((None, ''))
|
||||
|
||||
return out
|
||||
|
||||
FULL_TZOFFSETS = _generate_tzoffsets(False)
|
||||
FULL_TZOFFSETS_AWARE = [x for x in FULL_TZOFFSETS if x[1]]
|
||||
TZOFFSETS = _generate_tzoffsets(True)
|
||||
|
||||
DATES = [datetime(1996, 1, 1), datetime(2017, 1, 1)]
|
||||
@pytest.mark.parametrize('dt', tuple(DATES))
|
||||
def test_year_only(dt):
|
||||
dtstr = dt.strftime('%Y')
|
||||
|
||||
assert isoparse(dtstr) == dt
|
||||
|
||||
DATES += [datetime(2000, 2, 1), datetime(2017, 4, 1)]
|
||||
@pytest.mark.parametrize('dt', tuple(DATES))
|
||||
def test_year_month(dt):
|
||||
fmt = '%Y-%m'
|
||||
dtstr = dt.strftime(fmt)
|
||||
|
||||
assert isoparse(dtstr) == dt
|
||||
|
||||
DATES += [datetime(2016, 2, 29), datetime(2018, 3, 15)]
|
||||
YMD_FMTS = ('%Y%m%d', '%Y-%m-%d')
|
||||
@pytest.mark.parametrize('dt', tuple(DATES))
|
||||
@pytest.mark.parametrize('fmt', YMD_FMTS)
|
||||
def test_year_month_day(dt, fmt):
|
||||
dtstr = dt.strftime(fmt)
|
||||
|
||||
assert isoparse(dtstr) == dt
|
||||
|
||||
def _isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset,
|
||||
microsecond_precision=None):
|
||||
tzi, offset_str = tzoffset
|
||||
fmt = date_fmt + 'T' + time_fmt
|
||||
dt = dt.replace(tzinfo=tzi)
|
||||
dtstr = dt.strftime(fmt)
|
||||
|
||||
if microsecond_precision is not None:
|
||||
if not fmt.endswith('%f'):
|
||||
raise ValueError('Time format has no microseconds!')
|
||||
|
||||
if microsecond_precision != 6:
|
||||
dtstr = dtstr[:-(6 - microsecond_precision)]
|
||||
elif microsecond_precision > 6:
|
||||
raise ValueError('Precision must be 1-6')
|
||||
|
||||
dtstr += offset_str
|
||||
|
||||
assert isoparse(dtstr) == dt
|
||||
|
||||
DATETIMES = [datetime(1998, 4, 16, 12),
|
||||
datetime(2019, 11, 18, 23),
|
||||
datetime(2014, 12, 16, 4)]
|
||||
@pytest.mark.parametrize('dt', tuple(DATETIMES))
|
||||
@pytest.mark.parametrize('date_fmt', YMD_FMTS)
|
||||
@pytest.mark.parametrize('tzoffset', TZOFFSETS)
|
||||
def test_ymd_h(dt, date_fmt, tzoffset):
|
||||
_isoparse_date_and_time(dt, date_fmt, '%H', tzoffset)
|
||||
|
||||
DATETIMES = [datetime(2012, 1, 6, 9, 37)]
|
||||
@pytest.mark.parametrize('dt', tuple(DATETIMES))
|
||||
@pytest.mark.parametrize('date_fmt', YMD_FMTS)
|
||||
@pytest.mark.parametrize('time_fmt', ('%H%M', '%H:%M'))
|
||||
@pytest.mark.parametrize('tzoffset', TZOFFSETS)
|
||||
def test_ymd_hm(dt, date_fmt, time_fmt, tzoffset):
|
||||
_isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset)
|
||||
|
||||
DATETIMES = [datetime(2003, 9, 2, 22, 14, 2),
|
||||
datetime(2003, 8, 8, 14, 9, 14),
|
||||
datetime(2003, 4, 7, 6, 14, 59)]
|
||||
HMS_FMTS = ('%H%M%S', '%H:%M:%S')
|
||||
@pytest.mark.parametrize('dt', tuple(DATETIMES))
|
||||
@pytest.mark.parametrize('date_fmt', YMD_FMTS)
|
||||
@pytest.mark.parametrize('time_fmt', HMS_FMTS)
|
||||
@pytest.mark.parametrize('tzoffset', TZOFFSETS)
|
||||
def test_ymd_hms(dt, date_fmt, time_fmt, tzoffset):
|
||||
_isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset)
|
||||
|
||||
DATETIMES = [datetime(2017, 11, 27, 6, 14, 30, 123456)]
|
||||
@pytest.mark.parametrize('dt', tuple(DATETIMES))
|
||||
@pytest.mark.parametrize('date_fmt', YMD_FMTS)
|
||||
@pytest.mark.parametrize('time_fmt', (x + '.%f' for x in HMS_FMTS))
|
||||
@pytest.mark.parametrize('tzoffset', TZOFFSETS)
|
||||
@pytest.mark.parametrize('precision', list(range(3, 7)))
|
||||
def test_ymd_hms_micro(dt, date_fmt, time_fmt, tzoffset, precision):
|
||||
# Truncate the microseconds to the desired precision for the representation
|
||||
dt = dt.replace(microsecond=int(round(dt.microsecond, precision-6)))
|
||||
|
||||
_isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset, precision)
|
||||
|
||||
@pytest.mark.parametrize('tzoffset', FULL_TZOFFSETS)
|
||||
def test_full_tzoffsets(tzoffset):
|
||||
dt = datetime(2017, 11, 27, 6, 14, 30, 123456)
|
||||
date_fmt = '%Y-%m-%d'
|
||||
time_fmt = '%H:%M:%S.%f'
|
||||
|
||||
_isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset)
|
||||
|
||||
@pytest.mark.parametrize('dt_str', [
|
||||
'2014-04-11T00',
|
||||
'2014-04-11T24',
|
||||
'2014-04-11T00:00',
|
||||
'2014-04-11T24:00',
|
||||
'2014-04-11T00:00:00',
|
||||
'2014-04-11T24:00:00',
|
||||
'2014-04-11T00:00:00.000',
|
||||
'2014-04-11T24:00:00.000',
|
||||
'2014-04-11T00:00:00.000000',
|
||||
'2014-04-11T24:00:00.000000']
|
||||
)
|
||||
def test_datetime_midnight(dt_str):
|
||||
assert isoparse(dt_str) == datetime(2014, 4, 11, 0, 0, 0, 0)
|
||||
|
||||
@pytest.mark.parametrize('datestr', [
|
||||
'2014-01-01',
|
||||
'20140101',
|
||||
])
|
||||
@pytest.mark.parametrize('sep', [' ', 'a', 'T', '_', '-'])
|
||||
def test_isoparse_sep_none(datestr, sep):
|
||||
isostr = datestr + sep + '14:33:09'
|
||||
assert isoparse(isostr) == datetime(2014, 1, 1, 14, 33, 9)
|
||||
|
||||
##
|
||||
# Uncommon date formats
|
||||
TIME_ARGS = ('time_args',
|
||||
((None, time(0), None), ) + tuple(('%H:%M:%S.%f', _t, _tz)
|
||||
for _t, _tz in it.product([time(0), time(9, 30), time(14, 47)],
|
||||
TZOFFSETS)))
|
||||
|
||||
@pytest.mark.parametrize('isocal,dt_expected',[
|
||||
((2017, 10), datetime(2017, 3, 6)),
|
||||
((2020, 1), datetime(2019, 12, 30)), # ISO year != Cal year
|
||||
((2004, 53), datetime(2004, 12, 27)), # Only half the week is in 2014
|
||||
])
|
||||
def test_isoweek(isocal, dt_expected):
|
||||
# TODO: Figure out how to parametrize this on formats, too
|
||||
for fmt in ('{:04d}-W{:02d}', '{:04d}W{:02d}'):
|
||||
dtstr = fmt.format(*isocal)
|
||||
assert isoparse(dtstr) == dt_expected
|
||||
|
||||
@pytest.mark.parametrize('isocal,dt_expected',[
|
||||
((2016, 13, 7), datetime(2016, 4, 3)),
|
||||
((2004, 53, 7), datetime(2005, 1, 2)), # ISO year != Cal year
|
||||
((2009, 1, 2), datetime(2008, 12, 30)), # ISO year < Cal year
|
||||
((2009, 53, 6), datetime(2010, 1, 2)) # ISO year > Cal year
|
||||
])
|
||||
def test_isoweek_day(isocal, dt_expected):
|
||||
# TODO: Figure out how to parametrize this on formats, too
|
||||
for fmt in ('{:04d}-W{:02d}-{:d}', '{:04d}W{:02d}{:d}'):
|
||||
dtstr = fmt.format(*isocal)
|
||||
assert isoparse(dtstr) == dt_expected
|
||||
|
||||
@pytest.mark.parametrize('isoord,dt_expected', [
|
||||
((2004, 1), datetime(2004, 1, 1)),
|
||||
((2016, 60), datetime(2016, 2, 29)),
|
||||
((2017, 60), datetime(2017, 3, 1)),
|
||||
((2016, 366), datetime(2016, 12, 31)),
|
||||
((2017, 365), datetime(2017, 12, 31))
|
||||
])
|
||||
def test_iso_ordinal(isoord, dt_expected):
|
||||
for fmt in ('{:04d}-{:03d}', '{:04d}{:03d}'):
|
||||
dtstr = fmt.format(*isoord)
|
||||
|
||||
assert isoparse(dtstr) == dt_expected
|
||||
|
||||
|
||||
###
|
||||
# Acceptance of bytes
|
||||
@pytest.mark.parametrize('isostr,dt', [
|
||||
(b'2014', datetime(2014, 1, 1)),
|
||||
(b'20140204', datetime(2014, 2, 4)),
|
||||
(b'2014-02-04', datetime(2014, 2, 4)),
|
||||
(b'2014-02-04T12', datetime(2014, 2, 4, 12)),
|
||||
(b'2014-02-04T12:30', datetime(2014, 2, 4, 12, 30)),
|
||||
(b'2014-02-04T12:30:15', datetime(2014, 2, 4, 12, 30, 15)),
|
||||
(b'2014-02-04T12:30:15.224', datetime(2014, 2, 4, 12, 30, 15, 224000)),
|
||||
(b'20140204T123015.224', datetime(2014, 2, 4, 12, 30, 15, 224000)),
|
||||
(b'2014-02-04T12:30:15.224Z', datetime(2014, 2, 4, 12, 30, 15, 224000,
|
||||
tz.tzutc())),
|
||||
(b'2014-02-04T12:30:15.224+05:00',
|
||||
datetime(2014, 2, 4, 12, 30, 15, 224000,
|
||||
tzinfo=tz.tzoffset(None, timedelta(hours=5))))])
|
||||
def test_bytes(isostr, dt):
|
||||
assert isoparse(isostr) == dt
|
||||
|
||||
|
||||
###
|
||||
# Invalid ISO strings
|
||||
@pytest.mark.parametrize('isostr,exception', [
|
||||
('201', ValueError), # ISO string too short
|
||||
('2012-0425', ValueError), # Inconsistent date separators
|
||||
('201204-25', ValueError), # Inconsistent date separators
|
||||
('20120425T0120:00', ValueError), # Inconsistent time separators
|
||||
('20120425T012500-334', ValueError), # Wrong microsecond separator
|
||||
('2001-1', ValueError), # YYYY-M not valid
|
||||
('2012-04-9', ValueError), # YYYY-MM-D not valid
|
||||
('201204', ValueError), # YYYYMM not valid
|
||||
('20120411T03:30+', ValueError), # Time zone too short
|
||||
('20120411T03:30+1234567', ValueError), # Time zone too long
|
||||
('20120411T03:30-25:40', ValueError), # Time zone invalid
|
||||
('2012-1a', ValueError), # Invalid month
|
||||
('20120411T03:30+00:60', ValueError), # Time zone invalid minutes
|
||||
('20120411T03:30+00:61', ValueError), # Time zone invalid minutes
|
||||
('20120411T033030.123456012:00', # No sign in time zone
|
||||
ValueError),
|
||||
('2012-W00', ValueError), # Invalid ISO week
|
||||
('2012-W55', ValueError), # Invalid ISO week
|
||||
('2012-W01-0', ValueError), # Invalid ISO week day
|
||||
('2012-W01-8', ValueError), # Invalid ISO week day
|
||||
('2013-000', ValueError), # Invalid ordinal day
|
||||
('2013-366', ValueError), # Invalid ordinal day
|
||||
('2013366', ValueError), # Invalid ordinal day
|
||||
('2014-03-12Т12:30:14', ValueError), # Cyrillic T
|
||||
('2014-04-21T24:00:01', ValueError), # Invalid use of 24 for midnight
|
||||
('2014_W01-1', ValueError), # Invalid separator
|
||||
('2014W01-1', ValueError), # Inconsistent use of dashes
|
||||
('2014-W011', ValueError), # Inconsistent use of dashes
|
||||
|
||||
])
|
||||
def test_iso_raises(isostr, exception):
|
||||
with pytest.raises(exception):
|
||||
isoparse(isostr)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('sep_act,valid_sep', [
|
||||
('C', 'T'),
|
||||
('T', 'C')
|
||||
])
|
||||
def test_iso_raises_sep(sep_act, valid_sep):
|
||||
isostr = '2012-04-25' + sep_act + '01:25:00'
|
||||
|
||||
|
||||
@pytest.mark.xfail()
|
||||
@pytest.mark.parametrize('isostr,exception', [
|
||||
('20120425T01:2000', ValueError), # Inconsistent time separators
|
||||
])
|
||||
def test_iso_raises_failing(isostr, exception):
|
||||
# These are test cases where the current implementation is too lenient
|
||||
# and need to be fixed
|
||||
with pytest.raises(exception):
|
||||
isoparse(isostr)
|
||||
|
||||
|
||||
###
|
||||
# Test ISOParser constructor
|
||||
@pytest.mark.parametrize('sep', [' ', '9', '🍛'])
|
||||
def test_isoparser_invalid_sep(sep):
|
||||
with pytest.raises(ValueError):
|
||||
isoparser(sep=sep)
|
||||
|
||||
|
||||
# This only fails on Python 3
|
||||
@pytest.mark.xfail(six.PY3, reason="Fails on Python 3 only")
|
||||
def test_isoparser_byte_sep():
|
||||
dt = datetime(2017, 12, 6, 12, 30, 45)
|
||||
dt_str = dt.isoformat(sep=str('T'))
|
||||
|
||||
dt_rt = isoparser(sep=b'T').isoparse(dt_str)
|
||||
|
||||
assert dt == dt_rt
|
||||
|
||||
|
||||
###
|
||||
# Test parse_tzstr
|
||||
@pytest.mark.parametrize('tzoffset', FULL_TZOFFSETS)
|
||||
def test_parse_tzstr(tzoffset):
|
||||
dt = datetime(2017, 11, 27, 6, 14, 30, 123456)
|
||||
date_fmt = '%Y-%m-%d'
|
||||
time_fmt = '%H:%M:%S.%f'
|
||||
|
||||
_isoparse_date_and_time(dt, date_fmt, time_fmt, tzoffset)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('tzstr', [
|
||||
'-00:00', '+00:00', '+00', '-00', '+0000', '-0000'
|
||||
])
|
||||
@pytest.mark.parametrize('zero_as_utc', [True, False])
|
||||
def test_parse_tzstr_zero_as_utc(tzstr, zero_as_utc):
|
||||
tzi = isoparser().parse_tzstr(tzstr, zero_as_utc=zero_as_utc)
|
||||
assert tzi == tz.tzutc()
|
||||
assert (type(tzi) == tz.tzutc) == zero_as_utc
|
||||
|
||||
|
||||
@pytest.mark.parametrize('tzstr,exception', [
|
||||
('00:00', ValueError), # No sign
|
||||
('05:00', ValueError), # No sign
|
||||
('_00:00', ValueError), # Invalid sign
|
||||
('+25:00', ValueError), # Offset too large
|
||||
('00:0000', ValueError), # String too long
|
||||
])
|
||||
def test_parse_tzstr_fails(tzstr, exception):
|
||||
with pytest.raises(exception):
|
||||
isoparser().parse_tzstr(tzstr)
|
||||
|
||||
###
|
||||
# Test parse_isodate
|
||||
def __make_date_examples():
|
||||
dates_no_day = [
|
||||
date(1999, 12, 1),
|
||||
date(2016, 2, 1)
|
||||
]
|
||||
|
||||
if six.PY3:
|
||||
# strftime does not support dates before 1900 in Python 2
|
||||
dates_no_day.append(date(1000, 11, 1))
|
||||
|
||||
# Only one supported format for dates with no day
|
||||
o = zip(dates_no_day, it.repeat('%Y-%m'))
|
||||
|
||||
dates_w_day = [
|
||||
date(1969, 12, 31),
|
||||
date(1900, 1, 1),
|
||||
date(2016, 2, 29),
|
||||
date(2017, 11, 14)
|
||||
]
|
||||
|
||||
dates_w_day_fmts = ('%Y%m%d', '%Y-%m-%d')
|
||||
o = it.chain(o, it.product(dates_w_day, dates_w_day_fmts))
|
||||
|
||||
return list(o)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('d,dt_fmt', __make_date_examples())
|
||||
@pytest.mark.parametrize('as_bytes', [True, False])
|
||||
def test_parse_isodate(d, dt_fmt, as_bytes):
|
||||
d_str = d.strftime(dt_fmt)
|
||||
if isinstance(d_str, six.text_type) and as_bytes:
|
||||
d_str = d_str.encode('ascii')
|
||||
elif isinstance(d_str, six.binary_type) and not as_bytes:
|
||||
d_str = d_str.decode('ascii')
|
||||
|
||||
iparser = isoparser()
|
||||
assert iparser.parse_isodate(d_str) == d
|
||||
|
||||
|
||||
@pytest.mark.parametrize('isostr,exception', [
|
||||
('243', ValueError), # ISO string too short
|
||||
('2014-0423', ValueError), # Inconsistent date separators
|
||||
('201404-23', ValueError), # Inconsistent date separators
|
||||
('2014日03月14', ValueError), # Not ASCII
|
||||
('2013-02-29', ValueError), # Not a leap year
|
||||
('2014/12/03', ValueError), # Wrong separators
|
||||
('2014-04-19T', ValueError), # Unknown components
|
||||
])
|
||||
def test_isodate_raises(isostr, exception):
|
||||
with pytest.raises(exception):
|
||||
isoparser().parse_isodate(isostr)
|
||||
|
||||
|
||||
###
|
||||
# Test parse_isotime
|
||||
def __make_time_examples():
|
||||
outputs = []
|
||||
|
||||
# HH
|
||||
time_h = [time(0), time(8), time(22)]
|
||||
time_h_fmts = ['%H']
|
||||
|
||||
outputs.append(it.product(time_h, time_h_fmts))
|
||||
|
||||
# HHMM / HH:MM
|
||||
time_hm = [time(0, 0), time(0, 30), time(8, 47), time(16, 1)]
|
||||
time_hm_fmts = ['%H%M', '%H:%M']
|
||||
|
||||
outputs.append(it.product(time_hm, time_hm_fmts))
|
||||
|
||||
# HHMMSS / HH:MM:SS
|
||||
time_hms = [time(0, 0, 0), time(0, 15, 30),
|
||||
time(8, 2, 16), time(12, 0), time(16, 2), time(20, 45)]
|
||||
|
||||
time_hms_fmts = ['%H%M%S', '%H:%M:%S']
|
||||
|
||||
outputs.append(it.product(time_hms, time_hms_fmts))
|
||||
|
||||
# HHMMSS.ffffff / HH:MM:SS.ffffff
|
||||
time_hmsu = [time(0, 0, 0, 0), time(4, 15, 3, 247993),
|
||||
time(14, 21, 59, 948730),
|
||||
time(23, 59, 59, 999999)]
|
||||
|
||||
time_hmsu_fmts = ['%H%M%S.%f', '%H:%M:%S.%f']
|
||||
|
||||
outputs.append(it.product(time_hmsu, time_hmsu_fmts))
|
||||
|
||||
outputs = list(map(list, outputs))
|
||||
|
||||
# Time zones
|
||||
ex_naive = list(it.chain.from_iterable(x[0:2] for x in outputs))
|
||||
o = it.product(ex_naive, TZOFFSETS) # ((time, fmt), (tzinfo, offsetstr))
|
||||
o = ((t.replace(tzinfo=tzi), fmt + off_str)
|
||||
for (t, fmt), (tzi, off_str) in o)
|
||||
|
||||
outputs.append(o)
|
||||
|
||||
return list(it.chain.from_iterable(outputs))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('time_val,time_fmt', __make_time_examples())
|
||||
@pytest.mark.parametrize('as_bytes', [True, False])
|
||||
def test_isotime(time_val, time_fmt, as_bytes):
|
||||
tstr = time_val.strftime(time_fmt)
|
||||
if isinstance(time_val, six.text_type) and as_bytes:
|
||||
tstr = tstr.encode('ascii')
|
||||
elif isinstance(time_val, six.binary_type) and not as_bytes:
|
||||
tstr = tstr.decode('ascii')
|
||||
|
||||
iparser = isoparser()
|
||||
|
||||
assert iparser.parse_isotime(tstr) == time_val
|
||||
|
||||
@pytest.mark.parametrize('isostr,exception', [
|
||||
('3', ValueError), # ISO string too short
|
||||
('14時30分15秒', ValueError), # Not ASCII
|
||||
('14_30_15', ValueError), # Invalid separators
|
||||
('1430:15', ValueError), # Inconsistent separator use
|
||||
('14:30:15.3684000309', ValueError), # Too much us precision
|
||||
('25', ValueError), # Invalid hours
|
||||
('25:15', ValueError), # Invalid hours
|
||||
('14:60', ValueError), # Invalid minutes
|
||||
('14:59:61', ValueError), # Invalid seconds
|
||||
('14:30:15.3446830500', ValueError), # No sign in time zone
|
||||
('14:30:15+', ValueError), # Time zone too short
|
||||
('14:30:15+1234567', ValueError), # Time zone invalid
|
||||
('14:59:59+25:00', ValueError), # Invalid tz hours
|
||||
('14:59:59+12:62', ValueError), # Invalid tz minutes
|
||||
('14:59:30_344583', ValueError), # Invalid microsecond separator
|
||||
])
|
||||
def test_isotime_raises(isostr, exception):
|
||||
iparser = isoparser()
|
||||
with pytest.raises(exception):
|
||||
iparser.parse_isotime(isostr)
|
||||
|
||||
|
||||
@pytest.mark.xfail()
|
||||
@pytest.mark.parametrize('isostr,exception', [
|
||||
('14:3015', ValueError), # Inconsistent separator use
|
||||
('201202', ValueError) # Invalid ISO format
|
||||
])
|
||||
def test_isotime_raises_xfail(isostr, exception):
|
||||
iparser = isoparser()
|
||||
with pytest.raises(exception):
|
||||
iparser.parse_isotime(isostr)
|
1114
libraries/dateutil/test/test_parser.py
Normal file
1114
libraries/dateutil/test/test_parser.py
Normal file
File diff suppressed because it is too large
Load diff
678
libraries/dateutil/test/test_relativedelta.py
Normal file
678
libraries/dateutil/test/test_relativedelta.py
Normal file
|
@ -0,0 +1,678 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from ._common import WarningTestMixin, NotAValue
|
||||
|
||||
import calendar
|
||||
from datetime import datetime, date, timedelta
|
||||
import unittest
|
||||
|
||||
from dateutil.relativedelta import relativedelta, MO, TU, WE, FR, SU
|
||||
|
||||
|
||||
class RelativeDeltaTest(WarningTestMixin, unittest.TestCase):
|
||||
now = datetime(2003, 9, 17, 20, 54, 47, 282310)
|
||||
today = date(2003, 9, 17)
|
||||
|
||||
def testInheritance(self):
|
||||
# Ensure that relativedelta is inheritance-friendly.
|
||||
class rdChildClass(relativedelta):
|
||||
pass
|
||||
|
||||
ccRD = rdChildClass(years=1, months=1, days=1, leapdays=1, weeks=1,
|
||||
hours=1, minutes=1, seconds=1, microseconds=1)
|
||||
|
||||
rd = relativedelta(years=1, months=1, days=1, leapdays=1, weeks=1,
|
||||
hours=1, minutes=1, seconds=1, microseconds=1)
|
||||
|
||||
self.assertEqual(type(ccRD + rd), type(ccRD),
|
||||
msg='Addition does not inherit type.')
|
||||
|
||||
self.assertEqual(type(ccRD - rd), type(ccRD),
|
||||
msg='Subtraction does not inherit type.')
|
||||
|
||||
self.assertEqual(type(-ccRD), type(ccRD),
|
||||
msg='Negation does not inherit type.')
|
||||
|
||||
self.assertEqual(type(ccRD * 5.0), type(ccRD),
|
||||
msg='Multiplication does not inherit type.')
|
||||
|
||||
self.assertEqual(type(ccRD / 5.0), type(ccRD),
|
||||
msg='Division does not inherit type.')
|
||||
|
||||
def testMonthEndMonthBeginning(self):
|
||||
self.assertEqual(relativedelta(datetime(2003, 1, 31, 23, 59, 59),
|
||||
datetime(2003, 3, 1, 0, 0, 0)),
|
||||
relativedelta(months=-1, seconds=-1))
|
||||
|
||||
self.assertEqual(relativedelta(datetime(2003, 3, 1, 0, 0, 0),
|
||||
datetime(2003, 1, 31, 23, 59, 59)),
|
||||
relativedelta(months=1, seconds=1))
|
||||
|
||||
def testMonthEndMonthBeginningLeapYear(self):
|
||||
self.assertEqual(relativedelta(datetime(2012, 1, 31, 23, 59, 59),
|
||||
datetime(2012, 3, 1, 0, 0, 0)),
|
||||
relativedelta(months=-1, seconds=-1))
|
||||
|
||||
self.assertEqual(relativedelta(datetime(2003, 3, 1, 0, 0, 0),
|
||||
datetime(2003, 1, 31, 23, 59, 59)),
|
||||
relativedelta(months=1, seconds=1))
|
||||
|
||||
def testNextMonth(self):
|
||||
self.assertEqual(self.now+relativedelta(months=+1),
|
||||
datetime(2003, 10, 17, 20, 54, 47, 282310))
|
||||
|
||||
def testNextMonthPlusOneWeek(self):
|
||||
self.assertEqual(self.now+relativedelta(months=+1, weeks=+1),
|
||||
datetime(2003, 10, 24, 20, 54, 47, 282310))
|
||||
|
||||
def testNextMonthPlusOneWeek10am(self):
|
||||
self.assertEqual(self.today +
|
||||
relativedelta(months=+1, weeks=+1, hour=10),
|
||||
datetime(2003, 10, 24, 10, 0))
|
||||
|
||||
def testNextMonthPlusOneWeek10amDiff(self):
|
||||
self.assertEqual(relativedelta(datetime(2003, 10, 24, 10, 0),
|
||||
self.today),
|
||||
relativedelta(months=+1, days=+7, hours=+10))
|
||||
|
||||
def testOneMonthBeforeOneYear(self):
|
||||
self.assertEqual(self.now+relativedelta(years=+1, months=-1),
|
||||
datetime(2004, 8, 17, 20, 54, 47, 282310))
|
||||
|
||||
def testMonthsOfDiffNumOfDays(self):
|
||||
self.assertEqual(date(2003, 1, 27)+relativedelta(months=+1),
|
||||
date(2003, 2, 27))
|
||||
self.assertEqual(date(2003, 1, 31)+relativedelta(months=+1),
|
||||
date(2003, 2, 28))
|
||||
self.assertEqual(date(2003, 1, 31)+relativedelta(months=+2),
|
||||
date(2003, 3, 31))
|
||||
|
||||
def testMonthsOfDiffNumOfDaysWithYears(self):
|
||||
self.assertEqual(date(2000, 2, 28)+relativedelta(years=+1),
|
||||
date(2001, 2, 28))
|
||||
self.assertEqual(date(2000, 2, 29)+relativedelta(years=+1),
|
||||
date(2001, 2, 28))
|
||||
|
||||
self.assertEqual(date(1999, 2, 28)+relativedelta(years=+1),
|
||||
date(2000, 2, 28))
|
||||
self.assertEqual(date(1999, 3, 1)+relativedelta(years=+1),
|
||||
date(2000, 3, 1))
|
||||
self.assertEqual(date(1999, 3, 1)+relativedelta(years=+1),
|
||||
date(2000, 3, 1))
|
||||
|
||||
self.assertEqual(date(2001, 2, 28)+relativedelta(years=-1),
|
||||
date(2000, 2, 28))
|
||||
self.assertEqual(date(2001, 3, 1)+relativedelta(years=-1),
|
||||
date(2000, 3, 1))
|
||||
|
||||
def testNextFriday(self):
|
||||
self.assertEqual(self.today+relativedelta(weekday=FR),
|
||||
date(2003, 9, 19))
|
||||
|
||||
def testNextFridayInt(self):
|
||||
self.assertEqual(self.today+relativedelta(weekday=calendar.FRIDAY),
|
||||
date(2003, 9, 19))
|
||||
|
||||
def testLastFridayInThisMonth(self):
|
||||
self.assertEqual(self.today+relativedelta(day=31, weekday=FR(-1)),
|
||||
date(2003, 9, 26))
|
||||
|
||||
def testNextWednesdayIsToday(self):
|
||||
self.assertEqual(self.today+relativedelta(weekday=WE),
|
||||
date(2003, 9, 17))
|
||||
|
||||
def testNextWenesdayNotToday(self):
|
||||
self.assertEqual(self.today+relativedelta(days=+1, weekday=WE),
|
||||
date(2003, 9, 24))
|
||||
|
||||
def test15thISOYearWeek(self):
|
||||
self.assertEqual(date(2003, 1, 1) +
|
||||
relativedelta(day=4, weeks=+14, weekday=MO(-1)),
|
||||
date(2003, 4, 7))
|
||||
|
||||
def testMillenniumAge(self):
|
||||
self.assertEqual(relativedelta(self.now, date(2001, 1, 1)),
|
||||
relativedelta(years=+2, months=+8, days=+16,
|
||||
hours=+20, minutes=+54, seconds=+47,
|
||||
microseconds=+282310))
|
||||
|
||||
def testJohnAge(self):
|
||||
self.assertEqual(relativedelta(self.now,
|
||||
datetime(1978, 4, 5, 12, 0)),
|
||||
relativedelta(years=+25, months=+5, days=+12,
|
||||
hours=+8, minutes=+54, seconds=+47,
|
||||
microseconds=+282310))
|
||||
|
||||
def testJohnAgeWithDate(self):
|
||||
self.assertEqual(relativedelta(self.today,
|
||||
datetime(1978, 4, 5, 12, 0)),
|
||||
relativedelta(years=+25, months=+5, days=+11,
|
||||
hours=+12))
|
||||
|
||||
def testYearDay(self):
|
||||
self.assertEqual(date(2003, 1, 1)+relativedelta(yearday=260),
|
||||
date(2003, 9, 17))
|
||||
self.assertEqual(date(2002, 1, 1)+relativedelta(yearday=260),
|
||||
date(2002, 9, 17))
|
||||
self.assertEqual(date(2000, 1, 1)+relativedelta(yearday=260),
|
||||
date(2000, 9, 16))
|
||||
self.assertEqual(self.today+relativedelta(yearday=261),
|
||||
date(2003, 9, 18))
|
||||
|
||||
def testYearDayBug(self):
|
||||
# Tests a problem reported by Adam Ryan.
|
||||
self.assertEqual(date(2010, 1, 1)+relativedelta(yearday=15),
|
||||
date(2010, 1, 15))
|
||||
|
||||
def testNonLeapYearDay(self):
|
||||
self.assertEqual(date(2003, 1, 1)+relativedelta(nlyearday=260),
|
||||
date(2003, 9, 17))
|
||||
self.assertEqual(date(2002, 1, 1)+relativedelta(nlyearday=260),
|
||||
date(2002, 9, 17))
|
||||
self.assertEqual(date(2000, 1, 1)+relativedelta(nlyearday=260),
|
||||
date(2000, 9, 17))
|
||||
self.assertEqual(self.today+relativedelta(yearday=261),
|
||||
date(2003, 9, 18))
|
||||
|
||||
def testAddition(self):
|
||||
self.assertEqual(relativedelta(days=10) +
|
||||
relativedelta(years=1, months=2, days=3, hours=4,
|
||||
minutes=5, microseconds=6),
|
||||
relativedelta(years=1, months=2, days=13, hours=4,
|
||||
minutes=5, microseconds=6))
|
||||
|
||||
def testAbsoluteAddition(self):
|
||||
self.assertEqual(relativedelta() + relativedelta(day=0, hour=0),
|
||||
relativedelta(day=0, hour=0))
|
||||
self.assertEqual(relativedelta(day=0, hour=0) + relativedelta(),
|
||||
relativedelta(day=0, hour=0))
|
||||
|
||||
def testAdditionToDatetime(self):
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=1),
|
||||
datetime(2000, 1, 2))
|
||||
|
||||
def testRightAdditionToDatetime(self):
|
||||
self.assertEqual(relativedelta(days=1) + datetime(2000, 1, 1),
|
||||
datetime(2000, 1, 2))
|
||||
|
||||
def testAdditionInvalidType(self):
|
||||
with self.assertRaises(TypeError):
|
||||
relativedelta(days=3) + 9
|
||||
|
||||
def testAdditionUnsupportedType(self):
|
||||
# For unsupported types that define their own comparators, etc.
|
||||
self.assertIs(relativedelta(days=1) + NotAValue, NotAValue)
|
||||
|
||||
def testAdditionFloatValue(self):
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=float(1)),
|
||||
datetime(2000, 1, 2))
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(months=float(1)),
|
||||
datetime(2000, 2, 1))
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(years=float(1)),
|
||||
datetime(2001, 1, 1))
|
||||
|
||||
def testAdditionFloatFractionals(self):
|
||||
self.assertEqual(datetime(2000, 1, 1, 0) +
|
||||
relativedelta(days=float(0.5)),
|
||||
datetime(2000, 1, 1, 12))
|
||||
self.assertEqual(datetime(2000, 1, 1, 0, 0) +
|
||||
relativedelta(hours=float(0.5)),
|
||||
datetime(2000, 1, 1, 0, 30))
|
||||
self.assertEqual(datetime(2000, 1, 1, 0, 0, 0) +
|
||||
relativedelta(minutes=float(0.5)),
|
||||
datetime(2000, 1, 1, 0, 0, 30))
|
||||
self.assertEqual(datetime(2000, 1, 1, 0, 0, 0, 0) +
|
||||
relativedelta(seconds=float(0.5)),
|
||||
datetime(2000, 1, 1, 0, 0, 0, 500000))
|
||||
self.assertEqual(datetime(2000, 1, 1, 0, 0, 0, 0) +
|
||||
relativedelta(microseconds=float(500000.25)),
|
||||
datetime(2000, 1, 1, 0, 0, 0, 500000))
|
||||
|
||||
def testSubtraction(self):
|
||||
self.assertEqual(relativedelta(days=10) -
|
||||
relativedelta(years=1, months=2, days=3, hours=4,
|
||||
minutes=5, microseconds=6),
|
||||
relativedelta(years=-1, months=-2, days=7, hours=-4,
|
||||
minutes=-5, microseconds=-6))
|
||||
|
||||
def testRightSubtractionFromDatetime(self):
|
||||
self.assertEqual(datetime(2000, 1, 2) - relativedelta(days=1),
|
||||
datetime(2000, 1, 1))
|
||||
|
||||
def testSubractionWithDatetime(self):
|
||||
self.assertRaises(TypeError, lambda x, y: x - y,
|
||||
(relativedelta(days=1), datetime(2000, 1, 1)))
|
||||
|
||||
def testSubtractionInvalidType(self):
|
||||
with self.assertRaises(TypeError):
|
||||
relativedelta(hours=12) - 14
|
||||
|
||||
def testSubtractionUnsupportedType(self):
|
||||
self.assertIs(relativedelta(days=1) + NotAValue, NotAValue)
|
||||
|
||||
def testMultiplication(self):
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=1) * 28,
|
||||
datetime(2000, 1, 29))
|
||||
self.assertEqual(datetime(2000, 1, 1) + 28 * relativedelta(days=1),
|
||||
datetime(2000, 1, 29))
|
||||
|
||||
def testMultiplicationUnsupportedType(self):
|
||||
self.assertIs(relativedelta(days=1) * NotAValue, NotAValue)
|
||||
|
||||
def testDivision(self):
|
||||
self.assertEqual(datetime(2000, 1, 1) + relativedelta(days=28) / 28,
|
||||
datetime(2000, 1, 2))
|
||||
|
||||
def testDivisionUnsupportedType(self):
|
||||
self.assertIs(relativedelta(days=1) / NotAValue, NotAValue)
|
||||
|
||||
def testBoolean(self):
|
||||
self.assertFalse(relativedelta(days=0))
|
||||
self.assertTrue(relativedelta(days=1))
|
||||
|
||||
def testAbsoluteValueNegative(self):
|
||||
rd_base = relativedelta(years=-1, months=-5, days=-2, hours=-3,
|
||||
minutes=-5, seconds=-2, microseconds=-12)
|
||||
rd_expected = relativedelta(years=1, months=5, days=2, hours=3,
|
||||
minutes=5, seconds=2, microseconds=12)
|
||||
self.assertEqual(abs(rd_base), rd_expected)
|
||||
|
||||
def testAbsoluteValuePositive(self):
|
||||
rd_base = relativedelta(years=1, months=5, days=2, hours=3,
|
||||
minutes=5, seconds=2, microseconds=12)
|
||||
rd_expected = rd_base
|
||||
|
||||
self.assertEqual(abs(rd_base), rd_expected)
|
||||
|
||||
def testComparison(self):
|
||||
d1 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
|
||||
minutes=1, seconds=1, microseconds=1)
|
||||
d2 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
|
||||
minutes=1, seconds=1, microseconds=1)
|
||||
d3 = relativedelta(years=1, months=1, days=1, leapdays=0, hours=1,
|
||||
minutes=1, seconds=1, microseconds=2)
|
||||
|
||||
self.assertEqual(d1, d2)
|
||||
self.assertNotEqual(d1, d3)
|
||||
|
||||
def testInequalityTypeMismatch(self):
|
||||
# Different type
|
||||
self.assertFalse(relativedelta(year=1) == 19)
|
||||
|
||||
def testInequalityUnsupportedType(self):
|
||||
self.assertIs(relativedelta(hours=3) == NotAValue, NotAValue)
|
||||
|
||||
def testInequalityWeekdays(self):
|
||||
# Different weekdays
|
||||
no_wday = relativedelta(year=1997, month=4)
|
||||
wday_mo_1 = relativedelta(year=1997, month=4, weekday=MO(+1))
|
||||
wday_mo_2 = relativedelta(year=1997, month=4, weekday=MO(+2))
|
||||
wday_tu = relativedelta(year=1997, month=4, weekday=TU)
|
||||
|
||||
self.assertTrue(wday_mo_1 == wday_mo_1)
|
||||
|
||||
self.assertFalse(no_wday == wday_mo_1)
|
||||
self.assertFalse(wday_mo_1 == no_wday)
|
||||
|
||||
self.assertFalse(wday_mo_1 == wday_mo_2)
|
||||
self.assertFalse(wday_mo_2 == wday_mo_1)
|
||||
|
||||
self.assertFalse(wday_mo_1 == wday_tu)
|
||||
self.assertFalse(wday_tu == wday_mo_1)
|
||||
|
||||
def testMonthOverflow(self):
|
||||
self.assertEqual(relativedelta(months=273),
|
||||
relativedelta(years=22, months=9))
|
||||
|
||||
def testWeeks(self):
|
||||
# Test that the weeks property is working properly.
|
||||
rd = relativedelta(years=4, months=2, weeks=8, days=6)
|
||||
self.assertEqual((rd.weeks, rd.days), (8, 8 * 7 + 6))
|
||||
|
||||
rd.weeks = 3
|
||||
self.assertEqual((rd.weeks, rd.days), (3, 3 * 7 + 6))
|
||||
|
||||
def testRelativeDeltaRepr(self):
|
||||
self.assertEqual(repr(relativedelta(years=1, months=-1, days=15)),
|
||||
'relativedelta(years=+1, months=-1, days=+15)')
|
||||
|
||||
self.assertEqual(repr(relativedelta(months=14, seconds=-25)),
|
||||
'relativedelta(years=+1, months=+2, seconds=-25)')
|
||||
|
||||
self.assertEqual(repr(relativedelta(month=3, hour=3, weekday=SU(3))),
|
||||
'relativedelta(month=3, weekday=SU(+3), hour=3)')
|
||||
|
||||
def testRelativeDeltaFractionalYear(self):
|
||||
with self.assertRaises(ValueError):
|
||||
relativedelta(years=1.5)
|
||||
|
||||
def testRelativeDeltaFractionalMonth(self):
|
||||
with self.assertRaises(ValueError):
|
||||
relativedelta(months=1.5)
|
||||
|
||||
def testRelativeDeltaFractionalAbsolutes(self):
|
||||
# Fractional absolute values will soon be unsupported,
|
||||
# check for the deprecation warning.
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(year=2.86)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(month=1.29)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(day=0.44)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(hour=23.98)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(minute=45.21)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(second=13.2)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
relativedelta(microsecond=157221.93)
|
||||
|
||||
def testRelativeDeltaFractionalRepr(self):
|
||||
rd = relativedelta(years=3, months=-2, days=1.25)
|
||||
|
||||
self.assertEqual(repr(rd),
|
||||
'relativedelta(years=+3, months=-2, days=+1.25)')
|
||||
|
||||
rd = relativedelta(hours=0.5, seconds=9.22)
|
||||
self.assertEqual(repr(rd),
|
||||
'relativedelta(hours=+0.5, seconds=+9.22)')
|
||||
|
||||
def testRelativeDeltaFractionalWeeks(self):
|
||||
# Equivalent to days=8, hours=18
|
||||
rd = relativedelta(weeks=1.25)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd,
|
||||
datetime(2009, 9, 11, 18))
|
||||
|
||||
def testRelativeDeltaFractionalDays(self):
|
||||
rd1 = relativedelta(days=1.48)
|
||||
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd1,
|
||||
datetime(2009, 9, 4, 11, 31, 12))
|
||||
|
||||
rd2 = relativedelta(days=1.5)
|
||||
self.assertEqual(d1 + rd2,
|
||||
datetime(2009, 9, 4, 12, 0, 0))
|
||||
|
||||
def testRelativeDeltaFractionalHours(self):
|
||||
rd = relativedelta(days=1, hours=12.5)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd,
|
||||
datetime(2009, 9, 4, 12, 30, 0))
|
||||
|
||||
def testRelativeDeltaFractionalMinutes(self):
|
||||
rd = relativedelta(hours=1, minutes=30.5)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd,
|
||||
datetime(2009, 9, 3, 1, 30, 30))
|
||||
|
||||
def testRelativeDeltaFractionalSeconds(self):
|
||||
rd = relativedelta(hours=5, minutes=30, seconds=30.5)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd,
|
||||
datetime(2009, 9, 3, 5, 30, 30, 500000))
|
||||
|
||||
def testRelativeDeltaFractionalPositiveOverflow(self):
|
||||
# Equivalent to (days=1, hours=14)
|
||||
rd1 = relativedelta(days=1.5, hours=2)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd1,
|
||||
datetime(2009, 9, 4, 14, 0, 0))
|
||||
|
||||
# Equivalent to (days=1, hours=14, minutes=45)
|
||||
rd2 = relativedelta(days=1.5, hours=2.5, minutes=15)
|
||||
d1 = datetime(2009, 9, 3, 0, 0)
|
||||
self.assertEqual(d1 + rd2,
|
||||
datetime(2009, 9, 4, 14, 45))
|
||||
|
||||
# Carry back up - equivalent to (days=2, hours=2, minutes=0, seconds=1)
|
||||
rd3 = relativedelta(days=1.5, hours=13, minutes=59.5, seconds=31)
|
||||
self.assertEqual(d1 + rd3,
|
||||
datetime(2009, 9, 5, 2, 0, 1))
|
||||
|
||||
def testRelativeDeltaFractionalNegativeDays(self):
|
||||
# Equivalent to (days=-1, hours=-1)
|
||||
rd1 = relativedelta(days=-1.5, hours=11)
|
||||
d1 = datetime(2009, 9, 3, 12, 0)
|
||||
self.assertEqual(d1 + rd1,
|
||||
datetime(2009, 9, 2, 11, 0, 0))
|
||||
|
||||
# Equivalent to (days=-1, hours=-9)
|
||||
rd2 = relativedelta(days=-1.25, hours=-3)
|
||||
self.assertEqual(d1 + rd2,
|
||||
datetime(2009, 9, 2, 3))
|
||||
|
||||
def testRelativeDeltaNormalizeFractionalDays(self):
|
||||
# Equivalent to (days=2, hours=18)
|
||||
rd1 = relativedelta(days=2.75)
|
||||
|
||||
self.assertEqual(rd1.normalized(), relativedelta(days=2, hours=18))
|
||||
|
||||
# Equvalent to (days=1, hours=11, minutes=31, seconds=12)
|
||||
rd2 = relativedelta(days=1.48)
|
||||
|
||||
self.assertEqual(rd2.normalized(),
|
||||
relativedelta(days=1, hours=11, minutes=31, seconds=12))
|
||||
|
||||
def testRelativeDeltaNormalizeFractionalDays2(self):
|
||||
# Equivalent to (hours=1, minutes=30)
|
||||
rd1 = relativedelta(hours=1.5)
|
||||
|
||||
self.assertEqual(rd1.normalized(), relativedelta(hours=1, minutes=30))
|
||||
|
||||
# Equivalent to (hours=3, minutes=17, seconds=5, microseconds=100)
|
||||
rd2 = relativedelta(hours=3.28472225)
|
||||
|
||||
self.assertEqual(rd2.normalized(),
|
||||
relativedelta(hours=3, minutes=17, seconds=5, microseconds=100))
|
||||
|
||||
def testRelativeDeltaNormalizeFractionalMinutes(self):
|
||||
# Equivalent to (minutes=15, seconds=36)
|
||||
rd1 = relativedelta(minutes=15.6)
|
||||
|
||||
self.assertEqual(rd1.normalized(),
|
||||
relativedelta(minutes=15, seconds=36))
|
||||
|
||||
# Equivalent to (minutes=25, seconds=20, microseconds=25000)
|
||||
rd2 = relativedelta(minutes=25.33375)
|
||||
|
||||
self.assertEqual(rd2.normalized(),
|
||||
relativedelta(minutes=25, seconds=20, microseconds=25000))
|
||||
|
||||
def testRelativeDeltaNormalizeFractionalSeconds(self):
|
||||
# Equivalent to (seconds=45, microseconds=25000)
|
||||
rd1 = relativedelta(seconds=45.025)
|
||||
self.assertEqual(rd1.normalized(),
|
||||
relativedelta(seconds=45, microseconds=25000))
|
||||
|
||||
def testRelativeDeltaFractionalPositiveOverflow2(self):
|
||||
# Equivalent to (days=1, hours=14)
|
||||
rd1 = relativedelta(days=1.5, hours=2)
|
||||
self.assertEqual(rd1.normalized(),
|
||||
relativedelta(days=1, hours=14))
|
||||
|
||||
# Equivalent to (days=1, hours=14, minutes=45)
|
||||
rd2 = relativedelta(days=1.5, hours=2.5, minutes=15)
|
||||
self.assertEqual(rd2.normalized(),
|
||||
relativedelta(days=1, hours=14, minutes=45))
|
||||
|
||||
# Carry back up - equivalent to:
|
||||
# (days=2, hours=2, minutes=0, seconds=2, microseconds=3)
|
||||
rd3 = relativedelta(days=1.5, hours=13, minutes=59.50045,
|
||||
seconds=31.473, microseconds=500003)
|
||||
self.assertEqual(rd3.normalized(),
|
||||
relativedelta(days=2, hours=2, minutes=0,
|
||||
seconds=2, microseconds=3))
|
||||
|
||||
def testRelativeDeltaFractionalNegativeOverflow(self):
|
||||
# Equivalent to (days=-1)
|
||||
rd1 = relativedelta(days=-0.5, hours=-12)
|
||||
self.assertEqual(rd1.normalized(),
|
||||
relativedelta(days=-1))
|
||||
|
||||
# Equivalent to (days=-1)
|
||||
rd2 = relativedelta(days=-1.5, hours=12)
|
||||
self.assertEqual(rd2.normalized(),
|
||||
relativedelta(days=-1))
|
||||
|
||||
# Equivalent to (days=-1, hours=-14, minutes=-45)
|
||||
rd3 = relativedelta(days=-1.5, hours=-2.5, minutes=-15)
|
||||
self.assertEqual(rd3.normalized(),
|
||||
relativedelta(days=-1, hours=-14, minutes=-45))
|
||||
|
||||
# Equivalent to (days=-1, hours=-14, minutes=+15)
|
||||
rd4 = relativedelta(days=-1.5, hours=-2.5, minutes=45)
|
||||
self.assertEqual(rd4.normalized(),
|
||||
relativedelta(days=-1, hours=-14, minutes=+15))
|
||||
|
||||
# Carry back up - equivalent to:
|
||||
# (days=-2, hours=-2, minutes=0, seconds=-2, microseconds=-3)
|
||||
rd3 = relativedelta(days=-1.5, hours=-13, minutes=-59.50045,
|
||||
seconds=-31.473, microseconds=-500003)
|
||||
self.assertEqual(rd3.normalized(),
|
||||
relativedelta(days=-2, hours=-2, minutes=0,
|
||||
seconds=-2, microseconds=-3))
|
||||
|
||||
def testInvalidYearDay(self):
|
||||
with self.assertRaises(ValueError):
|
||||
relativedelta(yearday=367)
|
||||
|
||||
def testAddTimedeltaToUnpopulatedRelativedelta(self):
|
||||
td = timedelta(
|
||||
days=1,
|
||||
seconds=1,
|
||||
microseconds=1,
|
||||
milliseconds=1,
|
||||
minutes=1,
|
||||
hours=1,
|
||||
weeks=1
|
||||
)
|
||||
|
||||
expected = relativedelta(
|
||||
weeks=1,
|
||||
days=1,
|
||||
hours=1,
|
||||
minutes=1,
|
||||
seconds=1,
|
||||
microseconds=1001
|
||||
)
|
||||
|
||||
self.assertEqual(expected, relativedelta() + td)
|
||||
|
||||
def testAddTimedeltaToPopulatedRelativeDelta(self):
|
||||
td = timedelta(
|
||||
days=1,
|
||||
seconds=1,
|
||||
microseconds=1,
|
||||
milliseconds=1,
|
||||
minutes=1,
|
||||
hours=1,
|
||||
weeks=1
|
||||
)
|
||||
|
||||
rd = relativedelta(
|
||||
year=1,
|
||||
month=1,
|
||||
day=1,
|
||||
hour=1,
|
||||
minute=1,
|
||||
second=1,
|
||||
microsecond=1,
|
||||
years=1,
|
||||
months=1,
|
||||
days=1,
|
||||
weeks=1,
|
||||
hours=1,
|
||||
minutes=1,
|
||||
seconds=1,
|
||||
microseconds=1
|
||||
)
|
||||
|
||||
expected = relativedelta(
|
||||
year=1,
|
||||
month=1,
|
||||
day=1,
|
||||
hour=1,
|
||||
minute=1,
|
||||
second=1,
|
||||
microsecond=1,
|
||||
years=1,
|
||||
months=1,
|
||||
weeks=2,
|
||||
days=2,
|
||||
hours=2,
|
||||
minutes=2,
|
||||
seconds=2,
|
||||
microseconds=1002,
|
||||
)
|
||||
|
||||
self.assertEqual(expected, rd + td)
|
||||
|
||||
def testHashable(self):
|
||||
try:
|
||||
{relativedelta(minute=1): 'test'}
|
||||
except:
|
||||
self.fail("relativedelta() failed to hash!")
|
||||
|
||||
|
||||
class RelativeDeltaWeeksPropertyGetterTest(unittest.TestCase):
|
||||
"""Test the weeks property getter"""
|
||||
|
||||
def test_one_day(self):
|
||||
rd = relativedelta(days=1)
|
||||
self.assertEqual(rd.days, 1)
|
||||
self.assertEqual(rd.weeks, 0)
|
||||
|
||||
def test_minus_one_day(self):
|
||||
rd = relativedelta(days=-1)
|
||||
self.assertEqual(rd.days, -1)
|
||||
self.assertEqual(rd.weeks, 0)
|
||||
|
||||
def test_height_days(self):
|
||||
rd = relativedelta(days=8)
|
||||
self.assertEqual(rd.days, 8)
|
||||
self.assertEqual(rd.weeks, 1)
|
||||
|
||||
def test_minus_height_days(self):
|
||||
rd = relativedelta(days=-8)
|
||||
self.assertEqual(rd.days, -8)
|
||||
self.assertEqual(rd.weeks, -1)
|
||||
|
||||
|
||||
class RelativeDeltaWeeksPropertySetterTest(unittest.TestCase):
|
||||
"""Test the weeks setter which makes a "smart" update of the days attribute"""
|
||||
|
||||
def test_one_day_set_one_week(self):
|
||||
rd = relativedelta(days=1)
|
||||
rd.weeks = 1 # add 7 days
|
||||
self.assertEqual(rd.days, 8)
|
||||
self.assertEqual(rd.weeks, 1)
|
||||
|
||||
def test_minus_one_day_set_one_week(self):
|
||||
rd = relativedelta(days=-1)
|
||||
rd.weeks = 1 # add 7 days
|
||||
self.assertEqual(rd.days, 6)
|
||||
self.assertEqual(rd.weeks, 0)
|
||||
|
||||
def test_height_days_set_minus_one_week(self):
|
||||
rd = relativedelta(days=8)
|
||||
rd.weeks = -1 # change from 1 week, 1 day to -1 week, 1 day
|
||||
self.assertEqual(rd.days, -6)
|
||||
self.assertEqual(rd.weeks, 0)
|
||||
|
||||
def test_minus_height_days_set_minus_one_week(self):
|
||||
rd = relativedelta(days=-8)
|
||||
rd.weeks = -1 # does not change anything
|
||||
self.assertEqual(rd.days, -8)
|
||||
self.assertEqual(rd.weeks, -1)
|
||||
|
||||
|
||||
# vim:ts=4:sw=4:et
|
4842
libraries/dateutil/test/test_rrule.py
Normal file
4842
libraries/dateutil/test/test_rrule.py
Normal file
File diff suppressed because it is too large
Load diff
2603
libraries/dateutil/test/test_tz.py
Normal file
2603
libraries/dateutil/test/test_tz.py
Normal file
File diff suppressed because it is too large
Load diff
53
libraries/dateutil/test/test_utils.py
Normal file
53
libraries/dateutil/test/test_utils.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
import unittest
|
||||
|
||||
from dateutil import tz
|
||||
from dateutil import utils
|
||||
from dateutil.utils import within_delta
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
UTC = tz.tzutc()
|
||||
NYC = tz.gettz("America/New_York")
|
||||
|
||||
|
||||
class UtilsTest(unittest.TestCase):
|
||||
@freeze_time(datetime(2014, 12, 15, 1, 21, 33, 4003))
|
||||
def testToday(self):
|
||||
self.assertEqual(utils.today(), datetime(2014, 12, 15, 0, 0, 0))
|
||||
|
||||
@freeze_time(datetime(2014, 12, 15, 12), tz_offset=5)
|
||||
def testTodayTzInfo(self):
|
||||
self.assertEqual(utils.today(NYC),
|
||||
datetime(2014, 12, 15, 0, 0, 0, tzinfo=NYC))
|
||||
|
||||
@freeze_time(datetime(2014, 12, 15, 23), tz_offset=5)
|
||||
def testTodayTzInfoDifferentDay(self):
|
||||
self.assertEqual(utils.today(UTC),
|
||||
datetime(2014, 12, 16, 0, 0, 0, tzinfo=UTC))
|
||||
|
||||
def testDefaultTZInfoNaive(self):
|
||||
dt = datetime(2014, 9, 14, 9, 30)
|
||||
self.assertIs(utils.default_tzinfo(dt, NYC).tzinfo,
|
||||
NYC)
|
||||
|
||||
def testDefaultTZInfoAware(self):
|
||||
dt = datetime(2014, 9, 14, 9, 30, tzinfo=UTC)
|
||||
self.assertIs(utils.default_tzinfo(dt, NYC).tzinfo,
|
||||
UTC)
|
||||
|
||||
def testWithinDelta(self):
|
||||
d1 = datetime(2016, 1, 1, 12, 14, 1, 9)
|
||||
d2 = d1.replace(microsecond=15)
|
||||
|
||||
self.assertTrue(within_delta(d1, d2, timedelta(seconds=1)))
|
||||
self.assertFalse(within_delta(d1, d2, timedelta(microseconds=1)))
|
||||
|
||||
def testWithinDeltaWithNegativeDelta(self):
|
||||
d1 = datetime(2016, 1, 1)
|
||||
d2 = datetime(2015, 12, 31)
|
||||
|
||||
self.assertTrue(within_delta(d2, d1, timedelta(days=-1)))
|
17
libraries/dateutil/tz/__init__.py
Normal file
17
libraries/dateutil/tz/__init__.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from .tz import *
|
||||
from .tz import __doc__
|
||||
|
||||
#: Convenience constant providing a :class:`tzutc()` instance
|
||||
#:
|
||||
#: .. versionadded:: 2.7.0
|
||||
UTC = tzutc()
|
||||
|
||||
__all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
|
||||
"tzstr", "tzical", "tzwin", "tzwinlocal", "gettz",
|
||||
"enfold", "datetime_ambiguous", "datetime_exists",
|
||||
"resolve_imaginary", "UTC", "DeprecatedTzFormatWarning"]
|
||||
|
||||
|
||||
class DeprecatedTzFormatWarning(Warning):
|
||||
"""Warning raised when time zones are parsed from deprecated formats."""
|
415
libraries/dateutil/tz/_common.py
Normal file
415
libraries/dateutil/tz/_common.py
Normal file
|
@ -0,0 +1,415 @@
|
|||
from six import PY3
|
||||
|
||||
from functools import wraps
|
||||
|
||||
from datetime import datetime, timedelta, tzinfo
|
||||
|
||||
|
||||
ZERO = timedelta(0)
|
||||
|
||||
__all__ = ['tzname_in_python2', 'enfold']
|
||||
|
||||
|
||||
def tzname_in_python2(namefunc):
|
||||
"""Change unicode output into bytestrings in Python 2
|
||||
|
||||
tzname() API changed in Python 3. It used to return bytes, but was changed
|
||||
to unicode strings
|
||||
"""
|
||||
def adjust_encoding(*args, **kwargs):
|
||||
name = namefunc(*args, **kwargs)
|
||||
if name is not None and not PY3:
|
||||
name = name.encode()
|
||||
|
||||
return name
|
||||
|
||||
return adjust_encoding
|
||||
|
||||
|
||||
# The following is adapted from Alexander Belopolsky's tz library
|
||||
# https://github.com/abalkin/tz
|
||||
if hasattr(datetime, 'fold'):
|
||||
# This is the pre-python 3.6 fold situation
|
||||
def enfold(dt, fold=1):
|
||||
"""
|
||||
Provides a unified interface for assigning the ``fold`` attribute to
|
||||
datetimes both before and after the implementation of PEP-495.
|
||||
|
||||
:param fold:
|
||||
The value for the ``fold`` attribute in the returned datetime. This
|
||||
should be either 0 or 1.
|
||||
|
||||
:return:
|
||||
Returns an object for which ``getattr(dt, 'fold', 0)`` returns
|
||||
``fold`` for all versions of Python. In versions prior to
|
||||
Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
|
||||
subclass of :py:class:`datetime.datetime` with the ``fold``
|
||||
attribute added, if ``fold`` is 1.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
return dt.replace(fold=fold)
|
||||
|
||||
else:
|
||||
class _DatetimeWithFold(datetime):
|
||||
"""
|
||||
This is a class designed to provide a PEP 495-compliant interface for
|
||||
Python versions before 3.6. It is used only for dates in a fold, so
|
||||
the ``fold`` attribute is fixed at ``1``.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
def replace(self, *args, **kwargs):
|
||||
"""
|
||||
Return a datetime with the same attributes, except for those
|
||||
attributes given new values by whichever keyword arguments are
|
||||
specified. Note that tzinfo=None can be specified to create a naive
|
||||
datetime from an aware datetime with no conversion of date and time
|
||||
data.
|
||||
|
||||
This is reimplemented in ``_DatetimeWithFold`` because pypy3 will
|
||||
return a ``datetime.datetime`` even if ``fold`` is unchanged.
|
||||
"""
|
||||
argnames = (
|
||||
'year', 'month', 'day', 'hour', 'minute', 'second',
|
||||
'microsecond', 'tzinfo'
|
||||
)
|
||||
|
||||
for arg, argname in zip(args, argnames):
|
||||
if argname in kwargs:
|
||||
raise TypeError('Duplicate argument: {}'.format(argname))
|
||||
|
||||
kwargs[argname] = arg
|
||||
|
||||
for argname in argnames:
|
||||
if argname not in kwargs:
|
||||
kwargs[argname] = getattr(self, argname)
|
||||
|
||||
dt_class = self.__class__ if kwargs.get('fold', 1) else datetime
|
||||
|
||||
return dt_class(**kwargs)
|
||||
|
||||
@property
|
||||
def fold(self):
|
||||
return 1
|
||||
|
||||
def enfold(dt, fold=1):
|
||||
"""
|
||||
Provides a unified interface for assigning the ``fold`` attribute to
|
||||
datetimes both before and after the implementation of PEP-495.
|
||||
|
||||
:param fold:
|
||||
The value for the ``fold`` attribute in the returned datetime. This
|
||||
should be either 0 or 1.
|
||||
|
||||
:return:
|
||||
Returns an object for which ``getattr(dt, 'fold', 0)`` returns
|
||||
``fold`` for all versions of Python. In versions prior to
|
||||
Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
|
||||
subclass of :py:class:`datetime.datetime` with the ``fold``
|
||||
attribute added, if ``fold`` is 1.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
if getattr(dt, 'fold', 0) == fold:
|
||||
return dt
|
||||
|
||||
args = dt.timetuple()[:6]
|
||||
args += (dt.microsecond, dt.tzinfo)
|
||||
|
||||
if fold:
|
||||
return _DatetimeWithFold(*args)
|
||||
else:
|
||||
return datetime(*args)
|
||||
|
||||
|
||||
def _validate_fromutc_inputs(f):
|
||||
"""
|
||||
The CPython version of ``fromutc`` checks that the input is a ``datetime``
|
||||
object and that ``self`` is attached as its ``tzinfo``.
|
||||
"""
|
||||
@wraps(f)
|
||||
def fromutc(self, dt):
|
||||
if not isinstance(dt, datetime):
|
||||
raise TypeError("fromutc() requires a datetime argument")
|
||||
if dt.tzinfo is not self:
|
||||
raise ValueError("dt.tzinfo is not self")
|
||||
|
||||
return f(self, dt)
|
||||
|
||||
return fromutc
|
||||
|
||||
|
||||
class _tzinfo(tzinfo):
|
||||
"""
|
||||
Base class for all ``dateutil`` ``tzinfo`` objects.
|
||||
"""
|
||||
|
||||
def is_ambiguous(self, dt):
|
||||
"""
|
||||
Whether or not the "wall time" of a given datetime is ambiguous in this
|
||||
zone.
|
||||
|
||||
:param dt:
|
||||
A :py:class:`datetime.datetime`, naive or time zone aware.
|
||||
|
||||
|
||||
:return:
|
||||
Returns ``True`` if ambiguous, ``False`` otherwise.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
|
||||
dt = dt.replace(tzinfo=self)
|
||||
|
||||
wall_0 = enfold(dt, fold=0)
|
||||
wall_1 = enfold(dt, fold=1)
|
||||
|
||||
same_offset = wall_0.utcoffset() == wall_1.utcoffset()
|
||||
same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)
|
||||
|
||||
return same_dt and not same_offset
|
||||
|
||||
def _fold_status(self, dt_utc, dt_wall):
|
||||
"""
|
||||
Determine the fold status of a "wall" datetime, given a representation
|
||||
of the same datetime as a (naive) UTC datetime. This is calculated based
|
||||
on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
|
||||
datetimes, and that this offset is the actual number of hours separating
|
||||
``dt_utc`` and ``dt_wall``.
|
||||
|
||||
:param dt_utc:
|
||||
Representation of the datetime as UTC
|
||||
|
||||
:param dt_wall:
|
||||
Representation of the datetime as "wall time". This parameter must
|
||||
either have a `fold` attribute or have a fold-naive
|
||||
:class:`datetime.tzinfo` attached, otherwise the calculation may
|
||||
fail.
|
||||
"""
|
||||
if self.is_ambiguous(dt_wall):
|
||||
delta_wall = dt_wall - dt_utc
|
||||
_fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst()))
|
||||
else:
|
||||
_fold = 0
|
||||
|
||||
return _fold
|
||||
|
||||
def _fold(self, dt):
|
||||
return getattr(dt, 'fold', 0)
|
||||
|
||||
def _fromutc(self, dt):
|
||||
"""
|
||||
Given a timezone-aware datetime in a given timezone, calculates a
|
||||
timezone-aware datetime in a new timezone.
|
||||
|
||||
Since this is the one time that we *know* we have an unambiguous
|
||||
datetime object, we take this opportunity to determine whether the
|
||||
datetime is ambiguous and in a "fold" state (e.g. if it's the first
|
||||
occurence, chronologically, of the ambiguous datetime).
|
||||
|
||||
:param dt:
|
||||
A timezone-aware :class:`datetime.datetime` object.
|
||||
"""
|
||||
|
||||
# Re-implement the algorithm from Python's datetime.py
|
||||
dtoff = dt.utcoffset()
|
||||
if dtoff is None:
|
||||
raise ValueError("fromutc() requires a non-None utcoffset() "
|
||||
"result")
|
||||
|
||||
# The original datetime.py code assumes that `dst()` defaults to
|
||||
# zero during ambiguous times. PEP 495 inverts this presumption, so
|
||||
# for pre-PEP 495 versions of python, we need to tweak the algorithm.
|
||||
dtdst = dt.dst()
|
||||
if dtdst is None:
|
||||
raise ValueError("fromutc() requires a non-None dst() result")
|
||||
delta = dtoff - dtdst
|
||||
|
||||
dt += delta
|
||||
# Set fold=1 so we can default to being in the fold for
|
||||
# ambiguous dates.
|
||||
dtdst = enfold(dt, fold=1).dst()
|
||||
if dtdst is None:
|
||||
raise ValueError("fromutc(): dt.dst gave inconsistent "
|
||||
"results; cannot convert")
|
||||
return dt + dtdst
|
||||
|
||||
@_validate_fromutc_inputs
|
||||
def fromutc(self, dt):
|
||||
"""
|
||||
Given a timezone-aware datetime in a given timezone, calculates a
|
||||
timezone-aware datetime in a new timezone.
|
||||
|
||||
Since this is the one time that we *know* we have an unambiguous
|
||||
datetime object, we take this opportunity to determine whether the
|
||||
datetime is ambiguous and in a "fold" state (e.g. if it's the first
|
||||
occurance, chronologically, of the ambiguous datetime).
|
||||
|
||||
:param dt:
|
||||
A timezone-aware :class:`datetime.datetime` object.
|
||||
"""
|
||||
dt_wall = self._fromutc(dt)
|
||||
|
||||
# Calculate the fold status given the two datetimes.
|
||||
_fold = self._fold_status(dt, dt_wall)
|
||||
|
||||
# Set the default fold value for ambiguous dates
|
||||
return enfold(dt_wall, fold=_fold)
|
||||
|
||||
|
||||
class tzrangebase(_tzinfo):
|
||||
"""
|
||||
This is an abstract base class for time zones represented by an annual
|
||||
transition into and out of DST. Child classes should implement the following
|
||||
methods:
|
||||
|
||||
* ``__init__(self, *args, **kwargs)``
|
||||
* ``transitions(self, year)`` - this is expected to return a tuple of
|
||||
datetimes representing the DST on and off transitions in standard
|
||||
time.
|
||||
|
||||
A fully initialized ``tzrangebase`` subclass should also provide the
|
||||
following attributes:
|
||||
* ``hasdst``: Boolean whether or not the zone uses DST.
|
||||
* ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
|
||||
representing the respective UTC offsets.
|
||||
* ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
|
||||
abbreviations in DST and STD, respectively.
|
||||
* ``_hasdst``: Whether or not the zone has DST.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
def __init__(self):
|
||||
raise NotImplementedError('tzrangebase is an abstract base class')
|
||||
|
||||
def utcoffset(self, dt):
|
||||
isdst = self._isdst(dt)
|
||||
|
||||
if isdst is None:
|
||||
return None
|
||||
elif isdst:
|
||||
return self._dst_offset
|
||||
else:
|
||||
return self._std_offset
|
||||
|
||||
def dst(self, dt):
|
||||
isdst = self._isdst(dt)
|
||||
|
||||
if isdst is None:
|
||||
return None
|
||||
elif isdst:
|
||||
return self._dst_base_offset
|
||||
else:
|
||||
return ZERO
|
||||
|
||||
@tzname_in_python2
|
||||
def tzname(self, dt):
|
||||
if self._isdst(dt):
|
||||
return self._dst_abbr
|
||||
else:
|
||||
return self._std_abbr
|
||||
|
||||
def fromutc(self, dt):
|
||||
""" Given a datetime in UTC, return local time """
|
||||
if not isinstance(dt, datetime):
|
||||
raise TypeError("fromutc() requires a datetime argument")
|
||||
|
||||
if dt.tzinfo is not self:
|
||||
raise ValueError("dt.tzinfo is not self")
|
||||
|
||||
# Get transitions - if there are none, fixed offset
|
||||
transitions = self.transitions(dt.year)
|
||||
if transitions is None:
|
||||
return dt + self.utcoffset(dt)
|
||||
|
||||
# Get the transition times in UTC
|
||||
dston, dstoff = transitions
|
||||
|
||||
dston -= self._std_offset
|
||||
dstoff -= self._std_offset
|
||||
|
||||
utc_transitions = (dston, dstoff)
|
||||
dt_utc = dt.replace(tzinfo=None)
|
||||
|
||||
isdst = self._naive_isdst(dt_utc, utc_transitions)
|
||||
|
||||
if isdst:
|
||||
dt_wall = dt + self._dst_offset
|
||||
else:
|
||||
dt_wall = dt + self._std_offset
|
||||
|
||||
_fold = int(not isdst and self.is_ambiguous(dt_wall))
|
||||
|
||||
return enfold(dt_wall, fold=_fold)
|
||||
|
||||
def is_ambiguous(self, dt):
|
||||
"""
|
||||
Whether or not the "wall time" of a given datetime is ambiguous in this
|
||||
zone.
|
||||
|
||||
:param dt:
|
||||
A :py:class:`datetime.datetime`, naive or time zone aware.
|
||||
|
||||
|
||||
:return:
|
||||
Returns ``True`` if ambiguous, ``False`` otherwise.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
"""
|
||||
if not self.hasdst:
|
||||
return False
|
||||
|
||||
start, end = self.transitions(dt.year)
|
||||
|
||||
dt = dt.replace(tzinfo=None)
|
||||
return (end <= dt < end + self._dst_base_offset)
|
||||
|
||||
def _isdst(self, dt):
|
||||
if not self.hasdst:
|
||||
return False
|
||||
elif dt is None:
|
||||
return None
|
||||
|
||||
transitions = self.transitions(dt.year)
|
||||
|
||||
if transitions is None:
|
||||
return False
|
||||
|
||||
dt = dt.replace(tzinfo=None)
|
||||
|
||||
isdst = self._naive_isdst(dt, transitions)
|
||||
|
||||
# Handle ambiguous dates
|
||||
if not isdst and self.is_ambiguous(dt):
|
||||
return not self._fold(dt)
|
||||
else:
|
||||
return isdst
|
||||
|
||||
def _naive_isdst(self, dt, transitions):
|
||||
dston, dstoff = transitions
|
||||
|
||||
dt = dt.replace(tzinfo=None)
|
||||
|
||||
if dston < dstoff:
|
||||
isdst = dston <= dt < dstoff
|
||||
else:
|
||||
isdst = not dstoff <= dt < dston
|
||||
|
||||
return isdst
|
||||
|
||||
@property
|
||||
def _dst_base_offset(self):
|
||||
return self._dst_offset - self._std_offset
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
def __repr__(self):
|
||||
return "%s(...)" % self.__class__.__name__
|
||||
|
||||
__reduce__ = object.__reduce__
|
49
libraries/dateutil/tz/_factories.py
Normal file
49
libraries/dateutil/tz/_factories.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from datetime import timedelta
|
||||
|
||||
|
||||
class _TzSingleton(type):
|
||||
def __init__(cls, *args, **kwargs):
|
||||
cls.__instance = None
|
||||
super(_TzSingleton, cls).__init__(*args, **kwargs)
|
||||
|
||||
def __call__(cls):
|
||||
if cls.__instance is None:
|
||||
cls.__instance = super(_TzSingleton, cls).__call__()
|
||||
return cls.__instance
|
||||
|
||||
class _TzFactory(type):
|
||||
def instance(cls, *args, **kwargs):
|
||||
"""Alternate constructor that returns a fresh instance"""
|
||||
return type.__call__(cls, *args, **kwargs)
|
||||
|
||||
|
||||
class _TzOffsetFactory(_TzFactory):
|
||||
def __init__(cls, *args, **kwargs):
|
||||
cls.__instances = {}
|
||||
|
||||
def __call__(cls, name, offset):
|
||||
if isinstance(offset, timedelta):
|
||||
key = (name, offset.total_seconds())
|
||||
else:
|
||||
key = (name, offset)
|
||||
|
||||
instance = cls.__instances.get(key, None)
|
||||
if instance is None:
|
||||
instance = cls.__instances.setdefault(key,
|
||||
cls.instance(name, offset))
|
||||
return instance
|
||||
|
||||
|
||||
class _TzStrFactory(_TzFactory):
|
||||
def __init__(cls, *args, **kwargs):
|
||||
cls.__instances = {}
|
||||
|
||||
def __call__(cls, s, posix_offset=False):
|
||||
key = (s, posix_offset)
|
||||
instance = cls.__instances.get(key, None)
|
||||
|
||||
if instance is None:
|
||||
instance = cls.__instances.setdefault(key,
|
||||
cls.instance(s, posix_offset))
|
||||
return instance
|
||||
|
1785
libraries/dateutil/tz/tz.py
Normal file
1785
libraries/dateutil/tz/tz.py
Normal file
File diff suppressed because it is too large
Load diff
331
libraries/dateutil/tz/win.py
Normal file
331
libraries/dateutil/tz/win.py
Normal file
|
@ -0,0 +1,331 @@
|
|||
# This code was originally contributed by Jeffrey Harris.
|
||||
import datetime
|
||||
import struct
|
||||
|
||||
from six.moves import winreg
|
||||
from six import text_type
|
||||
|
||||
try:
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
except ValueError:
|
||||
# ValueError is raised on non-Windows systems for some horrible reason.
|
||||
raise ImportError("Running tzwin on non-Windows system")
|
||||
|
||||
from ._common import tzrangebase
|
||||
|
||||
__all__ = ["tzwin", "tzwinlocal", "tzres"]
|
||||
|
||||
ONEWEEK = datetime.timedelta(7)
|
||||
|
||||
TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
|
||||
TZKEYNAME9X = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones"
|
||||
TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
|
||||
|
||||
|
||||
def _settzkeyname():
|
||||
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
|
||||
try:
|
||||
winreg.OpenKey(handle, TZKEYNAMENT).Close()
|
||||
TZKEYNAME = TZKEYNAMENT
|
||||
except WindowsError:
|
||||
TZKEYNAME = TZKEYNAME9X
|
||||
handle.Close()
|
||||
return TZKEYNAME
|
||||
|
||||
|
||||
TZKEYNAME = _settzkeyname()
|
||||
|
||||
|
||||
class tzres(object):
|
||||
"""
|
||||
Class for accessing `tzres.dll`, which contains timezone name related
|
||||
resources.
|
||||
|
||||
.. versionadded:: 2.5.0
|
||||
"""
|
||||
p_wchar = ctypes.POINTER(wintypes.WCHAR) # Pointer to a wide char
|
||||
|
||||
def __init__(self, tzres_loc='tzres.dll'):
|
||||
# Load the user32 DLL so we can load strings from tzres
|
||||
user32 = ctypes.WinDLL('user32')
|
||||
|
||||
# Specify the LoadStringW function
|
||||
user32.LoadStringW.argtypes = (wintypes.HINSTANCE,
|
||||
wintypes.UINT,
|
||||
wintypes.LPWSTR,
|
||||
ctypes.c_int)
|
||||
|
||||
self.LoadStringW = user32.LoadStringW
|
||||
self._tzres = ctypes.WinDLL(tzres_loc)
|
||||
self.tzres_loc = tzres_loc
|
||||
|
||||
def load_name(self, offset):
|
||||
"""
|
||||
Load a timezone name from a DLL offset (integer).
|
||||
|
||||
>>> from dateutil.tzwin import tzres
|
||||
>>> tzr = tzres()
|
||||
>>> print(tzr.load_name(112))
|
||||
'Eastern Standard Time'
|
||||
|
||||
:param offset:
|
||||
A positive integer value referring to a string from the tzres dll.
|
||||
|
||||
..note:
|
||||
Offsets found in the registry are generally of the form
|
||||
`@tzres.dll,-114`. The offset in this case if 114, not -114.
|
||||
|
||||
"""
|
||||
resource = self.p_wchar()
|
||||
lpBuffer = ctypes.cast(ctypes.byref(resource), wintypes.LPWSTR)
|
||||
nchar = self.LoadStringW(self._tzres._handle, offset, lpBuffer, 0)
|
||||
return resource[:nchar]
|
||||
|
||||
def name_from_string(self, tzname_str):
|
||||
"""
|
||||
Parse strings as returned from the Windows registry into the time zone
|
||||
name as defined in the registry.
|
||||
|
||||
>>> from dateutil.tzwin import tzres
|
||||
>>> tzr = tzres()
|
||||
>>> print(tzr.name_from_string('@tzres.dll,-251'))
|
||||
'Dateline Daylight Time'
|
||||
>>> print(tzr.name_from_string('Eastern Standard Time'))
|
||||
'Eastern Standard Time'
|
||||
|
||||
:param tzname_str:
|
||||
A timezone name string as returned from a Windows registry key.
|
||||
|
||||
:return:
|
||||
Returns the localized timezone string from tzres.dll if the string
|
||||
is of the form `@tzres.dll,-offset`, else returns the input string.
|
||||
"""
|
||||
if not tzname_str.startswith('@'):
|
||||
return tzname_str
|
||||
|
||||
name_splt = tzname_str.split(',-')
|
||||
try:
|
||||
offset = int(name_splt[1])
|
||||
except:
|
||||
raise ValueError("Malformed timezone string.")
|
||||
|
||||
return self.load_name(offset)
|
||||
|
||||
|
||||
class tzwinbase(tzrangebase):
|
||||
"""tzinfo class based on win32's timezones available in the registry."""
|
||||
def __init__(self):
|
||||
raise NotImplementedError('tzwinbase is an abstract base class')
|
||||
|
||||
def __eq__(self, other):
|
||||
# Compare on all relevant dimensions, including name.
|
||||
if not isinstance(other, tzwinbase):
|
||||
return NotImplemented
|
||||
|
||||
return (self._std_offset == other._std_offset and
|
||||
self._dst_offset == other._dst_offset and
|
||||
self._stddayofweek == other._stddayofweek and
|
||||
self._dstdayofweek == other._dstdayofweek and
|
||||
self._stdweeknumber == other._stdweeknumber and
|
||||
self._dstweeknumber == other._dstweeknumber and
|
||||
self._stdhour == other._stdhour and
|
||||
self._dsthour == other._dsthour and
|
||||
self._stdminute == other._stdminute and
|
||||
self._dstminute == other._dstminute and
|
||||
self._std_abbr == other._std_abbr and
|
||||
self._dst_abbr == other._dst_abbr)
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
"""Return a list of all time zones known to the system."""
|
||||
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
|
||||
with winreg.OpenKey(handle, TZKEYNAME) as tzkey:
|
||||
result = [winreg.EnumKey(tzkey, i)
|
||||
for i in range(winreg.QueryInfoKey(tzkey)[0])]
|
||||
return result
|
||||
|
||||
def display(self):
|
||||
return self._display
|
||||
|
||||
def transitions(self, year):
|
||||
"""
|
||||
For a given year, get the DST on and off transition times, expressed
|
||||
always on the standard time side. For zones with no transitions, this
|
||||
function returns ``None``.
|
||||
|
||||
:param year:
|
||||
The year whose transitions you would like to query.
|
||||
|
||||
:return:
|
||||
Returns a :class:`tuple` of :class:`datetime.datetime` objects,
|
||||
``(dston, dstoff)`` for zones with an annual DST transition, or
|
||||
``None`` for fixed offset zones.
|
||||
"""
|
||||
|
||||
if not self.hasdst:
|
||||
return None
|
||||
|
||||
dston = picknthweekday(year, self._dstmonth, self._dstdayofweek,
|
||||
self._dsthour, self._dstminute,
|
||||
self._dstweeknumber)
|
||||
|
||||
dstoff = picknthweekday(year, self._stdmonth, self._stddayofweek,
|
||||
self._stdhour, self._stdminute,
|
||||
self._stdweeknumber)
|
||||
|
||||
# Ambiguous dates default to the STD side
|
||||
dstoff -= self._dst_base_offset
|
||||
|
||||
return dston, dstoff
|
||||
|
||||
def _get_hasdst(self):
|
||||
return self._dstmonth != 0
|
||||
|
||||
@property
|
||||
def _dst_base_offset(self):
|
||||
return self._dst_base_offset_
|
||||
|
||||
|
||||
class tzwin(tzwinbase):
|
||||
|
||||
def __init__(self, name):
|
||||
self._name = name
|
||||
|
||||
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
|
||||
tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
|
||||
with winreg.OpenKey(handle, tzkeyname) as tzkey:
|
||||
keydict = valuestodict(tzkey)
|
||||
|
||||
self._std_abbr = keydict["Std"]
|
||||
self._dst_abbr = keydict["Dlt"]
|
||||
|
||||
self._display = keydict["Display"]
|
||||
|
||||
# See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
|
||||
tup = struct.unpack("=3l16h", keydict["TZI"])
|
||||
stdoffset = -tup[0]-tup[1] # Bias + StandardBias * -1
|
||||
dstoffset = stdoffset-tup[2] # + DaylightBias * -1
|
||||
self._std_offset = datetime.timedelta(minutes=stdoffset)
|
||||
self._dst_offset = datetime.timedelta(minutes=dstoffset)
|
||||
|
||||
# for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
|
||||
(self._stdmonth,
|
||||
self._stddayofweek, # Sunday = 0
|
||||
self._stdweeknumber, # Last = 5
|
||||
self._stdhour,
|
||||
self._stdminute) = tup[4:9]
|
||||
|
||||
(self._dstmonth,
|
||||
self._dstdayofweek, # Sunday = 0
|
||||
self._dstweeknumber, # Last = 5
|
||||
self._dsthour,
|
||||
self._dstminute) = tup[12:17]
|
||||
|
||||
self._dst_base_offset_ = self._dst_offset - self._std_offset
|
||||
self.hasdst = self._get_hasdst()
|
||||
|
||||
def __repr__(self):
|
||||
return "tzwin(%s)" % repr(self._name)
|
||||
|
||||
def __reduce__(self):
|
||||
return (self.__class__, (self._name,))
|
||||
|
||||
|
||||
class tzwinlocal(tzwinbase):
|
||||
def __init__(self):
|
||||
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
|
||||
with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey:
|
||||
keydict = valuestodict(tzlocalkey)
|
||||
|
||||
self._std_abbr = keydict["StandardName"]
|
||||
self._dst_abbr = keydict["DaylightName"]
|
||||
|
||||
try:
|
||||
tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME,
|
||||
sn=self._std_abbr)
|
||||
with winreg.OpenKey(handle, tzkeyname) as tzkey:
|
||||
_keydict = valuestodict(tzkey)
|
||||
self._display = _keydict["Display"]
|
||||
except OSError:
|
||||
self._display = None
|
||||
|
||||
stdoffset = -keydict["Bias"]-keydict["StandardBias"]
|
||||
dstoffset = stdoffset-keydict["DaylightBias"]
|
||||
|
||||
self._std_offset = datetime.timedelta(minutes=stdoffset)
|
||||
self._dst_offset = datetime.timedelta(minutes=dstoffset)
|
||||
|
||||
# For reasons unclear, in this particular key, the day of week has been
|
||||
# moved to the END of the SYSTEMTIME structure.
|
||||
tup = struct.unpack("=8h", keydict["StandardStart"])
|
||||
|
||||
(self._stdmonth,
|
||||
self._stdweeknumber, # Last = 5
|
||||
self._stdhour,
|
||||
self._stdminute) = tup[1:5]
|
||||
|
||||
self._stddayofweek = tup[7]
|
||||
|
||||
tup = struct.unpack("=8h", keydict["DaylightStart"])
|
||||
|
||||
(self._dstmonth,
|
||||
self._dstweeknumber, # Last = 5
|
||||
self._dsthour,
|
||||
self._dstminute) = tup[1:5]
|
||||
|
||||
self._dstdayofweek = tup[7]
|
||||
|
||||
self._dst_base_offset_ = self._dst_offset - self._std_offset
|
||||
self.hasdst = self._get_hasdst()
|
||||
|
||||
def __repr__(self):
|
||||
return "tzwinlocal()"
|
||||
|
||||
def __str__(self):
|
||||
# str will return the standard name, not the daylight name.
|
||||
return "tzwinlocal(%s)" % repr(self._std_abbr)
|
||||
|
||||
def __reduce__(self):
|
||||
return (self.__class__, ())
|
||||
|
||||
|
||||
def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
|
||||
""" dayofweek == 0 means Sunday, whichweek 5 means last instance """
|
||||
first = datetime.datetime(year, month, 1, hour, minute)
|
||||
|
||||
# This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6),
|
||||
# Because 7 % 7 = 0
|
||||
weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
|
||||
wd = weekdayone + ((whichweek - 1) * ONEWEEK)
|
||||
if (wd.month != month):
|
||||
wd -= ONEWEEK
|
||||
|
||||
return wd
|
||||
|
||||
|
||||
def valuestodict(key):
|
||||
"""Convert a registry key's values to a dictionary."""
|
||||
dout = {}
|
||||
size = winreg.QueryInfoKey(key)[1]
|
||||
tz_res = None
|
||||
|
||||
for i in range(size):
|
||||
key_name, value, dtype = winreg.EnumValue(key, i)
|
||||
if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN:
|
||||
# If it's a DWORD (32-bit integer), it's stored as unsigned - convert
|
||||
# that to a proper signed integer
|
||||
if value & (1 << 31):
|
||||
value = value - (1 << 32)
|
||||
elif dtype == winreg.REG_SZ:
|
||||
# If it's a reference to the tzres DLL, load the actual string
|
||||
if value.startswith('@tzres'):
|
||||
tz_res = tz_res or tzres()
|
||||
value = tz_res.name_from_string(value)
|
||||
|
||||
value = value.rstrip('\x00') # Remove trailing nulls
|
||||
|
||||
dout[key_name] = value
|
||||
|
||||
return dout
|
2
libraries/dateutil/tzwin.py
Normal file
2
libraries/dateutil/tzwin.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
# tzwin has moved to dateutil.tz.win
|
||||
from .tz.win import *
|
71
libraries/dateutil/utils.py
Normal file
71
libraries/dateutil/utils.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module offers general convenience and utility functions for dealing with
|
||||
datetimes.
|
||||
|
||||
.. versionadded:: 2.7.0
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import datetime, time
|
||||
|
||||
|
||||
def today(tzinfo=None):
|
||||
"""
|
||||
Returns a :py:class:`datetime` representing the current day at midnight
|
||||
|
||||
:param tzinfo:
|
||||
The time zone to attach (also used to determine the current day).
|
||||
|
||||
:return:
|
||||
A :py:class:`datetime.datetime` object representing the current day
|
||||
at midnight.
|
||||
"""
|
||||
|
||||
dt = datetime.now(tzinfo)
|
||||
return datetime.combine(dt.date(), time(0, tzinfo=tzinfo))
|
||||
|
||||
|
||||
def default_tzinfo(dt, tzinfo):
|
||||
"""
|
||||
Sets the the ``tzinfo`` parameter on naive datetimes only
|
||||
|
||||
This is useful for example when you are provided a datetime that may have
|
||||
either an implicit or explicit time zone, such as when parsing a time zone
|
||||
string.
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> from dateutil.tz import tzoffset
|
||||
>>> from dateutil.parser import parse
|
||||
>>> from dateutil.utils import default_tzinfo
|
||||
>>> dflt_tz = tzoffset("EST", -18000)
|
||||
>>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz))
|
||||
2014-01-01 12:30:00+00:00
|
||||
>>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz))
|
||||
2014-01-01 12:30:00-05:00
|
||||
|
||||
:param dt:
|
||||
The datetime on which to replace the time zone
|
||||
|
||||
:param tzinfo:
|
||||
The :py:class:`datetime.tzinfo` subclass instance to assign to
|
||||
``dt`` if (and only if) it is naive.
|
||||
|
||||
:return:
|
||||
Returns an aware :py:class:`datetime.datetime`.
|
||||
"""
|
||||
if dt.tzinfo is not None:
|
||||
return dt
|
||||
else:
|
||||
return dt.replace(tzinfo=tzinfo)
|
||||
|
||||
|
||||
def within_delta(dt1, dt2, delta):
|
||||
"""
|
||||
Useful for comparing two datetimes that may a negilible difference
|
||||
to be considered equal.
|
||||
"""
|
||||
delta = abs(delta)
|
||||
difference = dt1 - dt2
|
||||
return -delta <= difference <= delta
|
167
libraries/dateutil/zoneinfo/__init__.py
Normal file
167
libraries/dateutil/zoneinfo/__init__.py
Normal file
|
@ -0,0 +1,167 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import warnings
|
||||
import json
|
||||
|
||||
from tarfile import TarFile
|
||||
from pkgutil import get_data
|
||||
from io import BytesIO
|
||||
|
||||
from dateutil.tz import tzfile as _tzfile
|
||||
|
||||
__all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"]
|
||||
|
||||
ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
|
||||
METADATA_FN = 'METADATA'
|
||||
|
||||
|
||||
class tzfile(_tzfile):
|
||||
def __reduce__(self):
|
||||
return (gettz, (self._filename,))
|
||||
|
||||
|
||||
def getzoneinfofile_stream():
|
||||
try:
|
||||
return BytesIO(get_data(__name__, ZONEFILENAME))
|
||||
except IOError as e: # TODO switch to FileNotFoundError?
|
||||
warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
|
||||
return None
|
||||
|
||||
|
||||
class ZoneInfoFile(object):
|
||||
def __init__(self, zonefile_stream=None):
|
||||
if zonefile_stream is not None:
|
||||
with TarFile.open(fileobj=zonefile_stream) as tf:
|
||||
self.zones = {zf.name: tzfile(tf.extractfile(zf), filename=zf.name)
|
||||
for zf in tf.getmembers()
|
||||
if zf.isfile() and zf.name != METADATA_FN}
|
||||
# deal with links: They'll point to their parent object. Less
|
||||
# waste of memory
|
||||
links = {zl.name: self.zones[zl.linkname]
|
||||
for zl in tf.getmembers() if
|
||||
zl.islnk() or zl.issym()}
|
||||
self.zones.update(links)
|
||||
try:
|
||||
metadata_json = tf.extractfile(tf.getmember(METADATA_FN))
|
||||
metadata_str = metadata_json.read().decode('UTF-8')
|
||||
self.metadata = json.loads(metadata_str)
|
||||
except KeyError:
|
||||
# no metadata in tar file
|
||||
self.metadata = None
|
||||
else:
|
||||
self.zones = {}
|
||||
self.metadata = None
|
||||
|
||||
def get(self, name, default=None):
|
||||
"""
|
||||
Wrapper for :func:`ZoneInfoFile.zones.get`. This is a convenience method
|
||||
for retrieving zones from the zone dictionary.
|
||||
|
||||
:param name:
|
||||
The name of the zone to retrieve. (Generally IANA zone names)
|
||||
|
||||
:param default:
|
||||
The value to return in the event of a missing key.
|
||||
|
||||
.. versionadded:: 2.6.0
|
||||
|
||||
"""
|
||||
return self.zones.get(name, default)
|
||||
|
||||
|
||||
# The current API has gettz as a module function, although in fact it taps into
|
||||
# a stateful class. So as a workaround for now, without changing the API, we
|
||||
# will create a new "global" class instance the first time a user requests a
|
||||
# timezone. Ugly, but adheres to the api.
|
||||
#
|
||||
# TODO: Remove after deprecation period.
|
||||
_CLASS_ZONE_INSTANCE = []
|
||||
|
||||
|
||||
def get_zonefile_instance(new_instance=False):
|
||||
"""
|
||||
This is a convenience function which provides a :class:`ZoneInfoFile`
|
||||
instance using the data provided by the ``dateutil`` package. By default, it
|
||||
caches a single instance of the ZoneInfoFile object and returns that.
|
||||
|
||||
:param new_instance:
|
||||
If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
|
||||
used as the cached instance for the next call. Otherwise, new instances
|
||||
are created only as necessary.
|
||||
|
||||
:return:
|
||||
Returns a :class:`ZoneInfoFile` object.
|
||||
|
||||
.. versionadded:: 2.6
|
||||
"""
|
||||
if new_instance:
|
||||
zif = None
|
||||
else:
|
||||
zif = getattr(get_zonefile_instance, '_cached_instance', None)
|
||||
|
||||
if zif is None:
|
||||
zif = ZoneInfoFile(getzoneinfofile_stream())
|
||||
|
||||
get_zonefile_instance._cached_instance = zif
|
||||
|
||||
return zif
|
||||
|
||||
|
||||
def gettz(name):
|
||||
"""
|
||||
This retrieves a time zone from the local zoneinfo tarball that is packaged
|
||||
with dateutil.
|
||||
|
||||
:param name:
|
||||
An IANA-style time zone name, as found in the zoneinfo file.
|
||||
|
||||
:return:
|
||||
Returns a :class:`dateutil.tz.tzfile` time zone object.
|
||||
|
||||
.. warning::
|
||||
It is generally inadvisable to use this function, and it is only
|
||||
provided for API compatibility with earlier versions. This is *not*
|
||||
equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
|
||||
time zone based on the inputs, favoring system zoneinfo. This is ONLY
|
||||
for accessing the dateutil-specific zoneinfo (which may be out of
|
||||
date compared to the system zoneinfo).
|
||||
|
||||
.. deprecated:: 2.6
|
||||
If you need to use a specific zoneinfofile over the system zoneinfo,
|
||||
instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
|
||||
:func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.
|
||||
|
||||
Use :func:`get_zonefile_instance` to retrieve an instance of the
|
||||
dateutil-provided zoneinfo.
|
||||
"""
|
||||
warnings.warn("zoneinfo.gettz() will be removed in future versions, "
|
||||
"to use the dateutil-provided zoneinfo files, instantiate a "
|
||||
"ZoneInfoFile object and use ZoneInfoFile.zones.get() "
|
||||
"instead. See the documentation for details.",
|
||||
DeprecationWarning)
|
||||
|
||||
if len(_CLASS_ZONE_INSTANCE) == 0:
|
||||
_CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
|
||||
return _CLASS_ZONE_INSTANCE[0].zones.get(name)
|
||||
|
||||
|
||||
def gettz_db_metadata():
|
||||
""" Get the zonefile metadata
|
||||
|
||||
See `zonefile_metadata`_
|
||||
|
||||
:returns:
|
||||
A dictionary with the database metadata
|
||||
|
||||
.. deprecated:: 2.6
|
||||
See deprecation warning in :func:`zoneinfo.gettz`. To get metadata,
|
||||
query the attribute ``zoneinfo.ZoneInfoFile.metadata``.
|
||||
"""
|
||||
warnings.warn("zoneinfo.gettz_db_metadata() will be removed in future "
|
||||
"versions, to use the dateutil-provided zoneinfo files, "
|
||||
"ZoneInfoFile object and query the 'metadata' attribute "
|
||||
"instead. See the documentation for details.",
|
||||
DeprecationWarning)
|
||||
|
||||
if len(_CLASS_ZONE_INSTANCE) == 0:
|
||||
_CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
|
||||
return _CLASS_ZONE_INSTANCE[0].metadata
|
BIN
libraries/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
Normal file
BIN
libraries/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz
Normal file
Binary file not shown.
53
libraries/dateutil/zoneinfo/rebuild.py
Normal file
53
libraries/dateutil/zoneinfo/rebuild.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
import json
|
||||
from subprocess import check_call
|
||||
from tarfile import TarFile
|
||||
|
||||
from dateutil.zoneinfo import METADATA_FN, ZONEFILENAME
|
||||
|
||||
|
||||
def rebuild(filename, tag=None, format="gz", zonegroups=[], metadata=None):
|
||||
"""Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*
|
||||
|
||||
filename is the timezone tarball from ``ftp.iana.org/tz``.
|
||||
|
||||
"""
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
zonedir = os.path.join(tmpdir, "zoneinfo")
|
||||
moduledir = os.path.dirname(__file__)
|
||||
try:
|
||||
with TarFile.open(filename) as tf:
|
||||
for name in zonegroups:
|
||||
tf.extract(name, tmpdir)
|
||||
filepaths = [os.path.join(tmpdir, n) for n in zonegroups]
|
||||
try:
|
||||
check_call(["zic", "-d", zonedir] + filepaths)
|
||||
except OSError as e:
|
||||
_print_on_nosuchfile(e)
|
||||
raise
|
||||
# write metadata file
|
||||
with open(os.path.join(zonedir, METADATA_FN), 'w') as f:
|
||||
json.dump(metadata, f, indent=4, sort_keys=True)
|
||||
target = os.path.join(moduledir, ZONEFILENAME)
|
||||
with TarFile.open(target, "w:%s" % format) as tf:
|
||||
for entry in os.listdir(zonedir):
|
||||
entrypath = os.path.join(zonedir, entry)
|
||||
tf.add(entrypath, entry)
|
||||
finally:
|
||||
shutil.rmtree(tmpdir)
|
||||
|
||||
|
||||
def _print_on_nosuchfile(e):
|
||||
"""Print helpful troubleshooting message
|
||||
|
||||
e is an exception raised by subprocess.check_call()
|
||||
|
||||
"""
|
||||
if e.errno == 2:
|
||||
logging.error(
|
||||
"Could not find zic. Perhaps you need to install "
|
||||
"libc-bin or some other package that provides it, "
|
||||
"or it's not in your PATH?")
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue