Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RQL
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
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
cubicweb
RQL
Commits
32268a80fc06
Commit
32268a80fc06
authored
16 years ago
by
Sylvain
Browse files
Options
Downloads
Patches
Plain Diff
rewrite rqlvar_maker as a class instead of a generator
parent
89c672ecdc6e
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
utils.py
+20
-9
20 additions, 9 deletions
utils.py
with
20 additions
and
9 deletions
utils.py
+
20
−
9
View file @
32268a80
...
...
@@ -17,10 +17,10 @@
return
table
[
mod
]
return
decompose_b26
(
div
-
1
)
+
table
[
mod
]
def
rqlvar_maker
(
stop
=
None
,
index
=
0
,
defined
=
None
):
class
rqlvar_maker
(
object
):
"""
yields consistent RQL variable names
:param stop: optional argument to stop iteration after the Nth variable
default is None which means
'
never stop
'
:param defined: optional dict of already defined vars
"""
...
...
@@ -21,17 +21,28 @@
"""
yields consistent RQL variable names
:param stop: optional argument to stop iteration after the Nth variable
default is None which means
'
never stop
'
:param defined: optional dict of already defined vars
"""
index
=
index
while
stop
is
None
or
index
<
stop
:
var
=
decompose_b26
(
index
)
index
+=
1
if
defined
is
not
None
and
var
in
defined
:
continue
yield
var
# NOTE: written a an iterator class instead of a simple generator to be
# picklable
def
__init__
(
self
,
stop
=
None
,
index
=
0
,
defined
=
None
):
self
.
index
=
index
self
.
stop
=
stop
self
.
defined
=
defined
def
__iter__
(
self
):
return
self
def
next
(
self
):
while
self
.
stop
is
None
or
self
.
index
<
self
.
stop
:
var
=
decompose_b26
(
self
.
index
)
self
.
index
+=
1
if
self
.
defined
is
not
None
and
var
in
self
.
defined
:
continue
return
var
raise
StopIteration
()
KEYWORDS
=
set
((
'
INSERT
'
,
'
SET
'
,
'
DELETE
'
,
'
UNION
'
,
'
WITH
'
,
'
BEING
'
,
'
WHERE
'
,
'
AND
'
,
'
OR
'
,
'
NOT
'
...
...
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