Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fachrat Informatik
pter
Commits
a872c887
Commit
a872c887
authored
Nov 25, 2020
by
dwoiwode
Browse files
Style cleanup
#1
parent
90827451
Changes
1
Hide whitespace changes
Inline
Side-by-side
linkToPDF2.py
View file @
a872c887
import
datetime
import
hashlib
import
os
import
subprocess
from
dataclasses
import
dataclass
from
pathlib
import
Path
from
typing
import
Optional
,
Dict
,
List
,
Iterator
,
Tuple
...
...
@@ -51,6 +53,10 @@ class Semester:
git
.
commit
(
f
"Added
{
self
.
part
.
value
}
{
self
.
year
}
"
)
git
.
push
()
def
uploadToCloud
(
self
):
# TODO: Upload semester folder to cloud if not exists
pass
# === Source Types ===
class
SourceTypes
:
...
...
@@ -68,7 +74,7 @@ class Etherpad(SourceTypes):
def
retrieveContent
(
self
):
url
=
f
"
{
self
.
url
}
.txt"
response
=
requests
.
get
(
url
)
return
response
.
content
.
decode
(
"utf-8"
)
return
response
.
text
@
classmethod
def
fitUrl
(
cls
,
url
:
str
)
->
bool
:
...
...
@@ -80,7 +86,7 @@ class CodiMD(SourceTypes):
def
retrieveContent
(
self
):
url
=
f
"
{
self
.
url
}
/download"
response
=
requests
.
get
(
url
)
return
response
.
content
.
decode
(
"utf-8"
)
return
response
.
text
@
classmethod
def
fitUrl
(
cls
,
url
:
str
)
->
bool
:
...
...
@@ -164,15 +170,18 @@ class BasePad:
def
compile
(
self
,
template
:
str
=
None
)
->
int
:
os
.
makedirs
(
str
(
self
.
compiledPath
.
parent
),
exist_ok
=
True
)
metadataStr
=
(
" "
+
" "
.
join
([
f
'-M
{
key
}
="
{
val
}
"'
for
key
,
val
in
self
.
metadata
.
items
()]))
templateStr
=
""
metadata
=
[
f
'-M
{
key
}
="
{
val
}
"'
for
key
,
val
in
self
.
metadata
.
items
()]
if
template
is
None
and
hasattr
(
self
,
"gremium"
):
templateStr
=
f
' --template="
{
getattr
(
self
,
"gremium"
).
fullTemplate
()
}
" '
elif
template
!=
""
:
templateStr
=
f
' --template="
{
template
}
" '
cmd
=
f
'pandoc "
{
self
.
rawPath
}
"
{
metadataStr
}{
templateStr
}
-o "
{
str
(
self
.
compiledPath
)
}
"'
ret
=
os
.
system
(
cmd
)
template
=
getattr
(
self
,
"gremium"
).
fullTemplate
()
proc
=
subprocess
.
run
([
"pandoc"
,
f
"
{
self
.
rawPath
}
"
,
*
metadata
,
f
"--template=
{
template
}
"
,
"-o"
,
f
"
{
self
.
compiledPath
}
"
])
ret
=
proc
.
returncode
if
ret
!=
0
:
raise
RuntimeWarning
(
f
"Non-Zero Returncode (
{
ret
}
)"
)
return
ret
...
...
@@ -271,7 +280,10 @@ class ProtocolPad(BasePad):
return
True
def
uploadToCloud
(
self
):
pass
assert
isinstance
(
self
.
semester
,
Semester
)
self
.
semester
.
uploadToCloud
()
# TODO: Upload pdf to cloud in semester-folder
# TODO: Upload raw md to cloud
def
uploadToGrav
(
self
):
# Init semester
...
...
Write
Preview
Supports
Markdown
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