mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
.ngf files should have priority when importing a grammar module
This commit is contained in:
@@ -1256,22 +1256,6 @@ GrammarImporter_find_spec(PyTypeObject *class, PyObject *args)
|
||||
if (dir == NULL)
|
||||
break;
|
||||
|
||||
{
|
||||
PyObject *py_fpath =
|
||||
(PyUnicode_GET_LENGTH(dir) == 0) ? PyUnicode_FromFormat("%U.pgf", name)
|
||||
: PyUnicode_FromFormat("%U/%U.pgf", dir, name);
|
||||
const char *fpath = PyUnicode_AsUTF8(py_fpath);
|
||||
if (access(fpath, F_OK) == 0) {
|
||||
py_importer = (GrammarImporterObject *)class->tp_alloc(class, 0);
|
||||
py_importer->package_path = get_package_path(dir,name);
|
||||
py_importer->grammar_path = py_fpath;
|
||||
py_importer->is_pgf = 1;
|
||||
Py_DECREF(dir);
|
||||
break;
|
||||
}
|
||||
Py_DECREF(py_fpath);
|
||||
}
|
||||
|
||||
{
|
||||
PyObject *py_fpath =
|
||||
(PyUnicode_GET_LENGTH(dir) == 0) ? PyUnicode_FromFormat("%U.ngf", name)
|
||||
@@ -1288,6 +1272,22 @@ GrammarImporter_find_spec(PyTypeObject *class, PyObject *args)
|
||||
Py_DECREF(py_fpath);
|
||||
}
|
||||
|
||||
{
|
||||
PyObject *py_fpath =
|
||||
(PyUnicode_GET_LENGTH(dir) == 0) ? PyUnicode_FromFormat("%U.pgf", name)
|
||||
: PyUnicode_FromFormat("%U/%U.pgf", dir, name);
|
||||
const char *fpath = PyUnicode_AsUTF8(py_fpath);
|
||||
if (access(fpath, F_OK) == 0) {
|
||||
py_importer = (GrammarImporterObject *)class->tp_alloc(class, 0);
|
||||
py_importer->package_path = get_package_path(dir,name);
|
||||
py_importer->grammar_path = py_fpath;
|
||||
py_importer->is_pgf = 1;
|
||||
Py_DECREF(dir);
|
||||
break;
|
||||
}
|
||||
Py_DECREF(py_fpath);
|
||||
}
|
||||
|
||||
Py_DECREF(dir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user