Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-tools
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e043490b
authored
Jun 14, 2022
by
aagusti
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
get_params
1 parent
6927a3eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
7 deletions
opensipkd/tools/__init__.py
opensipkd/tools/report.py
setup.py
opensipkd/tools/__init__.py
View file @
e043490
...
...
@@ -115,6 +115,19 @@ def round_up(n):
def
get_settings
():
return
get_current_registry
()
.
settings
def
get_params
(
params
,
alternate
=
None
):
"""
Digunakan untuk mengambil nilai dari konfigurasi sesuai params yang disebut
:param params: variable
:param alternate: default apabila tidak ditemukan data/params
:return: value
contoh penggunaan:
get_params('devel', False)
"""
settings
=
get_settings
()
result
=
settings
and
params
in
settings
and
settings
[
params
]
.
strip
()
or
None
return
result
and
result
or
alternate
def
devel
():
settings
=
get_settings
()
...
...
@@ -424,15 +437,26 @@ class Upload(SaveFile):
ext
=
get_ext
(
request
.
POST
[
name
]
.
filename
)
return
self
.
save_to_file
(
input_file
,
ext
)
def
save_fp
(
self
,
upload
):
if
'fp'
not
in
upload
or
upload
[
'fp'
]
==
b
''
:
if
"filename"
in
upload
:
return
upload
[
'filename'
]
return
filename
=
upload
[
'filename'
]
input_file
=
upload
[
'fp'
]
ext
=
get_ext
(
filename
)
return
self
.
save_to_file
(
input_file
,
ext
)
def
saves
(
self
,
uploads
):
d
=
{}
for
upload
in
uploads
:
if
'fp'
not
in
upload
or
upload
[
'fp'
]
==
b
''
:
continue
filename
=
upload
[
'filename'
]
input_file
=
upload
[
'fp'
]
ext
=
get_ext
(
filename
)
d
[
filename
]
=
self
.
save_to_file
(
input_file
,
ext
)
# input_file = upload['fp']
# ext = get_ext(filename)
# d[filename] = self.save_to_file(input_file, ext)
d
[
filename
]
=
self
.
save_fp
(
upload
)
return
d
...
...
opensipkd/tools/report.py
View file @
e043490
...
...
@@ -4,10 +4,10 @@ import ntpath
import
csv
import
io
from
datetime
import
datetime
#
from z3c.rml import rml2pdf
from
z3c.rml
import
rml2pdf
import
subprocess
import
logging
from
..tools
import
get_settings
from
..tools
import
get_settings
,
get_params
log
=
logging
.
getLogger
(
__name__
)
rpt_path
=
""
...
...
@@ -19,7 +19,7 @@ def get_root_path():
def
get_logo
():
path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
get_root_path
()),
'static/img'
)
path
=
get_params
(
'report_img'
,
os
.
path
.
join
(
os
.
path
.
dirname
(
get_root_path
()),
'static/img'
)
)
# FIXME opensipkd/static to be changed by active app folder
return
path
+
"/logo.png"
,
path
+
"/line.png"
...
...
setup.py
View file @
e043490
...
...
@@ -22,8 +22,8 @@ requires = [
"hupper"
,
"urllib3"
,
"idna"
,
"z3c.rml"
,
# "pikepdf",
# "z3c.rml",
]
dev_requires
=
[
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment