Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NIRS_Workflow
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
CEFE
PACE
NIRS_Workflow
Commits
ec96eafc
Commit
ec96eafc
authored
8 months ago
by
Nicolas Barthes
Browse files
Options
Downloads
Patches
Plain Diff
Class to manage spectra md5 hash
parent
27cb217a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Class_Mod/Hash.py
+26
-0
26 additions, 0 deletions
src/Class_Mod/Hash.py
src/Modules.py
+1
-0
1 addition, 0 deletions
src/Modules.py
src/data/hash/hash.txt
+0
-0
0 additions, 0 deletions
src/data/hash/hash.txt
with
27 additions
and
0 deletions
src/Class_Mod/Hash.py
0 → 100644
+
26
−
0
View file @
ec96eafc
from
Packages
import
*
def
create_hash
(
spectra
):
#using the md5 hash function.
hash_func
=
hashlib
.
md5
()
spectra
=
str
(
spectra
)
encoded_spectra
=
spectra
.
encode
()
hash_func
.
update
(
encoded_spectra
)
hash
=
hash_func
.
hexdigest
()
return
hash
def
check_hash
(
hash
):
# path to hash file and grep/cat functions for Win
subprocess_path
=
Path
(
"
src/data/hash/
"
)
# run a grep from the hash onto the hash file
nb_hash
=
subprocess
.
run
([
subprocess_path
/
'
grep.exe
'
,
'
-c
'
,
hash
,
subprocess_path
/
"
hash.txt
"
],
shell
=
True
)
# if hash present
if
'
returncode=0
'
in
str
(
nb_hash
):
return
'
existing hash
'
# if hash not present, add it to the file with cat function
else
:
add_hash
=
subprocess
.
run
([
'
echo
'
,
str
(
hash
)
+
'
>>
'
,
subprocess_path
/
"
hash.txt
"
],
shell
=
True
)
if
'
returncode=0
'
in
str
(
add_hash
):
return
'
hash added
'
else
:
return
'
error while adding the new hash
'
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Modules.py
+
1
−
0
View file @
ec96eafc
...
@@ -3,6 +3,7 @@ from Class_Mod import Plsr, LinearPCA, Umap, find_col_index, PinardPlsr, Nmf, AP
...
@@ -3,6 +3,7 @@ from Class_Mod import Plsr, LinearPCA, Umap, find_col_index, PinardPlsr, Nmf, AP
from
Class_Mod
import
LWPLSR
,
list_files
,
metrics
,
TpeIpls
,
reg_plot
,
resid_plot
,
Sk_Kmeans
,
DxRead
,
Hdbscan
,
read_dx
,
PlsProcess
from
Class_Mod
import
LWPLSR
,
list_files
,
metrics
,
TpeIpls
,
reg_plot
,
resid_plot
,
Sk_Kmeans
,
DxRead
,
Hdbscan
,
read_dx
,
PlsProcess
from
Class_Mod.DATA_HANDLING
import
*
from
Class_Mod.DATA_HANDLING
import
*
from
Class_Mod.Miscellaneous
import
prediction
,
download_results
,
plot_spectra
,
local_css
from
Class_Mod.Miscellaneous
import
prediction
,
download_results
,
plot_spectra
,
local_css
from
Class_Mod.Hash
import
create_hash
,
check_hash
from
Report
import
report
from
Report
import
report
css_file
=
Path
(
"
style/
"
)
css_file
=
Path
(
"
style/
"
)
pages_folder
=
Path
(
"
pages/
"
)
pages_folder
=
Path
(
"
pages/
"
)
...
...
This diff is collapsed.
Click to expand it.
src/data/hash/hash.txt
0 → 100644
+
0
−
0
View file @
ec96eafc
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