Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
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
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
finesse
pykat
Commits
24cf033e
There was a problem fetching the pipeline summary.
Commit
24cf033e
authored
8 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
addding readBlock method
parent
80a0f7f3
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pykat/finesse.py
+44
-4
44 additions, 4 deletions
pykat/finesse.py
with
44 additions
and
4 deletions
pykat/finesse.py
+
44
−
4
View file @
24cf033e
...
@@ -195,11 +195,51 @@ def f__lkat_trace_callback(lkat, trace_info, getCavities, getNodes, getSpaces):
...
@@ -195,11 +195,51 @@ def f__lkat_trace_callback(lkat, trace_info, getCavities, getNodes, getSpaces):
trace_info
[
space
.
name
]
=
space_trace
(
gouyx
=
space
.
gouy_x
,
trace_info
[
space
.
name
]
=
space_trace
(
gouyx
=
space
.
gouy_x
,
gouyy
=
space
.
gouy_y
)
gouyy
=
space
.
gouy_y
)
class
KatBatch
(
object
):
"""
def
readBlocks
(
katfile
):
"""
"""
For a given kat file, the blocks are parsed into dictionary as raw strings.
"""
__blocks
=
{}
__currentBlock
=
NO_BLOCK
__blocks
[
__currentBlock
]
=
""
with
open
(
katfile
)
as
f
:
commands
=
f
.
readlines
()
for
line
in
commands
:
line
=
line
.
strip
()
# Looking for block start or end
values
=
line
.
split
()
if
len
(
values
)
>=
3
and
values
[
0
]
==
"
%%%
"
:
if
values
[
1
]
==
"
FTblock
"
:
newTag
=
values
[
2
]
if
__currentBlock
!=
None
and
__currentBlock
!=
NO_BLOCK
:
warnings
.
warn
(
"
found block {0} before block {1} ended
"
.
format
(
newTag
,
__currentBlock
))
if
newTag
in
__blocks
:
raise
pkex
.
BasePyKatException
(
"
Block `{0}` has already been read
"
.
format
(
newTag
))
__blocks
[
newTag
]
=
""
__currentBlock
=
newTag
if
(
len
(
line
)
>
0
and
(
__currentBlock
is
NO_BLOCK
)):
continue
__blocks
[
__currentBlock
]
+=
line
+
"
\n
"
if
len
(
values
)
>=
3
and
values
[
0
]
==
"
%%%
"
:
if
values
[
1
]
==
"
FTend
"
:
__currentBlock
=
NO_BLOCK
return
__blocks
class
KatBatch
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
from
IPython.parallel
import
Client
from
IPython.parallel
import
Client
...
@@ -1048,7 +1088,7 @@ class kat(object):
...
@@ -1048,7 +1088,7 @@ class kat(object):
for
key
in
self
.
__variables
:
for
key
in
self
.
__variables
:
print
(
"
$
"
+
key
,
"
::::
"
,
"
owner =
"
,
self
.
__variables
[
key
].
owner
.
name
,
"
, use count =
"
,
self
.
__variables
[
key
].
putCount
)
print
(
"
$
"
+
key
,
"
::::
"
,
"
owner =
"
,
self
.
__variables
[
key
].
owner
.
name
,
"
, use count =
"
,
self
.
__variables
[
key
].
putCount
)
def
parseCommands
(
self
,
commands
,
blocks
=
None
,
addToBlock
=
None
):
def
parseCommands
(
self
,
commands
,
blocks
=
None
,
addToBlock
=
None
,
preserve
=
False
):
try
:
try
:
if
addToBlock
is
not
None
and
blocks
is
not
None
:
if
addToBlock
is
not
None
and
blocks
is
not
None
:
raise
pkex
.
BasePyKatException
(
"
When parsing commands you cannot set both blocks and addToBlock arguments
"
)
raise
pkex
.
BasePyKatException
(
"
When parsing commands you cannot set both blocks and addToBlock arguments
"
)
...
...
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