Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dft_graph_database
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
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nomad-lab
dft_graph_database
Commits
91b91ff7
Commit
91b91ff7
authored
1 year ago
by
Nathan Daelman
Browse files
Options
Downloads
Patches
Plain Diff
Make __main__.py work
parent
d8c658b7
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
__main__.py
+31
-0
31 additions, 0 deletions
__main__.py
config.yaml
+2
-0
2 additions, 0 deletions
config.yaml
general_parser.py
+3
-0
3 additions, 0 deletions
general_parser.py
maple_parser.py
+1
-4
1 addition, 4 deletions
maple_parser.py
with
37 additions
and
4 deletions
__main__.py
0 → 100644
+
31
−
0
View file @
91b91ff7
from
pathlib
import
Path
import
yaml
from
general_parser
import
trace_files
from
maple_parser
import
handler_maple
maple_dir
=
"
maple
"
maple_files
=
[
"
gga_k_apbe.mpl
"
]
def
get_libxc_settings
()
->
tuple
[
str
,
str
]:
# Read the YAML file
with
open
(
"
config.yaml
"
,
"
r
"
)
as
file
:
config
=
yaml
.
safe_load
(
file
)
file
.
close
()
return
config
[
"
libxc
"
][
"
path
"
],
config
[
"
libxc
"
][
"
maple
"
]
def
__main__
():
# Parse the Maple files
maple_dir
=
"
{}/{}/
"
.
format
(
*
get_libxc_settings
())
maple_files
=
[
str
(
file
).
split
(
'
/
'
)[
-
1
]
for
file
in
Path
(
maple_dir
).
rglob
(
'
*.mpl
'
)]
for
maple_file
in
maple_files
:
triples
=
trace_files
(
maple_file
,
maple_dir
,
handler_maple
,
triples
=
set
()
)
for
triple
in
triples
:
if
triple
[
2
]
==
"
FileReference
"
:
print
(
f
"
Maple file
{
triple
[
0
]
}
references
{
triple
[
1
]
}
"
)
# execute the main function
if
__name__
==
"
__main__
"
:
__main__
()
This diff is collapsed.
Click to expand it.
config.yaml
+
2
−
0
View file @
91b91ff7
...
...
@@ -5,3 +5,5 @@ neo4j:
port
:
7687
libxc
:
path
:
'
/home/nathan/Documents/libxc/'
maple
:
"
maple/"
src
:
"
src/"
This diff is collapsed.
Click to expand it.
general_parser.py
+
3
−
0
View file @
91b91ff7
...
...
@@ -15,6 +15,9 @@ BlockProcessor = Callable[[Block], Triple]
FileHandler
=
Callable
[[
FileName
],
set
[
Triple
]]
def
file_path_to_name
(
file_path
:
str
)
->
str
:
return
file_path
.
split
(
"
/
"
)[
-
1
]
def
read_file
(
file_path
:
str
,
line_processor
:
Callable
[[
str
],
str
])
->
FileContents
:
with
open
(
file_path
,
"
r
"
)
as
file
:
contents
=
[
line_processor
(
line
)
for
line
in
file
.
readlines
()]
...
...
This diff is collapsed.
Click to expand it.
maple_parser.py
+
1
−
4
View file @
91b91ff7
...
...
@@ -7,6 +7,7 @@ from general_parser import (
process_lines
,
read_file
,
clean_line
,
file_path_to_name
,
)
...
...
@@ -53,10 +54,6 @@ def split_formula(formula: str) -> MapleFormula:
# Composed, ready-made functions
def
file_path_to_name
(
file_path
:
str
)
->
str
:
return
file_path
.
split
(
"
/
"
)[
-
1
]
def
handler_maple
(
file_path
:
str
,
)
->
set
[
Triple
]:
# decide on how to handle file_name rather than file_path
...
...
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