Skip to content

Commit

Permalink
Make plugin_dir reference the directory instead of a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Parashara Shamaprasad committed Nov 22, 2019
1 parent e8cc67a commit 2678a39
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions foyer/plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import foyer
import glob
import os

def collect_plugins(plugin_names=None):
"""
Expand All @@ -25,6 +26,7 @@ def collect_plugins(plugin_names=None):
plugin_name = "_".join(plugin_func.split("_")[1:])
# TODO: plugin_version = get_version_info
plugin_dir = eval("foyer.forcefields.{}.__globals__['__file__']".format(plugin_func))
plugin_dir = os.path.dirname(plugin_dir)
# TODO: plugin_xml_path = get_xml_path
# This assumes that plugin directory tree is consistent.
# Does not consider versioned FFs.
Expand Down

2 comments on commit 2678a39

@rmatsum836
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That was the solution I came up with as well. I'm using os.walk to grab the xml path now.

@rmatsum836
Copy link
Contributor

@rmatsum836 rmatsum836 commented on 2678a39 Nov 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this:

         for paths, subdirs, files in os.walk(plugin_dir):
             for subdir in subdirs:
                 if subdir.endswith("xml"):
                     plugin_xml_path = plugin_dir + '/' + subdir

Please sign in to comment.