Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
ptbcli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniele Nicolodi
ptbcli
Commits
c699b0de
Commit
c699b0de
authored
3 years ago
by
Daniele Nicolodi
Browse files
Options
Downloads
Patches
Plain Diff
bestellanforderung: Add sketch for a sync command
parent
1d610c49
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bestellanforderung.py
+45
-0
45 additions, 0 deletions
bestellanforderung.py
with
45 additions
and
0 deletions
bestellanforderung.py
+
45
−
0
View file @
c699b0de
...
...
@@ -10,6 +10,7 @@ import toml
import
zipfile
import
openpyxl
from
itertools
import
groupby
from
os
import
path
from
xml.etree
import
ElementTree
...
...
@@ -219,5 +220,49 @@ def extract(conf, verbose):
printer
.
print_entries
(
entries
)
@main.command
()
@click.pass_obj
def
sync
(
conf
):
"""
Sync order request forms to central repository.
"""
fromdate
=
datetime
.
date
(
2021
,
11
,
1
)
datadir
=
path
.
realpath
(
conf
[
'
documents
'
])
destdir
=
r
'
O:\4-3\4-3-Alle\Organisation\Beschaffungen\2021\4.31\Nicolodi
'
click
.
echo
(
f
'
{
destdir
}{
os
.
sep
}
'
)
updated
=
[]
for
entry
in
os
.
listdir
(
datadir
):
src
=
path
.
join
(
datadir
,
entry
)
dst
=
path
.
join
(
destdir
,
entry
)
if
not
path
.
isdir
(
src
):
continue
m
=
re
.
match
(
r
'
(\d{8})__(.+)$
'
,
entry
)
if
not
m
:
continue
date
=
datetime
.
datetime
.
strptime
(
m
.
group
(
1
),
'
%Y%m%d
'
).
date
()
if
date
<
fromdate
:
continue
srcmap
=
{
entry
.
name
:
entry
.
stat
().
st_mtime
for
entry
in
os
.
scandir
(
src
)
if
not
entry
.
name
.
startswith
(
'
~
'
)}
dstmap
=
{
entry
.
name
:
entry
.
stat
().
st_mtime
for
entry
in
os
.
scandir
(
dst
)
if
not
entry
.
name
.
startswith
(
'
~
'
)}
for
name
,
mtime
in
srcmap
.
items
():
if
mtime
>
dstmap
.
get
(
name
,
0
):
updated
.
append
((
entry
,
'
>
'
,
name
))
for
name
,
mtime
in
dstmap
.
items
():
if
mtime
>
srcmap
.
get
(
name
,
0
):
updated
.
append
((
entry
,
'
<
'
,
name
))
for
folder
,
entries
in
groupby
(
updated
,
key
=
lambda
x
:
x
[
0
]):
click
.
echo
(
f
'
·
{
folder
}{
os
.
sep
}
'
)
for
entry
in
entries
:
note
=
click
.
style
(
entry
[
1
],
fg
=
'
red
'
if
entry
[
1
]
==
'
<
'
else
'
green
'
)
click
.
echo
(
f
'
{
note
}
{
entry
[
2
]
}
'
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment