edi/src/lib/edi_build_provider_python.c

56 lines
1.2 KiB
C

#ifdef HAVE_CONFIG
# include "config.h"
#endif
#include <unistd.h>
#include <Ecore.h>
#include <Ecore_File.h>
#include "Edi.h"
#include "edi_private.h"
static Eina_Bool
_relative_path_exists(const char *base, const char *relative)
{
char *path;
Eina_Bool ret;
path = edi_path_append(base, relative);
ret = ecore_file_exists(path);
free(path);
return ret;
}
static Eina_Bool
_python_project_supported(const char *path)
{
return _relative_path_exists(path, "requirements.txt");
}
static Eina_Bool
_python_file_hidden_is(const char *file)
{
if (!file || strlen(file) == 0)
return EINA_FALSE;
if (eina_str_has_extension(file, ".pyc") || eina_str_has_extension(file, ".pyo"))
return EINA_TRUE;
return EINA_FALSE;
}
static void
_python_test(void)
{
chdir(edi_project_get());
ecore_exe_pipe_run("python -m unittest", ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_READ |
ECORE_EXE_PIPE_ERROR_LINE_BUFFERED | ECORE_EXE_PIPE_ERROR |
ECORE_EXE_PIPE_WRITE | ECORE_EXE_USE_SH, NULL);
}
Edi_Build_Provider _edi_build_provider_python =
{"python", _python_project_supported, _python_file_hidden_is,
NULL, _python_test, NULL};