Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package 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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
4ed676c4
Commit
4ed676c4
authored
4 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
fixed several functions
parent
6de75cde
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
binarycpython/utils/functions.py
+36
-11
36 additions, 11 deletions
binarycpython/utils/functions.py
with
36 additions
and
11 deletions
binarycpython/utils/functions.py
+
36
−
11
View file @
4ed676c4
...
...
@@ -195,7 +195,7 @@ def parse_binary_c_version_info(version_info_string):
"
mass_g
"
:
mass_g
,
"
mass_amu
"
:
mass_amu
,
}
version_info_dict
[
"
isotopes
"
]
=
isotope_dict
version_info_dict
[
"
isotopes
"
]
=
isotope_dict
if
isotope_dict
else
None
##########################
# Argpairs:
...
...
@@ -212,7 +212,7 @@ def parse_binary_c_version_info(version_info_string):
else
:
argpair_dict
[
split_info
[
0
]][
split_info
[
1
]]
=
split_info
[
2
]
version_info_dict
[
"
argpairs
"
]
=
argpair_dict
version_info_dict
[
"
argpairs
"
]
=
argpair_dict
if
argpair_dict
else
None
##########################
# ensembles:
...
...
@@ -225,7 +225,7 @@ def parse_binary_c_version_info(version_info_string):
split_info
=
el
.
split
(
"
Ensemble
"
)[
-
1
].
split
(
"
is
"
)
if
len
(
split_info
)
>
1
:
ensemble_dict
[
int
(
split_info
[
0
])]
=
split_info
[
-
1
]
version_info_dict
[
"
ensembles
"
]
=
ensemble_dict
version_info_dict
[
"
ensembles
"
]
=
ensemble_dict
if
ensemble_dict
else
None
##########################
# macros:
...
...
@@ -254,7 +254,7 @@ def parse_binary_c_version_info(version_info_string):
macros_dict
[
param_name
]
=
param_type_dict
[
param_type
](
param_value
)
except
ValueError
:
macros_dict
[
param_name
]
=
str
(
param_value
)
version_info_dict
[
"
macros
"
]
=
macros_dict
version_info_dict
[
"
macros
"
]
=
macros_dict
if
macros_dict
else
None
##########################
# Elements:
...
...
@@ -283,7 +283,7 @@ def parse_binary_c_version_info(version_info_string):
"
amt_isotopes
"
:
len
(
isotopes
),
"
isotopes
"
:
isotopes
,
}
version_info_dict
[
"
elements
"
]
=
version_info_dict
version_info_dict
[
"
elements
"
]
=
elements_dict
if
elements_dict
else
None
##########################
# dt_limits:
...
...
@@ -300,7 +300,7 @@ def parse_binary_c_version_info(version_info_string):
"
value
"
:
float
(
split_info
[
-
1
]),
}
version_info_dict
[
"
dt_limits
"
]
=
dt_limits_dict
version_info_dict
[
"
dt_limits
"
]
=
dt_limits_dict
if
dt_limits_dict
else
None
##########################
# Nucleosynthesis sources:
...
...
@@ -314,7 +314,7 @@ def parse_binary_c_version_info(version_info_string):
split_info
=
el
.
split
(
"
Nucleosynthesis source
"
)[
-
1
].
strip
().
split
(
"
is
"
)
nucsyn_sources_dict
[
int
(
split_info
[
0
])]
=
split_info
[
-
1
]
version_info_dict
[
"
nucleosynthesis_sources
"
]
=
nucsyn_sources_dict
version_info_dict
[
"
nucleosynthesis_sources
"
]
=
nucsyn_sources_dict
if
nucsyn_sources_dict
else
None
##########################
# miscellaneous:
...
...
@@ -329,16 +329,29 @@ def parse_binary_c_version_info(version_info_string):
git_branch
=
[
el
for
el
in
cleaned
if
el
.
startswith
(
"
git branch
"
)]
misc_dict
[
"
git_branch
"
]
=
git_branch
[
0
].
split
(
"
git branch
"
)[
-
1
].
replace
(
'"'
,
""
)
cleaned
=
cleaned
-
set
(
git_branch
)
build
=
[
el
for
el
in
cleaned
if
el
.
startswith
(
"
Build
"
)]
misc_dict
[
"
build
"
]
=
build
[
0
].
split
(
"
Build:
"
)[
-
1
].
replace
(
'"'
,
""
)
cleaned
=
cleaned
-
set
(
build
)
email
=
[
el
for
el
in
cleaned
if
el
.
startswith
(
"
Email
"
)]
misc_dict
[
"
email
"
]
=
email
[
0
].
split
(
"
Email
"
)[
-
1
].
split
(
"
,
"
)
cleaned
=
cleaned
-
set
(
email
)
misc_dict
[
"
uncaught
"
]
=
cleaned
other_items
=
set
([
el
for
el
in
cleaned
if
'
is
'
in
el
])
cleaned
=
cleaned
-
other_items
version_info_dict
[
"
miscellaneous
"
]
=
misc_dict
for
el
in
other_items
:
split
=
el
.
split
(
'
is
'
)
key
=
split
[
0
].
strip
()
val
=
'
is
'
.
join
(
split
[
1
:]).
strip
()
misc_dict
[
key
]
=
val
misc_dict
[
"
uncaught
"
]
=
"
\n
"
.
join
(
cleaned
)
version_info_dict
[
"
miscellaneous
"
]
=
misc_dict
if
misc_dict
else
None
return
version_info_dict
...
...
@@ -957,6 +970,18 @@ class binarycDecoder(json.JSONDecoder):
return
o
class
BinaryCEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
o
):
print
(
'
inarycoij
'
)
try
:
str_repr
=
str
(
o
)
except
TypeError
:
pass
else
:
return
str_repr
# Let the base class default method raise the TypeError
return
JSONEncoder
.
default
(
self
,
o
)
def
binaryc_json_serializer
(
obj
):
"""
Custom serializer for binary_c to use when functions are present in the dictionary
...
...
@@ -967,8 +992,8 @@ def binaryc_json_serializer(obj):
if
inspect
.
isfunction
(
obj
):
return
str
(
obj
)
return
obj
else
:
return
obj
def
handle_ensemble_string_to_json
(
raw_output
):
"""
...
...
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