Git Product home page Git Product logo

python-module-resources's Issues

Support for directories in a resource module

Add a new directory, module_resources/examples/{json,yaml}/subdirectory to the examples, and ensure that imports are handled orderly.

Account for matching names between a file in the module's top-level directory, and a subdirectory within the module. Use from to distinguish these submodule imports versus named documents in the top-level.

Iterating over module resources is awkward

The __iter__ method is currently designed to help dict() work easily, but it makes for-loops deal with dicts, making things clumsy when working with loops.

Find a way to continue using __iter__ as dicts for calls to dict(), while avoiding this type of interaction in loops.

from some_module_resource import module_json_resource

dict(module_json_resource)
# {"first": {"namedtuple": True}, "second": {"namedtuple": True}}

for resource_key, dict_value in module_json_resource:
    namedtuple_value = getattr(module_json_resource, resource_key)
    print(hasattr(namedtuple_value.second))

Write to resource

A resource object should know how to write itself back to the filesystem in the same location and format it was in when it was imported.

Readme typo

Yaml configuration files work as well, with the module_resources.YamlResourceModule class.

Should be module_resources.YamlModuleResource.

Tests needed: ensure that intercepts from directories other than the current module location works

You should be able to import a module and have the contents of the imported object sourced from someplace like /var/config, /tmp/whatever/, etc.

Imports would still be requesting the same module that the associated __init__.py file is located in. It would just affect where the source json/yaml files are searched for.

This might already be the default behavior. If it isn't, it should support this.

Test needed: dict() conversion should never update original object

This came up during manual testing. I fixed it, but a regression test needs to be written.

See references to clean_value in module_resources.py for where I handled this issue in the first place.

Running dict() had a side effect of altering the namedtuple as it iterated through it.

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.