Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
ltfatpy
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
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
dev
ltfatpy
Commits
9a0ee891
There was a problem fetching the pipeline summary.
Commit
9a0ee891
authored
9 years ago
by
Denis Arrivault
Browse files
Options
Downloads
Patches
Plain Diff
Correct utf8 version reading bug
parent
efe5e612
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
copyright.py
+15
-12
15 additions, 12 deletions
copyright.py
setup.py
+12
-8
12 additions, 8 deletions
setup.py
with
27 additions
and
20 deletions
copyright.py
+
15
−
12
View file @
9a0ee891
...
...
@@ -8,32 +8,35 @@ import fileinput
def
findFiles
(
directory
,
files
=
[]):
"""
scan a directory for py, pyx, pxd extension files.
"""
for
file
in
os
.
listdir
(
directory
):
path
=
os
.
path
.
join
(
directory
,
file
)
for
file
name
in
os
.
listdir
(
directory
):
path
=
os
.
path
.
join
(
directory
,
file
name
)
if
os
.
path
.
isfile
(
path
)
and
(
path
.
endswith
(
"
.py
"
)
or
path
.
endswith
(
"
.pyx
"
)
or
path
.
endswith
(
"
.pxd
"
)):
if
file
!=
"
__init__.py
"
and
file
!=
"
version.py
"
:
if
file
name
!=
"
__init__.py
"
and
file
name
!=
"
version.py
"
:
files
.
append
(
path
)
elif
os
.
path
.
isdir
(
path
):
findFiles
(
path
,
files
)
return
files
def
fileUnStamping
(
file
):
def
fileUnStamping
(
file
name
):
"""
Remove stamp from a file
"""
is_stamp
=
False
for
line
in
fileinput
.
input
(
file
,
inplace
=
1
):
for
line
in
fileinput
.
input
(
file
name
,
inplace
=
1
):
if
line
.
find
(
"
# COPYRIGHT #
"
)
!=
-
1
:
is_stamp
=
not
is_stamp
elif
not
is_stamp
:
print
(
line
,
end
=
""
)
def
fileStamping
(
file
,
stamp
):
"""
Write a stamp on a file
"""
def
fileStamping
(
filename
,
stamp
):
"""
Write a stamp on a file
WARNING : The stamping must be done on an default utf8 machine !
"""
old_stamp
=
False
# If a copyright already exist over write it.
for
line
in
fileinput
.
input
(
file
,
inplace
=
1
):
for
line
in
fileinput
.
input
(
file
name
,
inplace
=
1
):
if
line
.
find
(
"
# COPYRIGHT #
"
)
!=
-
1
:
old_stamp
=
not
old_stamp
elif
line
.
startswith
(
"
# -*- coding: utf-8 -*-
"
):
...
...
@@ -70,8 +73,8 @@ def writeStamp():
stamp
=
getStamp
(
*
getVersionsAndDate
())
files
=
findFiles
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"
ltfatpy
"
))
for
file
in
files
:
fileStamping
(
file
,
stamp
)
for
file
name
in
files
:
fileStamping
(
file
name
,
stamp
)
fileStamping
(
"
setup.py
"
,
stamp
)
...
...
@@ -79,8 +82,8 @@ def eraseStamp():
"""
Erase a copyright stamp from all files
"""
files
=
findFiles
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"
ltfatpy
"
))
for
file
in
files
:
fileUnStamping
(
file
)
for
file
name
in
files
:
fileUnStamping
(
file
name
)
fileUnStamping
(
"
setup.py
"
)
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
12
−
8
View file @
9a0ee891
...
...
@@ -5,7 +5,6 @@ from __future__ import print_function, division
import
sys
import
os
import
shutil
import
fileinput
import
distutils.spawn
as
ds
import
distutils.dir_util
as
dd
...
...
@@ -50,10 +49,13 @@ def get_version():
########################
def
set_version
(
ltfat_dir
,
VERSION
):
filename
=
os
.
path
.
join
(
ltfat_dir
,
'
__init__.py
'
)
for
line
in
fileinput
.
input
(
filename
,
inplace
=
1
):
buf
=
""
for
line
in
open
(
filename
):
if
not
line
.
startswith
(
"
__version__ =
"
):
print
(
line
,
end
=
""
)
open
(
filename
,
'
a
'
).
write
(
'
__version__ =
"
%s
"
\n
'
%
VERSION
)
buf
+=
line
f
=
open
(
filename
,
"
w
"
,
encoding
=
"
utf-8
"
)
f
.
write
(
buf
)
f
.
write
(
'
__version__ =
"
%s
"
\n
'
%
VERSION
)
#################
...
...
@@ -164,8 +166,8 @@ def read(*paths):
#####################################
def
findpyxfiles
(
directory
,
files
=
[]):
"""
scan a directory for pyx extension files.
"""
for
file
in
os
.
listdir
(
directory
):
path
=
os
.
path
.
join
(
directory
,
file
)
for
file
name
in
os
.
listdir
(
directory
):
path
=
os
.
path
.
join
(
directory
,
file
name
)
if
os
.
path
.
isfile
(
path
)
and
path
.
endswith
(
"
.pyx
"
):
files
.
append
(
path
.
replace
(
os
.
path
.
sep
,
"
.
"
)[:
-
4
])
elif
os
.
path
.
isdir
(
path
):
...
...
@@ -220,7 +222,10 @@ class m_clean(clean):
# Custom sdist command
##############################
class
m_sdist
(
sdist
):
"""
Build source package
"""
"""
Build source package
WARNING : The stamping must be done on an default utf8 machine !
"""
def
run
(
self
):
if
USE_COPYRIGHT
:
...
...
@@ -285,7 +290,6 @@ def setup_package():
'
Programming Language :: C
'
,
'
Programming Language :: Python :: 2.7
'
,
'
Programming Language :: Python :: 3.4
'
,
'
Topic :: Software Development
'
,
'
Topic :: Scientific/Engineering :: Mathematics
'
,
'
Topic :: Scientific/Engineering
'
],
...
...
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