Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
python-unitex
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Patrick Watrin
python-unitex
Validations
04d6ca3a
Valider
04d6ca3a
rédigé
9 years ago
par
Patrick Watrin
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Pre-install Unitex library to allow _unitex extension linking.
parent
b1e85b9b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
extensions/_unitex.c
+8
-5
8 ajouts, 5 suppressions
extensions/_unitex.c
setup.py
+19
-23
19 ajouts, 23 suppressions
setup.py
unitex/__init__.py
+1
-1
1 ajout, 1 suppression
unitex/__init__.py
unitex/io.py
+7
-3
7 ajouts, 3 suppressions
unitex/io.py
avec
35 ajouts
et
32 suppressions
extensions/_unitex.c
+
8
−
5
Voir le fichier @
04d6ca3a
#include
<Python.h>
#include
<Python.h>
#include
"UnitexLibIO.h"
#include
"UnitexLibIO.h"
static
char
unitex_docstring
[]
=
static
char
unitex_docstring
[]
=
"This module provides some usefull C function to work with the Unitex library."
;
"This module provides some usefull C function to work with the Unitex library."
;
static
char
unitex_get_vfs_file_list_docstring
[]
=
"This function converts a C array of string (char**) into a Python list."
;
static
char
unitex_get_vfs_file_list_docstring
[]
=
"This function list (disk or virtual) directory contents."
;
static
PyObject
*
unitex_get_vfs_file_list
(
PyObject
*
self
,
PyObject
*
args
);
static
PyObject
*
unitex_get_vfs_file_list
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
unitex_get_vfs_file_list
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
unitex_get_vfs_file_list
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
filename
;
char
*
path
;
if
(
!
PyArg_ParseTuple
(
args
,
"s"
,
&
filename
))
if
(
!
PyArg_ParseTuple
(
args
,
"s"
,
&
path
))
return
NULL
;
return
NULL
;
char
**
array
=
GetUnitexFileList
(
filename
);
char
**
array
=
GetUnitexFileList
(
path
);
if
(
array
==
NULL
)
if
(
array
==
NULL
)
return
PyList_New
(
0
);
return
PyList_New
(
0
);
...
@@ -57,3 +58,5 @@ PyMODINIT_FUNC PyInit__unitex(void) {
...
@@ -57,3 +58,5 @@ PyMODINIT_FUNC PyInit__unitex(void) {
return
NULL
;
return
NULL
;
return
module
;
return
module
;
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
setup.py
+
19
−
23
Voir le fichier @
04d6ca3a
...
@@ -24,8 +24,7 @@ UNITEX_INC = os.path.abspath(UNITEX_INC)
...
@@ -24,8 +24,7 @@ UNITEX_INC = os.path.abspath(UNITEX_INC)
class
CustomBuild
(
build
):
class
CustomBuild
(
build
):
def
run
(
self
):
def
run
(
self
):
build
.
run
(
self
)
# Unitex library compilation.
command
=
"
cd %s && make 64BITS=yes LIBRARY=yes TRE_DIRECT_COMPILE=yes DEBUG=yes
"
%
os
.
path
.
join
(
UNITEX_INC
,
"
build
"
)
command
=
"
cd %s && make 64BITS=yes LIBRARY=yes TRE_DIRECT_COMPILE=yes DEBUG=yes
"
%
os
.
path
.
join
(
UNITEX_INC
,
"
build
"
)
try
:
try
:
...
@@ -39,14 +38,18 @@ class CustomBuild(build):
...
@@ -39,14 +38,18 @@ class CustomBuild(build):
if
process
.
returncode
!=
0
:
if
process
.
returncode
!=
0
:
raise
OSError
(
process
.
stderr
.
read
())
raise
OSError
(
process
.
stderr
.
read
())
# Unitex library installation (needed by _unitex C extension).
library
=
None
if
sys
.
platform
==
"
darwin
"
:
library
=
"
libunitex.dylib
"
elif
sys
.
platform
==
"
linux
"
:
library
=
"
libunitex.so
"
else
:
sys
.
stderr
.
write
(
"
Plateform
'
%s
'
not supported...
\n
"
%
sys
.
platform
)
sys
.
exit
(
1
)
class
CustomClean
(
clean
):
command
=
"
cd %s && cp %s /usr/local/lib
"
%
(
os
.
path
.
join
(
UNITEX_INC
,
"
bin
"
),
library
)
def
run
(
self
):
clean
.
run
(
self
)
command
=
"
cd %s && make clean
"
%
os
.
path
.
join
(
UNITEX_INC
,
"
build
"
)
try
:
try
:
process
=
subprocess
.
Popen
(
command
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
process
=
subprocess
.
Popen
(
command
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
...
@@ -59,24 +62,16 @@ class CustomClean(clean):
...
@@ -59,24 +62,16 @@ class CustomClean(clean):
if
process
.
returncode
!=
0
:
if
process
.
returncode
!=
0
:
raise
OSError
(
process
.
stderr
.
read
())
raise
OSError
(
process
.
stderr
.
read
())
build
.
run
(
self
)
class
CustomInstall
(
install
):
def
run
(
self
):
install
.
run
(
self
)
library
=
None
class
CustomClean
(
clean
):
if
sys
.
platform
==
"
darwin
"
:
def
run
(
self
):
library
=
"
libunitex.dylib
"
clean
.
run
(
self
)
elif
sys
.
platform
==
"
linux2
"
:
library
=
"
libunitex.so
"
else
:
sys
.
stderr
.
write
(
"
Plateform
'
%s
'
not supported...
\n
"
%
sys
.
platform
)
sys
.
exit
(
1
)
command
=
"
cd %s &&
cp %s /usr/local/lib
"
%
(
os
.
path
.
join
(
UNITEX_INC
,
"
b
in
"
),
library
)
command
=
"
cd %s &&
make clean
"
%
os
.
path
.
join
(
UNITEX_INC
,
"
b
uild
"
)
try
:
try
:
process
=
subprocess
.
Popen
(
command
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
process
=
subprocess
.
Popen
(
command
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
)
...
@@ -124,12 +119,13 @@ setup(
...
@@ -124,12 +119,13 @@ setup(
ext_modules
=
[
ext_modules
=
[
Extension
(
"
_unitex
"
,
Extension
(
"
_unitex
"
,
include_dirs
=
[
UNITEX_INC
],
include_dirs
=
[
UNITEX_INC
],
libraries
=
[
"
unitex
"
],
library_dirs
=
[
'
/usr/local/lib
'
],
sources
=
[
"
extensions/_unitex.c
"
])
sources
=
[
"
extensions/_unitex.c
"
])
],
],
cmdclass
=
{
cmdclass
=
{
"
build
"
:
CustomBuild
,
"
build
"
:
CustomBuild
,
"
clean
"
:
CustomClean
,
"
clean
"
:
CustomClean
"
install
"
:
CustomInstall
}
}
)
)
Ce diff est replié.
Cliquez pour l'agrandir.
unitex/__init__.py
+
1
−
1
Voir le fichier @
04d6ca3a
...
@@ -22,7 +22,7 @@ LIBUNITEX = None
...
@@ -22,7 +22,7 @@ LIBUNITEX = None
if
sys
.
platform
==
"
darwin
"
:
if
sys
.
platform
==
"
darwin
"
:
LIBUNITEX
=
ctypes
.
cdll
.
LoadLibrary
(
"
libunitex.dylib
"
)
LIBUNITEX
=
ctypes
.
cdll
.
LoadLibrary
(
"
libunitex.dylib
"
)
elif
sys
.
platform
==
"
linux
2
"
:
elif
sys
.
platform
==
"
linux
"
:
LIBUNITEX
=
ctypes
.
cdll
.
LoadLibrary
(
"
libunitex.so
"
)
LIBUNITEX
=
ctypes
.
cdll
.
LoadLibrary
(
"
libunitex.so
"
)
else
:
else
:
raise
UnitexException
(
"
Plateform
'
%s
'
not supported...
"
%
sys
.
platform
)
raise
UnitexException
(
"
Plateform
'
%s
'
not supported...
"
%
sys
.
platform
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
unitex/io.py
+
7
−
3
Voir le fichier @
04d6ca3a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
ctypes
import
ctypes
from
_unitex
import
unitex_get_vfs_file_list
from
unitex
import
UnitexException
,
LOGGER
,
LIBUNITEX
from
unitex
import
UnitexException
,
LOGGER
,
LIBUNITEX
...
@@ -69,7 +70,7 @@ class UnitexIOConstants:
...
@@ -69,7 +70,7 @@ class UnitexIOConstants:
def
vfs_
cp
(
source_path
,
target_path
):
def
cp
(
source_path
,
target_path
):
_source_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
source_path
),
"
utf-8
"
))
_source_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
source_path
),
"
utf-8
"
))
_target_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
target_path
),
"
utf-8
"
))
_target_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
target_path
),
"
utf-8
"
))
...
@@ -77,14 +78,14 @@ def vfs_cp(source_path, target_path):
...
@@ -77,14 +78,14 @@ def vfs_cp(source_path, target_path):
if
ret
!=
0
:
if
ret
!=
0
:
raise
UnitexException
(
"
File copy failed!
"
)
raise
UnitexException
(
"
File copy failed!
"
)
def
vfs_
rm
(
path
):
def
rm
(
path
):
_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
path
),
"
utf-8
"
))
_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
path
),
"
utf-8
"
))
ret
=
LIBUNITEX
.
RemoveUnitexFile
(
_path
)
ret
=
LIBUNITEX
.
RemoveUnitexFile
(
_path
)
if
ret
!=
0
:
if
ret
!=
0
:
raise
UnitexException
(
"
File suppression failed!
"
)
raise
UnitexException
(
"
File suppression failed!
"
)
def
vfs_
mv
(
old_path
,
new_path
):
def
mv
(
old_path
,
new_path
):
_old_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
old_path
),
"
utf-8
"
))
_old_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
old_path
),
"
utf-8
"
))
_new_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
new_path
),
"
utf-8
"
))
_new_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
new_path
),
"
utf-8
"
))
...
@@ -92,6 +93,9 @@ def vfs_mv(old_path, new_path):
...
@@ -92,6 +93,9 @@ def vfs_mv(old_path, new_path):
if
ret
!=
0
:
if
ret
!=
0
:
raise
UnitexException
(
"
File renaming failed!
"
)
raise
UnitexException
(
"
File renaming failed!
"
)
def
ls
(
path
):
return
unitex_get_vfs_file_list
(
path
)
def
mkdir
(
path
):
def
mkdir
(
path
):
_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
path
),
"
utf-8
"
))
_path
=
ctypes
.
c_char_p
(
bytes
(
str
(
path
),
"
utf-8
"
))
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter