Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
9c24a7bd
Commit
9c24a7bd
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
consolidate
parent
d77c6952
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devtools/code-tools/update-website.py
+28
-33
28 additions, 33 deletions
devtools/code-tools/update-website.py
with
28 additions
and
33 deletions
devtools/code-tools/update-website.py
+
28
−
33
View file @
9c24a7bd
...
@@ -12,6 +12,13 @@ python update-examples.py <website-source-dir> <BornAgain-source-dir> <BornAgain
...
@@ -12,6 +12,13 @@ python update-examples.py <website-source-dir> <BornAgain-source-dir> <BornAgain
import
argparse
,
datetime
,
os
,
shutil
import
argparse
,
datetime
,
os
,
shutil
def
log
(
msg
):
flog
.
write
(
msg
+
"
\n
"
)
def
log2
(
msg
):
print
(
msg
)
log
(
msg
)
def
find_files
(
dir_name
):
def
find_files
(
dir_name
):
"""
"""
Return recursive list of files in given dir_name
Return recursive list of files in given dir_name
...
@@ -42,14 +49,23 @@ def find_files_with_same_name(filename_list, name_to_find):
...
@@ -42,14 +49,23 @@ def find_files_with_same_name(filename_list, name_to_find):
return
same_names
return
same_names
def
copy_files
(
source
_list
,
destination
_list
):
def
update_all_files_of_one_type
(
source
,
destination
,
extension
):
"""
"""
Every file in dest
ination
_list will be replaced by the file with the same
Every file in dest_list will be replaced by the file with the same
basename found in source_list
basename found in source_list
"""
"""
source_list
=
get_files
(
source
,
extension
)
dest_list
=
get_files
(
destination
,
extension
)
log2
(
f
'
Update
{
len
(
dest_list
)
}
{
extension
}
files
'
)
log2
(
f
'
from
{
source
}
'
)
log2
(
f
'
to
{
destination
}
'
)
log
(
f
'
{
dest_list
}
'
)
missed_files
=
[]
missed_files
=
[]
updated_files
=
[]
updated_files
=
[]
for
f
in
dest
ination
_list
:
for
f
in
dest_list
:
found_source
=
find_files_with_same_name
(
source_list
,
os
.
path
.
basename
(
f
))
found_source
=
find_files_with_same_name
(
source_list
,
os
.
path
.
basename
(
f
))
if
len
(
found_source
)
==
1
:
if
len
(
found_source
)
==
1
:
updated_files
.
append
(
f
)
updated_files
.
append
(
f
)
...
@@ -68,19 +84,6 @@ def copy_files(source_list, destination_list):
...
@@ -68,19 +84,6 @@ def copy_files(source_list, destination_list):
print
(
f
)
print
(
f
)
def
update_all_files_of_one_type
(
source
,
destination
,
extension
):
source_files
=
get_files
(
source
,
extension
)
website_files
=
get_files
(
destination
,
extension
)
print
(
f
'
Update
{
len
(
website_files
)
}
{
extension
}
files ...
'
)
flog
.
write
(
f
'
Update
{
len
(
website_files
)
}
{
extension
}
files:
'
)
flog
.
write
(
f
'
{
website_files
}
'
)
copy_files
(
source_files
,
website_files
)
def
update_website
(
website_source_dir
,
ba_source_dir
,
ba_build_dir
):
def
update_website
(
website_source_dir
,
ba_source_dir
,
ba_build_dir
):
"""
"""
Updates example scripts and images on website.
Updates example scripts and images on website.
...
@@ -92,25 +95,17 @@ def update_website(website_source_dir, ba_source_dir, ba_build_dir):
...
@@ -92,25 +95,17 @@ def update_website(website_source_dir, ba_source_dir, ba_build_dir):
global
flog
global
flog
flog
=
open
(
log_path
,
"
a
"
)
flog
=
open
(
log_path
,
"
a
"
)
print
(
f
'
Appending log to
{
log_path
}
'
)
print
(
f
'
Appending log to
{
log_path
}
'
)
flog
.
write
(
f
'
\n
===
\n
{
datetime
.
datetime
.
now
().
strftime
(
"
%d%b%y %H
:
%
M
:
%
S
"
)
}
\n
'
)
log
(
f
'
\n
===
\n
{
datetime
.
datetime
.
now
().
strftime
(
"
%d%b%y %H
:
%
M
:
%
S
"
)
}
'
)
user_source_dir
=
os
.
path
.
expanduser
(
ba_source_dir
)
user_build_dir
=
os
.
path
.
expanduser
(
ba_build_dir
)
user_image_dir
=
os
.
path
.
join
(
user_build_dir
,
"
test_output/Functional/PyExamples
"
)
flog
.
write
(
'
Directories:
\n
'
)
flog
.
write
(
f
'
website_dir :
{
website_dirpath
}
\n
'
)
flog
.
write
(
f
'
source_dir :
{
user_source_dir
}
\n
'
)
flog
.
write
(
f
'
build_dir :
{
user_build_dir
}
\n
'
)
flog
.
write
(
f
'
image_dir :
{
user_image_dir
}
\n
'
)
website
=
os
.
path
.
join
(
website_dirpath
,
"
static/files/python
"
)
update_all_files_of_one_type
(
source
=
os
.
path
.
join
(
user_source_dir
,
"
Examples/Python
"
)
os
.
path
.
join
(
ba_source_dir
,
"
Examples/Python
"
),
update_all_files_of_one_type
(
source
,
website_dirpath
,
'
.py
'
)
os
.
path
.
join
(
website_dirpath
,
"
static/files/python
"
),
'
.py
'
)
website
=
os
.
path
.
join
(
website_dirpath
,
"
content/documentation/examples
"
)
update_all_files_of_one_type
(
source
=
user_image_dir
os
.
path
.
join
(
website_dirpath
,
"
content/documentation/examples
"
),
update_all_files_of_one_type
(
source
,
website_dirpath
,
'
.png
'
)
os
.
path
.
join
(
ba_build_dir
,
"
test_output/Functional/PyExamples
"
),
'
.png
'
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__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