Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
22f634977c95
Commit
e6f9e8ba
authored
Mar 25, 2009
by
sylvain.thenault@logilab.fr
Browse files
make pylint happy, fix some bugs on the way
--HG-- branch : tls-sprint
parent
00eb43688a57
Changes
26
Hide whitespace changes
Inline
Side-by-side
cwvreg.py
View file @
22f63497
...
...
@@ -126,7 +126,7 @@ class CubicWebRegistry(VRegistry):
for
cls
in
classes
:
for
iface
in
cls
.
__implements__
:
interfaces
.
update
(
iface
.
__mro__
)
interfaces
.
update
(
expand_parent_classes
(
cls
.
__mro__
)
)
interfaces
.
update
(
cls
.
__mro__
)
for
obj
,
ifaces
in
self
.
_needs_iface
.
items
():
ifaces
=
frozenset
(
isinstance
(
iface
,
basestring
)
and
iface
in
self
.
schema
...
...
devtools/_apptest.py
View file @
22f63497
...
...
@@ -61,6 +61,7 @@ def unprotected_entities(app_schema, strict=False):
def
ignore_relations
(
*
relations
):
global
SYSTEM_RELATIONS
SYSTEM_RELATIONS
+=
relations
class
TestEnvironment
(
object
):
...
...
@@ -83,7 +84,6 @@ class TestEnvironment(object):
self
.
restore_database
()
if
verbose
:
print
"init done"
login
=
source
[
'db-user'
]
config
.
repository
=
lambda
x
=
None
:
self
.
repo
self
.
app
=
CubicWebPublisher
(
config
,
vreg
=
vreg
)
self
.
verbose
=
verbose
...
...
devtools/devctl.py
View file @
22f63497
...
...
@@ -16,10 +16,11 @@ from os.path import join, exists, abspath, basename, normpath, split, isdir
from
logilab.common
import
STD_BLACKLIST
from
logilab.common.modutils
import
get_module_files
from
logilab.common.textutils
import
get_csv
from
logilab.common.clcommands
import
register_commands
from
cubicweb
import
CW_SOFTWARE_ROOT
as
BASEDIR
,
BadCommandUsage
from
cubicweb.__pkginfo__
import
version
as
cubicwebversion
from
cubicweb.toolsutils
import
Command
,
register_commands
,
confirm
,
copy_skeleton
from
cubicweb.toolsutils
import
Command
,
confirm
,
copy_skeleton
from
cubicweb.web.webconfig
import
WebConfiguration
from
cubicweb.server.serverconfig
import
ServerConfiguration
...
...
devtools/livetest.py
View file @
22f63497
...
...
@@ -36,12 +36,9 @@ class LivetestResource(CubicWebRootResource):
"""Indicate which resource to use to process down the URL's path"""
if
len
(
segments
)
and
segments
[
0
]
==
'data'
:
# Anything in data/ is treated as static files
dirlist
=
[
self
.
data_dir
,
join
(
dirname
(
cubicweb
.
web
.
__file__
),
'data'
)]
for
alternative
in
dirlist
:
filepath
=
join
(
alternative
,
*
segments
[
1
:])
if
exists
(
filepath
):
self
.
info
(
'publish static file: %s'
,
'/'
.
join
(
segments
))
return
static
.
File
(
filepath
),
()
datadir
=
self
.
config
.
locate_resource
(
segments
[
1
])
if
datadir
:
return
static
.
File
(
str
(
datadir
),
segments
[
1
:])
# Otherwise we use this single resource
return
self
,
()
...
...
devtools/repotest.py
View file @
22f63497
...
...
@@ -256,7 +256,7 @@ try:
from
cubicweb.server.msplanner
import
PartPlanInformation
except
ImportError
:
class
PartPlanInformation
(
object
):
def
merge_input_maps
(
*
args
):
def
merge_input_maps
(
self
,
*
args
):
pass
def
_choose_var
(
self
,
sourcevars
):
pass
...
...
entity.py
View file @
22f63497
...
...
@@ -226,12 +226,13 @@ class Entity(AppRsetObject, dict):
__registry__
=
'etypes'
__select__
=
yes
()
widgets
=
{}
rtags
=
None
id
=
None
e_schema
=
None
eid
=
None
rest_attr
=
None
fetch_attrs
=
None
skip_copy_for
=
()
@
classmethod
def
registered
(
cls
,
registry
):
"""build class using descriptor at registration time"""
...
...
gettext.py
View file @
22f63497
...
...
@@ -442,7 +442,6 @@ def textdomain(domain=None):
def
bindtextdomain
(
domain
,
localedir
=
None
):
global
_localedirs
if
localedir
is
not
None
:
_localedirs
[
domain
]
=
localedir
return
_localedirs
.
get
(
domain
,
_default_localedir
)
...
...
goa/goactl.py
View file @
22f63497
...
...
@@ -10,10 +10,9 @@ from os.path import exists, join, split, basename, normpath, abspath
from
logilab.common.clcommands
import
register_commands
from
cubicweb
import
BadCommandUsage
from
cubicweb
import
CW_SOFTWARE_ROOT
from
cubicweb.toolsutils
import
(
Command
,
register_commands
,
copy_skeleton
,
create_dir
,
create_symlink
)
from
cubicweb
import
CW_SOFTWARE_ROOT
,
BadCommandUsage
from
cubicweb.toolsutils
import
(
Command
,
copy_skeleton
,
create_symlink
,
create_dir
)
from
cubicweb.cwconfig
import
CubicWebConfiguration
from
logilab
import
common
as
lgc
...
...
goa/testlib.py
View file @
22f63497
...
...
@@ -17,8 +17,8 @@ try:
from
cubicweb.goa
import
db
,
do_monkey_patch
import_appengine_failed
=
None
except
ImportError
,
exc
:
raise
class
db
:
# XXX necessary ?
class
db
:
class
Model
:
pass
class
DummyProperty
:
...
...
hercule.py
View file @
22f63497
"""RQL client for cubicweb, connecting to application using pyro
:organization: Logilab
:copyright: 2001-200
8
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2001-200
9
LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__
=
"restructuredtext en"
...
...
@@ -132,11 +132,11 @@ class RQLCli(CLIHelper):
def
do_description
(
self
):
"""display the description of the latest result"""
if
self
.
cursor
.
description
is
None
:
if
self
.
rset
.
description
is
None
:
print
_
(
'No query has been executed'
)
else
:
print
'
\n
'
.
join
([
', '
.
join
(
line_desc
)
for
line_desc
in
self
.
cursor
.
description
])
for
line_desc
in
self
.
rset
.
description
])
help_do_description
=
(
'description'
,
"description"
,
_
(
do_description
.
__doc__
))
...
...
@@ -200,7 +200,7 @@ class RQLCli(CLIHelper):
self
.
_previous_lines
=
[]
# search results
try
:
self
.
cursor
.
execute
(
query
)
self
.
rset
=
rset
=
self
.
cursor
.
execute
(
query
)
except
:
if
self
.
autocommit
:
self
.
cnx
.
rollback
()
...
...
@@ -208,18 +208,18 @@ class RQLCli(CLIHelper):
else
:
if
self
.
autocommit
:
self
.
cnx
.
commit
()
self
.
handle_result
(
self
.
cursor
.
fetchall
(),
self
.
cursor
.
description
)
self
.
handle_result
(
rset
)
def
handle_result
(
self
,
r
esult
,
description
):
def
handle_result
(
self
,
r
set
):
"""display query results if any"""
if
not
re
sul
t
:
if
not
r
s
et
:
print
_
(
'No result matching query'
)
else
:
from
logilab.common.ureports
import
Table
children
=
flatten
(
izip2
(
description
,
r
esult
),
to_string
)
layout
=
Table
(
cols
=
2
*
len
(
r
esult
[
0
]),
children
=
children
,
cheaders
=
1
)
children
=
flatten
(
izip2
(
rset
.
description
,
r
set
.
rows
),
to_string
)
layout
=
Table
(
cols
=
2
*
len
(
r
set
.
rows
[
0
]),
children
=
children
,
cheaders
=
1
)
self
.
_format
(
self
.
writer
,
layout
)
print
_
(
'%s results matching query'
)
%
len
(
result
)
print
_
(
'%s results matching query'
)
%
rset
.
rowcount
def
display_schema
(
self
,
schema
):
"""display a schema object"""
...
...
schema.py
View file @
22f63497
...
...
@@ -22,6 +22,7 @@ from yams.reader import (CONSTRAINTS, RelationFileReader, PyFileReader,
from
rql
import
parse
,
nodes
,
RQLSyntaxError
,
TypeResolverException
from
cubicweb
import
ETYPE_NAME_MAP
,
ValidationError
,
Unauthorized
from
cubicweb
import
set_log_methods
# XXX <3.2 bw compat
from
yams
import
schema
...
...
@@ -981,8 +982,6 @@ format_constraint = FormatConstraint()
CONSTRAINTS
[
'FormatConstraint'
]
=
FormatConstraint
PyFileReader
.
context
[
'format_constraint'
]
=
format_constraint
from
logging
import
getLogger
from
cubicweb
import
set_log_methods
set_log_methods
(
CubicWebSchemaLoader
,
getLogger
(
'cubicweb.schemaloader'
))
set_log_methods
(
BootstrapSchemaLoader
,
getLogger
(
'cubicweb.bootstrapschemaloader'
))
set_log_methods
(
RQLExpression
,
getLogger
(
'cubicweb.schema'
))
...
...
selectors.py
View file @
22f63497
...
...
@@ -218,10 +218,13 @@ class EntitySelector(EClassSelector):
# very basic selectors ########################################################
@
objectify_selector
def
yes
(
cls
,
*
args
,
**
kwargs
):
"""accept everything"""
return
1
class
yes
(
Selector
):
"""return arbitrary score"""
def
__init__
(
self
,
score
=
1
):
self
.
score
=
score
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
self
.
score
@
objectify_selector
@
lltrace
...
...
@@ -908,7 +911,7 @@ class score_entity(EntitySelector):
return a score >= 0
"""
def
__init__
(
self
,
scorefunc
,
once_is_enough
=
False
):
super
(
EntitySelector
,
self
).
__init__
(
once_is_enough
)
super
(
score_entity
,
self
).
__init__
(
once_is_enough
)
self
.
score_entity
=
scorefunc
...
...
server/repository.py
View file @
22f63497
...
...
@@ -394,11 +394,13 @@ class Repository(object):
return
euser
def
_build_user
(
self
,
session
,
eid
):
"""return a EUser entity for user with the given eid"""
cls
=
self
.
vreg
.
etype_class
(
'EUser'
)
rql
=
cls
.
fetch_rql
(
session
.
user
,
[
'X eid %(x)s'
])
rset
=
session
.
execute
(
rql
,
{
'x'
:
eid
},
'x'
)
assert
len
(
rset
)
==
1
,
rset
euser
=
rset
.
get_entity
(
0
,
0
)
# pylint: disable-msg=W0104
# prefetch / cache euser's groups and properties. This is especially
# useful for internal sessions to avoid security insertions
euser
.
groups
...
...
server/rqlrewrite.py
View file @
22f63497
...
...
@@ -315,7 +315,7 @@ class RQLRewriter(object):
return
cmp_
def
visit_mathexpression
(
self
,
mexpr
):
cmp_
=
nodes
.
MathExpression
(
cmp
.
operator
)
cmp_
=
nodes
.
MathExpression
(
mexpr
.
operator
)
for
c
in
cmp
.
children
:
cmp_
.
append
(
c
.
accept
(
self
))
return
cmp_
...
...
server/schemahooks.py
View file @
22f63497
...
...
@@ -100,6 +100,7 @@ class UpdateSchemaOp(SingleLastOperation):
class
DropTableOp
(
PreCommitOperation
):
"""actually remove a database from the application's schema"""
table
=
None
# make pylint happy
def
precommit_event
(
self
):
dropped
=
self
.
session
.
query_data
(
'droppedtables'
,
default
=
set
(),
setdefault
=
True
)
...
...
@@ -113,6 +114,7 @@ class DropColumnOp(PreCommitOperation):
"""actually remove the attribut's column from entity table in the system
database
"""
table
=
column
=
None
# make pylint happy
def
precommit_event
(
self
):
session
,
table
,
column
=
self
.
session
,
self
.
table
,
self
.
column
# drop index if any
...
...
@@ -236,6 +238,7 @@ def after_del_relation_type(session, rdefeid, rtype, rteid):
class
AddEETypeOp
(
EarlySchemaOperation
):
"""actually add the entity type to the application's schema"""
eid
=
None
# make pylint happy
def
commit_event
(
self
):
eschema
=
self
.
schema
.
add_entity_type
(
self
.
kobj
)
eschema
.
eid
=
self
.
eid
...
...
@@ -296,6 +299,7 @@ def after_add_eetype(session, entity):
class
AddERTypeOp
(
EarlySchemaOperation
):
"""actually add the relation type to the application's schema"""
eid
=
None
# make pylint happy
def
commit_event
(
self
):
rschema
=
self
.
schema
.
add_relation_type
(
self
.
kobj
)
rschema
.
set_default_groups
()
...
...
@@ -355,6 +359,7 @@ class AddEFRDefPreCommitOp(PreCommitOperation):
constraints are handled by specific hooks
"""
entity
=
None
# make pylint happy
def
precommit_event
(
self
):
session
=
self
.
session
entity
=
self
.
entity
...
...
@@ -439,6 +444,7 @@ class AddENFRDefPreCommitOp(PreCommitOperation):
constraints are handled by specific hooks
"""
entity
=
None
# make pylint happy
def
precommit_event
(
self
):
session
=
self
.
session
entity
=
self
.
entity
...
...
@@ -530,6 +536,7 @@ def before_update_ertype(session, entity):
class
UpdateEntityTypeName
(
SchemaOperation
):
"""this operation updates physical storage accordingly"""
oldname
=
newname
=
None
# make pylint happy
def
precommit_event
(
self
):
# we need sql to operate physical changes on the system database
...
...
@@ -547,6 +554,7 @@ class UpdateEntityTypeName(SchemaOperation):
class
UpdateRdefOp
(
SchemaOperation
):
"""actually update some properties of a relation definition"""
rschema
=
values
=
None
# make pylint happy
def
precommit_event
(
self
):
if
'indexed'
in
self
.
values
:
...
...
@@ -581,6 +589,8 @@ def after_update_erdef(session, entity):
class
UpdateRtypeOp
(
SchemaOperation
):
"""actually update some properties of a relation definition"""
rschema
=
values
=
entity
=
None
# make pylint happy
def
precommit_event
(
self
):
session
=
self
.
session
rschema
=
self
.
rschema
...
...
@@ -655,6 +665,8 @@ from cubicweb.schema import CONSTRAINTS
class
ConstraintOp
(
SchemaOperation
):
"""actually update constraint of a relation definition"""
entity
=
None
# make pylint happy
def
prepare_constraints
(
self
,
rtype
,
subjtype
,
objtype
):
constraints
=
rtype
.
rproperty
(
subjtype
,
objtype
,
'constraints'
)
self
.
constraints
=
list
(
constraints
)
...
...
@@ -708,6 +720,7 @@ def after_update_econstraint(session, entity):
class
DelConstraintOp
(
ConstraintOp
):
"""actually remove a constraint of a relation definition"""
rtype
=
subjtype
=
objtype
=
None
# make pylint happy
def
precommit_event
(
self
):
self
.
prepare_constraints
(
self
.
rtype
,
self
.
subjtype
,
self
.
objtype
)
...
...
server/sources/pyrorql.py
View file @
22f63497
...
...
@@ -24,7 +24,7 @@ from cubicweb import BadConnectionId, UnknownEid, ConnectionError
from
cubicweb.cwconfig
import
register_persistent_options
from
cubicweb.server.sources
import
AbstractSource
,
ConnectionWrapper
class
ReplaceByInOperator
:
class
ReplaceByInOperator
(
Exception
)
:
def
__init__
(
self
,
eids
):
self
.
eids
=
eids
...
...
server/utils.py
View file @
22f63497
...
...
@@ -117,7 +117,7 @@ class RepoThread(Thread):
func
()
finally
:
self
.
running_threads
.
remove
(
self
)
Thread
.
__init__
(
self
,
target
=
target
)
Thread
.
__init__
(
self
,
target
=
auto_remove_func
)
self
.
running_threads
=
running_threads
self
.
_name
=
target
.
__name__
...
...
sobjects/email.py
View file @
22f63497
...
...
@@ -14,7 +14,8 @@ class SetUseEmailRelationOp(PreCommitOperation):
already setting the relation
"""
rtype
=
'use_email'
fromeid
=
toeid
=
None
# make pylint happy
def
condition
(
self
):
"""check entity has use_email set for the email address"""
return
not
self
.
session
.
unsafe_execute
(
...
...
sobjects/hooks.py
View file @
22f63497
...
...
@@ -22,6 +22,7 @@ class AddUpdateEUserHook(Hook):
class
AutoDeleteBookmark
(
PreCommitOperation
):
beid
=
None
# make pylint happy
def
precommit_event
(
self
):
session
=
self
.
session
if
not
self
.
beid
in
session
.
query_data
(
'pendingeids'
,
()):
...
...
toolsutils.py
View file @
22f63497
...
...
@@ -114,7 +114,7 @@ def copy_skeleton(skeldir, targetdir, context,
tfpath
=
tfpath
[:
-
5
]
if
not
askconfirm
or
not
exists
(
tfpath
)
or
\
confirm
(
'%s exists, overwrite?'
%
tfpath
):
fname
=
fill_templated_file
(
fpath
,
tfpath
,
context
)
fill_templated_file
(
fpath
,
tfpath
,
context
)
print
'[generate] %s <-- %s'
%
(
tfpath
,
fpath
)
elif
exists
(
tfpath
):
show_diffs
(
tfpath
,
fpath
,
askconfirm
)
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment