Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
82269ee6
Commit
82269ee6
authored
Dec 27, 2023
by
shadMod
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced old copy tree data news with GetNews().init_assets_news()
added debug param
parent
08dafe75
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
18 deletions
+10
-18
uitwww/__init__.py
uitwww/__init__.py
+10
-18
No files found.
uitwww/__init__.py
View file @
82269ee6
...
@@ -85,7 +85,7 @@ def create_app(data_path, debug=False):
...
@@ -85,7 +85,7 @@ def create_app(data_path, debug=False):
return
app
return
app
def
init_data_directory
(
data_path
:
str
):
def
init_data_directory
(
data_path
:
str
,
debug
:
bool
=
False
):
"""Initialize the data directory"""
"""Initialize the data directory"""
src_directory
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
src_directory
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
...
@@ -94,23 +94,15 @@ def init_data_directory(data_path: str):
...
@@ -94,23 +94,15 @@ def init_data_directory(data_path: str):
for
_dir
in
dirs
:
for
_dir
in
dirs
:
os
.
makedirs
(
os
.
path
.
join
(
data_path
,
_dir
),
exist_ok
=
True
)
os
.
makedirs
(
os
.
path
.
join
(
data_path
,
_dir
),
exist_ok
=
True
)
# Copy news tree dirs and file
news_path
=
os
.
path
.
join
(
data_path
,
"news"
)
os
.
makedirs
(
news_path
,
exist_ok
=
True
)
# check if exists
if
not
os
.
listdir
(
news_path
)
or
debug
:
# init ROOT_NEWS and NEWS_PATH
ROOT_NEWS
=
os
.
path
.
join
(
BASE_DIR
,
"assets/news"
)
ROOT_NEWS
=
os
.
path
.
join
(
BASE_DIR
,
"assets/news"
)
NEWS_PATH
=
os
.
path
.
join
(
data_path
,
"news"
)
NEWS_PATH
=
os
.
path
.
join
(
data_path
,
"news"
)
if
sys
.
version_info
[:
2
]
>
(
3
,
8
):
# clean and populate news directory with all news and create indexes
shutil
.
copytree
(
ROOT_NEWS
,
NEWS_PATH
,
dirs_exist_ok
=
True
)
nw_cl
=
GetNews
(
data_path
)
else
:
nw_cl
.
init_assets_news
(
ROOT_NEWS
,
NEWS_PATH
)
try
:
# if path already exists, remove it before copying with copytree()
if
os
.
path
.
exists
(
NEWS_PATH
):
shutil
.
rmtree
(
NEWS_PATH
)
shutil
.
copytree
(
ROOT_NEWS
,
NEWS_PATH
)
else
:
shutil
.
copytree
(
ROOT_NEWS
,
NEWS_PATH
)
except
OSError
as
ex
:
shutil
.
copy
(
ROOT_NEWS
,
NEWS_PATH
)
except
Exception
as
ex
:
print
(
ex
)
# Initialize the cache
# Initialize the cache
static_dirs
=
{
"static"
:
"+assets"
}
static_dirs
=
{
"static"
:
"+assets"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment