Compare commits
17 Commits
Author | SHA1 | Date |
---|---|---|
|
d54ccd64f6 | |
|
836792429f | |
|
b7435c4eac | |
|
723f549f73 | |
|
47b9aa57ae | |
|
9e32052ce3 | |
|
ed58383ea0 | |
|
f6816c6c01 | |
|
b7f0cafe98 | |
|
573a63998e | |
|
01b47c8c40 | |
|
52768f64db | |
|
cdfa408206 | |
|
eee3c71f6a | |
|
1eb2a2c6e0 | |
|
58e282fd87 | |
|
a1ba0663b6 |
|
@ -1,19 +1,139 @@
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
# Compiled python modules.
|
# Compiled python modules.
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
/build/
|
# Other
|
||||||
/.coverage
|
/diagnostics.lua
|
||||||
docs/_build
|
|
||||||
docs/Ordigi_data_scheme.odg
|
docs/Ordigi_data_scheme.odg
|
||||||
|
|
||||||
# Setuptools distribution folder.
|
|
||||||
/dist/
|
|
||||||
|
|
||||||
# Python egg metadata, regenerated from source files by setuptools.
|
|
||||||
/*.egg-info
|
|
||||||
|
|
||||||
/env/
|
|
||||||
/htmlcov
|
|
||||||
/ressources
|
/ressources
|
||||||
/Session.vim
|
/Session.vim
|
||||||
/tags
|
/tags
|
||||||
|
|
471
LICENSE
471
LICENSE
|
@ -1,26 +1,23 @@
|
||||||
### GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
<https://fsf.org/>
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this
|
Preamble
|
||||||
license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
### Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
to share and change all versions of a program--to make sure it remains
|
share and change all versions of a program--to make sure it remains free
|
||||||
free software for all its users. We, the Free Software Foundation, use
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
the GNU General Public License for most of our software; it applies
|
GNU General Public License for most of our software; it applies also to
|
||||||
also to any other work released this way by its authors. You can apply
|
any other work released this way by its authors. You can apply it to
|
||||||
it to your programs, too.
|
your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
@ -30,10 +27,9 @@ 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.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
To protect your rights, we need to prevent others from denying you
|
||||||
these rights or asking you to surrender the rights. Therefore, you
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
have certain responsibilities if you distribute copies of the
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
software, or if you modify it: responsibilities to respect the freedom
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
For example, if you distribute copies of such a program, whether
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
@ -52,44 +48,43 @@ changed, so that their problems will not be attributed erroneously to
|
||||||
authors of previous versions.
|
authors of previous versions.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
Some devices are designed to deny users access to install or run
|
||||||
modified versions of the software inside them, although the
|
modified versions of the software inside them, although the manufacturer
|
||||||
manufacturer can do so. This is fundamentally incompatible with the
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
aim of protecting users' freedom to change the software. The
|
protecting users' freedom to change the software. The systematic
|
||||||
systematic pattern of such abuse occurs in the area of products for
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
individuals to use, which is precisely where it is most unacceptable.
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
Therefore, we have designed this version of the GPL to prohibit the
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
practice for those products. If such problems arise substantially in
|
products. If such problems arise substantially in other domains, we
|
||||||
other domains, we stand ready to extend this provision to those
|
stand ready to extend this provision to those domains in future versions
|
||||||
domains in future versions of the GPL, as needed to protect the
|
of the GPL, as needed to protect the freedom of users.
|
||||||
freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
Finally, every program is threatened constantly by software patents.
|
||||||
States should not allow patents to restrict development and use of
|
States should not allow patents to restrict development and use of
|
||||||
software on general-purpose computers, but in those that do, we wish
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
to avoid the special danger that patents applied to a free program
|
avoid the special danger that patents applied to a free program could
|
||||||
could make it effectively proprietary. To prevent this, the GPL
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
assures that patents cannot be used to render the program non-free.
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
### TERMS AND CONDITIONS
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
#### 0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
of works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
"recipients" may be individuals or organizations.
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
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
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
an exact copy. The resulting work is called a "modified version" of
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
the earlier work or a work "based on" the earlier work.
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A "covered work" means either the unmodified Program or a work based
|
||||||
on the Program.
|
on the Program.
|
||||||
|
@ -102,12 +97,11 @@ distribution (with or without modification), making available to the
|
||||||
public, and in some countries other activities as well.
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
To "convey" a work means any kind of propagation that enables other
|
||||||
parties to make or receive copies. Mere interaction with a user
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
through a computer network, with no transfer of a copy, is not
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices" to
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
the extent that it includes a convenient and prominently visible
|
to the extent that it includes a convenient and prominently visible
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
tells the user that there is no warranty for the work (except to the
|
tells the user that there is no warranty for the work (except to the
|
||||||
extent that warranties are provided), that licensees may convey the
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
@ -115,11 +109,11 @@ 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
|
the interface presents a list of user commands or options, such as a
|
||||||
menu, a prominent item in the list meets this criterion.
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
#### 1. Source Code.
|
1. Source Code.
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work for
|
The "source code" for a work means the preferred form of the work
|
||||||
making modifications to it. "Object code" means any non-source form of
|
for making modifications to it. "Object code" means any non-source
|
||||||
a work.
|
form of a work.
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
A "Standard Interface" means an interface that either is an official
|
||||||
standard defined by a recognized standards body, or, in the case of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
@ -150,13 +144,14 @@ linked subprograms that the work is specifically designed to require,
|
||||||
such as by intimate data communication or control flow between those
|
such as by intimate data communication or control flow between those
|
||||||
subprograms and other parts of the work.
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can
|
The Corresponding Source need not include anything that users
|
||||||
regenerate automatically from other parts of the Corresponding Source.
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same
|
The Corresponding Source for a work in source code form is that
|
||||||
work.
|
same work.
|
||||||
|
|
||||||
#### 2. Basic Permissions.
|
2. Basic Permissions.
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
All rights granted under this License are granted for the term of
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
@ -166,22 +161,22 @@ covered work is covered by this License only if the output, given its
|
||||||
content, constitutes a covered work. This License acknowledges your
|
content, constitutes a covered work. This License acknowledges your
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
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,
|
You may make, run and propagate covered works that you do not
|
||||||
without conditions so long as your license otherwise remains in force.
|
convey, without conditions so long as your license otherwise remains
|
||||||
You may convey covered works to others for the sole purpose of having
|
in force. You may convey covered works to others for the sole purpose
|
||||||
them make modifications exclusively for you, or provide you with
|
of having them make modifications exclusively for you, or provide you
|
||||||
facilities for running those works, provided that you comply with the
|
with facilities for running those works, provided that you comply with
|
||||||
terms of this License in conveying all material for which you do not
|
the terms of this License in conveying all material for which you do
|
||||||
control copyright. Those thus making or running the covered works for
|
not control copyright. Those thus making or running the covered works
|
||||||
you must do so exclusively on your behalf, under your direction and
|
for you must do so exclusively on your behalf, under your direction
|
||||||
control, on terms that prohibit them from making any copies of your
|
and control, on terms that prohibit them from making any copies of
|
||||||
copyrighted material outside their relationship with you.
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the
|
Conveying under any other circumstances is permitted solely under
|
||||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
it unnecessary.
|
makes it unnecessary.
|
||||||
|
|
||||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
No covered work shall be deemed part of an effective technological
|
||||||
measure under any applicable law fulfilling obligations under article
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
@ -190,14 +185,14 @@ similar laws prohibiting or restricting circumvention of such
|
||||||
measures.
|
measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
circumvention of technological measures to the extent such
|
circumvention of technological measures to the extent such circumvention
|
||||||
circumvention is effected by exercising rights under this License with
|
is effected by exercising rights under this License with respect to
|
||||||
respect to the covered work, and you disclaim any intention to limit
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
operation or modification of the work as a means of enforcing, against
|
modification of the work as a means of enforcing, against the work's
|
||||||
the work's users, your or third parties' legal rights to forbid
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
circumvention of technological measures.
|
technological measures.
|
||||||
|
|
||||||
#### 4. Conveying Verbatim Copies.
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
You may convey verbatim copies of the Program's source code as you
|
||||||
receive it, in any medium, provided that you conspicuously and
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
@ -210,27 +205,29 @@ recipients a copy of this License along with the Program.
|
||||||
You may charge any price or no price for each copy that you convey,
|
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.
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
#### 5. Conveying Modified Source Versions.
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
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
|
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
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
conditions:
|
|
||||||
|
|
||||||
- a) The work must carry prominent notices stating that you modified
|
a) The work must carry prominent notices stating that you modified
|
||||||
it, and giving a relevant date.
|
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
|
b) The work must carry prominent notices stating that it is
|
||||||
section 7. This requirement modifies the requirement in section 4
|
released under this License and any conditions added under section
|
||||||
to "keep intact all notices".
|
7. This requirement modifies the requirement in section 4 to
|
||||||
- c) You must license the entire work, as a whole, under this
|
"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 to anyone who comes into possession of a copy. This
|
||||||
License will therefore apply, along with any applicable section 7
|
License will therefore apply, along with any applicable section 7
|
||||||
additional terms, to the whole of the work, and all its parts,
|
additional terms, to the whole of the work, and all its parts,
|
||||||
regardless of how they are packaged. This License gives no
|
regardless of how they are packaged. This License gives no
|
||||||
permission to license the work in any other way, but it does not
|
permission to license the work in any other way, but it does not
|
||||||
invalidate such permission if you have separately received it.
|
invalidate such permission if you have separately received it.
|
||||||
- d) If the work has interactive user interfaces, each must display
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
work need not make them do so.
|
work need not make them do so.
|
||||||
|
@ -245,18 +242,19 @@ beyond what the individual works permit. Inclusion of a covered work
|
||||||
in an aggregate does not cause this License to apply to the other
|
in an aggregate does not cause this License to apply to the other
|
||||||
parts of the aggregate.
|
parts of the aggregate.
|
||||||
|
|
||||||
#### 6. Conveying Non-Source Forms.
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms of
|
You may convey a covered work in object code form under the terms
|
||||||
sections 4 and 5, provided that you also convey the machine-readable
|
of sections 4 and 5, provided that you also convey the
|
||||||
Corresponding Source under the terms of this License, in one of these
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
ways:
|
in one of these ways:
|
||||||
|
|
||||||
- a) Convey the object code in, or embodied in, a physical product
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by the
|
(including a physical distribution medium), accompanied by the
|
||||||
Corresponding Source fixed on a durable physical medium
|
Corresponding Source fixed on a durable physical medium
|
||||||
customarily used for software interchange.
|
customarily used for software interchange.
|
||||||
- b) Convey the object code in, or embodied in, a physical product
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
(including a physical distribution medium), accompanied by a
|
(including a physical distribution medium), accompanied by a
|
||||||
written offer, valid for at least three years and valid for as
|
written offer, valid for at least three years and valid for as
|
||||||
long as you offer spare parts or customer support for that product
|
long as you offer spare parts or customer support for that product
|
||||||
|
@ -265,14 +263,16 @@ ways:
|
||||||
product that is covered by this License, on a durable physical
|
product that is covered by this License, on a durable physical
|
||||||
medium customarily used for software interchange, for a price no
|
medium customarily used for software interchange, for a price no
|
||||||
more than your reasonable cost of physically performing this
|
more than your reasonable cost of physically performing this
|
||||||
conveying of source, or (2) access to copy the Corresponding
|
conveying of source, or (2) access to copy the
|
||||||
Source from a network server at no charge.
|
Corresponding Source from a network server at no charge.
|
||||||
- c) Convey individual copies of the object code with a copy of the
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
written offer to provide the Corresponding Source. This
|
written offer to provide the Corresponding Source. This
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
only if you received the object code with such an offer, in accord
|
only if you received the object code with such an offer, in accord
|
||||||
with subsection 6b.
|
with subsection 6b.
|
||||||
- d) Convey the object code by offering access from a designated
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
Corresponding Source in the same way through the same place at no
|
Corresponding Source in the same way through the same place at no
|
||||||
further charge. You need not require recipients to copy the
|
further charge. You need not require recipients to copy the
|
||||||
|
@ -284,36 +284,36 @@ ways:
|
||||||
Corresponding Source. Regardless of what server hosts the
|
Corresponding Source. Regardless of what server hosts the
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
available for as long as needed to satisfy these requirements.
|
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
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
Corresponding Source of the work are being offered to the general
|
you inform other peers where the object code and Corresponding
|
||||||
public at no charge under subsection 6d.
|
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
|
A separable portion of the object code, whose source code is excluded
|
||||||
from the Corresponding Source as a System Library, need not be
|
from the Corresponding Source as a System Library, need not be
|
||||||
included in conveying the object code work.
|
included in conveying the object code work.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
tangible personal property which is normally used for personal,
|
tangible personal property which is normally used for personal, family,
|
||||||
family, or household purposes, or (2) anything designed or sold for
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
incorporation into a dwelling. In determining whether a product is a
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
consumer product, doubtful cases shall be resolved in favor of
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
coverage. For a particular product received by a particular user,
|
product received by a particular user, "normally used" refers to a
|
||||||
"normally used" refers to a typical or common use of that class of
|
typical or common use of that class of product, regardless of the status
|
||||||
product, regardless of the status of the particular user or of the way
|
of the particular user or of the way in which the particular user
|
||||||
in which the particular user actually uses, or expects or is expected
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
to use, the product. A product is a consumer product regardless of
|
is a consumer product regardless of whether the product has substantial
|
||||||
whether the product has substantial commercial, industrial or
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
non-consumer uses, unless such uses represent the only significant
|
the only significant mode of use of the product.
|
||||||
mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
"Installation Information" for a User Product means any methods,
|
||||||
procedures, authorization keys, or other information required to
|
procedures, authorization keys, or other information required to install
|
||||||
install and execute modified versions of a covered work in that User
|
and execute modified versions of a covered work in that User Product from
|
||||||
Product from a modified version of its Corresponding Source. The
|
a modified version of its Corresponding Source. The information must
|
||||||
information must suffice to ensure that the continued functioning of
|
suffice to ensure that the continued functioning of the modified object
|
||||||
the modified object code is in no case prevented or interfered with
|
code is in no case prevented or interfered with solely because
|
||||||
solely because modification has been made.
|
modification has been made.
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
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
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
@ -327,13 +327,12 @@ modified object code on the User Product (for example, the work has
|
||||||
been installed in ROM).
|
been installed in ROM).
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
The requirement to provide Installation Information does not include a
|
||||||
requirement to continue to provide support service, warranty, or
|
requirement to continue to provide support service, warranty, or updates
|
||||||
updates for a work that has been modified or installed by the
|
for a work that has been modified or installed by the recipient, or for
|
||||||
recipient, or for the User Product in which it has been modified or
|
the User Product in which it has been modified or installed. Access to a
|
||||||
installed. Access to a network may be denied when the modification
|
network may be denied when the modification itself materially and
|
||||||
itself materially and adversely affects the operation of the network
|
adversely affects the operation of the network or violates the rules and
|
||||||
or violates the rules and protocols for communication across the
|
protocols for communication across the network.
|
||||||
network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
in accord with this section must be in a format that is publicly
|
in accord with this section must be in a format that is publicly
|
||||||
|
@ -341,7 +340,7 @@ documented (and with an implementation available to the public in
|
||||||
source code form), and must require no special password or key for
|
source code form), and must require no special password or key for
|
||||||
unpacking, reading or copying.
|
unpacking, reading or copying.
|
||||||
|
|
||||||
#### 7. Additional Terms.
|
7. Additional Terms.
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
License by making exceptions from one or more of its conditions.
|
License by making exceptions from one or more of its conditions.
|
||||||
|
@ -360,26 +359,31 @@ additional permissions on material, added by you to a covered work,
|
||||||
for which you have or can give appropriate copyright permission.
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
Notwithstanding any other provision of this License, for material you
|
||||||
add to a covered work, you may (if authorized by the copyright holders
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
of that material) supplement the terms of this License with terms:
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
- a) Disclaiming warranty or limiting liability differently from the
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
terms of sections 15 and 16 of this License; or
|
terms of sections 15 and 16 of this License; or
|
||||||
- b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
author attributions in that material or in the Appropriate Legal
|
author attributions in that material or in the Appropriate Legal
|
||||||
Notices displayed by works containing it; or
|
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
|
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
|
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
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
- e) Declining to grant rights under trademark law for use of some
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
trade names, trademarks, or service marks; or
|
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
|
f) Requiring indemnification of licensors and authors of that
|
||||||
of it) with contractual assumptions of liability to the recipient,
|
material by anyone who conveys the material (or modified versions of
|
||||||
for any liability that these contractual assumptions directly
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
impose on those licensors and authors.
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
All other non-permissive additional terms are considered "further
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
@ -397,10 +401,10 @@ additional terms that apply to those files, or a notice indicating
|
||||||
where to find the applicable terms.
|
where to find the applicable terms.
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
form of a separately written license, or stated as exceptions; the
|
form of a separately written license, or stated as exceptions;
|
||||||
above requirements apply either way.
|
the above requirements apply either way.
|
||||||
|
|
||||||
#### 8. Termination.
|
8. Termination.
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
You may not propagate or modify a covered work except as expressly
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
@ -408,12 +412,12 @@ modify it is void, and will automatically terminate your rights under
|
||||||
this License (including any patent licenses granted under the third
|
this License (including any patent licenses granted under the third
|
||||||
paragraph of section 11).
|
paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license
|
However, if you cease all violation of this License, then your
|
||||||
from a particular copyright holder is reinstated (a) provisionally,
|
license from a particular copyright holder is reinstated (a)
|
||||||
unless and until the copyright holder explicitly and finally
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
terminates your license, and (b) permanently, if the copyright holder
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
fails to notify you of the violation by some reasonable means prior to
|
holder fails to notify you of the violation by some reasonable means
|
||||||
60 days after the cessation.
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
Moreover, your license from a particular copyright holder is
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
@ -428,10 +432,10 @@ this License. If your rights have been terminated and not permanently
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
material under section 10.
|
material under section 10.
|
||||||
|
|
||||||
#### 9. Acceptance Not Required for Having Copies.
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or run
|
You are not required to accept this License in order to receive or
|
||||||
a copy of the Program. Ancillary propagation of a covered work
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
to receive a copy likewise does not require acceptance. However,
|
to receive a copy likewise does not require acceptance. However,
|
||||||
nothing other than this License grants you permission to propagate or
|
nothing other than this License grants you permission to propagate or
|
||||||
|
@ -439,7 +443,7 @@ modify any covered work. These actions infringe copyright if you do
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
#### 10. Automatic Licensing of Downstream Recipients.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
Each time you convey a covered work, the recipient automatically
|
||||||
receives a license from the original licensors, to run, modify and
|
receives a license from the original licensors, to run, modify and
|
||||||
|
@ -464,14 +468,14 @@ rights granted under this License, and you may not initiate litigation
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
sale, or importing the Program or any portion of it.
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
#### 11. Patents.
|
11. Patents.
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
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
|
License of the Program or a work on which the Program is based. The
|
||||||
work thus licensed is called the contributor's "contributor version".
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims owned
|
A contributor's "essential patent claims" are all patent claims
|
||||||
or controlled by the contributor, whether already acquired or
|
owned or controlled by the contributor, whether already acquired or
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
by this License, of making, using, or selling its contributor version,
|
by this License, of making, using, or selling its contributor version,
|
||||||
but do not include claims that would be infringed only as a
|
but do not include claims that would be infringed only as a
|
||||||
|
@ -514,39 +518,38 @@ or convey a specific copy of the covered work, then the patent license
|
||||||
you grant is automatically extended to all recipients of the covered
|
you grant is automatically extended to all recipients of the covered
|
||||||
work and works based on it.
|
work and works based on it.
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within the
|
A patent license is "discriminatory" if it does not include within
|
||||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
the non-exercise of one or more of the rights that are specifically
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
granted under this License. You may not convey a covered work if you
|
specifically granted under this License. You may not convey a covered
|
||||||
are a party to an arrangement with a third party that is in the
|
work if you are a party to an arrangement with a third party that is
|
||||||
business of distributing software, under which you make payment to the
|
in the business of distributing software, under which you make payment
|
||||||
third party based on the extent of your activity of conveying the
|
to the third party based on the extent of your activity of conveying
|
||||||
work, and under which the third party grants, to any of the parties
|
the work, and under which the third party grants, to any of the
|
||||||
who would receive the covered work from you, a discriminatory patent
|
parties who would receive the covered work from you, a discriminatory
|
||||||
license (a) in connection with copies of the covered work conveyed by
|
patent license (a) in connection with copies of the covered work
|
||||||
you (or copies made from those copies), or (b) primarily for and in
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
connection with specific products or compilations that contain the
|
for and in connection with specific products or compilations that
|
||||||
covered work, unless you entered into that arrangement, or that patent
|
contain the covered work, unless you entered into that arrangement,
|
||||||
license was granted, prior to 28 March 2007.
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
any implied license or other defenses to infringement that may
|
any implied license or other defenses to infringement that may
|
||||||
otherwise be available to you under applicable patent law.
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
#### 12. No Surrender of Others' Freedom.
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
covered work so as to satisfy simultaneously your obligations under
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
this License and any other pertinent obligations, then as a
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
consequence you may not convey it at all. For example, if you agree to
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
terms that obligate you to collect a royalty for further conveying
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
from those to whom you convey the Program, the only way you could
|
the Program, the only way you could satisfy both those terms and this
|
||||||
satisfy both those terms and this License would be to refrain entirely
|
License would be to refrain entirely from conveying the Program.
|
||||||
from conveying the Program.
|
|
||||||
|
|
||||||
#### 13. Use with the GNU Affero General Public License.
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
|
@ -557,57 +560,56 @@ but the special requirements of the GNU Affero General Public License,
|
||||||
section 13, concerning interaction through a network will apply to the
|
section 13, concerning interaction through a network will apply to the
|
||||||
combination as such.
|
combination as such.
|
||||||
|
|
||||||
#### 14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
of the GNU General Public License from time to time. Such new versions
|
the GNU General Public License from time to time. Such new versions will
|
||||||
will be similar in spirit to the present version, but may differ in
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
detail to address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program
|
Each version is given a distinguishing version number. If the
|
||||||
specifies that a certain numbered version of the GNU General Public
|
Program specifies that a certain numbered version of the GNU General
|
||||||
License "or any later version" applies to it, you have the option of
|
Public License "or any later version" applies to it, you have the
|
||||||
following the terms and conditions either of that numbered version or
|
option of following the terms and conditions either of that numbered
|
||||||
of any later version published by the Free Software Foundation. If the
|
version or of any later version published by the Free Software
|
||||||
Program does not specify a version number of the GNU General Public
|
Foundation. If the Program does not specify a version number of the
|
||||||
License, you may choose any version ever published by the Free
|
GNU General Public License, you may choose any version ever published
|
||||||
Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions
|
If the Program specifies that a proxy can decide which future
|
||||||
of the GNU General Public License can be used, that proxy's public
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
statement of acceptance of a version permanently authorizes you to
|
public statement of acceptance of a version permanently authorizes you
|
||||||
choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
Later license versions may give you additional or different
|
||||||
permissions. However, no additional obligations are imposed on any
|
permissions. However, no additional obligations are imposed on any
|
||||||
author or copyright holder as a result of your choosing to follow a
|
author or copyright holder as a result of your choosing to follow a
|
||||||
later version.
|
later version.
|
||||||
|
|
||||||
#### 15. Disclaimer of Warranty.
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
CORRECTION.
|
|
||||||
|
|
||||||
#### 16. Limitation of Liability.
|
16. Limitation of Liability.
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
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
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
SUCH DAMAGES.
|
||||||
|
|
||||||
#### 17. Interpretation of Sections 15 and 16.
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
above cannot be given local legal effect according to their terms,
|
above cannot be given local legal effect according to their terms,
|
||||||
|
@ -618,17 +620,16 @@ copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
### How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
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
|
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
|
free software which everyone can redistribute and change under these terms.
|
||||||
terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to
|
To do so, attach the following notices to the program. It is safest
|
||||||
attach them to the start of each source file to most effectively state
|
to attach them to the start of each source file to most effectively
|
||||||
the exclusion of warranty; and each file should have at least the
|
state the exclusion of warranty; and each file should have at least
|
||||||
"copyright" line and a pointer to where the full notice is found.
|
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.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
@ -646,8 +647,7 @@ the exclusion of warranty; and each file should have at least the
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
@ -657,19 +657,18 @@ notice like this when it starts in an interactive mode:
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands \`show w' and \`show c' should show the
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
appropriate parts of the General Public License. Of course, your
|
parts of the General Public License. Of course, your program's commands
|
||||||
program's commands might be different; for a GUI interface, you would
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
necessary. For more information on this, and how to apply and follow
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your
|
The GNU General Public License does not permit incorporating your program
|
||||||
program into proprietary programs. If your program is a subroutine
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
library, you may consider it more useful to permit linking proprietary
|
may consider it more useful to permit linking proprietary applications with
|
||||||
applications with the library. If this is what you want to do, use the
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
GNU Lesser General Public License instead of this License. But first,
|
Public License instead of this License. But first, please read
|
||||||
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|
18
ordigi.conf
18
ordigi.conf
|
@ -1,5 +1,17 @@
|
||||||
|
[Exif]
|
||||||
|
#album_from_folder=False
|
||||||
|
fill_date_original=True
|
||||||
|
#cache=True
|
||||||
|
#ignore_tags=None
|
||||||
|
use_date_filename=True
|
||||||
|
#use_file_dates=False
|
||||||
|
|
||||||
[Filters]
|
[Filters]
|
||||||
exclude=["**/.directory", "**/.DS_Store"]
|
exclude=["**/.directory", "**/.DS_Store"]
|
||||||
|
#extensions=None
|
||||||
|
#glob=**/*
|
||||||
|
#max_deep=None
|
||||||
|
remove_duplicates=True
|
||||||
|
|
||||||
[Geolocation]
|
[Geolocation]
|
||||||
geocoder=Nominatim
|
geocoder=Nominatim
|
||||||
|
@ -15,5 +27,9 @@ day_begins=4
|
||||||
|
|
||||||
# Path format
|
# Path format
|
||||||
dirs_path=<%Y>/<%m-%b>_<location>_<folder>
|
dirs_path=<%Y>/<%m-%b>_<location>_<folder>
|
||||||
name=<%Y%m%d-%H%M%S>_<<original_name>|<name>>.%l<ext>
|
name=<%Y%m%d-%H%M%S>_<<name>.%l<ext>|<original_name>>
|
||||||
# name=<%Y%m%d-%H%M%S>-%u<original_name>.%l<ext>
|
# name=<%Y%m%d-%H%M%S>-%u<original_name>.%l<ext>
|
||||||
|
|
||||||
|
[Terminal]
|
||||||
|
dry_run=False
|
||||||
|
interactive=False
|
||||||
|
|
114
ordigi/cli.py
114
ordigi/cli.py
|
@ -5,17 +5,33 @@ import sys
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from ordigi import constants, log, LOG
|
from ordigi import log, LOG
|
||||||
from ordigi.collection import Collection
|
from ordigi.collection import Collection
|
||||||
|
from ordigi import constants
|
||||||
from ordigi.geolocation import GeoLocation
|
from ordigi.geolocation import GeoLocation
|
||||||
from ordigi import utils
|
from ordigi import utils
|
||||||
|
|
||||||
_logger_options = [
|
_logger_options = [
|
||||||
|
click.option(
|
||||||
|
'--quiet',
|
||||||
|
'-q',
|
||||||
|
default=False,
|
||||||
|
is_flag=True,
|
||||||
|
help='Log level set to ERROR',
|
||||||
|
),
|
||||||
click.option(
|
click.option(
|
||||||
'--verbose',
|
'--verbose',
|
||||||
'-v',
|
'-v',
|
||||||
default='WARNING',
|
default=False,
|
||||||
help='Log level [WARNING,INFO,DEBUG,NOTSET]',
|
is_flag=True,
|
||||||
|
help='Log level set to INFO',
|
||||||
|
),
|
||||||
|
click.option(
|
||||||
|
'--debug',
|
||||||
|
'-d',
|
||||||
|
default=False,
|
||||||
|
is_flag=True,
|
||||||
|
help='Log level set to DEBUG',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -85,7 +101,7 @@ _sort_options = [
|
||||||
click.option(
|
click.option(
|
||||||
'--path-format',
|
'--path-format',
|
||||||
'-p',
|
'-p',
|
||||||
default=None,
|
default=constants.DEFAULT_PATH_FORMAT,
|
||||||
help='Custom featured path format',
|
help='Custom featured path format',
|
||||||
),
|
),
|
||||||
click.option(
|
click.option(
|
||||||
|
@ -147,15 +163,10 @@ def _cli_get_location(collection):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _cli_sort(collection, src_paths, import_mode, remove_duplicates):
|
def _cli_sort(collection, src_paths, import_mode):
|
||||||
loc = _cli_get_location(collection)
|
loc = _cli_get_location(collection)
|
||||||
|
|
||||||
path_format = collection.opt['Path']['path_format']
|
return collection.sort_files(src_paths, loc, import_mode)
|
||||||
LOG.debug(f'path_format: {path_format}')
|
|
||||||
|
|
||||||
return collection.sort_files(
|
|
||||||
src_paths, path_format, loc, import_mode, remove_duplicates
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
|
@ -172,7 +183,7 @@ def _check(**kwargs):
|
||||||
"""
|
"""
|
||||||
root = Path(kwargs['path']).expanduser().absolute()
|
root = Path(kwargs['path']).expanduser().absolute()
|
||||||
|
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
collection = Collection(root)
|
collection = Collection(root)
|
||||||
|
@ -182,6 +193,7 @@ def _check(**kwargs):
|
||||||
if log_level < 30:
|
if log_level < 30:
|
||||||
summary.print()
|
summary.print()
|
||||||
if summary.errors:
|
if summary.errors:
|
||||||
|
LOG.error('Db data is not accurate run `ordigi update --checksum`')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
LOG.error('Db data is not accurate run `ordigi update`')
|
LOG.error('Db data is not accurate run `ordigi update`')
|
||||||
|
@ -194,7 +206,7 @@ def _check(**kwargs):
|
||||||
@add_options(_filter_options)
|
@add_options(_filter_options)
|
||||||
@click.option(
|
@click.option(
|
||||||
'--dedup-regex',
|
'--dedup-regex',
|
||||||
'-d',
|
'-D',
|
||||||
default=None,
|
default=None,
|
||||||
multiple=True,
|
multiple=True,
|
||||||
help='Regex to match duplicate strings parts',
|
help='Regex to match duplicate strings parts',
|
||||||
|
@ -218,10 +230,10 @@ def _check(**kwargs):
|
||||||
@click.argument('subdirs', required=False, nargs=-1, type=click.Path())
|
@click.argument('subdirs', required=False, nargs=-1, type=click.Path())
|
||||||
@click.argument('collection', required=True, nargs=1, type=click.Path())
|
@click.argument('collection', required=True, nargs=1, type=click.Path())
|
||||||
def _clean(**kwargs):
|
def _clean(**kwargs):
|
||||||
"""Remove empty folders"""
|
"""Clean media collection"""
|
||||||
|
|
||||||
folders = kwargs['folders']
|
folders = kwargs['folders']
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
subdirs = kwargs['subdirs']
|
subdirs = kwargs['subdirs']
|
||||||
|
@ -231,24 +243,21 @@ def _clean(**kwargs):
|
||||||
collection = Collection(
|
collection = Collection(
|
||||||
root,
|
root,
|
||||||
{
|
{
|
||||||
"dry_run": kwargs['dry_run'],
|
'dry_run': kwargs['dry_run'],
|
||||||
"extensions": kwargs['ext'],
|
'extensions': kwargs['ext'],
|
||||||
"glob": kwargs['glob'],
|
'glob': kwargs['glob'],
|
||||||
|
'remove_duplicates': kwargs['remove_duplicates'],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
# os.path.join(
|
# os.path.join(
|
||||||
# TODO make function to remove duplicates
|
# TODO make function to remove duplicates
|
||||||
# path_format = collection.opt['Path']['path_format']
|
# path_format = collection.opt['Path']['path_format']
|
||||||
# summary = collection.sort_files(
|
# summary = collection.sort_files(paths, None)
|
||||||
# paths, path_format, None, remove_duplicates=kwargs['remove_duplicates']
|
|
||||||
# )
|
|
||||||
|
|
||||||
if kwargs['path_string']:
|
if kwargs['path_string']:
|
||||||
dedup_regex = set(kwargs['dedup_regex'])
|
dedup_regex = set(kwargs['dedup_regex'])
|
||||||
collection.dedup_path(
|
collection.dedup_path(paths, dedup_regex)
|
||||||
paths, dedup_regex, kwargs['remove_duplicates']
|
|
||||||
)
|
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if folders:
|
if folders:
|
||||||
|
@ -274,7 +283,7 @@ def _clean(**kwargs):
|
||||||
def _clone(**kwargs):
|
def _clone(**kwargs):
|
||||||
"""Clone media collection to another location"""
|
"""Clone media collection to another location"""
|
||||||
|
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
src_path = Path(kwargs['src']).expanduser().absolute()
|
src_path = Path(kwargs['src']).expanduser().absolute()
|
||||||
|
@ -327,16 +336,17 @@ def _compare(**kwargs):
|
||||||
subdirs = kwargs['subdirs']
|
subdirs = kwargs['subdirs']
|
||||||
root = kwargs['collection']
|
root = kwargs['collection']
|
||||||
|
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
paths, root = _get_paths(subdirs, root)
|
paths, root = _get_paths(subdirs, root)
|
||||||
|
|
||||||
collection = Collection(
|
collection = Collection(
|
||||||
root,
|
root,
|
||||||
{
|
{
|
||||||
"extensions": kwargs['ext'],
|
'extensions': kwargs['ext'],
|
||||||
"glob": kwargs['glob'],
|
'glob': kwargs['glob'],
|
||||||
"dry_run": kwargs['dry_run'],
|
'dry_run': kwargs['dry_run'],
|
||||||
|
'remove_duplicates': kwargs['remove_duplicates'],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -363,16 +373,25 @@ def _compare(**kwargs):
|
||||||
multiple=True,
|
multiple=True,
|
||||||
help="Select exif tags groups to edit",
|
help="Select exif tags groups to edit",
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
'--overwrite',
|
||||||
|
'-O',
|
||||||
|
default=False,
|
||||||
|
is_flag=True,
|
||||||
|
help="Overwrite db and exif value by key value",
|
||||||
|
)
|
||||||
@click.argument('subdirs', required=False, nargs=-1, type=click.Path())
|
@click.argument('subdirs', required=False, nargs=-1, type=click.Path())
|
||||||
@click.argument('path', required=True, nargs=1, type=click.Path())
|
@click.argument('path', required=True, nargs=1, type=click.Path())
|
||||||
def _edit(**kwargs):
|
def _edit(**kwargs):
|
||||||
"""Edit EXIF metadata in files or directories"""
|
"""Edit EXIF metadata in files or directories"""
|
||||||
|
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
paths, root = _get_paths(kwargs['subdirs'], kwargs['path'])
|
paths, root = _get_paths(kwargs['subdirs'], kwargs['path'])
|
||||||
|
|
||||||
|
overwrite = kwargs['overwrite']
|
||||||
|
|
||||||
collection = Collection(
|
collection = Collection(
|
||||||
root,
|
root,
|
||||||
{
|
{
|
||||||
|
@ -389,13 +408,11 @@ def _edit(**kwargs):
|
||||||
'camera_make',
|
'camera_make',
|
||||||
'camera_model',
|
'camera_model',
|
||||||
'city',
|
'city',
|
||||||
'coordinates',
|
|
||||||
'country',
|
'country',
|
||||||
# 'date_created',
|
# 'date_created',
|
||||||
'date_media',
|
'date_media',
|
||||||
# 'date_modified',
|
# 'date_modified',
|
||||||
'date_original',
|
'date_original',
|
||||||
'default',
|
|
||||||
'latitude',
|
'latitude',
|
||||||
'location',
|
'location',
|
||||||
'longitude',
|
'longitude',
|
||||||
|
@ -410,6 +427,9 @@ def _edit(**kwargs):
|
||||||
keys = set(editable_keys)
|
keys = set(editable_keys)
|
||||||
else:
|
else:
|
||||||
keys = set(kwargs['key'])
|
keys = set(kwargs['key'])
|
||||||
|
if 'coordinates' in keys:
|
||||||
|
keys.remove('coordinates')
|
||||||
|
keys.update(['latitude', 'longitude'])
|
||||||
|
|
||||||
location = False
|
location = False
|
||||||
for key in keys:
|
for key in keys:
|
||||||
|
@ -417,10 +437,6 @@ def _edit(**kwargs):
|
||||||
LOG.error(f"key '{key}' is not valid")
|
LOG.error(f"key '{key}' is not valid")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if key == 'coordinates':
|
|
||||||
keys.remove('coordinates')
|
|
||||||
keys.update(['latitude', 'longitude'])
|
|
||||||
|
|
||||||
if key in (
|
if key in (
|
||||||
'city',
|
'city',
|
||||||
'latitude',
|
'latitude',
|
||||||
|
@ -436,7 +452,7 @@ def _edit(**kwargs):
|
||||||
else:
|
else:
|
||||||
loc = None
|
loc = None
|
||||||
|
|
||||||
summary = collection.edit_metadata(paths, keys, loc, overwrite=True)
|
summary = collection.edit_metadata(paths, keys, loc, overwrite)
|
||||||
|
|
||||||
if log_level < 30:
|
if log_level < 30:
|
||||||
summary.print()
|
summary.print()
|
||||||
|
@ -453,7 +469,7 @@ def _init(**kwargs):
|
||||||
Init media collection database.
|
Init media collection database.
|
||||||
"""
|
"""
|
||||||
root = Path(kwargs['path']).expanduser().absolute()
|
root = Path(kwargs['path']).expanduser().absolute()
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
collection = Collection(root)
|
collection = Collection(root)
|
||||||
|
@ -490,7 +506,7 @@ def _import(**kwargs):
|
||||||
"""Sort files or directories by reading their EXIF and organizing them
|
"""Sort files or directories by reading their EXIF and organizing them
|
||||||
according to ordigi.conf preferences.
|
according to ordigi.conf preferences.
|
||||||
"""
|
"""
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
src_paths, root = _get_paths(kwargs['src'], kwargs['dest'])
|
src_paths, root = _get_paths(kwargs['src'], kwargs['dest'])
|
||||||
|
@ -509,7 +525,7 @@ def _import(**kwargs):
|
||||||
'dry_run': kwargs['dry_run'],
|
'dry_run': kwargs['dry_run'],
|
||||||
'interactive': kwargs['interactive'],
|
'interactive': kwargs['interactive'],
|
||||||
'path_format': kwargs['path_format'],
|
'path_format': kwargs['path_format'],
|
||||||
|
'remove_duplicates': kwargs['remove_duplicates'],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -517,7 +533,7 @@ def _import(**kwargs):
|
||||||
import_mode = 'copy'
|
import_mode = 'copy'
|
||||||
else:
|
else:
|
||||||
import_mode = 'move'
|
import_mode = 'move'
|
||||||
summary = _cli_sort(collection, src_paths, import_mode, kwargs['remove_duplicates'])
|
summary = _cli_sort(collection, src_paths, import_mode)
|
||||||
|
|
||||||
if log_level < 30:
|
if log_level < 30:
|
||||||
summary.print()
|
summary.print()
|
||||||
|
@ -546,7 +562,7 @@ def _sort(**kwargs):
|
||||||
"""Sort files or directories by reading their EXIF and organizing them
|
"""Sort files or directories by reading their EXIF and organizing them
|
||||||
according to ordigi.conf preferences.
|
according to ordigi.conf preferences.
|
||||||
"""
|
"""
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
paths, root = _get_paths(kwargs['subdirs'], kwargs['dest'])
|
paths, root = _get_paths(kwargs['subdirs'], kwargs['dest'])
|
||||||
|
@ -566,10 +582,11 @@ def _sort(**kwargs):
|
||||||
'glob': kwargs['glob'],
|
'glob': kwargs['glob'],
|
||||||
'dry_run': kwargs['dry_run'],
|
'dry_run': kwargs['dry_run'],
|
||||||
'interactive': kwargs['interactive'],
|
'interactive': kwargs['interactive'],
|
||||||
|
'remove_duplicates': kwargs['remove_duplicates'],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
summary = _cli_sort(collection, paths, False, kwargs['remove_duplicates'])
|
summary = _cli_sort(collection, paths, False)
|
||||||
|
|
||||||
if kwargs['clean']:
|
if kwargs['clean']:
|
||||||
collection.remove_empty_folders(root)
|
collection.remove_empty_folders(root)
|
||||||
|
@ -583,18 +600,25 @@ def _sort(**kwargs):
|
||||||
|
|
||||||
@cli.command('update')
|
@cli.command('update')
|
||||||
@add_options(_logger_options)
|
@add_options(_logger_options)
|
||||||
|
@click.option(
|
||||||
|
'--checksum',
|
||||||
|
'-c',
|
||||||
|
default=False,
|
||||||
|
is_flag=True,
|
||||||
|
help='Update checksum, assuming file are changed by the user',
|
||||||
|
)
|
||||||
@click.argument('path', required=True, nargs=1, type=click.Path())
|
@click.argument('path', required=True, nargs=1, type=click.Path())
|
||||||
def _update(**kwargs):
|
def _update(**kwargs):
|
||||||
"""
|
"""
|
||||||
Update media collection database.
|
Update media collection database.
|
||||||
"""
|
"""
|
||||||
root = Path(kwargs['path']).expanduser().absolute()
|
root = Path(kwargs['path']).expanduser().absolute()
|
||||||
log_level = log.get_level(kwargs['verbose'])
|
log_level = log.get_level(kwargs['quiet'], kwargs['verbose'], kwargs['debug'])
|
||||||
log.console(LOG, level=log_level)
|
log.console(LOG, level=log_level)
|
||||||
|
|
||||||
collection = Collection(root)
|
collection = Collection(root)
|
||||||
loc = _cli_get_location(collection)
|
loc = _cli_get_location(collection)
|
||||||
summary = collection.update(loc)
|
summary = collection.update(loc, kwargs['checksum'])
|
||||||
|
|
||||||
if log_level < 30:
|
if log_level < 30:
|
||||||
summary.print()
|
summary.print()
|
||||||
|
|
|
@ -138,8 +138,9 @@ class FPath:
|
||||||
elif item == 'name':
|
elif item == 'name':
|
||||||
# Remove date prefix added to the name.
|
# Remove date prefix added to the name.
|
||||||
part = stem
|
part = stem
|
||||||
for regex in utils.get_date_regex().values():
|
date_filename, regex, sep = utils.get_date_from_string(stem)
|
||||||
part = re.sub(regex, '', part)
|
if date_filename:
|
||||||
|
part = re.sub(regex, sep, part)
|
||||||
# Delete separator
|
# Delete separator
|
||||||
if re.search('^[-_ .]', part):
|
if re.search('^[-_ .]', part):
|
||||||
part = part[1:]
|
part = part[1:]
|
||||||
|
@ -272,7 +273,7 @@ class CollectionDb:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
self.sqlite = Sqlite(root)
|
self.sqlite = Sqlite(root)
|
||||||
|
|
||||||
def _set_row_data(self, table, metadata):
|
def _get_row_data(self, table, metadata):
|
||||||
row_data = {}
|
row_data = {}
|
||||||
for title in self.sqlite.tables[table]['header']:
|
for title in self.sqlite.tables[table]['header']:
|
||||||
key = utils.camel2snake(title)
|
key = utils.camel2snake(title)
|
||||||
|
@ -283,11 +284,11 @@ class CollectionDb:
|
||||||
def add_file_data(self, metadata):
|
def add_file_data(self, metadata):
|
||||||
"""Save metadata informations to db"""
|
"""Save metadata informations to db"""
|
||||||
if metadata['latitude'] and metadata['longitude']:
|
if metadata['latitude'] and metadata['longitude']:
|
||||||
loc_values = self._set_row_data('location', metadata)
|
loc_values = self._get_row_data('location', metadata)
|
||||||
metadata['location_id'] = self.sqlite.upsert_location(loc_values)
|
metadata['location_id'] = self.sqlite.upsert_location(loc_values)
|
||||||
|
|
||||||
if metadata['file_path']:
|
if metadata['file_path']:
|
||||||
row_data = self._set_row_data('metadata', metadata)
|
row_data = self._get_row_data('metadata', metadata)
|
||||||
self.sqlite.upsert_metadata(row_data)
|
self.sqlite.upsert_metadata(row_data)
|
||||||
|
|
||||||
|
|
||||||
|
@ -359,7 +360,7 @@ class Paths:
|
||||||
:return: Path path
|
:return: Path path
|
||||||
"""
|
"""
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
self.log.error(f'Directory {path} does not exist')
|
self.log.error(f'Path {path} does not exist')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
@ -476,6 +477,7 @@ class SortMedias:
|
||||||
db=None,
|
db=None,
|
||||||
dry_run=False,
|
dry_run=False,
|
||||||
interactive=False,
|
interactive=False,
|
||||||
|
remove_duplicates=False,
|
||||||
):
|
):
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
@ -488,9 +490,11 @@ class SortMedias:
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
self.interactive = interactive
|
self.interactive = interactive
|
||||||
self.log = LOG.getChild(self.__class__.__name__)
|
self.log = LOG.getChild(self.__class__.__name__)
|
||||||
|
self.remove_duplicates = remove_duplicates
|
||||||
self.summary = Summary(self.root)
|
self.summary = Summary(self.root)
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
|
self.input = request.Input()
|
||||||
self.theme = request.load_theme()
|
self.theme = request.load_theme()
|
||||||
|
|
||||||
def _checkcomp(self, dest_path, src_checksum):
|
def _checkcomp(self, dest_path, src_checksum):
|
||||||
|
@ -519,7 +523,7 @@ class SortMedias:
|
||||||
|
|
||||||
# change media file_path to dest_path
|
# change media file_path to dest_path
|
||||||
if not self.dry_run:
|
if not self.dry_run:
|
||||||
updated = self.medias.update_exif_data(metadata)
|
updated = self.medias.update_exif_data(metadata, imp)
|
||||||
if updated:
|
if updated:
|
||||||
checksum = utils.checksum(dest_path)
|
checksum = utils.checksum(dest_path)
|
||||||
metadata['checksum'] = checksum
|
metadata['checksum'] = checksum
|
||||||
|
@ -577,14 +581,10 @@ class SortMedias:
|
||||||
self.log.warning(f'Target directory {dir_path} is a file')
|
self.log.warning(f'Target directory {dir_path} is a file')
|
||||||
# Rename the src_file
|
# Rename the src_file
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
prompt = [
|
answer = self.input.text(
|
||||||
inquirer.Text(
|
"New name for" f"'{dir_path.name}' file"
|
||||||
'file_path',
|
)
|
||||||
message="New name for" f"'{dir_path.name}' file",
|
file_path = dir_path.parent / answer
|
||||||
),
|
|
||||||
]
|
|
||||||
answers = inquirer.prompt(prompt, theme=self.theme)
|
|
||||||
file_path = dir_path.parent / answers['file_path']
|
|
||||||
else:
|
else:
|
||||||
file_path = dir_path.parent / (dir_path.name + '_file')
|
file_path = dir_path.parent / (dir_path.name + '_file')
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ class SortMedias:
|
||||||
directory_path.mkdir(parents=True, exist_ok=True)
|
directory_path.mkdir(parents=True, exist_ok=True)
|
||||||
self.log.info(f'Create {directory_path}')
|
self.log.info(f'Create {directory_path}')
|
||||||
|
|
||||||
def check_conflicts(self, src_path, dest_path, remove_duplicates=False):
|
def check_conflicts(self, src_path, dest_path):
|
||||||
"""
|
"""
|
||||||
Check if file can be copied or moved file to dest_path.
|
Check if file can be copied or moved file to dest_path.
|
||||||
"""
|
"""
|
||||||
|
@ -615,7 +615,7 @@ class SortMedias:
|
||||||
|
|
||||||
if dest_path.is_file():
|
if dest_path.is_file():
|
||||||
self.log.info(f"File {dest_path} already exist")
|
self.log.info(f"File {dest_path} already exist")
|
||||||
if remove_duplicates:
|
if self.remove_duplicates:
|
||||||
if filecmp.cmp(src_path, dest_path):
|
if filecmp.cmp(src_path, dest_path):
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"File in source and destination are identical. Duplicate will be ignored."
|
"File in source and destination are identical. Duplicate will be ignored."
|
||||||
|
@ -632,15 +632,15 @@ class SortMedias:
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def _solve_conflicts(self, conflicts, remove_duplicates):
|
def _solve_conflicts(self, conflicts):
|
||||||
unresolved_conflicts = []
|
unresolved_conflicts = []
|
||||||
while conflicts != []:
|
while conflicts != []:
|
||||||
src_path, dest_path, metadata = conflicts.pop()
|
src_path, dest_path, metadata = conflicts.pop()
|
||||||
# Check for conflict status again in case is has changed
|
# Check for conflict status again in case is has changed
|
||||||
|
|
||||||
conflict = self.check_conflicts(src_path, dest_path, remove_duplicates)
|
conflict = self.check_conflicts(src_path, dest_path)
|
||||||
|
|
||||||
for i in range(1, 100):
|
for i in range(1, 1000):
|
||||||
if conflict != 1:
|
if conflict != 1:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ class SortMedias:
|
||||||
else:
|
else:
|
||||||
stem = dest_path.stem
|
stem = dest_path.stem
|
||||||
dest_path = dest_path.parent / (stem + '_' + str(i) + suffix)
|
dest_path = dest_path.parent / (stem + '_' + str(i) + suffix)
|
||||||
conflict = self.check_conflicts(src_path, dest_path, remove_duplicates)
|
conflict = self.check_conflicts(src_path, dest_path)
|
||||||
|
|
||||||
if conflict == 1:
|
if conflict == 1:
|
||||||
# i = 100:
|
# i = 100:
|
||||||
|
@ -662,7 +662,7 @@ class SortMedias:
|
||||||
|
|
||||||
yield (src_path, dest_path, metadata), conflict
|
yield (src_path, dest_path, metadata), conflict
|
||||||
|
|
||||||
def sort_medias(self, imp=False, remove_duplicates=False):
|
def sort_medias(self, imp=False):
|
||||||
"""
|
"""
|
||||||
sort files and solve conflicts
|
sort files and solve conflicts
|
||||||
"""
|
"""
|
||||||
|
@ -673,7 +673,7 @@ class SortMedias:
|
||||||
for src_path, metadata in self.medias.datas.items():
|
for src_path, metadata in self.medias.datas.items():
|
||||||
dest_path = self.root / metadata['file_path']
|
dest_path = self.root / metadata['file_path']
|
||||||
|
|
||||||
conflict = self.check_conflicts(src_path, dest_path, remove_duplicates)
|
conflict = self.check_conflicts(src_path, dest_path)
|
||||||
|
|
||||||
if not conflict:
|
if not conflict:
|
||||||
self.sort_file(
|
self.sort_file(
|
||||||
|
@ -691,9 +691,7 @@ class SortMedias:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if conflicts != []:
|
if conflicts != []:
|
||||||
for files_data, conflict in self._solve_conflicts(
|
for files_data, conflict in self._solve_conflicts(conflicts):
|
||||||
conflicts, remove_duplicates
|
|
||||||
):
|
|
||||||
|
|
||||||
src_path, dest_path, metadata = files_data
|
src_path, dest_path, metadata = files_data
|
||||||
if not conflict:
|
if not conflict:
|
||||||
|
@ -726,13 +724,13 @@ class Collection(SortMedias):
|
||||||
self.log = LOG.getChild(self.__class__.__name__)
|
self.log = LOG.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
# Get config options
|
# Get config options
|
||||||
self.opt = self.get_config_options()
|
self.opt, default_options = self.get_config_options()
|
||||||
|
|
||||||
# Set client options
|
# Set client options
|
||||||
for option, value in cli_options.items():
|
for option, value in cli_options.items():
|
||||||
if value not in (None, set()):
|
|
||||||
for section in self.opt:
|
for section in self.opt:
|
||||||
if option in self.opt[section]:
|
if option in self.opt[section]:
|
||||||
|
if value != default_options[section][option]:
|
||||||
if option == 'exclude':
|
if option == 'exclude':
|
||||||
self.opt[section][option].union(set(value))
|
self.opt[section][option].union(set(value))
|
||||||
elif option in ('ignore_tags', 'extensions'):
|
elif option in ('ignore_tags', 'extensions'):
|
||||||
|
@ -759,6 +757,7 @@ class Collection(SortMedias):
|
||||||
self.paths,
|
self.paths,
|
||||||
root,
|
root,
|
||||||
self.opt['Exif'],
|
self.opt['Exif'],
|
||||||
|
{},
|
||||||
self.db,
|
self.db,
|
||||||
self.opt['Terminal']['interactive'],
|
self.opt['Terminal']['interactive'],
|
||||||
)
|
)
|
||||||
|
@ -771,6 +770,7 @@ class Collection(SortMedias):
|
||||||
self.db,
|
self.db,
|
||||||
self.opt['Terminal']['dry_run'],
|
self.opt['Terminal']['dry_run'],
|
||||||
self.opt['Terminal']['interactive'],
|
self.opt['Terminal']['interactive'],
|
||||||
|
self.opt['Filters']['remove_duplicates'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
|
@ -791,7 +791,7 @@ class Collection(SortMedias):
|
||||||
"""Get collection config"""
|
"""Get collection config"""
|
||||||
config = Config(self.root.joinpath('.ordigi', 'ordigi.conf'))
|
config = Config(self.root.joinpath('.ordigi', 'ordigi.conf'))
|
||||||
|
|
||||||
return config.get_config_options()
|
return config.get_config_options(), config.get_default_options()
|
||||||
|
|
||||||
def _set_option(self, section, option, cli_option):
|
def _set_option(self, section, option, cli_option):
|
||||||
"""if client option is set overwrite collection option value"""
|
"""if client option is set overwrite collection option value"""
|
||||||
|
@ -817,7 +817,7 @@ class Collection(SortMedias):
|
||||||
def init(self, loc):
|
def init(self, loc):
|
||||||
"""Init collection db"""
|
"""Init collection db"""
|
||||||
for file_path in self.get_collection_files():
|
for file_path in self.get_collection_files():
|
||||||
metadata = self.medias.get_metadata(file_path, self.root, loc)
|
metadata = self.medias.get_metadata(file_path, self.root, loc=loc)
|
||||||
metadata['file_path'] = os.path.relpath(file_path, self.root)
|
metadata['file_path'] = os.path.relpath(file_path, self.root)
|
||||||
|
|
||||||
self.db.add_file_data(metadata)
|
self.db.add_file_data(metadata)
|
||||||
|
@ -825,7 +825,60 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
return self.summary
|
return self.summary
|
||||||
|
|
||||||
def check_db(self):
|
def check_files(self):
|
||||||
|
"""Check file integrity."""
|
||||||
|
for file_path in self.paths.get_files(self.root):
|
||||||
|
checksum = utils.checksum(file_path)
|
||||||
|
relpath = file_path.relative_to(self.root)
|
||||||
|
if checksum == self.db.sqlite.get_checksum(relpath):
|
||||||
|
self.summary.append('check', True, file_path)
|
||||||
|
else:
|
||||||
|
self.log.error(f'{file_path} is corrupted')
|
||||||
|
self.summary.append('check', False, file_path)
|
||||||
|
|
||||||
|
return self.summary
|
||||||
|
|
||||||
|
def file_in_db(self, file_path, db_rows):
|
||||||
|
# Assuming file_path are inside collection root dir
|
||||||
|
relpath = os.path.relpath(file_path, self.root)
|
||||||
|
|
||||||
|
# If file not in database
|
||||||
|
if relpath not in db_rows:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _check_file(self, file_path, file_checksum):
|
||||||
|
"""Check if file checksum as changed"""
|
||||||
|
relpath = os.path.relpath(file_path, self.root)
|
||||||
|
db_checksum = self.db.sqlite.get_checksum(relpath)
|
||||||
|
# Check if checksum match
|
||||||
|
if not db_checksum:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if db_checksum != file_checksum:
|
||||||
|
self.log.warning(f'{file_path} checksum as changed')
|
||||||
|
self.log.info(
|
||||||
|
f'file_checksum={file_checksum},\ndb_checksum={db_checksum}'
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def check_file(self, file_path):
|
||||||
|
self.medias.checksums[file_path] = utils.checksum(file_path)
|
||||||
|
if self._check_file(file_path, self.medias.checksums[file_path]):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# We d'ont want to silently ignore or correct this without
|
||||||
|
# resetting the cache as is could be due to file corruption
|
||||||
|
self.log.error(f'modified or corrupted file.')
|
||||||
|
self.log.info(
|
||||||
|
'Use ordigi update --checksum or --reset-cache, check database integrity or try to restore the file'
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_db(self, checksums=True):
|
||||||
"""
|
"""
|
||||||
Check if db FilePath match to collection filesystem
|
Check if db FilePath match to collection filesystem
|
||||||
:returns: bool
|
:returns: bool
|
||||||
|
@ -833,12 +886,13 @@ class Collection(SortMedias):
|
||||||
file_paths = list(self.get_collection_files())
|
file_paths = list(self.get_collection_files())
|
||||||
db_rows = [row['FilePath'] for row in self.db.sqlite.get_rows('metadata')]
|
db_rows = [row['FilePath'] for row in self.db.sqlite.get_rows('metadata')]
|
||||||
for file_path in file_paths:
|
for file_path in file_paths:
|
||||||
relpath = os.path.relpath(file_path, self.root)
|
result = self.file_in_db(file_path, db_rows)
|
||||||
# If file not in database
|
if not result:
|
||||||
if relpath not in db_rows:
|
|
||||||
self.log.error('Db data is not accurate')
|
self.log.error('Db data is not accurate')
|
||||||
self.log.info(f'{file_path} not in db')
|
self.log.info(f'{file_path} not in db')
|
||||||
return False
|
return False
|
||||||
|
elif checksums and not self.check_file(file_path):
|
||||||
|
return False
|
||||||
|
|
||||||
nb_files = len(file_paths)
|
nb_files = len(file_paths)
|
||||||
nb_row = len(db_rows)
|
nb_row = len(db_rows)
|
||||||
|
@ -856,10 +910,10 @@ class Collection(SortMedias):
|
||||||
self.log.error('Db data is not accurate run `ordigi update`')
|
self.log.error('Db data is not accurate run `ordigi update`')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def _init_check_db(self, loc=None):
|
def _init_check_db(self, checksums=True, loc=None):
|
||||||
if self.db.sqlite.is_empty('metadata'):
|
if self.db.sqlite.is_empty('metadata'):
|
||||||
self.init(loc)
|
self.init(loc)
|
||||||
elif not self.check_db():
|
elif not self.check_db(checksums):
|
||||||
self.log.error('Db data is not accurate run `ordigi update`')
|
self.log.error('Db data is not accurate run `ordigi update`')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -882,12 +936,13 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
return self.summary
|
return self.summary
|
||||||
|
|
||||||
def update(self, loc):
|
def update(self, loc, update_checksum=False):
|
||||||
"""Update collection db"""
|
"""Update collection db"""
|
||||||
file_paths = list(self.get_collection_files())
|
file_paths = list(self.get_collection_files())
|
||||||
db_rows = list(self.db.sqlite.get_rows('metadata'))
|
db_rows = list(self.db.sqlite.get_rows('metadata'))
|
||||||
invalid_db_rows = set()
|
invalid_db_rows = set()
|
||||||
db_paths = set()
|
db_paths = set()
|
||||||
|
self.log.info(f"Update database:")
|
||||||
for db_row in db_rows:
|
for db_row in db_rows:
|
||||||
abspath = self.root / db_row['FilePath']
|
abspath = self.root / db_row['FilePath']
|
||||||
if abspath not in file_paths:
|
if abspath not in file_paths:
|
||||||
|
@ -897,9 +952,24 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
for file_path in file_paths:
|
for file_path in file_paths:
|
||||||
relpath = os.path.relpath(file_path, self.root)
|
relpath = os.path.relpath(file_path, self.root)
|
||||||
|
metadata = {}
|
||||||
|
|
||||||
|
self.medias.checksums[file_path] = utils.checksum(file_path)
|
||||||
|
if (
|
||||||
|
not self._check_file(file_path, self.medias.checksums[file_path])
|
||||||
|
and update_checksum
|
||||||
|
):
|
||||||
|
# metatata will fill checksum from file
|
||||||
|
metadata = self.medias.get_metadata(file_path, self.root, loc=loc)
|
||||||
|
metadata['file_path'] = relpath
|
||||||
|
# set row attribute to the file
|
||||||
|
self.db.add_file_data(metadata)
|
||||||
|
self.log.info(f"Update '{file_path}' checksum to db")
|
||||||
|
self.summary.append('update', file_path)
|
||||||
|
|
||||||
# If file not in database
|
# If file not in database
|
||||||
if relpath not in db_paths:
|
if relpath not in db_paths:
|
||||||
metadata = self.medias.get_metadata(file_path, self.root, loc)
|
metadata = self.medias.get_metadata(file_path, self.root, loc=loc)
|
||||||
metadata['file_path'] = relpath
|
metadata['file_path'] = relpath
|
||||||
# Check if file checksum is in invalid rows
|
# Check if file checksum is in invalid rows
|
||||||
row = []
|
row = []
|
||||||
|
@ -915,24 +985,13 @@ class Collection(SortMedias):
|
||||||
break
|
break
|
||||||
# set row attribute to the file
|
# set row attribute to the file
|
||||||
self.db.add_file_data(metadata)
|
self.db.add_file_data(metadata)
|
||||||
|
self.log.info(f"Add '{file_path}' to db")
|
||||||
self.summary.append('update', file_path)
|
self.summary.append('update', file_path)
|
||||||
|
|
||||||
# Finally delete invalid rows
|
# Finally delete invalid rows
|
||||||
for row in invalid_db_rows:
|
for row in invalid_db_rows:
|
||||||
self.db.sqlite.delete_filepath(row['FilePath'])
|
self.db.sqlite.delete_filepath(row['FilePath'])
|
||||||
|
self.log.info(f"Delete invalid row : '{row['FilePath']}' from db")
|
||||||
return self.summary
|
|
||||||
|
|
||||||
def check_files(self):
|
|
||||||
"""Check file integrity."""
|
|
||||||
for file_path in self.paths.get_files(self.root):
|
|
||||||
checksum = utils.checksum(file_path)
|
|
||||||
relpath = file_path.relative_to(self.root)
|
|
||||||
if checksum == self.db.sqlite.get_checksum(relpath):
|
|
||||||
self.summary.append('check', True, file_path)
|
|
||||||
else:
|
|
||||||
self.log.error(f'{file_path} is corrupted')
|
|
||||||
self.summary.append('check', False, file_path)
|
|
||||||
|
|
||||||
return self.summary
|
return self.summary
|
||||||
|
|
||||||
|
@ -1002,17 +1061,15 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
return self.summary
|
return self.summary
|
||||||
|
|
||||||
def sort_files(
|
def sort_files(self, src_dirs, loc, imp=False):
|
||||||
self, src_dirs, path_format, loc, imp=False, remove_duplicates=False
|
|
||||||
):
|
|
||||||
"""
|
"""
|
||||||
Sort files into appropriate folder
|
Sort files into appropriate folder
|
||||||
"""
|
"""
|
||||||
# Check db
|
# Check db
|
||||||
self._init_check_db(loc)
|
self._init_check_db(loc=loc)
|
||||||
|
|
||||||
# if path format client option is set overwrite it
|
path_format = self.opt['Path']['path_format']
|
||||||
self._set_option('Path', 'path_format', path_format)
|
self.log.debug(f'path_format: {path_format}')
|
||||||
|
|
||||||
# Get medias data
|
# Get medias data
|
||||||
subdirs = set()
|
subdirs = set()
|
||||||
|
@ -1026,7 +1083,7 @@ class Collection(SortMedias):
|
||||||
self.medias.datas[src_path] = copy(metadata)
|
self.medias.datas[src_path] = copy(metadata)
|
||||||
|
|
||||||
# Sort files and solve conflicts
|
# Sort files and solve conflicts
|
||||||
self.summary = self.sort_medias(imp, remove_duplicates)
|
self.summary = self.sort_medias(imp)
|
||||||
|
|
||||||
if imp != 'copy':
|
if imp != 'copy':
|
||||||
self.remove_empty_subdirs(subdirs, src_dirs)
|
self.remove_empty_subdirs(subdirs, src_dirs)
|
||||||
|
@ -1036,7 +1093,7 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
return self.summary
|
return self.summary
|
||||||
|
|
||||||
def dedup_path(self, paths, dedup_regex=None, remove_duplicates=False):
|
def dedup_path(self, paths, dedup_regex=None):
|
||||||
"""Deduplicate file path parts"""
|
"""Deduplicate file path parts"""
|
||||||
|
|
||||||
# Check db
|
# Check db
|
||||||
|
@ -1077,7 +1134,7 @@ class Collection(SortMedias):
|
||||||
self.medias.datas[src_path] = copy(metadata)
|
self.medias.datas[src_path] = copy(metadata)
|
||||||
|
|
||||||
# Sort files and solve conflicts
|
# Sort files and solve conflicts
|
||||||
self.sort_medias(remove_duplicates=remove_duplicates)
|
self.sort_medias()
|
||||||
|
|
||||||
if not self.check_db():
|
if not self.check_db():
|
||||||
self.summary.append('check', False)
|
self.summary.append('check', False)
|
||||||
|
@ -1109,7 +1166,7 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def sort_similar_images(self, path, similarity=80, remove_duplicates=False):
|
def sort_similar_images(self, path, similarity=80):
|
||||||
"""Sort similar images using imagehash library"""
|
"""Sort similar images using imagehash library"""
|
||||||
# Check db
|
# Check db
|
||||||
self._init_check_db()
|
self._init_check_db()
|
||||||
|
@ -1128,7 +1185,7 @@ class Collection(SortMedias):
|
||||||
)
|
)
|
||||||
if similar_images:
|
if similar_images:
|
||||||
# Move the simlars file into the destination directory
|
# Move the simlars file into the destination directory
|
||||||
self.sort_medias(remove_duplicates=remove_duplicates)
|
self.sort_medias()
|
||||||
|
|
||||||
nb_row_end = self.db.sqlite.len('metadata')
|
nb_row_end = self.db.sqlite.len('metadata')
|
||||||
if nb_row_ini and nb_row_ini != nb_row_end:
|
if nb_row_ini and nb_row_ini != nb_row_end:
|
||||||
|
@ -1141,35 +1198,43 @@ class Collection(SortMedias):
|
||||||
|
|
||||||
def edit_metadata(self, paths, keys, loc=None, overwrite=False):
|
def edit_metadata(self, paths, keys, loc=None, overwrite=False):
|
||||||
"""Edit metadata and exif data for given key"""
|
"""Edit metadata and exif data for given key"""
|
||||||
self._init_check_db()
|
|
||||||
|
|
||||||
|
if self.db.sqlite.is_empty('metadata'):
|
||||||
|
self.init(loc)
|
||||||
for file_path, media in self.medias.get_medias_datas(paths, loc=loc):
|
for file_path, media in self.medias.get_medias_datas(paths, loc=loc):
|
||||||
|
result = False
|
||||||
media.metadata['file_path'] = os.path.relpath(file_path, self.root)
|
media.metadata['file_path'] = os.path.relpath(file_path, self.root)
|
||||||
|
if not self.check_file(file_path):
|
||||||
|
self.log.error('Db data is not accurate run `ordigi update`')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
exif = WriteExif(
|
||||||
|
file_path,
|
||||||
|
media.metadata,
|
||||||
|
ignore_tags=self.opt['Exif']['ignore_tags'],
|
||||||
|
)
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
print()
|
print()
|
||||||
value = media.metadata[key]
|
value = media.metadata[key]
|
||||||
if overwrite or not value:
|
if overwrite or not value:
|
||||||
print(f"FILE: '{file_path}'")
|
print(f"FILE: '{file_path}'")
|
||||||
if overwrite:
|
if overwrite and value:
|
||||||
print(f"{key}: '{value}'")
|
print(f"{key}: '{value}'")
|
||||||
if overwrite or not value:
|
if overwrite or not value:
|
||||||
# Prompt value for given key for file_path
|
# Prompt value for given key for file_path
|
||||||
prompt = [
|
answer = self.input.text(key)
|
||||||
inquirer.Text('value', message=key),
|
# Check value
|
||||||
]
|
|
||||||
answer = inquirer.prompt(prompt, theme=self.theme)
|
|
||||||
# answer = {'value': '03-12-2021 08:12:35'}
|
|
||||||
# Validate value
|
|
||||||
if key in ('date_original', 'date_created', 'date_modified'):
|
if key in ('date_original', 'date_created', 'date_modified'):
|
||||||
# Check date format
|
# Check date format
|
||||||
value = media.get_date_format(answer['value'])
|
value = media.get_date_format(answer)
|
||||||
else:
|
else:
|
||||||
value = answer['value']
|
value = answer
|
||||||
if not value.isalnum():
|
while not value.isalnum():
|
||||||
|
if not value: break
|
||||||
print("Invalid entry, use alphanumeric chars")
|
print("Invalid entry, use alphanumeric chars")
|
||||||
value = inquirer.prompt(prompt, theme=self.theme)
|
value = inquirer.prompt(prompt, theme=self.theme)
|
||||||
|
|
||||||
result = False
|
|
||||||
if value:
|
if value:
|
||||||
media.metadata[key] = value
|
media.metadata[key] = value
|
||||||
if key == 'location':
|
if key == 'location':
|
||||||
|
@ -1179,24 +1244,7 @@ class Collection(SortMedias):
|
||||||
media.metadata['longitude'] = coordinates['longitude']
|
media.metadata['longitude'] = coordinates['longitude']
|
||||||
media.set_location_from_coordinates(loc)
|
media.set_location_from_coordinates(loc)
|
||||||
|
|
||||||
# Update database
|
|
||||||
self.db.add_file_data(media.metadata)
|
|
||||||
# Update exif data
|
# Update exif data
|
||||||
if key in (
|
|
||||||
'date_original',
|
|
||||||
'album',
|
|
||||||
'title',
|
|
||||||
'latitude',
|
|
||||||
'location',
|
|
||||||
'longitude',
|
|
||||||
'latitude_ref',
|
|
||||||
'longitude_ref',
|
|
||||||
):
|
|
||||||
exif = WriteExif(
|
|
||||||
file_path,
|
|
||||||
media.metadata,
|
|
||||||
ignore_tags=self.opt['Exif']['ignore_tags'],
|
|
||||||
)
|
|
||||||
if key == 'location':
|
if key == 'location':
|
||||||
result = exif.set_key_values(
|
result = exif.set_key_values(
|
||||||
'latitude', media.metadata['latitude']
|
'latitude', media.metadata['latitude']
|
||||||
|
@ -1204,8 +1252,15 @@ class Collection(SortMedias):
|
||||||
result = exif.set_key_values(
|
result = exif.set_key_values(
|
||||||
'longitude', media.metadata['longitude']
|
'longitude', media.metadata['longitude']
|
||||||
)
|
)
|
||||||
else:
|
elif key in exif.get_tags().keys():
|
||||||
result = exif.set_key_values(key, value)
|
result = exif.set_key_values(key, value)
|
||||||
|
|
||||||
|
# Update checksum
|
||||||
|
media.metadata['checksum'] = utils.checksum(file_path)
|
||||||
|
|
||||||
|
# Update database
|
||||||
|
self.db.add_file_data(media.metadata)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
self.summary.append('update', True, file_path)
|
self.summary.append('update', True, file_path)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -53,9 +53,9 @@ class Config:
|
||||||
else:
|
else:
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
|
|
||||||
self.options = self.set_default_options()
|
self.options = self.get_default_options()
|
||||||
|
|
||||||
def set_default_options(self) -> dict:
|
def get_default_options(self) -> dict:
|
||||||
# Initialize with default options
|
# Initialize with default options
|
||||||
return {
|
return {
|
||||||
'Exif': {
|
'Exif': {
|
||||||
|
@ -71,6 +71,7 @@ class Config:
|
||||||
'extensions': None,
|
'extensions': None,
|
||||||
'glob': '**/*',
|
'glob': '**/*',
|
||||||
'max_deep': None,
|
'max_deep': None,
|
||||||
|
'remove_duplicates': False,
|
||||||
},
|
},
|
||||||
'Geolocation': {
|
'Geolocation': {
|
||||||
'geocoder': constants.DEFAULT_GEOCODER,
|
'geocoder': constants.DEFAULT_GEOCODER,
|
||||||
|
@ -137,6 +138,7 @@ class Config:
|
||||||
'dry_run',
|
'dry_run',
|
||||||
'interactive',
|
'interactive',
|
||||||
'prefer_english_names',
|
'prefer_english_names',
|
||||||
|
'remove_duplicates',
|
||||||
'use_date_filename',
|
'use_date_filename',
|
||||||
'use_file_dates',
|
'use_file_dates',
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,9 @@ class Sqlite:
|
||||||
value = None
|
value = None
|
||||||
self.cur.execute('SELECT * FROM location')
|
self.cur.execute('SELECT * FROM location')
|
||||||
for row in self.cur:
|
for row in self.cur:
|
||||||
distance = distance_between_two_points(latitude, longitude, row[0], row[1])
|
distance = distance_between_two_points(
|
||||||
|
latitude, longitude, row['Latitude'], row['Longitude']
|
||||||
|
)
|
||||||
# Use if closer then threshold_km reuse lookup
|
# Use if closer then threshold_km reuse lookup
|
||||||
if distance < shorter_distance and distance <= threshold_m:
|
if distance < shorter_distance and distance <= threshold_m:
|
||||||
shorter_distance = distance
|
shorter_distance = distance
|
||||||
|
|
|
@ -46,9 +46,16 @@ def file_logger(logger, file, level=30):
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
def get_level(verbose):
|
def get_level(quiet=False, verbose=False, debug=False, num=None):
|
||||||
"""Return int logging level from string"""
|
"""Return int logging level from command line args"""
|
||||||
if verbose.isnumeric():
|
if num and num.isnumeric():
|
||||||
return int(verbose)
|
return int(verbose)
|
||||||
|
|
||||||
return int(logging.getLevelName(verbose))
|
if debug:
|
||||||
|
return int(logging.getLevelName('DEBUG'))
|
||||||
|
if verbose:
|
||||||
|
return int(logging.getLevelName('INFO'))
|
||||||
|
if quiet:
|
||||||
|
return int(logging.getLevelName('ERROR'))
|
||||||
|
|
||||||
|
return int(logging.getLevelName('WARNING'))
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ExifMetadata:
|
||||||
]
|
]
|
||||||
tags_keys['latitude_ref'] = ['EXIF:GPSLatitudeRef']
|
tags_keys['latitude_ref'] = ['EXIF:GPSLatitudeRef']
|
||||||
tags_keys['longitude_ref'] = ['EXIF:GPSLongitudeRef']
|
tags_keys['longitude_ref'] = ['EXIF:GPSLongitudeRef']
|
||||||
tags_keys['original_name'] = ['XMP:OriginalFileName']
|
tags_keys['original_name'] = ['EXIF:OriginalFileName', 'XMP:OriginalFileName']
|
||||||
|
|
||||||
# Remove ignored tag from list
|
# Remove ignored tag from list
|
||||||
for tag_regex in self.ignore_tags:
|
for tag_regex in self.ignore_tags:
|
||||||
|
@ -279,6 +279,7 @@ class Media(ReadExif):
|
||||||
ignore_tags=None,
|
ignore_tags=None,
|
||||||
interactive=False,
|
interactive=False,
|
||||||
cache=True,
|
cache=True,
|
||||||
|
checksum=None,
|
||||||
use_date_filename=False,
|
use_date_filename=False,
|
||||||
use_file_dates=False,
|
use_file_dates=False,
|
||||||
):
|
):
|
||||||
|
@ -292,6 +293,11 @@ class Media(ReadExif):
|
||||||
|
|
||||||
self.album_from_folder = album_from_folder
|
self.album_from_folder = album_from_folder
|
||||||
self.cache = cache
|
self.cache = cache
|
||||||
|
if checksum:
|
||||||
|
self.checksum = checksum
|
||||||
|
else:
|
||||||
|
self.checksum = utils.checksum(file_path)
|
||||||
|
|
||||||
self.interactive = interactive
|
self.interactive = interactive
|
||||||
self.log = LOG.getChild(self.__class__.__name__)
|
self.log = LOG.getChild(self.__class__.__name__)
|
||||||
self.metadata = None
|
self.metadata = None
|
||||||
|
@ -339,11 +345,8 @@ class Media(ReadExif):
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if not answers['date_list']:
|
if not answers['date_list']:
|
||||||
prompt = [
|
answer = self.prompt.text("date")
|
||||||
inquirer.Text('date_custom', message="date"),
|
return self.get_date_format(answer)
|
||||||
]
|
|
||||||
answers = inquirer.prompt(prompt, theme=self.theme)
|
|
||||||
return self.get_date_format(answers['date_custom'])
|
|
||||||
|
|
||||||
return answers['date_list']
|
return answers['date_list']
|
||||||
|
|
||||||
|
@ -359,9 +362,9 @@ class Media(ReadExif):
|
||||||
stem = os.path.splitext(filename)[0]
|
stem = os.path.splitext(filename)[0]
|
||||||
date_original = self.metadata['date_original']
|
date_original = self.metadata['date_original']
|
||||||
if self.metadata['original_name']:
|
if self.metadata['original_name']:
|
||||||
date_filename = utils.get_date_from_string(self.metadata['original_name'])
|
date_filename, _, _ = utils.get_date_from_string(self.metadata['original_name'])
|
||||||
else:
|
else:
|
||||||
date_filename = utils.get_date_from_string(stem)
|
date_filename, _, _ = utils.get_date_from_string(stem)
|
||||||
self.log.debug(f'date_filename: {date_filename}')
|
self.log.debug(f'date_filename: {date_filename}')
|
||||||
|
|
||||||
date_original = self.metadata['date_original']
|
date_original = self.metadata['date_original']
|
||||||
|
@ -370,6 +373,8 @@ class Media(ReadExif):
|
||||||
file_modify_date = self.metadata['file_modify_date']
|
file_modify_date = self.metadata['file_modify_date']
|
||||||
if self.metadata['date_original']:
|
if self.metadata['date_original']:
|
||||||
if date_filename and date_filename != date_original:
|
if date_filename and date_filename != date_original:
|
||||||
|
timedelta = abs(date_original - date_filename)
|
||||||
|
if timedelta.total_seconds() > 60:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
f"{filename} time mark is different from {date_original}"
|
f"{filename} time mark is different from {date_original}"
|
||||||
)
|
)
|
||||||
|
@ -385,13 +390,15 @@ class Media(ReadExif):
|
||||||
|
|
||||||
return self.metadata['date_original']
|
return self.metadata['date_original']
|
||||||
|
|
||||||
self.log.warning(f"could not find original date for {self.file_path}")
|
self.log.warning(f"could not find date original for {self.file_path}")
|
||||||
|
|
||||||
if self.use_date_filename and date_filename:
|
if self.use_date_filename and date_filename:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
f"use date from filename:{date_filename} for {self.file_path}"
|
f"use date from filename:{date_filename} for {self.file_path}"
|
||||||
)
|
)
|
||||||
if date_created and date_filename > date_created:
|
if date_created and date_filename > date_created:
|
||||||
|
timedelta = abs(date_created - date_filename)
|
||||||
|
if timedelta.total_seconds() > 60:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
f"{filename} time mark is more recent than {date_created}"
|
f"{filename} time mark is more recent than {date_created}"
|
||||||
)
|
)
|
||||||
|
@ -457,17 +464,12 @@ class Media(ReadExif):
|
||||||
default=f'{album}',
|
default=f'{album}',
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
prompt = [
|
|
||||||
inquirer.Text('custom', message="album"),
|
|
||||||
]
|
|
||||||
|
|
||||||
answers = inquirer.prompt(choices_list, theme=self.theme)
|
answers = inquirer.prompt(choices_list, theme=self.theme)
|
||||||
if not answers:
|
if not answers:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if not answers['album']:
|
if not answers['album']:
|
||||||
answers = inquirer.prompt(prompt, theme=self.theme)
|
return self.input.text("album")
|
||||||
return answers['custom']
|
|
||||||
|
|
||||||
return answers['album']
|
return answers['album']
|
||||||
|
|
||||||
|
@ -523,31 +525,6 @@ class Media(ReadExif):
|
||||||
|
|
||||||
return db.get_metadata(relpath, 'LocationId')
|
return db.get_metadata(relpath, 'LocationId')
|
||||||
|
|
||||||
def _check_file(self, db, root):
|
|
||||||
"""Check if file_path is a subpath of root"""
|
|
||||||
|
|
||||||
if str(self.file_path).startswith(str(root)):
|
|
||||||
relpath = os.path.relpath(self.file_path, root)
|
|
||||||
db_checksum = db.get_checksum(relpath)
|
|
||||||
file_checksum = self.metadata['checksum']
|
|
||||||
# Check if checksum match
|
|
||||||
if db_checksum and db_checksum != file_checksum:
|
|
||||||
self.log.error(f'{self.file_path} checksum has changed')
|
|
||||||
self.log.error('(modified or corrupted file).')
|
|
||||||
self.log.error(
|
|
||||||
f'file_checksum={file_checksum},\ndb_checksum={db_checksum}'
|
|
||||||
)
|
|
||||||
self.log.info(
|
|
||||||
'Use --reset-cache, check database integrity or try to restore the file'
|
|
||||||
)
|
|
||||||
# We d'ont want to silently ignore or correct this without
|
|
||||||
# resetting the cache as is could be due to file corruption
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
return relpath, db_checksum
|
|
||||||
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
def set_location_from_db(self, location_id, db):
|
def set_location_from_db(self, location_id, db):
|
||||||
|
|
||||||
self.metadata['location_id'] = location_id
|
self.metadata['location_id'] = location_id
|
||||||
|
@ -607,17 +584,17 @@ class Media(ReadExif):
|
||||||
All keys will be present and have a value of None if not obtained.
|
All keys will be present and have a value of None if not obtained.
|
||||||
"""
|
"""
|
||||||
self.metadata = {}
|
self.metadata = {}
|
||||||
self.metadata['checksum'] = utils.checksum(self.file_path)
|
self.metadata['checksum'] = self.checksum
|
||||||
|
|
||||||
db_checksum = False
|
db_checksum = False
|
||||||
location_id = None
|
location_id = None
|
||||||
if cache and db:
|
if cache and db and str(self.file_path).startswith(str(root)):
|
||||||
relpath, db_checksum = self._check_file(db, root)
|
relpath = os.path.relpath(self.file_path, root)
|
||||||
|
db_checksum = db.get_checksum(relpath)
|
||||||
if db_checksum:
|
if db_checksum:
|
||||||
location_id = self._set_metadata_from_db(db, relpath)
|
location_id = self._set_metadata_from_db(db, relpath)
|
||||||
self.set_location_from_db(location_id, db)
|
self.set_location_from_db(location_id, db)
|
||||||
else:
|
else:
|
||||||
# file not in db
|
|
||||||
self.metadata['src_dir'] = str(self.src_dir)
|
self.metadata['src_dir'] = str(self.src_dir)
|
||||||
self.metadata['subdirs'] = str(
|
self.metadata['subdirs'] = str(
|
||||||
self.file_path.relative_to(self.src_dir).parent
|
self.file_path.relative_to(self.src_dir).parent
|
||||||
|
@ -661,6 +638,7 @@ class Medias:
|
||||||
paths,
|
paths,
|
||||||
root,
|
root,
|
||||||
exif_options,
|
exif_options,
|
||||||
|
checksums=None,
|
||||||
db=None,
|
db=None,
|
||||||
interactive=False,
|
interactive=False,
|
||||||
):
|
):
|
||||||
|
@ -673,6 +651,11 @@ class Medias:
|
||||||
self.root = root
|
self.root = root
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
if checksums:
|
||||||
|
self.checksums = checksums
|
||||||
|
else:
|
||||||
|
self.checksums = {}
|
||||||
|
|
||||||
self.exif_opt = exif_options
|
self.exif_opt = exif_options
|
||||||
|
|
||||||
self.ignore_tags = self.exif_opt['ignore_tags']
|
self.ignore_tags = self.exif_opt['ignore_tags']
|
||||||
|
@ -684,7 +667,7 @@ class Medias:
|
||||||
self.datas = {}
|
self.datas = {}
|
||||||
self.theme = request.load_theme()
|
self.theme = request.load_theme()
|
||||||
|
|
||||||
def get_media(self, file_path, src_dir):
|
def get_media(self, file_path, src_dir, checksum=None):
|
||||||
media = Media(
|
media = Media(
|
||||||
file_path,
|
file_path,
|
||||||
src_dir,
|
src_dir,
|
||||||
|
@ -692,6 +675,7 @@ class Medias:
|
||||||
self.exif_opt['ignore_tags'],
|
self.exif_opt['ignore_tags'],
|
||||||
self.interactive,
|
self.interactive,
|
||||||
self.exif_opt['cache'],
|
self.exif_opt['cache'],
|
||||||
|
checksum,
|
||||||
self.exif_opt['use_date_filename'],
|
self.exif_opt['use_date_filename'],
|
||||||
self.exif_opt['use_file_dates'],
|
self.exif_opt['use_file_dates'],
|
||||||
)
|
)
|
||||||
|
@ -699,7 +683,14 @@ class Medias:
|
||||||
return media
|
return media
|
||||||
|
|
||||||
def get_media_data(self, file_path, src_dir, loc=None):
|
def get_media_data(self, file_path, src_dir, loc=None):
|
||||||
media = self.get_media(file_path, src_dir)
|
"""Get media class instance with metadata"""
|
||||||
|
|
||||||
|
if self.checksums and file_path in self.checksums.keys():
|
||||||
|
checksum = self.checksums[file_path]
|
||||||
|
else:
|
||||||
|
checksum = None
|
||||||
|
|
||||||
|
media = self.get_media(file_path, src_dir, checksum)
|
||||||
media.get_metadata(
|
media.get_metadata(
|
||||||
self.root, loc, self.db.sqlite, self.exif_opt['cache']
|
self.root, loc, self.db.sqlite, self.exif_opt['cache']
|
||||||
)
|
)
|
||||||
|
@ -714,6 +705,11 @@ class Medias:
|
||||||
"""Get paths"""
|
"""Get paths"""
|
||||||
for src_dir in src_dirs:
|
for src_dir in src_dirs:
|
||||||
src_dir = self.paths.check(src_dir)
|
src_dir = self.paths.check(src_dir)
|
||||||
|
|
||||||
|
if src_dir.is_file():
|
||||||
|
yield src_dir.parent, src_dir
|
||||||
|
continue
|
||||||
|
|
||||||
paths = self.paths.get_paths_list(src_dir)
|
paths = self.paths.get_paths_list(src_dir)
|
||||||
|
|
||||||
# Get medias and src_dirs
|
# Get medias and src_dirs
|
||||||
|
@ -730,7 +726,7 @@ class Medias:
|
||||||
"""Get medias datas"""
|
"""Get medias datas"""
|
||||||
for src_dir, src_path in self.get_paths(src_dirs, imp=imp):
|
for src_dir, src_path in self.get_paths(src_dirs, imp=imp):
|
||||||
# Get file metadata
|
# Get file metadata
|
||||||
media = self.get_media_data(src_path, src_dir, loc)
|
media = self.get_media_data(src_path, src_dir, loc=loc)
|
||||||
|
|
||||||
yield src_path, media
|
yield src_path, media
|
||||||
|
|
||||||
|
@ -738,11 +734,11 @@ class Medias:
|
||||||
"""Get medias data"""
|
"""Get medias data"""
|
||||||
for src_dir, src_path in self.get_paths(src_dirs, imp=imp):
|
for src_dir, src_path in self.get_paths(src_dirs, imp=imp):
|
||||||
# Get file metadata
|
# Get file metadata
|
||||||
metadata = self.get_metadata(src_path, src_dir, loc)
|
metadata = self.get_metadata(src_path, src_dir, loc=loc)
|
||||||
|
|
||||||
yield src_path, metadata
|
yield src_path, metadata
|
||||||
|
|
||||||
def update_exif_data(self, metadata):
|
def update_exif_data(self, metadata, imp=False):
|
||||||
|
|
||||||
file_path = self.root / metadata['file_path']
|
file_path = self.root / metadata['file_path']
|
||||||
exif = WriteExif(
|
exif = WriteExif(
|
||||||
|
@ -752,8 +748,8 @@ class Medias:
|
||||||
)
|
)
|
||||||
|
|
||||||
updated = False
|
updated = False
|
||||||
if metadata['original_name'] in (None, ''):
|
if imp and metadata['original_name'] in (None, ''):
|
||||||
exif.set_value('original_name', metadata['filename'])
|
exif.set_key_values('original_name', metadata['filename'])
|
||||||
updated = True
|
updated = True
|
||||||
if self.exif_opt['album_from_folder']:
|
if self.exif_opt['album_from_folder']:
|
||||||
exif.set_album_from_folder()
|
exif.set_album_from_folder()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import inquirer
|
import inquirer
|
||||||
from blessed import Terminal
|
from blessed import Terminal
|
||||||
|
from colorama import init,Fore,Style,Back
|
||||||
|
|
||||||
term = Terminal()
|
term = Terminal()
|
||||||
|
|
||||||
|
@ -34,6 +35,15 @@ def load_theme():
|
||||||
return inquirer.themes.load_theme_from_dict(custom_theme)
|
return inquirer.themes.load_theme_from_dict(custom_theme)
|
||||||
|
|
||||||
|
|
||||||
|
class Input():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
init()
|
||||||
|
|
||||||
|
def text(self, message):
|
||||||
|
return input(f'{Fore.BLUE}[{Fore.YELLOW}?{Fore.BLUE}]{Fore.WHITE} {message}: ')
|
||||||
|
|
||||||
|
|
||||||
# def edit_prompt(self, key: str, value: str) -> str:
|
# def edit_prompt(self, key: str, value: str) -> str:
|
||||||
# print(f"Date conflict for file: {self.file_path}")
|
# print(f"Date conflict for file: {self.file_path}")
|
||||||
|
|
|
@ -69,17 +69,17 @@ def get_date_regex(user_regex=None):
|
||||||
# regex to match date format type %Y%m%d, %y%m%d, %d%m%Y,
|
# regex to match date format type %Y%m%d, %y%m%d, %d%m%Y,
|
||||||
# etc...
|
# etc...
|
||||||
'a': re.compile(
|
'a': re.compile(
|
||||||
r'.*[_-]?(?P<year>\d{4})[_-]?(?P<month>\d{2})[_-]?(?P<day>\d{2})[_-]?(?P<hour>\d{2})[_-]?(?P<minute>\d{2})[_-]?(?P<second>\d{2})'
|
r'[-_./ ](?P<year>\d{4})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})[-_.]?(?P<hour>\d{2})[-_.]?(?P<minute>\d{2})[-_.]?(?P<second>\d{2})([-_./ ])'
|
||||||
),
|
),
|
||||||
'b': re.compile(
|
'b': re.compile(
|
||||||
r'[-_./](?P<year>\d{4})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})[-_./]'
|
r'[-_./ ](?P<year>\d{4})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})([-_./ ])'
|
||||||
),
|
),
|
||||||
# not very accurate
|
# not very accurate
|
||||||
'c': re.compile(
|
'c': re.compile(
|
||||||
r'[-_./](?P<year>\d{2})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})[-_./]'
|
r'[-_./ ](?P<year>\d{2})[-_.]?(?P<month>\d{2})[-_.]?(?P<day>\d{2})([-_./ ])'
|
||||||
),
|
),
|
||||||
'd': re.compile(
|
'd': re.compile(
|
||||||
r'[-_./](?P<day>\d{2})[-_.](?P<month>\d{2})[-_.](?P<year>\d{4})[-_./]'
|
r'[-_./ ](?P<day>\d{2})[-_.](?P<month>\d{2})[-_.](?P<year>\d{4})([-_./ ])'
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,15 +96,18 @@ def get_date_from_string(string):
|
||||||
# Otherwise assume a filename such as IMG_20160915_123456.jpg as default.
|
# Otherwise assume a filename such as IMG_20160915_123456.jpg as default.
|
||||||
|
|
||||||
matches = []
|
matches = []
|
||||||
|
sep = ''
|
||||||
for i, regex in DATE_REGEX.items():
|
for i, regex in DATE_REGEX.items():
|
||||||
match = re.findall(regex, string)
|
match = re.findall(regex, string)
|
||||||
if match != []:
|
if match != []:
|
||||||
|
sep = match[0][3]
|
||||||
if i == 'c':
|
if i == 'c':
|
||||||
match = [('20' + match[0][0], match[0][1], match[0][2])]
|
match = [('20' + match[0][0], match[0][1], match[0][2])]
|
||||||
elif i == 'd':
|
elif i == 'd':
|
||||||
# reorder items
|
# reorder items
|
||||||
match = [(match[0][2], match[0][1], match[0][0])]
|
match = [(match[0][2], match[0][1], match[0][0])]
|
||||||
# matches = match + matches
|
else:
|
||||||
|
match = [(match[0][0], match[0][1], match[0][2])]
|
||||||
if len(match) != 1:
|
if len(match) != 1:
|
||||||
# The time string is not uniq
|
# The time string is not uniq
|
||||||
continue
|
continue
|
||||||
|
@ -119,9 +122,11 @@ def get_date_from_string(string):
|
||||||
date_object = tuple(map(int, matches[0][0]))
|
date_object = tuple(map(int, matches[0][0]))
|
||||||
date = datetime(*date_object)
|
date = datetime(*date_object)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
return None
|
return None, matches[0][1], sep
|
||||||
|
|
||||||
return date
|
return date, matches[0][1], sep
|
||||||
|
|
||||||
|
return None, None, sep
|
||||||
|
|
||||||
|
|
||||||
def match_date_regex(regex, value):
|
def match_date_regex(regex, value):
|
||||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
||||||
import inquirer
|
import inquirer
|
||||||
|
|
||||||
from ordigi import cli
|
from ordigi import cli
|
||||||
|
from ordigi.request import Input
|
||||||
|
|
||||||
CONTENT = "content"
|
CONTENT = "content"
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ class TestOrdigi:
|
||||||
def setup_class(cls, sample_files_paths):
|
def setup_class(cls, sample_files_paths):
|
||||||
cls.runner = CliRunner()
|
cls.runner = CliRunner()
|
||||||
cls.src_path, cls.file_paths = sample_files_paths
|
cls.src_path, cls.file_paths = sample_files_paths
|
||||||
cls.logger_options = (('--verbose', 'DEBUG'),)
|
cls.logger_options = ('--debug',)
|
||||||
cls.filter_options = (
|
cls.filter_options = (
|
||||||
('--ignore-tags', 'CreateDate'),
|
('--ignore-tags', 'CreateDate'),
|
||||||
('--ext', 'jpg'),
|
('--ext', 'jpg'),
|
||||||
|
@ -81,21 +82,23 @@ class TestOrdigi:
|
||||||
|
|
||||||
def test_edit(self, monkeypatch):
|
def test_edit(self, monkeypatch):
|
||||||
|
|
||||||
bool_options = ()
|
bool_options = (
|
||||||
|
*self.logger_options,
|
||||||
|
)
|
||||||
|
|
||||||
arg_options = (
|
arg_options = (
|
||||||
*self.logger_options,
|
|
||||||
*self.filter_options,
|
*self.filter_options,
|
||||||
)
|
)
|
||||||
|
|
||||||
def mockreturn(prompt, theme):
|
def mockreturn(self, message):
|
||||||
return {'value': '03-12-2021 08:12:35'}
|
return '03-12-2021 08:12:35'
|
||||||
|
|
||||||
monkeypatch.setattr(inquirer, 'prompt', mockreturn)
|
monkeypatch.setattr(Input, 'text', mockreturn)
|
||||||
|
|
||||||
args = (
|
args = (
|
||||||
'--key',
|
'--key',
|
||||||
'date_original',
|
'date_original',
|
||||||
|
'--overwrite',
|
||||||
str(self.src_path.joinpath('test_exif/photo.png')),
|
str(self.src_path.joinpath('test_exif/photo.png')),
|
||||||
str(self.src_path),
|
str(self.src_path),
|
||||||
)
|
)
|
||||||
|
@ -107,6 +110,7 @@ class TestOrdigi:
|
||||||
|
|
||||||
def test_sort(self):
|
def test_sort(self):
|
||||||
bool_options = (
|
bool_options = (
|
||||||
|
*self.logger_options,
|
||||||
# '--interactive',
|
# '--interactive',
|
||||||
'--dry-run',
|
'--dry-run',
|
||||||
'--album-from-folder',
|
'--album-from-folder',
|
||||||
|
@ -117,7 +121,6 @@ class TestOrdigi:
|
||||||
)
|
)
|
||||||
|
|
||||||
arg_options = (
|
arg_options = (
|
||||||
*self.logger_options,
|
|
||||||
*self.filter_options,
|
*self.filter_options,
|
||||||
('--path-format', '{%Y}/{folder}/{name}.{ext}'),
|
('--path-format', '{%Y}/{folder}/{name}.{ext}'),
|
||||||
|
|
||||||
|
@ -132,35 +135,29 @@ class TestOrdigi:
|
||||||
|
|
||||||
def test_clone(self, tmp_path):
|
def test_clone(self, tmp_path):
|
||||||
|
|
||||||
arg_options = (
|
|
||||||
*self.logger_options,
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
paths = (str(self.src_path), str(tmp_path))
|
paths = (str(self.src_path), str(tmp_path))
|
||||||
|
|
||||||
self.assert_cli(cli._init, [str(self.src_path)])
|
self.assert_cli(cli._init, [str(self.src_path)])
|
||||||
self.assert_cli(cli._clone, ['--dry-run', '--verbose', 'DEBUG', *paths])
|
self.assert_cli(cli._clone, ['--dry-run', *self.logger_options, *paths])
|
||||||
self.assert_cli(cli._clone, paths)
|
self.assert_cli(cli._clone, paths)
|
||||||
|
|
||||||
|
|
||||||
def assert_init(self):
|
def assert_init(self):
|
||||||
for opt, arg in self.logger_options:
|
self.assert_cli(cli._init, [*self.logger_options, str(self.src_path)])
|
||||||
self.assert_cli(cli._init, [opt, arg, str(self.src_path)])
|
|
||||||
|
|
||||||
def assert_update(self):
|
def assert_update(self):
|
||||||
file_path = Path(ORDIGI_PATH, 'samples/test_exif/photo.cr2')
|
file_path = Path(ORDIGI_PATH, 'samples/test_exif/photo.cr2')
|
||||||
dest_path = self.src_path / 'photo_moved.cr2'
|
dest_path = self.src_path / 'photo_moved.cr2'
|
||||||
shutil.copyfile(file_path, dest_path)
|
shutil.copyfile(file_path, dest_path)
|
||||||
for opt, arg in self.logger_options:
|
self.assert_cli(cli._update, [*self.logger_options, str(self.src_path)])
|
||||||
self.assert_cli(cli._update, [opt, arg, str(self.src_path)])
|
self.assert_cli(cli._update, ['--checksum', str(self.src_path)])
|
||||||
|
|
||||||
def assert_check(self):
|
def assert_check(self):
|
||||||
for opt, arg in self.logger_options:
|
self.assert_cli(cli._check, [*self.logger_options, str(self.src_path)])
|
||||||
self.assert_cli(cli._check, [opt, arg, str(self.src_path)])
|
|
||||||
|
|
||||||
def assert_clean(self):
|
def assert_clean(self):
|
||||||
bool_options = (
|
bool_options = (
|
||||||
|
*self.logger_options,
|
||||||
# '--interactive',
|
# '--interactive',
|
||||||
'--dry-run',
|
'--dry-run',
|
||||||
'--delete-excluded',
|
'--delete-excluded',
|
||||||
|
@ -170,7 +167,6 @@ class TestOrdigi:
|
||||||
)
|
)
|
||||||
|
|
||||||
arg_options = (
|
arg_options = (
|
||||||
*self.logger_options,
|
|
||||||
*self.filter_options,
|
*self.filter_options,
|
||||||
('--dedup-regex', r'\d{4}-\d{2}'),
|
('--dedup-regex', r'\d{4}-\d{2}'),
|
||||||
)
|
)
|
||||||
|
@ -187,11 +183,11 @@ class TestOrdigi:
|
||||||
def test_init_update_check_clean(self):
|
def test_init_update_check_clean(self):
|
||||||
self.assert_init()
|
self.assert_init()
|
||||||
self.assert_update()
|
self.assert_update()
|
||||||
self.assert_check()
|
|
||||||
self.assert_clean()
|
self.assert_clean()
|
||||||
|
|
||||||
def test_import(self, tmp_path):
|
def test_import(self, tmp_path):
|
||||||
bool_options = (
|
bool_options = (
|
||||||
|
*self.logger_options,
|
||||||
# '--interactive',
|
# '--interactive',
|
||||||
'--dry-run',
|
'--dry-run',
|
||||||
'--album-from-folder',
|
'--album-from-folder',
|
||||||
|
@ -202,11 +198,9 @@ class TestOrdigi:
|
||||||
)
|
)
|
||||||
|
|
||||||
arg_options = (
|
arg_options = (
|
||||||
*self.logger_options,
|
|
||||||
('--exclude', '.DS_Store'),
|
('--exclude', '.DS_Store'),
|
||||||
*self.filter_options,
|
*self.filter_options,
|
||||||
('--path-format', '{%Y}/{folder}/{stem}.{ext}'),
|
('--path-format', '{%Y}/{folder}/{stem}.{ext}'),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
paths = (str(self.src_path), str(tmp_path))
|
paths = (str(self.src_path), str(tmp_path))
|
||||||
|
@ -219,6 +213,7 @@ class TestOrdigi:
|
||||||
|
|
||||||
def test_compare(self):
|
def test_compare(self):
|
||||||
bool_options = (
|
bool_options = (
|
||||||
|
*self.logger_options,
|
||||||
# '--interactive',
|
# '--interactive',
|
||||||
'--dry-run',
|
'--dry-run',
|
||||||
'--find-duplicates',
|
'--find-duplicates',
|
||||||
|
@ -226,7 +221,6 @@ class TestOrdigi:
|
||||||
)
|
)
|
||||||
|
|
||||||
arg_options = (
|
arg_options = (
|
||||||
*self.logger_options,
|
|
||||||
*self.filter_options,
|
*self.filter_options,
|
||||||
# ('--similar-to', ''),
|
# ('--similar-to', ''),
|
||||||
('--similarity', '65'),
|
('--similarity', '65'),
|
||||||
|
@ -240,6 +234,9 @@ class TestOrdigi:
|
||||||
self.assert_cli(cli._compare, paths)
|
self.assert_cli(cli._compare, paths)
|
||||||
self.assert_options(cli._compare, bool_options, arg_options, paths)
|
self.assert_options(cli._compare, bool_options, arg_options, paths)
|
||||||
|
|
||||||
|
def test_check(self):
|
||||||
|
self.assert_check()
|
||||||
|
|
||||||
|
|
||||||
def test_needsfiles(tmpdir):
|
def test_needsfiles(tmpdir):
|
||||||
assert tmpdir
|
assert tmpdir
|
||||||
|
|
|
@ -8,13 +8,14 @@ import inquirer
|
||||||
|
|
||||||
from ordigi import LOG
|
from ordigi import LOG
|
||||||
from ordigi import constants
|
from ordigi import constants
|
||||||
|
from ordigi import utils
|
||||||
|
from ordigi.summary import Summary
|
||||||
from ordigi.collection import Collection, FPath, Paths
|
from ordigi.collection import Collection, FPath, Paths
|
||||||
from ordigi.exiftool import ExifTool, ExifToolCaching, exiftool_is_running, terminate_exiftool
|
from ordigi.exiftool import ExifTool, ExifToolCaching, exiftool_is_running, terminate_exiftool
|
||||||
from ordigi.geolocation import GeoLocation
|
from ordigi.geolocation import GeoLocation
|
||||||
from ordigi.media import Media, ReadExif
|
from ordigi.media import Media, ReadExif
|
||||||
from ordigi import utils
|
from ordigi.request import Input
|
||||||
from .conftest import randomize_files, randomize_db
|
from .conftest import randomize_files, randomize_db
|
||||||
from ordigi.summary import Summary
|
|
||||||
|
|
||||||
LOG.setLevel(10)
|
LOG.setLevel(10)
|
||||||
|
|
||||||
|
@ -137,11 +138,12 @@ class TestCollection:
|
||||||
assert summary.success_table.sum('sort') == nb
|
assert summary.success_table.sum('sort') == nb
|
||||||
|
|
||||||
def test_sort_files(self, tmp_path):
|
def test_sort_files(self, tmp_path):
|
||||||
cli_options = {'album_from_folder': True, 'cache': False}
|
cli_options = {
|
||||||
|
'album_from_folder': True, 'cache': False, 'path_format': self.path_format
|
||||||
|
}
|
||||||
collection = Collection(tmp_path, cli_options=cli_options)
|
collection = Collection(tmp_path, cli_options=cli_options)
|
||||||
loc = GeoLocation()
|
loc = GeoLocation()
|
||||||
summary = collection.sort_files([self.src_path],
|
summary = collection.sort_files([self.src_path], loc, imp='copy')
|
||||||
self.path_format, loc, imp='copy')
|
|
||||||
|
|
||||||
self.assert_import(summary, 29)
|
self.assert_import(summary, 29)
|
||||||
|
|
||||||
|
@ -166,16 +168,16 @@ class TestCollection:
|
||||||
collection = Collection(tmp_path, cli_options=cli_options)
|
collection = Collection(tmp_path, cli_options=cli_options)
|
||||||
# Try to change path format and sort files again
|
# Try to change path format and sort files again
|
||||||
path_format = 'test_exif/<city>/<%Y>-<name>.%l<ext>'
|
path_format = 'test_exif/<city>/<%Y>-<name>.%l<ext>'
|
||||||
summary = collection.sort_files([tmp_path], path_format, loc)
|
summary = collection.sort_files([tmp_path], loc)
|
||||||
|
|
||||||
self.assert_sort(summary, 27)
|
self.assert_sort(summary, 23)
|
||||||
|
|
||||||
shutil.copytree(tmp_path / 'test_exif', tmp_path / 'test_exif_copy')
|
shutil.copytree(tmp_path / 'test_exif', tmp_path / 'test_exif_copy')
|
||||||
collection.summary = Summary(tmp_path)
|
collection.summary = Summary(tmp_path)
|
||||||
assert collection.summary.success_table.sum() == 0
|
assert collection.summary.success_table.sum() == 0
|
||||||
summary = collection.update(loc)
|
summary = collection.update(loc)
|
||||||
assert summary.success_table.sum('update') == 29
|
assert summary.success_table.sum('update') == 2
|
||||||
assert summary.success_table.sum() == 29
|
assert summary.success_table.sum() == 2
|
||||||
assert not summary.errors
|
assert not summary.errors
|
||||||
collection.summary = Summary(tmp_path)
|
collection.summary = Summary(tmp_path)
|
||||||
summary = collection.update(loc)
|
summary = collection.update(loc)
|
||||||
|
@ -195,12 +197,11 @@ class TestCollection:
|
||||||
assert not summary.errors
|
assert not summary.errors
|
||||||
|
|
||||||
def test_sort_files_invalid_db(self, tmp_path):
|
def test_sort_files_invalid_db(self, tmp_path):
|
||||||
collection = Collection(tmp_path)
|
collection = Collection(tmp_path, {'path_format': self.path_format})
|
||||||
loc = GeoLocation()
|
loc = GeoLocation()
|
||||||
randomize_db(tmp_path)
|
randomize_db(tmp_path)
|
||||||
with pytest.raises(sqlite3.DatabaseError) as e:
|
with pytest.raises(sqlite3.DatabaseError) as e:
|
||||||
summary = collection.sort_files([self.src_path],
|
summary = collection.sort_files([self.src_path], loc, imp='copy')
|
||||||
self.path_format, loc, imp='copy')
|
|
||||||
|
|
||||||
def test_sort_file(self, tmp_path):
|
def test_sort_file(self, tmp_path):
|
||||||
for imp in ('copy', 'move', False):
|
for imp in ('copy', 'move', False):
|
||||||
|
@ -218,6 +219,7 @@ class TestCollection:
|
||||||
)
|
)
|
||||||
assert not summary.errors
|
assert not summary.errors
|
||||||
# Ensure files remain the same
|
# Ensure files remain the same
|
||||||
|
if not imp:
|
||||||
assert collection._checkcomp(dest_path, src_checksum)
|
assert collection._checkcomp(dest_path, src_checksum)
|
||||||
|
|
||||||
if imp == 'copy':
|
if imp == 'copy':
|
||||||
|
@ -256,10 +258,10 @@ class TestCollection:
|
||||||
shutil.copytree(self.src_path, path)
|
shutil.copytree(self.src_path, path)
|
||||||
collection = Collection(path, {'cache': False})
|
collection = Collection(path, {'cache': False})
|
||||||
|
|
||||||
def mockreturn(prompt, theme):
|
def mockreturn(self, message):
|
||||||
return {'value': '03-12-2021 08:12:35'}
|
return '03-12-2021 08:12:35'
|
||||||
|
|
||||||
monkeypatch.setattr(inquirer, 'prompt', mockreturn)
|
monkeypatch.setattr(Input, 'text', mockreturn)
|
||||||
|
|
||||||
collection.edit_metadata({path}, {'date_original'}, overwrite=True)
|
collection.edit_metadata({path}, {'date_original'}, overwrite=True)
|
||||||
# check if db value is set
|
# check if db value is set
|
||||||
|
@ -277,10 +279,10 @@ class TestCollection:
|
||||||
collection = Collection(path, {'cache': False})
|
collection = Collection(path, {'cache': False})
|
||||||
loc = GeoLocation()
|
loc = GeoLocation()
|
||||||
|
|
||||||
def mockreturn(prompt, theme):
|
def mockreturn(self, message):
|
||||||
return {'value': 'lyon'}
|
return 'lyon'
|
||||||
|
|
||||||
monkeypatch.setattr(inquirer, 'prompt', mockreturn)
|
monkeypatch.setattr(Input, 'text', mockreturn)
|
||||||
|
|
||||||
collection.edit_metadata({path}, {'location'}, loc, True)
|
collection.edit_metadata({path}, {'location'}, loc, True)
|
||||||
# check if db value is set
|
# check if db value is set
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TestSqlite:
|
||||||
'CameraMake': 'camera_make',
|
'CameraMake': 'camera_make',
|
||||||
'CameraModel': 'camera_model',
|
'CameraModel': 'camera_model',
|
||||||
'OriginalName':'original_name',
|
'OriginalName':'original_name',
|
||||||
'SrcPath': 'src_path',
|
'SrcDir': 'src_dir',
|
||||||
'Subdirs': 'subdirs',
|
'Subdirs': 'subdirs',
|
||||||
'Filename': 'filename'
|
'Filename': 'filename'
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ class TestSqlite:
|
||||||
'Location': 'location'
|
'Location': 'location'
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.sqlite.add_row('metadata', row_data)
|
cls.sqlite.upsert_metadata(row_data)
|
||||||
cls.sqlite.add_row('location', location_data)
|
cls.sqlite.upsert_location(location_data)
|
||||||
# cls.sqlite.add_metadata_data('filename', 'ksinslsdosic', 'original_name', 'date_original', 'album', 1)
|
# cls.sqlite.add_metadata_data('filename', 'ksinslsdosic', 'original_name', 'date_original', 'album', 1)
|
||||||
# cls.sqlite.add_location(24.2, 7.3, 'city', 'state', 'country', 'location')
|
# cls.sqlite.add_location(24.2, 7.3, 'city', 'state', 'country', 'location')
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ class TestSqlite:
|
||||||
result = tuple(self.sqlite.cur.execute("""select * from metadata where
|
result = tuple(self.sqlite.cur.execute("""select * from metadata where
|
||||||
rowid=1""").fetchone())
|
rowid=1""").fetchone())
|
||||||
assert result == (
|
assert result == (
|
||||||
|
1,
|
||||||
'file_path',
|
'file_path',
|
||||||
'checksum',
|
'checksum',
|
||||||
'album',
|
'album',
|
||||||
|
@ -79,7 +80,7 @@ class TestSqlite:
|
||||||
'camera_make',
|
'camera_make',
|
||||||
'camera_model',
|
'camera_model',
|
||||||
'original_name',
|
'original_name',
|
||||||
'src_path',
|
'src_dir',
|
||||||
'subdirs',
|
'subdirs',
|
||||||
'filename'
|
'filename'
|
||||||
)
|
)
|
||||||
|
@ -96,7 +97,9 @@ class TestSqlite:
|
||||||
result = tuple(self.sqlite.cur.execute("""select * from location where
|
result = tuple(self.sqlite.cur.execute("""select * from location where
|
||||||
rowid=1""").fetchone())
|
rowid=1""").fetchone())
|
||||||
assert result == (
|
assert result == (
|
||||||
24.2, 7.3,
|
1,
|
||||||
|
24.2,
|
||||||
|
7.3,
|
||||||
'latitude_ref',
|
'latitude_ref',
|
||||||
'longitude_ref',
|
'longitude_ref',
|
||||||
'city',
|
'city',
|
||||||
|
|
|
@ -90,10 +90,10 @@ class TestMedia:
|
||||||
date_filename = None
|
date_filename = None
|
||||||
for tag in media.tags_keys['original_name']:
|
for tag in media.tags_keys['original_name']:
|
||||||
if tag in exif_data:
|
if tag in exif_data:
|
||||||
date_filename = get_date_from_string(exif_data[tag])
|
date_filename, _, _ = get_date_from_string(exif_data[tag])
|
||||||
break
|
break
|
||||||
if not date_filename:
|
if not date_filename:
|
||||||
date_filename = get_date_from_string(file_path.name)
|
date_filename, _, _ = get_date_from_string(file_path.name)
|
||||||
|
|
||||||
if media.metadata['date_original']:
|
if media.metadata['date_original']:
|
||||||
assert date_media == media.metadata['date_original']
|
assert date_media == media.metadata['date_original']
|
||||||
|
|
Loading…
Reference in New Issue