Giter Site home page Giter Site logo

plumbing's People

Contributors

dc23 avatar svetlyak40wt avatar xapple avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

svetlyak40wt dc23

plumbing's Issues

Can SQLiteDatabase accept pathlib objects?

Current status

ipdb> db_v1 = SQLiteDatabase(db_path_v1)
*** TypeError: argument of type 'PosixPath' is not iterable
ipdb> str(db_path_v1)
'/home/paul/repos/eu_cbm/eu_cbm_aidb/countries/SI/aidb_v1.db'

Longer stack trace of the error in that case:

File ~/eu_cbm/eu_cbm_hat/scripts/conversion/update_aidb_1x_to_2x.py:66, in convert_aidb_to_v2(db_path)
     64 # Rename the old AIDB to v1
     65 shutil.copy(db_path, db_path_v1)
---> 66 # Remove the "index" column in the disturbance_matrix_value table.
     67 # This was introduced by mistake and shouldn't be there.
     68 db_v1 = SQLiteDatabase(db_path_v1)
     69 dm_values = db_v1.read_df("disturbance_matrix_value")

File ~/repos/autopaths/autopaths/base_path.py:60, in BasePath.__new__(cls, path, *args, **kwargs)
     58 def __new__(cls, path, *args, **kwargs):
     59     """A Path object is in fact a string."""
---> 60     return str.__new__(cls, cls.clean_path(path))

File ~/repos/autopaths/autopaths/base_path.py:38, in BasePath.clean_path(cls, path)
     36 if hasattr(path, 'path'): path = path.path
     37 # Expand the tilda #
---> 38 if "~" in path: path = os.path.expanduser(path)
     39 # We will store the path with the OS specific separator #
     40 # We will never mix both kinds of separators #
     41 if os.name == "posix": path = path.replace("\\", sep)

TypeError: argument of type 'PosixPath' is not iterable

Easily fixed by converting to a string

ipdb> db_v1 = SQLiteDatabase(str(db_path_v1))

But the error message "TypeError: argument of type 'PosixPath' is not iterable" is confusing at first.

Proposal

The "argument of type 'PosixPath' is not iterable" is a bit confusing. Can SQLiteDatabase accept pathlib objects?

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.