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
57dfde80df11
Commit
af8d0cb8
authored
Sep 15, 2015
by
Rémi Cardona
Browse files
[py3k] file → open
parent
8d9fe02387e3
Changes
17
Hide whitespace changes
Inline
Side-by-side
cwconfig.py
View file @
57dfde80
...
...
@@ -961,7 +961,7 @@ the repository',
i
=
1
while
exists
(
path
)
and
i
<
100
:
# arbitrary limit to avoid infinite loop
try
:
file
(
path
,
'a'
)
open
(
path
,
'a'
)
break
except
IOError
:
path
=
'%s-%s.log'
%
(
basepath
,
i
)
...
...
cwctl.py
View file @
57dfde80
...
...
@@ -115,7 +115,7 @@ class InstanceCommand(Command):
_allinstances
=
list_instances
(
regdir
)
if
isfile
(
join
(
regdir
,
'startorder'
)):
allinstances
=
[]
for
line
in
file
(
join
(
regdir
,
'startorder'
)):
for
line
in
open
(
join
(
regdir
,
'startorder'
)):
line
=
line
.
strip
()
if
line
and
not
line
.
startswith
(
'#'
):
try
:
...
...
devtools/devctl.py
View file @
57dfde80
...
...
@@ -322,7 +322,7 @@ class UpdateCubicWebCatalogCommand(Command):
potfiles
.
append
(
schemapot
)
# explicit close necessary else the file may not be yet flushed when
# we'll using it below
schemapotstream
=
file
(
schemapot
,
'w'
)
schemapotstream
=
open
(
schemapot
,
'w'
)
generate_schema_pot
(
schemapotstream
.
write
,
cubedir
=
None
)
schemapotstream
.
close
()
print
(
'TAL'
,
end
=
' '
)
...
...
@@ -446,7 +446,7 @@ def update_cube_catalogs(cubedir):
potfiles
.
append
(
schemapot
)
# explicit close necessary else the file may not be yet flushed when
# we'll using it below
schemapotstream
=
file
(
schemapot
,
'w'
)
schemapotstream
=
open
(
schemapot
,
'w'
)
generate_schema_pot
(
schemapotstream
.
write
,
cubedir
)
schemapotstream
.
close
()
print
(
'TAL'
,
end
=
' '
)
...
...
@@ -712,7 +712,7 @@ class ExamineLogCommand(Command):
requests
=
{}
for
filepath
in
args
:
try
:
stream
=
file
(
filepath
)
stream
=
open
(
filepath
)
except
OSError
as
ex
:
raise
BadCommandUsage
(
"can't open rql log file %s: %s"
%
(
filepath
,
ex
))
...
...
devtools/stresstester.py
View file @
57dfde80
...
...
@@ -156,7 +156,7 @@ def run(args):
elif
opt
in
(
'-P'
,
'--profile'
):
prof_file
=
val
elif
opt
in
(
'-o'
,
'--report-output'
):
report_output
=
file
(
val
,
'w'
)
report_output
=
open
(
val
,
'w'
)
if
len
(
args
)
!=
2
:
usage
(
1
)
queries
=
[
query
for
query
in
lines
(
args
[
1
])
if
not
query
.
startswith
(
'#'
)]
...
...
devtools/test/unittest_dbfill.py
View file @
57dfde80
...
...
@@ -52,7 +52,7 @@ class ValueGeneratorTC(TestCase):
return
None
def
_available_Person_firstname
(
self
,
etype
,
attrname
):
return
[
f
.
strip
()
for
f
in
file
(
osp
.
join
(
DATADIR
,
'firstnames.txt'
))]
return
[
f
.
strip
()
for
f
in
open
(
osp
.
join
(
DATADIR
,
'firstnames.txt'
))]
def
setUp
(
self
):
config
=
ApptestConfiguration
(
'data'
,
apphome
=
DATADIR
)
...
...
devtools/testlib.py
View file @
57dfde80
...
...
@@ -63,7 +63,7 @@ class CubicWebDebugger(Debugger):
def
do_view
(
self
,
arg
):
import
webbrowser
data
=
self
.
_getval
(
arg
)
with
file
(
'/tmp/toto.html'
,
'w'
)
as
toto
:
with
open
(
'/tmp/toto.html'
,
'w'
)
as
toto
:
toto
.
write
(
data
)
webbrowser
.
open
(
'file:///tmp/toto.html'
)
...
...
ext/tal.py
View file @
57dfde80
...
...
@@ -206,7 +206,7 @@ def compile_template_file(filepath):
:type filepath: str
:param template: path of the file to compile
"""
fp
=
file
(
filepath
)
fp
=
open
(
filepath
)
file_content
=
unicode
(
fp
.
read
())
# template file should be pure ASCII
fp
.
close
()
return
compile_template
(
file_content
)
...
...
misc/cwfs/cwfs_test.py
View file @
57dfde80
...
...
@@ -30,7 +30,7 @@ def spec_parser(filename) :
sections
=
[]
buffer
=
""
in_section
=
False
for
line
in
file
(
filename
)
:
for
line
in
open
(
filename
)
:
if
line
.
startswith
(
'Test::'
):
in_section
=
True
buffer
=
""
...
...
server/serverconfig.py
View file @
57dfde80
...
...
@@ -235,7 +235,7 @@ notified of every changes.',
def
bootstrap_cubes
(
self
):
from
logilab.common.textutils
import
splitstrip
for
line
in
file
(
join
(
self
.
apphome
,
'bootstrap_cubes'
)):
for
line
in
open
(
join
(
self
.
apphome
,
'bootstrap_cubes'
)):
line
=
line
.
strip
()
if
not
line
or
line
.
startswith
(
'#'
):
continue
...
...
@@ -246,7 +246,7 @@ notified of every changes.',
self
.
init_cubes
(())
def
write_bootstrap_cubes_file
(
self
,
cubes
):
stream
=
file
(
join
(
self
.
apphome
,
'bootstrap_cubes'
),
'w'
)
stream
=
open
(
join
(
self
.
apphome
,
'bootstrap_cubes'
),
'w'
)
stream
.
write
(
'# this is a generated file only used for bootstraping
\n
'
)
stream
.
write
(
'# you should not have to edit this
\n
'
)
stream
.
write
(
'%s
\n
'
%
','
.
join
(
cubes
))
...
...
server/test/unittest_ldapsource.py
View file @
57dfde80
...
...
@@ -55,8 +55,8 @@ def create_slapd_configuration(cls):
slapddir
=
tempfile
.
mkdtemp
(
'cw-unittest-ldap'
)
config
=
cls
.
config
slapdconf
=
join
(
config
.
apphome
,
"slapd.conf"
)
confin
=
file
(
join
(
config
.
apphome
,
"slapd.conf.in"
)).
read
()
confstream
=
file
(
slapdconf
,
'w'
)
confin
=
open
(
join
(
config
.
apphome
,
"slapd.conf.in"
)).
read
()
confstream
=
open
(
slapdconf
,
'w'
)
confstream
.
write
(
confin
%
{
'apphome'
:
config
.
apphome
,
'testdir'
:
slapddir
})
confstream
.
close
()
# fill ldap server with some data
...
...
server/test/unittest_storage.py
View file @
57dfde80
...
...
@@ -215,7 +215,7 @@ class StorageTC(CubicWebTC):
f1
=
cnx
.
create_entity
(
'File'
,
data
=
Binary
(
filepath
),
data_format
=
u
'text/plain'
,
data_name
=
u
'foo'
)
cw_value
=
f1
.
data
.
getvalue
()
fs_value
=
file
(
filepath
).
read
()
fs_value
=
open
(
filepath
).
read
()
if
cw_value
!=
fs_value
:
self
.
fail
(
'cw value %r is different from file content'
%
cw_value
)
...
...
@@ -304,7 +304,7 @@ class StorageTC(CubicWebTC):
old_fspath
=
self
.
fspath
(
cnx
,
f1
)
cnx
.
transaction_data
[
'fs_importing'
]
=
True
new_fspath
=
osp
.
join
(
self
.
tempdir
,
'newfile.txt'
)
file
(
new_fspath
,
'w'
).
write
(
'the new data'
)
open
(
new_fspath
,
'w'
).
write
(
'the new data'
)
cnx
.
execute
(
'SET F data %(d)s WHERE F eid %(f)s'
,
{
'd'
:
Binary
(
new_fspath
),
'f'
:
f1
.
eid
})
cnx
.
commit
()
...
...
setup.py
View file @
57dfde80
...
...
@@ -42,7 +42,7 @@ from distutils.command import install_data
from
__pkginfo__
import
modname
,
version
,
license
,
description
,
web
,
\
author
,
author_email
long_description
=
file
(
'README'
).
read
()
long_description
=
open
(
'README'
).
read
()
# import optional features
import
__pkginfo__
...
...
skeleton/setup.py
View file @
57dfde80
...
...
@@ -44,7 +44,7 @@ from __pkginfo__ import modname, version, license, description, web, \
author
,
author_email
,
classifiers
if
exists
(
'README'
):
long_description
=
file
(
'README'
).
read
()
long_description
=
open
(
'README'
).
read
()
else
:
long_description
=
''
...
...
sobjects/__init__.py
View file @
57dfde80
...
...
@@ -26,5 +26,5 @@ def registration_callback(vreg):
if
vreg
.
config
.
apphome
:
url_mapping_file
=
osp
.
join
(
vreg
.
config
.
apphome
,
'urlmapping.py'
)
if
osp
.
exists
(
url_mapping_file
):
URL_MAPPING
=
eval
(
file
(
url_mapping_file
).
read
())
URL_MAPPING
=
eval
(
open
(
url_mapping_file
).
read
())
vreg
.
info
(
'using url mapping %s from %s'
,
URL_MAPPING
,
url_mapping_file
)
toolsutils.py
View file @
57dfde80
...
...
@@ -112,7 +112,7 @@ def show_diffs(appl_file, ref_file, askconfirm=True):
sys
.
exit
(
0
)
else
:
copy_file
=
appl_file
+
'.default'
copy
=
file
(
copy_file
,
'w'
)
copy
=
open
(
copy_file
,
'w'
)
copy
.
write
(
open
(
ref_file
).
read
())
copy
.
close
()
print
(
'keep current version, the new file has been written to'
,
copy_file
)
...
...
@@ -151,8 +151,8 @@ def copy_skeleton(skeldir, targetdir, context,
shutil
.
copyfile
(
fpath
,
tfpath
)
def
fill_templated_file
(
fpath
,
tfpath
,
context
):
fobj
=
file
(
tfpath
,
'w'
)
templated
=
file
(
fpath
).
read
()
fobj
=
open
(
tfpath
,
'w'
)
templated
=
open
(
fpath
).
read
()
fobj
.
write
(
templated
%
context
)
fobj
.
close
()
...
...
web/propertysheet.py
View file @
57dfde80
...
...
@@ -96,7 +96,7 @@ class PropertySheet(dict):
if
not
osp
.
exists
(
rcachedir
):
os
.
makedirs
(
rcachedir
)
sourcefile
=
osp
.
join
(
rdirectory
,
rid
)
content
=
file
(
sourcefile
).
read
()
content
=
open
(
sourcefile
).
read
()
# XXX replace % not followed by a paren by %% to avoid having to do
# this in the source css file ?
try
:
...
...
@@ -105,7 +105,7 @@ class PropertySheet(dict):
self
.
error
(
"can't process %s/%s: %s"
,
rdirectory
,
rid
,
ex
)
adirectory
=
rdirectory
else
:
stream
=
file
(
cachefile
,
'w'
)
stream
=
open
(
cachefile
,
'w'
)
stream
.
write
(
content
)
stream
.
close
()
adirectory
=
self
.
_cache_directory
...
...
web/webconfig.py
View file @
57dfde80
...
...
@@ -460,7 +460,7 @@ have the python imaging library installed to use captcha)',
staticdir
=
join
(
staticdir
,
rdir
)
if
not
isdir
(
staticdir
)
and
'w'
in
mode
:
os
.
makedirs
(
staticdir
)
return
file
(
join
(
staticdir
,
filename
),
mode
)
return
open
(
join
(
staticdir
,
filename
),
mode
)
def
static_file_add
(
self
,
rpath
,
data
):
stream
=
self
.
static_file_open
(
rpath
)
...
...
Write
Preview
Markdown
is supported
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