Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
r2ogs6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
r2ogs6
Commits
c177d182
Commit
c177d182
authored
4 years ago
by
Ruben Heinrich
Browse files
Options
Downloads
Patches
Plain Diff
Moved functions to generate_functions
parent
d8a6641d
No related branches found
No related tags found
4 merge requests
!5
7 vtkdiff
,
!4
7 parameter
,
!3
7 process borehole heat exchanger
,
!2
Basic import and export functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/analyse_xml.R
+1
-87
1 addition, 87 deletions
R/analyse_xml.R
with
1 addition
and
87 deletions
R/analyse_xml.R
+
1
−
87
View file @
c177d182
...
@@ -189,95 +189,9 @@ analyse_xml <- function(path, pattern, element_name) {
...
@@ -189,95 +189,9 @@ analyse_xml <- function(path, pattern, element_name) {
}
}
#Experimental stuff
generate_from_element
<-
function
(
element_name
,
attrs
,
children
)
{
}
generate_class_from_element
<-
function
(
element_name
,
class_name
=
NULL
)
{
#Generate name of new class from element name if class_name is not specified
if
(
is.null
(
class_name
)){
class_name
<-
snakecase
::
to_any_case
(
element_name
,
"snake"
)
}
generated_class
<-
structure
(
list
(),
class
=
class_name
)
return
(
generated_class
)
}
generate_validator_from_element
<-
function
()
{
}
#cat(generate_as_node_from_element("DataArray", c("SexyAttr")))
#'generate_as_node_from_element
#'@description Generates a method for the generic function as_node based on an XML element
#'@param element_name The name of the XML element to base the function on
#'@param attrs Optional: A list of element attributes
#'@param children Optional: A list of element children
generate_as_node_from_element
<-
function
(
element_name
,
attrs
=
NULL
,
children
=
NULL
)
{
attrs_snake_names
<-
sapply
(
attrs
,
snakecase
::
to_any_case
,
case
=
"snake"
)
children_snake_names
<-
sapply
(
children
,
snakecase
::
to_any_case
,
case
=
"snake"
)
element_snake_name
<-
snakecase
::
to_any_case
(
element_name
,
"snake"
)
f_name
<-
paste0
(
"as_node."
,
element_snake_name
)
#Is the child a parent itself?
is_parent
=
TRUE
func_str
<-
paste0
(
f_name
,
" <- function(obj) {\n"
)
node_name
<-
paste0
(
element_snake_name
,
"_node"
)
func_str
<-
paste0
(
func_str
,
"\t"
,
node_name
,
" <- list("
,
element_name
,
" = structure(list())\n"
)
#Add attributes
for
(
i
in
seq_len
(
length
(
attrs
))){
nattr
<-
attrs_snake_names
[[
i
]]
attr
<-
attrs
[[
i
]]
func_str
<-
paste0
(
func_str
,
"\t"
,
node_name
,
" <- add_attr("
,
node_name
,
", obj$"
,
nattr
,
", '"
,
attr
,
"')\n"
)
}
#Add children
for
(
i
in
seq_len
(
length
(
children
))){
child_snake
<-
children_snake_names
[[
i
]]
child
<-
children
[[
i
]]
#If a child is a parent, either call as_node or adopt_nodes
if
(
is_parent
){
if
(
1
){
func_str
<-
paste0
(
func_str
,
"\t"
,
node_name
,
" <- add_child("
,
node_name
,
", obj$"
,
child_snake
,
", '"
,
child
,
"')\n"
)
}
else
{
}
}
else
{
func_str
<-
paste0
(
func_str
,
"\t"
,
node_name
,
" <- add_child("
,
node_name
,
", obj$"
,
child_snake
,
")\n"
)
}
}
func_str
<-
paste0
(
func_str
,
"\t"
,
"return("
,
node_name
,
")\n"
)
func_str
<-
paste0
(
func_str
,
"}"
)
return
(
invisible
(
func_str
))
}
#============================== HELPERS FOR analyse_xml ================================
#============================== HELPERS FOR analyse_xml ================================
#'get_required
#'get_required
#'@description Helper function to mark required attributes or children from a vector of names and a
#'@description Helper function to mark required attributes or children from a vector of names and a
#' vector of occurrence probabilities
#' vector of occurrence probabilities
...
...
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