Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
toolbox
WindEnergyToolbox
Commits
d6cd9211
Commit
d6cd9211
authored
8 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
improved set function in htcfile
parent
f3012cf8
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
wetb/hawc2/htc_contents.py
+17
-10
17 additions, 10 deletions
wetb/hawc2/htc_contents.py
with
17 additions
and
10 deletions
wetb/hawc2/htc_contents.py
+
17
−
10
View file @
d6cd9211
...
...
@@ -34,6 +34,14 @@ def parse_next_line(lines):
comments
+=
"
\n
%s
"
%
lines
.
pop
(
0
).
rstrip
()
return
line
.
strip
(),
comments
def
fmt_value
(
v
):
try
:
if
int
(
float
(
v
))
==
float
(
v
):
return
int
(
float
(
v
))
return
float
(
v
)
except
ValueError
:
return
v
class
HTCContents
(
object
):
lines
=
[]
contents
=
None
...
...
@@ -63,9 +71,13 @@ class HTCContents(object):
def
__setattr__
(
self
,
*
args
,
**
kwargs
):
_3to2list1
=
list
(
args
)
k
,
v
,
=
_3to2list1
[:
1
]
+
[
_3to2list1
[
1
:]
]
k
,
v
,
=
_3to2list1
[:
1
]
+
_3to2list1
[
1
:]
if
k
in
dir
(
self
):
# in ['section', 'filename', 'lines']:
return
object
.
__setattr__
(
self
,
*
args
,
**
kwargs
)
if
isinstance
(
v
,
str
):
v
=
[
fmt_value
(
v
)
for
v
in
v
.
split
()]
if
not
isinstance
(
v
,
(
list
,
tuple
)):
v
=
[
v
]
self
.
contents
[
k
]
=
HTCLine
(
k
,
v
,
""
)
def
__delattr__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -158,7 +170,7 @@ class HTCLine(HTCContents):
if
"
__
"
in
name
:
name
=
name
[:
name
.
index
(
"
__
"
)]
self
.
name_
=
name
self
.
values
=
values
self
.
values
=
list
(
values
)
self
.
comments
=
comments
def
__repr__
(
self
):
...
...
@@ -185,16 +197,11 @@ class HTCLine(HTCContents):
else
:
name
=
line
values
=
[]
def
fmt
(
v
):
try
:
if
int
(
float
(
v
))
==
float
(
v
):
return
int
(
float
(
v
))
return
float
(
v
)
except
ValueError
:
return
v
values
=
[
fmt
(
v
)
for
v
in
values
]
values
=
[
fmt_value
(
v
)
for
v
in
values
]
return
HTCLine
(
name
,
values
,
end_comments
)
def
remove
(
self
):
self
.
name_
=
""
self
.
values
=
[]
...
...
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