Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sot-dyninv
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
Container Registry
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
Guilhem Saurel
sot-dyninv
Commits
f21cbeb4
Commit
f21cbeb4
authored
14 years ago
by
Nicolas Mansard
Browse files
Options
Downloads
Patches
Plain Diff
IVIGIT.
parent
6ace70b4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/attime.py
+41
-0
41 additions, 0 deletions
python/attime.py
with
41 additions
and
0 deletions
python/attime.py
0 → 100644
+
41
−
0
View file @
f21cbeb4
class
Calendar
:
events
=
dict
()
def
registerEvent
(
self
,
iter
,
fun
,
doc
):
if
not
iter
in
self
.
events
.
keys
():
self
.
events
[
iter
]
=
list
()
self
.
events
[
iter
]
+=
[
(
fun
,
doc
)
]
def
run
(
self
,
iter
,
*
args
):
if
iter
in
self
.
events
.
keys
():
for
fun
,
doc
in
self
.
events
[
iter
]:
intro
=
"
At time
"
+
str
(
iter
)
+
"
:
"
if
doc
!=
None
:
print
intro
,
doc
else
:
if
fun
.
__doc__
!=
None
:
print
intro
,
fun
.
__doc__
else
:
print
intro
,
"
Runing
"
,
fun
fun
(
*
args
)
def
__call__
(
self
,
iterarg
,
functer
=
None
,
doc
=
None
):
if
functer
==
None
:
return
self
.
generatorDecorator
(
iterarg
)
else
:
self
.
registerEvent
(
iterarg
,
functer
,
doc
)
def
generatorDecorator
(
self
,
iterarg
):
"""
This next calling pattern is a little bit strange. Use it to decorate
a function definition: @attime(30) def run30(): ...
"""
class
calendarDeco
:
iterRef
=
iterarg
calendarRef
=
self
fun
=
None
def
__init__
(
selfdeco
,
functer
):
if
functer
.
__doc__
!=
None
:
if
len
(
functer
.
__doc__
)
>
0
:
selfdeco
.
__doc__
=
functer
.
__doc__
selfdeco
.
__doc__
+=
"
(will be run at time
"
+
str
(
selfdeco
.
iterRef
)
+
"
)
"
selfdeco
.
fun
=
functer
selfdeco
.
calendarRef
.
registerEvent
(
selfdeco
.
iterRef
,
functer
,
functer
.
__doc__
)
def
__call__
(
deco
,
*
args
):
selfdeco
.
fun
(
*
args
)
return
calendarDeco
attime
=
Calendar
()
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