GithubHelp home page GithubHelp logo

exodusii's People

Contributors

tjfulle avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

sswan

exodusii's Issues

exodusii.exo_file() does not accept pathlib.Path objects

Upon trying to send in pathlib.Path objects to exodusii.exo_file() I end up getting an error in glob.glob() that kind of says what the problem is but isn't very user friendly to newer python developers.

I'd like to get full support for pathlib.Path objects or a strong type check on the files with a well-written error message. It seems that it is possible to put stars and question marks in pathlib.Path objects, so maybe all we need to do is cast pathlib.Path to str if we encounter any?

>>> p = pathlib.Path("foo/bar.?.*")
>>> p
PosixPath('foo/bar.?.*')
>>> p.resolve()
PosixPath('/Users/mswan/foo/bar.?.*')
>>> str(p)
'foo/bar.?.*'

Other than testing the new feature, an implementation would be this:

mswan@cee-pp-ldrd02 $ git diff __init__.py
diff --git a/exodusii/__init__.py b/exodusii/__init__.py
index 19e62be..c696f7f 100644
--- a/exodusii/__init__.py
+++ b/exodusii/__init__.py
@@ -32,9 +32,13 @@ exo_file = File
 
 def _find_files(*files):
     import glob
+    import pathlib
 
     found = []
     for file in files:
+        if isinstance(file, pathlib.Path):
+            found.append(str(file.resolve()))
+            continue
         globbed_files = glob.glob(file)
         if not globbed_files:
             raise FileNotFoundError(file)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.