Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
pfernique committed Nov 14, 2017
1 parent 0d957ef commit c286909
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 45 deletions.
15 changes: 15 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright [2017] UMR MISTEA INRA
Copyright [2017] UMR LEPSE INRA
Copyright [2015-2017] UMR AGAP CIRAD
Copyright [2015-2017] EPI Virtual Plants Inria

This file is part of the AutoWIG project (see http://autowig.rtfd.io).

The Apache Software Foundation (ASF) licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You should have received a copy of the Apache License, Version 2.0 along with this file; see the file LICENSE.
If not, you may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or mplied.
See the License for the specific language governing permissions and limitations under the License.
1 change: 0 additions & 1 deletion bin/conda/python-autowig/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ requirements:
- pandoc
- pypandoc
- path.py
- python-clang [py2k]
- numpy

test:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
license = 'Apache License 2.0',
package_data = {package: [ "*.so", "*.dll"] for package in packages},
entry_points = {
'autowig.parser': ['libclang = autowig.libclang_parser:libclang_parser'] * six.PY2,
'autowig.parser': [],
'autowig.controller': ['default = autowig.default_controller:default_controller'],
'autowig.generator': ['boost_python = autowig.boost_python_generator:boost_python_generator',
'boost_python_pattern = autowig.boost_python_generator:boost_python_pattern_generator',
Expand Down
2 changes: 1 addition & 1 deletion src/py/autowig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
elif 'libclang' in parser:
parser.plugin = 'libclang'
else:
warnings.warn("no parser implemented", RuntimeWarning)
warnings.warn("no parser available", RuntimeWarning)

from ._documenter import documenter
documenter.plugin = 'doxygen2sphinx'
Expand Down
80 changes: 40 additions & 40 deletions src/py/autowig/asg.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ def on_disk(self):
"""Is the filesystem component on disk"""
return os.path.exists(self.globalname)

@property
def globalname(self):
if 'CONDA_PREFIX' in os.environ and self._node.startswith('CONDA_PREFIX'):
return os.environ['CONDA_PREFIX'] + self._node[len('CONDA_PREFIX'):]
else:
return self._node

class DirectoryProxy(FilesystemProxy):
"""Abstract semantic graph node proxy for a directory
Expand All @@ -147,6 +154,10 @@ def parent(self):
try:
if self._node.lower() == os.path.abspath(os.sep).lower():
return None
elif self._node == 'CONDA_PREFIX' + os.sep:
return None
elif 'CONDA_PREFIX' in os.environ and self._node == os.environ['CONDA_PREFIX'] + os.sep:
return None
else:
return self._asg[self.globalname[:len(self.globalname)-len(self.localname)]]
except Exception as e:
Expand Down Expand Up @@ -1501,50 +1512,37 @@ def __len__(self):
return len(self._nodes)

def add_directory(self, dirname):
dirname = Path(dirname).abspath()
initname = str(dirname)
if not initname.endswith(os.sep):
initname += os.sep
if initname not in self._nodes:
idparent = initname
if idparent not in self._syntax_edges:
self._syntax_edges[idparent] = []
while not dirname == os.sep:
idnode = idparent
if not idnode.endswith(os.sep):
idnode += os.sep
if idnode not in self._nodes:
self._nodes[idnode] = dict(_proxy=DirectoryProxy)
dirname = dirname.parent
idparent = str(dirname)
if not idparent.endswith(os.sep):
idparent += os.sep
if idparent not in self._syntax_edges:
self._syntax_edges[idparent] = []
self._syntax_edges[idparent].append(idnode)
else:
break
if dirname == os.sep and os.sep not in self._nodes:
self._nodes[os.sep] = dict(_proxy=DirectoryProxy)
return self[initname]
if not dirname:
dirname = os.path.abspath(os.sep).lower()
if 'CONDA_PREFIX' not in os.environ or not dirname.startswith('CONDA_PREFIX'):
dirname = str(Path(dirname).abspath())
if not dirname.endswith(os.sep):
dirname += os.sep
if 'CONDA_PREFIX' in os.environ and dirname.startswith(os.environ['CONDA_PREFIX']):
dirname = 'CONDA_PREFIX' + dirname[len(os.environ['CONDA_PREFIX']):]
if not dirname in self._nodes:
self._nodes[dirname] = dict(_proxy=DirectoryProxy)
self._syntax_edges[dirname] = []
if dirname not in [os.sep, 'CONDA_PREFIX' + os.sep] and not dirname.lower() == os.path.abspath(os.sep).lower():
parent = self.add_directory(dirname.rsplit(os.sep, 2)[0])
if dirname not in self._syntax_edges[parent._node]:
self._syntax_edges[parent._node].append(dirname)
return self[dirname]

def add_file(self, filename, **kwargs):
filename = Path(filename).abspath()
initname = str(filename)
if 'CONDA_PREFIX' not in os.environ or not filename.startswith(os.environ['CONDA_PREFIX']):
filename = str(Path(filename).abspath())
if 'CONDA_PREFIX' in os.environ and filename.startswith(os.environ['CONDA_PREFIX']):
filename = 'CONDA_PREFIX' + filename[len(os.environ['CONDA_PREFIX']):]
proxy = kwargs.pop('proxy', FileProxy)
if initname not in self._nodes:
idnode = str(filename)
self._nodes[idnode] = dict(_proxy=proxy, **kwargs)
idparent = str(filename.parent)
if not idparent.endswith(os.sep):
idparent += os.sep
if idparent not in self._syntax_edges:
self._syntax_edges[idparent] = []
self._syntax_edges[idparent].append(idnode)
self.add_directory(idparent)
if filename not in self._nodes:
self._nodes[filename] = dict(_proxy=proxy, **kwargs)
parent = self.add_directory(filename.rsplit(os.sep, 1)[0])
if filename not in self._syntax_edges[parent._node]:
self._syntax_edges[parent._node].append(filename)
else:
self._nodes[initname].update(kwargs)
return self[initname]
self._nodes[filename].update(kwargs)
return self[filename]

def nodes(self, pattern=None):
if pattern is None:
Expand Down Expand Up @@ -1721,6 +1719,8 @@ def __contains__(self, node):
def __getitem__(self, node):
if isinstance(node, NodeProxy):
node = node.globalname
if 'CONDA_PREFIX' in os.environ and node.startswith(os.environ['CONDA_PREFIX']):
node = 'CONDA_PREFIX' + node[len(os.environ['CONDA_PREFIX']):]
if not isinstance(node, basestring):
raise TypeError('`node` parameter')
if node in self._nodes:
Expand Down
2 changes: 1 addition & 1 deletion test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestBasic(unittest.TestCase):

@classmethod
def setUpClass(cls):
if six.PY2:
if 'libclang' in autowig.parser:
autowig.parser.plugin = 'libclang'
autowig.generator.plugin = 'boost_python_internal'
cls.srcdir = Path('fp17')
Expand Down
3 changes: 2 additions & 1 deletion test/test_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class TestSubset(unittest.TestCase):

@classmethod
def setUpClass(cls):
autowig.parser.plugin = 'libclang'
if 'libclang' in autowig.parser:
autowig.parser.plugin = 'libclang'
cls.srcdir = Path('fp17')
Repo.clone_from('https://github.com/StatisKit/FP17.git', cls.srcdir.relpath('.'), recursive=True)
cls.srcdir = srcdir/'share'/'git'/'ClangLite'
Expand Down

0 comments on commit c286909

Please sign in to comment.