Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tuhe
slider
Commits
085c42c5
Commit
085c42c5
authored
2 years ago
by
tuhe
Browse files
Options
Downloads
Patches
Plain Diff
testing again
parent
6a1d695e
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#7538
failed
2 years ago
Stage: test
Stage: deploy
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/slider/convert.py
+1
-0
1 addition, 0 deletions
src/slider/convert.py
src/slider/slide.py
+26
-13
26 additions, 13 deletions
src/slider/slide.py
tests/test_slider.py
+14
-12
14 additions, 12 deletions
tests/test_slider.py
tests/tests_images/index.pdf
+0
-0
0 additions, 0 deletions
tests/tests_images/index.pdf
with
41 additions
and
25 deletions
src/slider/convert.py
+
1
−
0
View file @
085c42c5
...
...
@@ -63,6 +63,7 @@ def pdf2png(fin, fout=None, scale_to=None, page_to_convert=None):
if
scale_to
is
not
None
:
cmd
+=
f
"
-scale-to
{
scale_to
}
"
execute_command
(
cmd
.
split
())
return
fout
+
"
.png
"
...
...
This diff is collapsed.
Click to expand it.
src/slider/slide.py
+
26
−
13
View file @
085c42c5
...
...
@@ -22,6 +22,11 @@ def fix_handout(s):
s
=
s
[:
j2
+
1
]
+
"
[handout]
"
+
s
[
j2
+
1
:]
return
s
def
_get_osvg_labels
():
pass
def
set_svg_background_images
(
lecture_tex
,
verbose
=
False
,
fix_broken_osvg_files
=
False
,
recompile_on_change
=
True
,
...
...
@@ -43,6 +48,14 @@ def set_svg_background_images(lecture_tex, verbose=False,
SVG_TMP_DIR
=
MAIN_TEX_DIR
+
"
/
"
+
SVG_EDIT_RELPATH
+
"
/
"
+
SVG_TMP_RELPATH
SVG_OSVG_DIR
=
MAIN_TEX_DIR
+
"
/
"
+
SVG_EDIT_RELPATH
force_fix_broken_osvg_files
=
[]
if
force_fix_broken_osvg_files
is
None
else
force_fix_broken_osvg_files
NO_SVG_TMP_DIR
=
SVG_TMP_DIR
+
"
/no_svg_tmp
"
# if not os.path.isdir(NO_SVG_TMP_DIR):
# os.mkdir(NO_SVG_TMP_DIR)
if
os
.
path
.
isdir
(
NO_SVG_TMP_DIR
):
for
f
in
glob
.
glob
(
MAIN_TEX_DIR
+
"
/*_NO_SVGS.*
"
):
shutil
.
move
(
f
,
MAIN_TEX_DIR
+
"
/
"
+
os
.
path
.
basename
(
f
))
print
(
"
Slider is setting the background images for the .tex. file
\n
> %s
"
%
os
.
path
.
abspath
(
lecture_tex
))
if
copy_template_resource_files
:
...
...
@@ -107,7 +120,6 @@ def set_svg_background_images(lecture_tex, verbose=False,
lecture_tex_nosvg_pdf
=
lecture_tex_nosvg
[:
-
4
]
+
"
.pdf
"
# lecture_tex_nosvg_tex = recursive_tex_apply(lecture_tex_nosvg)
if
cache_contains_str
(
MAIN_TEX_DIR
,
key
=
'
all_tex
'
,
value
=
all_tex
)
and
os
.
path
.
exists
(
lecture_tex_nosvg_pdf
):
print
(
"
slider> Cache contains nosvg tex file
"
)
...
...
@@ -176,26 +188,27 @@ def set_svg_background_images(lecture_tex, verbose=False,
if
clean_temporary_files
:
if
verbose
:
print
(
"
> Slide
Converte
r: Removing temporary dirs...
"
)
print
(
"
> Slider: Removing temporary dirs...
"
)
# raise Exception()
DNE
=
SVG_OSVG_DIR
+
"
/do_not_edit
"
if
os
.
path
.
exists
(
SVG_TMP_DIR
):
for
v
in
glob
.
glob
(
SVG_TMP_DIR
+
"
/*
"
):
for
v
in
glob
.
glob
(
SVG_TMP_DIR
+
"
/*
.svg
"
):
if
not
v
.
endswith
(
"
png
"
):
os
.
remove
(
v
)
if
os
.
path
.
isdir
(
DNE
):
shutil
.
rmtree
(
DNE
)
if
not
os
.
path
.
isdir
(
NO_SVG_TMP_DIR
):
os
.
mkdir
(
NO_SVG_TMP_DIR
)
# for v in glob.glob(SVG_OSVG_DIR + "/x_do_not_edit*.pdf"):
for
f
in
glob
.
glob
(
MAIN_TEX_DIR
+
"
/*_NO_SVGS.*
"
):
shutil
.
move
(
f
,
NO_SVG_TMP_DIR
+
"
/
"
+
os
.
path
.
basename
(
f
))
# if os.path.exists(DNE):
# for v in glob.glob(DNE + "/*"):
# if not v.endswith("png"):
# os.remove(v)
# Not sure I want to do add this as an option right now. It makes everything slower...
# for f in glob.glob(lecture_tex[:-4] + '_NO_SVGS*'):
# os.remove(f)
if
os
.
path
.
exists
(
DNE
):
for
v
in
glob
.
glob
(
DNE
+
"
/*
"
):
if
not
v
.
endswith
(
"
png
"
):
os
.
remove
(
v
)
a
=
234
def
slide_no_by_text
(
pdf_file
,
text
):
assert
False
...
...
This diff is collapsed.
Click to expand it.
tests/test_slider.py
+
14
−
12
View file @
085c42c5
import
os
# import pytest
import
numpy
as
np
from
PIL
import
Image
from
unittest
import
TestCase
...
...
@@ -8,9 +7,6 @@ import os
import
subprocess
from
slider.convert
import
pdf2png
from
slider.slider_cli
import
slider_cli
# import sys
# sys.path.append(os.path.dirname(os.path.abspath(__file__)) +"/../src")
def
assert_images_equal
(
image_1
:
str
,
image_2
:
str
):
img1
=
Image
.
open
(
image_1
)
...
...
@@ -64,11 +60,6 @@ class TestSlider(TestCase):
s
=
f
.
read
()
i
=
s
.
find
(
"
</svg>
"
)
ss
=
s
[:
i
]
+
RECT1
+
RECT2
+
s
[
i
:]
# pieces = s.split("</svg>")
# ss = s.replace("</svg>", RECT + "</svg>")
# ss = pieces[0] + "<g>" + + pieces[1]
with
open
(
fn
,
'
w
'
)
as
f
:
f
.
write
(
ss
)
slider_cli
(
"
automatic/index.tex
"
,
interactive
=
False
)
...
...
@@ -98,15 +89,26 @@ class TestConverter(TestCase):
# Generate the output files.
if
os
.
path
.
isdir
(
"
./converted
"
):
shutil
.
rmtree
(
"
./converted
"
)
# if os.path.isdir("./test_images"):
# shutil.rmtree("./test_images")
os
.
mkdir
(
"
converted
"
)
shutil
.
copyfile
(
"
slideshow.pdf
"
,
"
converted/slideshow.pdf
"
)
from
slider.slider_cli
import
slider_converter_cli
slider_converter_cli
(
"
converted/slideshow.pdf
"
)
pdf2png
(
"
converted/slideshow_converted.pdf
"
,
fout
=
"
converted/converted_10.png
"
,
page_to_convert
=
10
)
out
=
pdf2png
(
"
converted/slideshow_converted.pdf
"
,
fout
=
"
converted/converted_10.png
"
,
page_to_convert
=
10
)
print
(
"
output file was
"
,
os
.
path
.
abspath
(
out
),
"
exists?
"
,
os
.
path
.
isfile
(
out
))
print
(
"
Current directory is
"
,
os
.
getcwd
())
print
(
"
Content of current dir is
"
)
import
glob
for
f
in
glob
.
glob
(
"
./*
"
):
print
(
f
)
print
(
"
Content of tests_images is
"
)
shutil
.
copyfile
(
"
converted/converted_10.png
"
,
"
tests_images/converted_10.png
"
)
# pdf2png("automatic/index.pdf", fout="automatic/index_b.png", page_to_convert=2)
# shutil.copyfile("automatic/index_a.png", "tests_images/index_a.png")
# shutil.copyfile("automatic/index_b.png", "tests_images/index_b.png")
# shutil.copyfile("automatic/index_a.png", "tests_images/index_a.png")
...
...
This diff is collapsed.
Click to expand it.
tests/tests_images/index.pdf
+
0
−
0
View file @
085c42c5
No preview for this file type
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